ipfs-cluster: github.com/ipfs/ipfs-cluster/state/dsstate Index | Files

package dsstate

import "github.com/ipfs/ipfs-cluster/state/dsstate"

Package dsstate implements the IPFS Cluster state interface using an underlying go-datastore.

Index

Package Files

datastore.go

func DefaultHandle Uses

func DefaultHandle() codec.Handle

DefaultHandle returns the codec handler of choice (Msgpack).

type BatchingState Uses

type BatchingState struct {
    *State
    // contains filtered or unexported fields
}

BatchingState implements the IPFS Cluster "state" interface by wrapping a batching go-datastore. All writes are batched and only written disk when Commit() is called.

func NewBatching Uses

func NewBatching(dstore ds.Batching, namespace string, handle codec.Handle) (*BatchingState, error)

NewBatching returns a new batching statate using the given datastore.

All keys are namespaced with the given string when written. Thus the same go-datastore can be sharded for different uses.

The Handle controls options for the serialization of the full state (marshaling/unmarshaling).

func (*BatchingState) Commit Uses

func (bst *BatchingState) Commit(ctx context.Context) error

Commit persists the batched write operations.

type State Uses

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

State implements the IPFS Cluster "state" interface by wrapping a go-datastore and choosing how api.Pin objects are stored in it. It also provides serialization methods for the whole state which are datastore-independent.

func New Uses

func New(dstore ds.Datastore, namespace string, handle codec.Handle) (*State, error)

New returns a new state using the given datastore.

All keys are namespaced with the given string when written. Thus the same go-datastore can be sharded for different uses.

The Handle controls options for the serialization of the full state (marshaling/unmarshaling).

func (*State) Add Uses

func (st *State) Add(ctx context.Context, c *api.Pin) error

Add adds a new Pin or replaces an existing one.

func (*State) Get Uses

func (st *State) Get(ctx context.Context, c cid.Cid) (*api.Pin, error)

Get returns a Pin from the store and whether it was present. When not present, a default pin is returned.

func (*State) Has Uses

func (st *State) Has(ctx context.Context, c cid.Cid) (bool, error)

Has returns whether a Cid is stored.

func (*State) List Uses

func (st *State) List(ctx context.Context) ([]*api.Pin, error)

List returns the unsorted list of all Pins that have been added to the datastore.

func (*State) Marshal Uses

func (st *State) Marshal(w io.Writer) error

Marshal dumps the state to a writer. It does this by encoding every key/value in the store. The keys are stored without the namespace part to reduce the size of the snapshot.

func (*State) Migrate Uses

func (st *State) Migrate(ctx context.Context, r io.Reader) error

Migrate migrates an older state version to the current one. This is a no-op for now.

func (*State) Rm Uses

func (st *State) Rm(ctx context.Context, c cid.Cid) error

Rm removes an existing Pin. It is a no-op when the item does not exist.

func (*State) Unmarshal Uses

func (st *State) Unmarshal(r io.Reader) error

Unmarshal reads and parses a previous dump of the state. All the parsed key/values are added to the store. As of now, Unmarshal does not empty the existing store from any values before unmarshaling from the given reader.

Package dsstate imports 11 packages (graph) and is imported by 3 packages. Updated 2020-04-20. Refresh now. Tools for package owners.