Commit edbdfb8f authored by Steven Allen's avatar Steven Allen

delayed: export datastructure type

That way, we can return it directly.
parent 27c83074
......@@ -9,50 +9,61 @@ import (
)
// New returns a new delayed datastore.
func New(ds ds.Datastore, delay delay.D) ds.Datastore {
return &delayed{ds: ds, delay: delay}
func New(ds ds.Datastore, delay delay.D) *Delayed {
return &Delayed{ds: ds, delay: delay}
}
type delayed struct {
// Delayed is an adapter that delays operations on the inner datastore.
type Delayed struct {
ds ds.Datastore
delay delay.D
}
func (dds *delayed) Put(key ds.Key, value []byte) (err error) {
var _ ds.Batching = (*Delayed)(nil)
// Put implements the ds.Datastore interface.
func (dds *Delayed) Put(key ds.Key, value []byte) (err error) {
dds.delay.Wait()
return dds.ds.Put(key, value)
}
func (dds *delayed) Get(key ds.Key) (value []byte, err error) {
// Get implements the ds.Datastore interface.
func (dds *Delayed) Get(key ds.Key) (value []byte, err error) {
dds.delay.Wait()
return dds.ds.Get(key)
}
func (dds *delayed) Has(key ds.Key) (exists bool, err error) {
// Has implements the ds.Datastore interface.
func (dds *Delayed) Has(key ds.Key) (exists bool, err error) {
dds.delay.Wait()
return dds.ds.Has(key)
}
func (dds *delayed) GetSize(key ds.Key) (size int, err error) {
// GetSize implements the ds.Datastore interface.
func (dds *Delayed) GetSize(key ds.Key) (size int, err error) {
dds.delay.Wait()
return dds.ds.GetSize(key)
}
func (dds *delayed) Delete(key ds.Key) (err error) {
// Delete implements the ds.Datastore interface.
func (dds *Delayed) Delete(key ds.Key) (err error) {
dds.delay.Wait()
return dds.ds.Delete(key)
}
func (dds *delayed) Query(q dsq.Query) (dsq.Results, error) {
// Query implements the ds.Datastore interface.
func (dds *Delayed) Query(q dsq.Query) (dsq.Results, error) {
dds.delay.Wait()
return dds.ds.Query(q)
}
func (dds *delayed) Batch() (ds.Batch, error) {
// Batch implements the ds.Batching interface.
func (dds *Delayed) Batch() (ds.Batch, error) {
return ds.NewBasicBatch(dds), nil
}
func (dds *delayed) DiskUsage() (uint64, error) {
// DiskUsage implements the ds.PersistentDatastore interface.
func (dds *Delayed) DiskUsage() (uint64, error) {
dds.delay.Wait()
return ds.DiskUsage(dds.ds)
}
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