Commit c4c2b1bc authored by Brian Tiger Chow's avatar Brian Tiger Chow

feat(interface) add ThreadsafeDatastore interface

ThreadsafeDatastore declares a datastore thread-safe by extending the
Datastore interface.

Callers who desire thread-safety may use this interface to assure that
the datastores they use provide this property.

Datastore implementers may satisfy the ThreadsafeDatastore interface
by defining the no-op method `IsThreadSafe()`
parent b8b8f537
...@@ -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