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

package state

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

Package state holds the interface that any state implementation for IPFS Cluster must satisfy.


Package Files

empty.go interface.go


var ErrNotFound = errors.New("pin is not part of the pinset")

ErrNotFound should be returned when a pin is not part of the state.

type BatchingState Uses

type BatchingState interface {
    // Commit writes any batched operations.
    Commit(context.Context) error

BatchingState represents a state which batches write operations.

type ReadOnly Uses

type ReadOnly interface {
    // List lists all the pins in the state.
    List(context.Context) ([]*api.Pin, error)
    // Has returns true if the state is holding information for a Cid.
    Has(context.Context, cid.Cid) (bool, error)
    // Get returns the information attacthed to this pin, if any. If the
    // pin is not part of the state, it should return ErrNotFound.
    Get(context.Context, cid.Cid) (*api.Pin, error)

ReadOnly represents the read side of a State.

func Empty Uses

func Empty() ReadOnly

Empty returns an empty read-only state.

type State Uses

type State interface {
    // Migrate restores the serialized format of an outdated state to the
    // current version.
    Migrate(ctx context.Context, r io.Reader) error
    // Marshal serializes the state to a byte slice.
    Marshal(io.Writer) error
    // Unmarshal deserializes the state from marshaled bytes.
    Unmarshal(io.Reader) error

State is a wrapper to the Cluster shared state so that Pin objects can be easily read, written and queried. The state can be marshaled and unmarshaled. Implementation should be thread-safe.

type WriteOnly Uses

type WriteOnly interface {
    // Add adds a pin to the State
    Add(context.Context, *api.Pin) error
    // Rm removes a pin from the State.
    Rm(context.Context, cid.Cid) error

WriteOnly represents the write side of a State.


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

Package state imports 5 packages (graph) and is imported by 8 packages. Updated 2020-06-07. Refresh now. Tools for package owners.