Documentation
¶
Overview ¶
Package jobticker provides functions and types to setup and trigger background jobs on a pre-defined ticker.
Package jobticker provides functions and types to setup and trigger background jobs on a pre-defined ticker.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type JobFunc ¶
JobFunc defines the jobs to execute. It is called with the execution context as well as the last and current tick of the job ticker.
type ScheduleSpec ¶
type ScheduleSpec string
ScheduleSpec defines a schedule based on a cron expression ([https://en.wikipedia.org/wiki/Cron]).
ScheduleSpec implements encoding.TextMarshaler and encoding.TextUnmarshaler.
func (ScheduleSpec) InInterval ¶
func (spec ScheduleSpec) InInterval(from, to time.Time) bool
InInterval determines whether this schedule lies within the given time interval.
func (ScheduleSpec) MarshalText ¶
func (spec ScheduleSpec) MarshalText() ([]byte, error)
func (ScheduleSpec) String ¶
func (spec ScheduleSpec) String() string
String gets the schedule expression as string.
func (*ScheduleSpec) UnmarshalText ¶
func (spec *ScheduleSpec) UnmarshalText(text []byte) error
type SequentialQueue ¶
type SequentialQueue struct {
// contains filtered or unexported fields
}
SequentialQueue defines a simple sequential job ticker. Jobs are executed in sequential order every time the ticker fires.
func StartSequential ¶
func StartSequential(ctx context.Context, schedule, deadline time.Duration, jobs ...JobFunc) *SequentialQueue
StartSequential starts a new sequential job ticker using the given schedule, deadline limit and jobs.
func (*SequentialQueue) AddJobs ¶
func (q *SequentialQueue) AddJobs(jobs ...JobFunc)
AddJobs adds the given jobs to this job ticker. The jobs are picked up the next time the job ticker fires.