pinset

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2019 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MemPinset

type MemPinset struct {
	Profiles registry.Profiles
	// contains filtered or unexported fields
}

MemPinset is a completely ficticious implementation of a pinset it shouldn't ever be used in real-world scenarios. We use it for mocking a pinning service without an actual backing store keeping pins

func (*MemPinset) Pin

func (m *MemPinset) Pin(req *PinRequest) (chan PinStatus, error)

Pin a dataset

func (*MemPinset) PinLen

func (m *MemPinset) PinLen() (int, error)

PinLen returns the number of pins in the pinset

func (*MemPinset) Pinned

func (m *MemPinset) Pinned(path string) (pinned bool, err error)

Pinned gets the pin status of a path

func (*MemPinset) Pins

func (m *MemPinset) Pins(limit, offset int) (pins []string, err error)

Pins reads from the list present in the pinset

func (*MemPinset) Status

func (m *MemPinset) Status(req *PinRequest) (PinStatus, error)

Status gives a hydrated, up-to-date progress struct for a given request ID

func (*MemPinset) Unpin

func (m *MemPinset) Unpin(req *PinRequest) error

Unpin a dataset

type PinRequest

type PinRequest struct {
	ProfileID     string
	Signature     string
	Path          string
	PeerAddresses []string
}

PinRequest is a signed request to modify the status of a pin

func NewPinRequest

func NewPinRequest(path string, privKey crypto.PrivKey, addrs []string) (*PinRequest, error)

NewPinRequest creates a pin request from a private key & path combo

type PinStatus

type PinStatus struct {
	Path        string
	Pinned      bool
	TTL         time.Time
	PctComplete float32
	// optional string representing status, intended to be shown to users
	Status string
	Error  string
}

PinStatus carries state about the status of a pin process

type PinStatusStore

type PinStatusStore struct {
	sync.Mutex
	// contains filtered or unexported fields
}

PinStatusStore is an in-memory key-value store of PinStatus using the Status "Path" field as keys To prevent the store from unbounded growth statuses are removed if the timespan since a status "Started" field exceeds the TTL value of the store (defaults to 4 hours). Statuses are checked with a ticker the defaults to calling Sweep every 20 minutes

func (*PinStatusStore) Delete

func (p *PinStatusStore) Delete(path string)

Delete removes a pinjob from the store by path

func (*PinStatusStore) Get

func (p *PinStatusStore) Get(path string) *PinStatus

Get a pinjob by path

func (*PinStatusStore) Set

func (p *PinStatusStore) Set(ps PinStatus)

Set a pin status

func (*PinStatusStore) StartGC

func (p *PinStatusStore) StartGC(interval time.Duration)

StartGC begins the garbage collection ticker

func (*PinStatusStore) StopGC

func (p *PinStatusStore) StopGC()

StopGC halts the ticker

func (*PinStatusStore) Sweep

func (p *PinStatusStore) Sweep()

Sweep checks for stale PinStatus and removes them

type Pinset

type Pinset interface {
	// Pin can take a while, so Pin returns a channel of PinStatus to
	// deliver updates structs that should all share an ID for the request that
	// the Pinset implementation will provide
	Pin(req *PinRequest) (chan PinStatus, error)
	// Unpin removes a pin
	Unpin(req *PinRequest) error
	// Status gets the current pin state value for a given PinRequest
	Status(req *PinRequest) (PinStatus, error)
	// Pins lists pins within the range defined by limit & offset in
	// lexographical order, smallest to largest
	Pins(limit, offset int) ([]string, error)
	// PinLen returns the number of pins in the set
	PinLen() (int, error)
}

Pinset is the interface for acting as a remote pinning service. Pinset implementations are expected to keep a store of PinStatus that callers can use to probe the progress of a request

Jump to

Keyboard shortcuts

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