maptracker

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2017 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

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

Index

Constants

This section is empty.

Variables

View Source
var (
	PinningTimeout   = 60 * time.Minute
	UnpinningTimeout = 15 * time.Minute
)

A Pin or Unpin operation will be considered failed if the Cid has stayed in Pinning or Unpinning state for longer than these values.

View Source
var PinQueueSize = 1024

PinQueueSize specifies the maximum amount of pin operations waiting to be performed. If the queue is full, pins/unpins will be set to pinError/unpinError.

Functions

This section is empty.

Types

type MapPinTracker

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

func NewMapPinTracker(pid peer.ID) *MapPinTracker

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

func (*MapPinTracker) Recover

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

Recover will re-track or re-untrack a Cid in error state, possibly retriggering an IPFS pinning operation and returning only when it is done. The pinning/unpinning operation happens synchronously, jumping the queues.

func (*MapPinTracker) SetClient

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

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

func (*MapPinTracker) Shutdown

func (mpt *MapPinTracker) Shutdown() error

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

func (*MapPinTracker) Status

func (mpt *MapPinTracker) Status(c *cid.Cid) api.PinInfo

Status returns information for a Cid tracked by this MapPinTracker.

func (*MapPinTracker) StatusAll

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

StatusAll returns information for all Cids tracked by this MapPinTracker.

func (*MapPinTracker) Sync

func (mpt *MapPinTracker) Sync(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

func (mpt *MapPinTracker) SyncAll() ([]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

func (mpt *MapPinTracker) Track(c api.Pin) error

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

func (*MapPinTracker) Untrack

func (mpt *MapPinTracker) Untrack(c *cid.Cid) error

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

Jump to

Keyboard shortcuts

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