Documentation ¶
Index ¶
- type Parameter
- type Service
- func (s *Service) CancelJob(_ context.Context, name string) error
- func (s *Service) CancelJobIfExists(ctx context.Context, name string)
- func (s *Service) CancelJobs(ctx context.Context, prefix string)
- func (s *Service) JobExists(_ context.Context, name string) bool
- func (s *Service) ListJobs(_ context.Context) []string
- func (s *Service) RunJob(ctx context.Context, name string) error
- func (s *Service) RunJobIfExists(ctx context.Context, name string)
- func (s *Service) ScheduleJob(ctx context.Context, class string, name string, runtime time.Time, ...) error
- func (s *Service) SchedulePeriodicJob(ctx context.Context, class string, name string, ...) error
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 ¶
WithLogLevel sets the log level for the module.
func WithMonitor ¶
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 (*Service) CancelJob ¶
CancelJob removes a named job. If the job does not exist it will return an appropriate error.
func (*Service) CancelJobIfExists ¶
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 ¶
CancelJobs cancels all jobs with the given prefix. If the prefix matches a period job then all future instances are cancelled.
func (*Service) RunJob ¶
RunJob runs a named job immediately. If the job does not exist it will return an appropriate error.
func (*Service) RunJobIfExists ¶
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.