Documentation ¶
Overview ¶
Package mount provides a Datastore that has other Datastores mounted at various key prefixes and is threadsafe
Index ¶
- Variables
- type Datastore
- func (d *Datastore) Batch(ctx context.Context) (ds.Batch, error)
- func (d *Datastore) Check(ctx context.Context) error
- func (d *Datastore) Close() error
- func (d *Datastore) CollectGarbage(ctx context.Context) error
- func (d *Datastore) Delete(ctx context.Context, key ds.Key) error
- func (d *Datastore) DiskUsage(ctx context.Context) (uint64, error)
- func (d *Datastore) Get(ctx context.Context, key ds.Key) (value []byte, err error)
- func (d *Datastore) GetSize(ctx context.Context, key ds.Key) (size int, err error)
- func (d *Datastore) Has(ctx context.Context, key ds.Key) (exists bool, err error)
- func (d *Datastore) Put(ctx context.Context, key ds.Key, value []byte) error
- func (d *Datastore) Query(ctx context.Context, master query.Query) (query.Results, error)
- func (d *Datastore) Scrub(ctx context.Context) error
- func (d *Datastore) Sync(ctx context.Context, prefix ds.Key) error
- type Mount
Constants ¶
This section is empty.
Variables ¶
var (
ErrNoMount = errors.New("no datastore mounted for this key")
)
Functions ¶
This section is empty.
Types ¶
type Datastore ¶
type Datastore struct {
// contains filtered or unexported fields
}
Datastore is a mount datastore. In this datastore, keys live under the most specific mounted sub-datastore. That is, given sub-datastores mounted under:
* / * /foo * /foo/bar
Keys would be written as follows:
* /foo, /foobar, /baz would all live under /. * /foo/baz, /foo/bar, etc. would live under /foo. * /foo/bar/baz would live under /foo/bar.
Additionally, even if the datastore mounted at / contains the key /foo/thing, the datastore mounted at /foo would mask this value in get, deletes, and query results.
Finally, if no root (/) mount is provided, operations on keys living outside all of the provided mounts will behave as follows:
* Get - Returns datastore.ErrNotFound. * Query - Returns no results. * Put - Returns ErrNoMount.
func New ¶
New creates a new mount datstore from the given mounts. See the documentation on Datastore for details.
The order of the mounts does not matter, they will be applied most specific to least specific.
func (*Datastore) Delete ¶
Delete deletes the value associated with the key in the appropriate datastore.
Delete returns no error if there is no value associated with the given key.
func (*Datastore) DiskUsage ¶
DiskUsage returns the sum of DiskUsages for the mounted datastores. Non PersistentDatastores will not be accounted.
func (*Datastore) Get ¶
Get returns the value associated with the key from the appropriate datastore.
func (*Datastore) GetSize ¶
Get returns the size of the value associated with the key in the appropriate datastore.
func (*Datastore) Has ¶
Has returns the true if there exists a value associated with key in the appropriate datastore.
func (*Datastore) Put ¶
Put puts the given value into the datastore at the given key.
Returns ErrNoMount if there no datastores are mounted at the appropriate prefix for the given key.