jstore

package
v0.0.1-beta.4 Latest Latest
Warning

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

Go to latest
Published: May 29, 2020 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// ErrNotFound indicates the instance doesn't exist.
	ErrNotFound = errors.New("job not found")
)

Functions

This section is empty.

Types

type Store

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

Store is a Datastore implementation of JobStore, which saves state of scheduler Jobs.

func New

func New(ds datastore.Datastore) *Store

New returns a new JobStore backed by the Datastore.

func (*Store) Close

func (s *Store) Close() error

Close closes the Store, unregistering any subscribed watchers.

func (*Store) Dequeue

func (s *Store) Dequeue() (*ffs.Job, error)

Dequeue dequeues a Job which doesn't have have another Executing Job for the same Cid. Saying it differently, it's safe to execute. The returned job Status is automatically changed to Queued. If no jobs are available to dequeue it returns a nil *ffs.Job and no-error.

func (*Store) Enqueue

func (s *Store) Enqueue(j ffs.Job) error

Enqueue queues a new Job. If other Job for the same Cid is in Queued status, it will be automatically marked as Canceled.

func (*Store) Finalize

func (s *Store) Finalize(jid ffs.JobID, st ffs.JobStatus, jobError error, dealErrors []ffs.DealError) error

Finalize sets a Job status to a final state, i.e. Success or Failed, with a list of Deal errors occurred during job execution.

func (*Store) Get

func (s *Store) Get(jid ffs.JobID) (ffs.Job, error)

Get returns the current state of Job. If doesn't exist, returns ErrNotFound.

func (*Store) Watch

func (s *Store) Watch(ctx context.Context, c chan<- ffs.Job, iid ffs.APIID) error

Watch subscribes to Job changes from a specified Api instance.

Jump to

Keyboard shortcuts

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