Documentation ¶
Overview ¶
Package dsstate implements the IPFS Cluster state interface using an underlying go-datastore.
Index ¶
- func DefaultHandle() codec.Handle
- type BatchingState
- type State
- func (st *State) Add(ctx context.Context, c api.Pin) (err error)
- func (st *State) Get(ctx context.Context, c api.Cid) (api.Pin, error)
- func (st *State) Has(ctx context.Context, c api.Cid) (bool, error)
- func (st *State) List(ctx context.Context, out chan<- api.Pin) error
- func (st *State) Marshal(w io.Writer) error
- func (st *State) Migrate(ctx context.Context, r io.Reader) error
- func (st *State) Rm(ctx context.Context, c api.Cid) error
- func (st *State) Unmarshal(r io.Reader) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultHandle ¶
DefaultHandle returns the codec handler of choice (Msgpack).
Types ¶
type BatchingState ¶
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 ¶
func NewBatching(ctx context.Context, 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).
type State ¶
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 ¶
func New(ctx context.Context, 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) Get ¶
Get returns a Pin from the store and whether it was present. When not present, a default pin is returned.
func (*State) List ¶
List sends all the pins on the pinset on the given channel. Returns and closes channel when done.
func (*State) Marshal ¶
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 ¶
Migrate migrates an older state version to the current one. This is a no-op for now.