job

package
v1.6.3 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2024 License: LGPL-3.0 Imports: 5 Imported by: 0

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

func NewIterator(array [][32]byte) *Iterator

NewIterator creates a new iterator.

func (*Iterator) Current added in v1.5.4

func (it *Iterator) Current() types.Job

Current returns the current job.

func (*Iterator) Error added in v1.5.4

func (it *Iterator) Error() error

Error returns the current error.

func (*Iterator) GetNextID added in v1.5.4

func (it *Iterator) GetNextID() [32]byte

GetNextID returns the next job.

func (*Iterator) IncrementIndex added in v1.5.4

func (it *Iterator) IncrementIndex()

IncrementIndex increments the index.

func (*Iterator) Index added in v1.5.4

func (it *Iterator) Index() int

Index returns the current index.

func (*Iterator) SetError added in v1.5.4

func (it *Iterator) SetError(err error)

SetError sets the error.

func (*Iterator) SetJob added in v1.5.4

func (it *Iterator) SetJob(job types.Job)

SetJob sets the current job.

func (*Iterator) Size added in v1.5.4

func (it *Iterator) Size() int

Size returns the size of the array.

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.

type SubmitJobOptions

type SubmitJobOptions struct {
	Uses       []types.Label
	Affinities []types.Affinity
}

SubmitJobOptions is the object containing optional parameters for submitting a job.

Jump to

Keyboard shortcuts

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