failstore

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2019 License: MIT Imports: 2 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() error

Commit commits all operations in the batch.

func (*FailBatch) Delete

func (b *FailBatch) Delete(k ds.Key) error

Delete does a batch delete.

func (*FailBatch) Put

func (b *FailBatch) Put(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() (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(k ds.Key) error

Delete removes a key/value from the datastore.

func (*Failstore) DiskUsage

func (d *Failstore) DiskUsage() (uint64, error)

DiskUsage implements the PersistentDatastore interface.

func (*Failstore) Get

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

Get retrieves a value from the datastore.

func (*Failstore) GetSize

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

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

func (*Failstore) Has

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

Has returns if the datastore contains a key/value.

func (*Failstore) Put

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

Put puts a key/value into the datastore.

func (*Failstore) Query

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

Query performs a query on the datastore.

Jump to

Keyboard shortcuts

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