From 1b6dd8f2ea7495a68b7419e45fcc56a81e16b26b Mon Sep 17 00:00:00 2001 From: yaowenhao Date: Sun, 27 Jan 2019 17:41:11 +0800 Subject: [PATCH] feat(datastore): expose datastore Close() --- autobatch/autobatch.go | 4 ++++ datastore.go | 2 ++ failstore/failstore.go | 5 +++++ 3 files changed, 11 insertions(+) diff --git a/autobatch/autobatch.go b/autobatch/autobatch.go index 64d68bd..62ea38d 100644 --- a/autobatch/autobatch.go +++ b/autobatch/autobatch.go @@ -112,3 +112,7 @@ func (d *Datastore) Query(q dsq.Query) (dsq.Results, error) { func (d *Datastore) DiskUsage() (uint64, error) { return ds.DiskUsage(d.child) } + +func (d *Datastore) Close() error { + return d.child.Close() +} diff --git a/datastore.go b/datastore.go index 898e574..3fb2d62 100644 --- a/datastore.go +++ b/datastore.go @@ -2,6 +2,7 @@ package datastore import ( "errors" + "io" "time" query "github.com/ipfs/go-datastore/query" @@ -33,6 +34,7 @@ should be checked by callers. type Datastore interface { Read Write + io.Closer } // Write is the write-side of the Datastore interface. diff --git a/failstore/failstore.go b/failstore/failstore.go index feee789..1408a3e 100644 --- a/failstore/failstore.go +++ b/failstore/failstore.go @@ -94,6 +94,11 @@ func (d *Failstore) DiskUsage() (uint64, error) { return ds.DiskUsage(d.child) } +// Close implements the Datastore interface +func (d *Failstore) Close() error { + return d.child.Close() +} + // FailBatch implements batching operations on the Failstore. type FailBatch struct { cb ds.Batch