1
0
mirror of https://github.com/ipfs/kubo.git synced 2025-09-14 01:35:23 +08:00
Files
kubo/util/datastore2/datastore_closer.go
Jeromy 35a5ca0ef5 update go-datastore to latest
License: MIT
Signed-off-by: Jeromy <jeromyj@gmail.com>
2015-09-15 17:15:29 -07:00

36 lines
706 B
Go

package datastore2
import (
"io"
"github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore"
)
type ThreadSafeDatastoreCloser interface {
datastore.ThreadSafeDatastore
io.Closer
Batch() (datastore.Batch, error)
}
func CloserWrap(ds datastore.ThreadSafeDatastore) ThreadSafeDatastoreCloser {
return &datastoreCloserWrapper{ds}
}
type datastoreCloserWrapper struct {
datastore.ThreadSafeDatastore
}
func (w *datastoreCloserWrapper) Close() error {
return nil // no-op
}
func (w *datastoreCloserWrapper) Batch() (datastore.Batch, error) {
bds, ok := w.ThreadSafeDatastore.(datastore.Batching)
if !ok {
return nil, datastore.ErrBatchUnsupported
}
return bds.Batch()
}