ipfs-cluster: github.com/ipfs/ipfs-cluster/pintracker/maptracker Index | Files

package maptracker

import "github.com/ipfs/ipfs-cluster/pintracker/maptracker"

Package maptracker implements a PinTracker component for IPFS Cluster. It uses a map to keep track of the state of tracked pins.


Package Files

config.go maptracker.go


const (
    DefaultMaxPinQueueSize = 50000
    DefaultConcurrentPins  = 10

Default values for this Config.

type Config Uses

type Config struct {

    // If higher, they will automatically marked with an error.
    MaxPinQueueSize int
    // ConcurrentPins specifies how many pin requests can be sent to the ipfs
    // daemon in parallel. If the pinning method is "refs", it might increase
    // speed. Unpin requests are always processed one by one.
    ConcurrentPins int

Config allows to initialize a Monitor and customize some parameters.

func (*Config) ApplyEnvVars Uses

func (cfg *Config) ApplyEnvVars() error

ApplyEnvVars fills in any Config fields found as environment variables.

func (*Config) ConfigKey Uses

func (cfg *Config) ConfigKey() string

ConfigKey provides a human-friendly identifier for this type of Config.

func (*Config) Default Uses

func (cfg *Config) Default() error

Default sets the fields of this Config to sensible values.

func (*Config) LoadJSON Uses

func (cfg *Config) LoadJSON(raw []byte) error

LoadJSON sets the fields of this Config to the values defined by the JSON representation of it, as generated by ToJSON.

func (*Config) ToJSON Uses

func (cfg *Config) ToJSON() ([]byte, error)

ToJSON generates a human-friendly JSON representation of this Config.

func (*Config) Validate Uses

func (cfg *Config) Validate() error

Validate checks that the fields of this Config have working values, at least in appearance.

type MapPinTracker Uses

type MapPinTracker struct {
    // contains filtered or unexported fields

MapPinTracker is a PinTracker implementation which uses a Go map to store the status of the tracked Cids. This component is thread-safe.

func NewMapPinTracker Uses

func NewMapPinTracker(cfg *Config, pid peer.ID, peerName string) *MapPinTracker

NewMapPinTracker returns a new object which has been correcly initialized with the given configuration.

func (*MapPinTracker) OpContext Uses

func (mpt *MapPinTracker) OpContext(ctx context.Context, c cid.Cid) context.Context

OpContext exports the internal optracker's OpContext method. For testing purposes only.

func (*MapPinTracker) Recover Uses

func (mpt *MapPinTracker) Recover(ctx context.Context, c cid.Cid) (*api.PinInfo, error)

Recover will re-queue a Cid in error state for the failed operation, possibly retriggering an IPFS pinning operation.

func (*MapPinTracker) RecoverAll Uses

func (mpt *MapPinTracker) RecoverAll(ctx context.Context) ([]*api.PinInfo, error)

RecoverAll attempts to recover all items tracked by this peer.

func (*MapPinTracker) SetClient Uses

func (mpt *MapPinTracker) SetClient(c *rpc.Client)

SetClient makes the MapPinTracker ready to perform RPC requests to other components.

func (*MapPinTracker) Shutdown Uses

func (mpt *MapPinTracker) Shutdown(ctx context.Context) error

Shutdown finishes the services provided by the MapPinTracker and cancels any active context.

func (*MapPinTracker) Status Uses

func (mpt *MapPinTracker) Status(ctx context.Context, c cid.Cid) *api.PinInfo

Status returns information for a Cid tracked by this MapPinTracker.

func (*MapPinTracker) StatusAll Uses

func (mpt *MapPinTracker) StatusAll(ctx context.Context) []*api.PinInfo

StatusAll returns information for all Cids tracked by this MapPinTracker.

func (*MapPinTracker) Sync Uses

func (mpt *MapPinTracker) Sync(ctx context.Context, c cid.Cid) (*api.PinInfo, error)

Sync verifies that the status of a Cid matches that of the IPFS daemon. If not, it will be transitioned to PinError or UnpinError.

Sync returns the updated local status for the given Cid. Pins in error states can be recovered with Recover(). An error is returned if we are unable to contact the IPFS daemon.

func (*MapPinTracker) SyncAll Uses

func (mpt *MapPinTracker) SyncAll(ctx context.Context) ([]*api.PinInfo, error)

SyncAll verifies that the statuses of all tracked Cids match the one reported by the IPFS daemon. If not, they will be transitioned to PinError or UnpinError.

SyncAll returns the list of local status for all tracked Cids which were updated or have errors. Cids in error states can be recovered with Recover(). An error is returned if we are unable to contact the IPFS daemon.

func (*MapPinTracker) Track Uses

func (mpt *MapPinTracker) Track(ctx context.Context, c *api.Pin) error

Track tells the MapPinTracker to start managing a Cid, possibly triggering Pin operations on the IPFS daemon.

func (*MapPinTracker) Untrack Uses

func (mpt *MapPinTracker) Untrack(ctx context.Context, c cid.Cid) error

Untrack tells the MapPinTracker to stop managing a Cid. If the Cid is pinned locally, it will be unpinned.

Package maptracker imports 14 packages (graph) and is imported by 1 packages. Updated 2019-06-16. Refresh now. Tools for package owners.