powergate: github.com/textileio/powergate/ffs/scheduler Index | Files | Directories

package scheduler

import "github.com/textileio/powergate/ffs/scheduler"


Package Files

scheduler.go scheduler_retrieval.go scheduler_storage.go


var (

    // ErrNotFound is returned when an item isn't found on a Store.
    ErrNotFound = errors.New("item not found")

    // RenewalEvalFrequency is the frequency in which renewable StorageConfigs
    // will be evaluated.
    RenewalEvalFrequency = time.Hour * 24

    // RepairEvalFrequency is the frequency in which repairable StorageConfigs
    // will be evaluated.
    RepairEvalFrequency = time.Hour * 24
var (
    // HardcodedHotTimeout is a temporary override of storage configs
    // value for AddTimeout.
    HardcodedHotTimeout = time.Second * 300

type Scheduler Uses

type Scheduler struct {
    // contains filtered or unexported fields

Scheduler receives actions to store a Cid in Hot and Cold layers. These actions are created as Jobs which have a lifecycle that can be watched by external actors. This Jobs are executed by delegating the work to the Hot and Cold layers configured for the scheduler.

func New Uses

func New(ds datastore.TxnDatastore, l ffs.JobLogger, hs ffs.HotStorage, cs ffs.ColdStorage) (*Scheduler, error)

New returns a new instance of Scheduler which uses JobStore as its backing repository for state, HotStorage for the hot layer, and ColdStorage for the cold layer.

func (*Scheduler) Cancel Uses

func (s *Scheduler) Cancel(jid ffs.JobID) error

Cancel cancels an executing Job.

func (*Scheduler) Close Uses

func (s *Scheduler) Close() error

Close terminates the scheduler.

func (*Scheduler) GetCidFromHot Uses

func (s *Scheduler) GetCidFromHot(ctx context.Context, c cid.Cid) (io.Reader, error)

GetCidFromHot returns an io.Reader of the data from the hot layer.

func (*Scheduler) GetCidInfo Uses

func (s *Scheduler) GetCidInfo(c cid.Cid) (ffs.CidInfo, error)

GetCidInfo returns the current storage state of a Cid. Returns ErrNotFound if there isn't information for a Cid.

func (*Scheduler) GetJob Uses

func (s *Scheduler) GetJob(jid ffs.JobID) (ffs.StorageJob, error)

GetJob the current state of a Job.

func (*Scheduler) GetLogsByCid Uses

func (s *Scheduler) GetLogsByCid(ctx context.Context, c cid.Cid) ([]ffs.LogEntry, error)

GetLogsByCid returns history logs of a Cid.

func (*Scheduler) GetRetrievalInfo Uses

func (s *Scheduler) GetRetrievalInfo(rid ffs.RetrievalID) (ffs.RetrievalInfo, error)

GetRetrievalInfo returns the information about an executed retrieval.

func (*Scheduler) ImportCidInfo Uses

func (s *Scheduler) ImportCidInfo(ci ffs.CidInfo) error

ImportCidInfo imports Cid information manually. That's to say, will be CidInfo which wasn't generated by executing a Job, but provided externally.

func (*Scheduler) PushConfig Uses

func (s *Scheduler) PushConfig(iid ffs.APIID, c cid.Cid, cfg ffs.StorageConfig) (ffs.JobID, error)

PushConfig queues the specified StorageConfig to be executed as a new Job. It returns the created JobID for further tracking of its state.

func (*Scheduler) PushReplace Uses

func (s *Scheduler) PushReplace(iid ffs.APIID, c cid.Cid, cfg ffs.StorageConfig, oldCid cid.Cid) (ffs.JobID, error)

PushReplace queues a new StorageConfig to be executed as a new Job, replacing an oldCid that will be untrack in the Scheduler (i.e: deal renewals, repairing).

func (*Scheduler) StartRetrieval Uses

func (s *Scheduler) StartRetrieval(iid ffs.APIID, rid ffs.RetrievalID, pyCid, piCid cid.Cid, sel string, miners []string, walletAddr string, maxPrice uint64) (ffs.JobID, error)

StartRetrieval schedules a new RetrievalJob to execute a Filecoin retrieval.

func (*Scheduler) Untrack Uses

func (s *Scheduler) Untrack(c cid.Cid) error

Untrack untracks a Cid for renewal and repair background crons.

func (*Scheduler) WatchJobs Uses

func (s *Scheduler) WatchJobs(ctx context.Context, c chan<- ffs.StorageJob, iid ffs.APIID) error

WatchJobs returns a channel to listen to Job status changes from a specified API instance. It immediately pushes the current Job state to the channel.

func (*Scheduler) WatchLogs Uses

func (s *Scheduler) WatchLogs(ctx context.Context, c chan<- ffs.LogEntry) error

WatchLogs writes to a channel all new logs for Cids. The context should be canceled when wanting to stop receiving updates to the channel.



Package scheduler imports 17 packages (graph) and is imported by 12 packages. Updated 2020-09-27. Refresh now. Tools for package owners.