1
0
mirror of https://github.com/ipfs/kubo.git synced 2025-08-06 11:31:54 +08:00
Files
kubo/thirdparty/datastore2/datastore_closer.go
Jeromy 0aafa6db8c update go-datastore changes 0.1.2
License: MIT
Signed-off-by: Jeromy <why@ipfs.io>
2016-07-01 22:40:57 -07:00

36 lines
697 B
Go

package datastore2
import (
"io"
"gx/ipfs/QmfQzVugPq1w5shWRcLWSeiHF4a2meBX7yVD8Vw7GWJM9o/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()
}