cron

package
v0.0.0-...-e1e9d1d Latest Latest
Warning

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

Go to latest
Published: May 20, 2021 License: BSD-3-Clause Imports: 2 Imported by: 0

Documentation

Overview

Package cron defines the standard interface for scheduled jobs (aka cron jobs).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MockScheduler

type MockScheduler struct {
	ScheduleFunc   func(context.Context, string, string, interface{}) error
	UnscheduleFunc func(context.Context, string) error
}

MockScheduler is a test mock for the Scheduler interface.

func (*MockScheduler) Schedule

func (m *MockScheduler) Schedule(ctx context.Context, jobID, cronSpec string, data interface{}) error

func (*MockScheduler) Unschedule

func (m *MockScheduler) Unschedule(ctx context.Context, jobID string) error

type Scheduler

type Scheduler interface {
	// Schedule registers a job for execution based on cronSpec. See
	// https://godoc.org/github.com/robfig/cron#hdr-CRON_Expression_Format for
	// information on the cron spec string.
	//
	// The jobID identifies this job, and data is the payload that will be sent
	// to every execution; it is implementation-specific (e.g. an implementation
	// could JSON-encode it and pass it as a message to a queue). If the same
	// jobID already exists as a scheduled job, the call must replace its
	// definition and do a best effort to schedule executions based on the new
	// spec.
	//
	// The context is used to control the deadline of the request to schedule the
	// job, it has no impact on the actual execution of the job.
	Schedule(ctx context.Context, jobID string, cronSpec string, data interface{}) error

	// Unschedule removes a scheduled job, doing a best effort to prevent further
	// execution.
	//
	// The context is used to control the deadline of the request to unschedule
	// the job.
	Unschedule(ctx context.Context, jobID string) error
}

Scheduler defines how to schedule a job to be executed based on a cronSpec.

Jump to

Keyboard shortcuts

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