Commit 238411e2 authored by Juan Batiz-Benet's avatar Juan Batiz-Benet

Merge pull request #4 from perfmode/master

feat(interface) add ThreadsafeDatastore interface
parents 73e92818 3dad2a44
...@@ -56,6 +56,11 @@ type Datastore interface { ...@@ -56,6 +56,11 @@ type Datastore interface {
KeyList() ([]Key, error) KeyList() ([]Key, error)
} }
type ThreadSafeDatastore interface {
Datastore
IsThreadSafe()
}
// Errors // Errors
// ErrNotFound is returned by Get, Has, and Delete when a datastore does not // ErrNotFound is returned by Get, Has, and Delete when a datastore does not
......
...@@ -13,7 +13,7 @@ type Datastore struct { ...@@ -13,7 +13,7 @@ type Datastore struct {
type Options opt.Options type Options opt.Options
func NewDatastore(path string, opts *Options) (*Datastore, error) { func NewDatastore(path string, opts *Options) (ds.ThreadSafeDatastore, error) {
var nopts opt.Options var nopts opt.Options
if opts != nil { if opts != nil {
nopts = opt.Options(*opts) nopts = opt.Options(*opts)
...@@ -76,3 +76,5 @@ func (d *Datastore) KeyList() ([]ds.Key, error) { ...@@ -76,3 +76,5 @@ func (d *Datastore) KeyList() ([]ds.Key, error) {
func (d *Datastore) Close() (err error) { func (d *Datastore) Close() (err error) {
return d.DB.Close() return d.DB.Close()
} }
func (d *Datastore) IsThreadSafe() {}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment