scheduler

package
v2.6.2 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2021 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
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
)

Functions

This section is empty.

Types

type GCConfig

type GCConfig struct {
	StageGracePeriod time.Duration
	AutoGCInterval   time.Duration
}

GCConfig provides configuration for FFS GC.

type ListStorageJobsConfig

type ListStorageJobsConfig struct {
	// APIIDFilter filters StorageJobs list to the specified APIID. Defaults to no filter.
	APIIDFilter ffs.APIID
	// CidFilter filters StorageJobs list to the specified cid. Defaults to no filter.
	CidFilter cid.Cid
	// Limit limits the number of StorageJobs returned. Defaults to no limit.
	Limit uint64
	// Ascending returns the StorageJobs ascending by time. Defaults to false, descending.
	Ascending bool
	// Select specifies to return StorageJobs in the specified state.
	Select Select
	// NextPageToken sets the slug from which to start building the next page of results.
	NextPageToken string
}

ListStorageJobsConfig controls the behavior for listing StorageJobs.

type Scheduler

type Scheduler struct {
	// contains filtered or unexported fields
}

Scheduler receives actions to store a Cid in hot and cold storage. 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 storage configured for the scheduler.

func New

func New(ds datastore.TxnDatastore, l ffs.JobLogger, hs ffs.HotStorage, cs ffs.ColdStorage, maxParallel int, dealFinalityTimeout time.Duration, sr2rf func() (int, error), gcConfig GCConfig) (*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

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

Cancel cancels an executing Job.

func (*Scheduler) Close

func (s *Scheduler) Close() error

Close terminates the scheduler.

func (*Scheduler) GCStaged

func (s *Scheduler) GCStaged(ctx context.Context) ([]cid.Cid, error)

GCStaged runs a unpinned garbage collection of stage-pins.

func (*Scheduler) GetCidFromHot

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

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

func (*Scheduler) GetLogsByCid

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

GetLogsByCid returns history logs of a Cid.

func (*Scheduler) GetRetrievalInfo

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

GetRetrievalInfo returns the information about an executed retrieval.

func (*Scheduler) GetStorageInfo

func (s *Scheduler) GetStorageInfo(iid ffs.APIID, c cid.Cid) (ffs.StorageInfo, error)

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

func (*Scheduler) ImportDeals

func (s *Scheduler) ImportDeals(iid ffs.APIID, payloadCid cid.Cid, dealIDs []uint64) error

ImportDeals create or augments a Storageinfo for a Cid with the provided deal ids. All deal ids must be active on-chain to let the operation succeed.

func (*Scheduler) ListStorageInfo

func (s *Scheduler) ListStorageInfo(iids []ffs.APIID, cids []cid.Cid) ([]ffs.StorageInfo, error)

ListStorageInfo returns a list of StorageInfo matching any provided query options.

func (*Scheduler) ListStorageJobs

func (s *Scheduler) ListStorageJobs(config ListStorageJobsConfig) ([]ffs.StorageJob, bool, string, error)

ListStorageJobs lists StorageJobs according to the provided ListStorageJobsConfig.

func (*Scheduler) PinnedCids

func (s *Scheduler) PinnedCids(ctx context.Context) ([]ffs.PinnedCid, error)

PinnedCids returns the pinned cids from Hot-Storage.

func (*Scheduler) PushConfig

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

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

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) StorageConfig

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

StorageConfig returns the storage config for a job.

func (*Scheduler) StorageJob

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

StorageJob the current storage state of a Job.

func (*Scheduler) Untrack

func (s *Scheduler) Untrack(iid ffs.APIID, c cid.Cid) error

Untrack untracks a Cid from iid for renewal and repair background crons.

func (*Scheduler) WatchJobs

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

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.

type Select

type Select int

Select specifies which StorageJobs to list.

const (
	// All lists all StorageJobs and is the default.
	All Select = iota
	// Queued lists queued StorageJobs.
	Queued
	// Executing lists executing StorageJobs.
	Executing
	// Final lists final StorageJobs.
	Final
)

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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