advanced

package
v1.8.0-beta.1 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Parameter

type Parameter interface {
	// contains filtered or unexported methods
}

Parameter is the interface for service parameters.

func WithLogLevel

func WithLogLevel(logLevel zerolog.Level) Parameter

WithLogLevel sets the log level for the module.

func WithMonitor

func WithMonitor(monitor metrics.SchedulerMonitor) Parameter

WithMonitor sets the monitor for this module.

type Service

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

Service is a scheduler service. It uses additional per-job information to manage the state of each job, in an attempt to ensure additional robustness in the face of high concurrent load.

func New

func New(_ context.Context, params ...Parameter) (*Service, error)

New creates a new scheduling service.

func (*Service) CancelJob

func (s *Service) CancelJob(_ context.Context, name string) error

CancelJob removes a named job. If the job does not exist it will return an appropriate error.

func (*Service) CancelJobIfExists

func (s *Service) CancelJobIfExists(ctx context.Context, name string)

CancelJobIfExists cancels a job that may or may not exist. If this is a period job then all future instances are cancelled.

func (*Service) CancelJobs

func (s *Service) CancelJobs(ctx context.Context, prefix string)

CancelJobs cancels all jobs with the given prefix. If the prefix matches a period job then all future instances are cancelled.

func (*Service) JobExists

func (s *Service) JobExists(_ context.Context, name string) bool

JobExists returns true if a job exists.

func (*Service) ListJobs

func (s *Service) ListJobs(_ context.Context) []string

ListJobs returns the names of all jobs.

func (*Service) RunJob

func (s *Service) RunJob(ctx context.Context, name string) error

RunJob runs a named job immediately. If the job does not exist it will return an appropriate error.

func (*Service) RunJobIfExists

func (s *Service) RunJobIfExists(ctx context.Context, name string)

RunJobIfExists runs a job if it exists. This does not return an error if the job does not exist or is otherwise unable to run.

func (*Service) ScheduleJob

func (s *Service) ScheduleJob(ctx context.Context,
	class string,
	name string,
	runtime time.Time,
	jobFunc scheduler.JobFunc,
	data interface{},
) error

ScheduleJob schedules a one-off job for a given time. Note that if the parent context is cancelled the job wil not run.

func (*Service) SchedulePeriodicJob

func (s *Service) SchedulePeriodicJob(ctx context.Context,
	class string,
	name string,
	runtimeFunc scheduler.RuntimeFunc,
	runtimeData interface{},
	jobFunc scheduler.JobFunc,
	jobData 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.

Jump to

Keyboard shortcuts

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