Add Close to StoreClient

master
Bel LaPointe 2018-10-08 15:33:21 -06:00
parent 836d5af9e4
commit 389bda7d40
3 changed files with 6 additions and 0 deletions

View File

@ -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))

View File

@ -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)
}

View File

@ -4,4 +4,5 @@ type Client interface {
Get(string, string) ([]byte, error)
Set(string, string, []byte) error
List(string, string) ([]string, error)
Close() error
}