From 389bda7d400d5e52c5a8a5fc1e37f785ab605c42 Mon Sep 17 00:00:00 2001 From: Bel LaPointe Date: Mon, 8 Oct 2018 15:33:21 -0600 Subject: [PATCH] Add Close to StoreClient --- store/bolt.go | 4 ++++ store/bolt_test.go | 1 + store/store.go | 1 + 3 files changed, 6 insertions(+) diff --git a/store/bolt.go b/store/bolt.go index 700469c..7d81758 100644 --- a/store/bolt.go +++ b/store/bolt.go @@ -18,6 +18,10 @@ func NewBolt(path string) (*BoltClient, error) { }, nil } +func (bc *BoltClient) Close() error { + return bc.db.Close() +} + func (bc *BoltClient) Set(namespace, key string, value []byte) error { return bc.db.Update(func(tx *bolt.Tx) error { bucket, err := tx.CreateBucketIfNotExists([]byte(namespace)) diff --git a/store/bolt_test.go b/store/bolt_test.go index c6f9011..4bb1086 100644 --- a/store/bolt_test.go +++ b/store/bolt_test.go @@ -45,6 +45,7 @@ func Test_BoltSetListGet(t *testing.T) { defer os.Remove(tmp.Name()) var sc Client sc, err = NewBolt(tmp.Name()) + defer sc.Close() if err != nil { t.Errorf("failed to create bolt %v: %v", sc, err) } diff --git a/store/store.go b/store/store.go index 6d9cc83..3150ef7 100644 --- a/store/store.go +++ b/store/store.go @@ -4,4 +4,5 @@ type Client interface { Get(string, string) ([]byte, error) Set(string, string, []byte) error List(string, string) ([]string, error) + Close() error }