package failstore
import "github.com/ipfs/go-datastore/failstore"
Package failstore implements a datastore which can produce custom failures on operations by calling a user-provided error function.
Index ¶
- type FailBatch
- func (b *FailBatch) Commit(ctx context.Context) error
- func (b *FailBatch) Delete(ctx context.Context, k ds.Key) error
- func (b *FailBatch) Put(ctx context.Context, k ds.Key, val []byte) error
- type Failstore
- func NewFailstore(c ds.Datastore, efunc func(string) error) *Failstore
- func (d *Failstore) Batch(ctx context.Context) (ds.Batch, error)
- func (d *Failstore) Close() error
- func (d *Failstore) Delete(ctx context.Context, k ds.Key) error
- func (d *Failstore) DiskUsage(ctx context.Context) (uint64, error)
- func (d *Failstore) Get(ctx context.Context, k ds.Key) ([]byte, error)
- func (d *Failstore) GetSize(ctx context.Context, k ds.Key) (int, error)
- func (d *Failstore) Has(ctx context.Context, k ds.Key) (bool, error)
- func (d *Failstore) Put(ctx context.Context, k ds.Key, val []byte) error
- func (d *Failstore) Query(ctx context.Context, q dsq.Query) (dsq.Results, error)
- func (d *Failstore) Sync(ctx context.Context, prefix ds.Key) error
Types ¶
type FailBatch ¶
type FailBatch struct {
// contains filtered or unexported fields
}
FailBatch implements batching operations on the Failstore.
func (*FailBatch) Commit ¶
Commit commits all operations in the batch.
func (*FailBatch) Delete ¶
Delete does a batch delete.
func (*FailBatch) Put ¶
Put does a batch put.
type Failstore ¶
type Failstore struct {
// contains filtered or unexported fields
}
Failstore is a datastore which fails according to a user-provided function.
func NewFailstore ¶
NewFailstore creates a new datastore with the given error function. The efunc will be called with different strings depending on the datastore function: put, get, has, delete, query, batch, batch-put, batch-delete and batch-commit are the possible values.
func (*Failstore) Batch ¶
Batch returns a new Batch Failstore.
func (*Failstore) Close ¶
Close implements the Datastore interface
func (*Failstore) Delete ¶
Delete removes a key/value from the datastore.
func (*Failstore) DiskUsage ¶
DiskUsage implements the PersistentDatastore interface.
func (*Failstore) Get ¶
Get retrieves a value from the datastore.
func (*Failstore) GetSize ¶
GetSize returns the size of the value in the datastore, if present.
func (*Failstore) Has ¶
Has returns if the datastore contains a key/value.
func (*Failstore) Put ¶
Put puts a key/value into the datastore.
func (*Failstore) Query ¶
Query performs a query on the datastore.
func (*Failstore) Sync ¶
Sync implements Datastore.Sync
Source Files ¶
- Version
- v0.8.2 (latest)
- Published
- Mar 4, 2025
- Platform
- linux/amd64
- Imports
- 3 packages
- Last checked
- 5 days ago –
Tools for package owners.