scheduler

package
v1.3.2 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2022 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrJobAlreadyExists = errors.New("job already exists")

ErrJobAlreadyExists is returned when the scheduler is asked to create a job that already exists.

View Source
var ErrJobFinalised = errors.New("job finalised")

ErrJobFinalised is returned when the scheduler is asked to interact with a job that is finalised.

View Source
var ErrJobRunning = errors.New("job running")

ErrJobRunning is returned when the scheduler is asked to interact with a job that is running.

View Source
var ErrNoJobFunc = errors.New("no job function")

ErrNoJobFunc is returned when an attempt is made to to run a nil job.

View Source
var ErrNoJobName = errors.New("no job name")

ErrNoJobName is returned when an attempt is made to to control a job without a name.

View Source
var ErrNoMoreInstances = errors.New("no more instances")

ErrNoMoreInstances is returned by the runtime generator when it has no more instances.

View Source
var ErrNoRuntimeFunc = errors.New("no runtime function")

ErrNoRuntimeFunc is returned when an attempt is made to to run a periodic job without a runtime function.

View Source
var ErrNoSuchJob = errors.New("no such job")

ErrNoSuchJob is returned when the scheduler is asked to act upon a job about which it has no information.

Functions

This section is empty.

Types

type JobFunc

type JobFunc func(context.Context, interface{})

JobFunc is the type for jobs.

type RuntimeFunc

type RuntimeFunc func(context.Context, interface{}) (time.Time, error)

RuntimeFunc is the type of a function that generates the next runtime.

type Service

type Service interface {
	// ScheduleJob schedules a one-off job for a given time.
	// This function returns two cancel funcs.  If the first is triggered the job will not run.  If the second is triggered the job
	// runs immediately.
	// Note that if the parent context is cancelled the job wil not run.
	ScheduleJob(ctx context.Context, class string, name string, runtime time.Time, job JobFunc, data interface{}) error

	// SchedulePeriodicJob schedules a job to run in a loop.
	// The loop starts by calling runtimeFunc, which sets the time for the first run.
	// Once the time as specified by runtimeFunc is met, jobFunc is called.
	// Once jobFunc returns, go back to the beginning of the loop.
	SchedulePeriodicJob(ctx context.Context, class string, name string, runtime RuntimeFunc, runtimeData interface{}, job JobFunc, jobData interface{}) error

	// CancelJob cancels a known job.
	// If this is a period job then all future instances are cancelled.
	CancelJob(ctx context.Context, name string) error

	// CancelJobIfExists cancels a job that may or may not exist.
	// If this is a period job then all future instances are cancelled.
	CancelJobIfExists(ctx context.Context, name string)

	// CancelJobs cancels all jobs with the given prefix.
	// If the prefix matches a period job then all future instances are cancelled.
	CancelJobs(ctx context.Context, prefix string)

	// RunJob runs a known job.
	// If this is a period job then the next instance will be scheduled.
	RunJob(ctx context.Context, name string) error

	// JobExists returns true if a job exists.
	JobExists(ctx context.Context, name string) bool

	// RunJobIfExists runs a job if it exists.
	// If this is a period job then the next instance will be scheduled.
	RunJobIfExists(ctx context.Context, name string)

	// ListJobs returns the names of all jobs.
	ListJobs(ctx context.Context) []string
}

Service is the interface for schedulers.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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