failstore

package
v0.6.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 17, 2022 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package failstore implements a datastore which can produce custom failures on operations by calling a user-provided error function.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FailBatch

type FailBatch struct {
	// contains filtered or unexported fields
}

FailBatch implements batching operations on the Failstore.

func (*FailBatch) Commit

func (b *FailBatch) Commit(ctx context.Context) error

Commit commits all operations in the batch.

func (*FailBatch) Delete

func (b *FailBatch) Delete(ctx context.Context, k ds.Key) error

Delete does a batch delete.

func (*FailBatch) Put

func (b *FailBatch) Put(ctx context.Context, k ds.Key, val []byte) error

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

func NewFailstore(c ds.Datastore, efunc func(string) error) *Failstore

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

func (d *Failstore) Batch(ctx context.Context) (ds.Batch, error)

Batch returns a new Batch Failstore.

func (*Failstore) Close

func (d *Failstore) Close() error

Close implements the Datastore interface

func (*Failstore) Delete

func (d *Failstore) Delete(ctx context.Context, k ds.Key) error

Delete removes a key/value from the datastore.

func (*Failstore) DiskUsage

func (d *Failstore) DiskUsage(ctx context.Context) (uint64, error)

DiskUsage implements the PersistentDatastore interface.

func (*Failstore) Get

func (d *Failstore) Get(ctx context.Context, k ds.Key) ([]byte, error)

Get retrieves a value from the datastore.

func (*Failstore) GetSize

func (d *Failstore) GetSize(ctx context.Context, k ds.Key) (int, error)

GetSize returns the size of the value in the datastore, if present.

func (*Failstore) Has

func (d *Failstore) Has(ctx context.Context, k ds.Key) (bool, error)

Has returns if the datastore contains a key/value.

func (*Failstore) Put

func (d *Failstore) Put(ctx context.Context, k ds.Key, val []byte) error

Put puts a key/value into the datastore.

func (*Failstore) Query

func (d *Failstore) Query(ctx context.Context, q dsq.Query) (dsq.Results, error)

Query performs a query on the datastore.

func (*Failstore) Sync added in v0.3.0

func (d *Failstore) Sync(ctx context.Context, prefix ds.Key) error

Sync implements Datastore.Sync

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL