Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ValidateSchedule ¶
ValidateSchedule validates schedule content is legal.
Types ¶
type Derivation ¶
Derivation derives new plans from scheduled plans. Derived plans will replace scheduled plans.
type DerivationFunc ¶
DerivationFunc wraps a function as Derivation.
type FileProvider ¶
type FileProvider struct {
Filename string
}
FileProvider provides a schedule from a file.
func (*FileProvider) Provide ¶
func (fp *FileProvider) Provide() (Schedule, error)
type Item ¶
type Item struct { Queue string `yaml:"queue"` // Args is a json array. Args string `yaml:"args"` // See https://en.wikipedia.org/wiki/Cron or https://github.com/robfig/cron Cron string `yaml:"cron"` RecoveryPolicy RecoveryPolicy `yaml:"recoveryPolicy"` RetryPolicy que.RetryPolicy `yaml:"retryPolicy"` }
Item represents a job need to enqueue queue according to cron.
type MemProvider ¶
type MemProvider struct {
Schedule Schedule
}
MemProvider provides a schedule from given Schedule.
func (*MemProvider) Provide ¶
func (mp *MemProvider) Provide() (Schedule, error)
type RecoveryPolicy ¶
type RecoveryPolicy string
RecoveryPolicy guides how to process schedule after a long period of downtime.
const ( // Ignore ignores missed events and schedule each item from now. Ignore RecoveryPolicy = "ignore" // Reparation schedule each item from last scheduled item run time to now. Reparation RecoveryPolicy = "reparation" )
type Scheduler ¶
type Scheduler struct { DB *sql.DB // Queue is used by scheduler ennqueue self. Queue string // Enqueue saves a set of jobs according to plans. Enqueue func(context.Context, *sql.Tx, ...que.Plan) ([]int64, error) // Provider privide a list of named schedule. // Scheduler enqueues new plans according to privided schedule. Provider Provider // Derivations is list of Derivation. // The key of provided Schedule corresponding to the key of Derivations. Derivations map[string]Derivation }
Scheduler enqueue jobs according to provided schedule. Prepare must be called in application initializtion. Scheduler with same Queue can run in different machines.
Click to show internal directories.
Click to hide internal directories.