add .Close() method to interface and all implementations.

This commit is contained in:
fiatjaf
2023-11-05 10:39:41 -03:00
parent 8c0fd4c760
commit 03517317f8
5 changed files with 17 additions and 0 deletions

View File

@@ -55,6 +55,8 @@ type ElasticsearchStorage struct {
bi esutil.BulkIndexer
}
func (ess *ElasticsearchStorage) Close() {}
func (ess *ElasticsearchStorage) Init() error {
if ess.IndexName == "" {
ess.IndexName = "events"

View File

@@ -13,3 +13,7 @@ type MySQLBackend struct {
QueryKindsLimit int
QueryTagsLimit int
}
func (b *MySQLBackend) Close() {
b.DB.Close()
}

View File

@@ -13,3 +13,7 @@ type PostgresBackend struct {
QueryKindsLimit int
QueryTagsLimit int
}
func (b *PostgresBackend) Close() {
b.DB.Close()
}

View File

@@ -10,3 +10,7 @@ type SQLite3Backend struct {
MaxOpenConns int
MaxIdleConns int
}
func (b *SQLite3Backend) Close() {
b.DB.Close()
}

View File

@@ -12,6 +12,9 @@ type Store interface {
// allowing a storage to initialize its internal resources.
Init() error
// Close must be called after you're done using the store, to free up resources and so on.
Close()
// QueryEvents is invoked upon a client's REQ as described in NIP-01.
// it should return a channel with the events as they're recovered from a database.
// the channel should be closed after the events are all delivered.