Documentation ¶
Overview ¶
Package job describes the types and methods to interact with the jobs.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ByProviderFetcher ¶
type ByProviderFetcher interface {
GetJobsByProvider(ctx context.Context, providerAddress common.Address) ([]types.Job, error)
}
ByProviderFetcher fetches the jobs meta-scheduled or running on the provider.
type Fetcher ¶
type Fetcher interface { // Get a job. GetJob(ctx context.Context, id [32]byte) (types.Job, error) // Get a iterator of jobs. If there is no job, nil is returned. GetJobs(ctx context.Context) (*Iterator, error) // Fetches the next job. Next(ctx context.Context, it LazyIterator) (ok bool) }
Fetcher fetches jobs.
type Iterator ¶ added in v1.5.4
type Iterator struct {
// contains filtered or unexported fields
}
Iterator is an iterator of jobs.
func NewIterator ¶ added in v1.5.4
NewIterator creates a new iterator.
func (*Iterator) IncrementIndex ¶ added in v1.5.4
func (it *Iterator) IncrementIndex()
IncrementIndex increments the index.
type LazyIterator ¶
type LazyIterator interface { // Get the current job. Current() types.Job // Get the current error. Error() error // Get the current index. Index() int // Get the current size. Size() int // Set the error. SetError(err error) // Increment the index. IncrementIndex() // Set the current job. SetJob(job types.Job) // Get the next index. GetNextID() [32]byte }
LazyIterator iterates on a lazy list of jobs.
When calling Next or Prev, a request will be sent to the data source.
type MetaScheduledIDsFetcher ¶ added in v1.5.2
type MetaScheduledIDsFetcher interface {
GetMetaScheduledJobIDs(ctx context.Context) ([][32]byte, error)
}
MetaScheduledIDsFetcher fetches meta-scheduled jobs ids.
This contacts directly the meta-scheduler without the need to fetch all the jobs.
type Scheduler ¶
type Scheduler interface { // Submit a batch script to the batch service and metascheduler. SubmitJob( ctx context.Context, job *sbatch.Job, lockedAmount *big.Int, jobName [32]byte, opts ...SubmitJobOption, ) ([32]byte, error) // Cancel a job. CancelJob(ctx context.Context, jobID [32]byte) error // TopUp a job. TopUpJob(ctx context.Context, jobID [32]byte, amount *big.Int) error // Panic a job. PanicJob(ctx context.Context, jobID [32]byte, reason string) error }
Scheduler schedules and cancels jobs.
type SubmitJobOption ¶
type SubmitJobOption func(*SubmitJobOptions)
SubmitJobOption is used to apply default and optional parameters for submitting a job.
func WithAffinity ¶
func WithAffinity(affinities ...types.Affinity) SubmitJobOption
WithAffinity adds key-value filters with operators to the job, which filters the available clusters.
func WithUse ¶
func WithUse(labels ...types.Label) SubmitJobOption
WithUse adds strict key-value filters to the job, which filters the available clusters.