Documentation ¶
Index ¶
- Constants
- func AddDefaultHook(hooks ...TaskHook)
- func EnableTracing(tracer opentracing.Tracer)
- type Mode
- type TaskCanceller
- type TaskFunc
- type TaskHook
- type TaskOption
- type TaskOptions
- func AtRate(repeatInterval time.Duration) TaskOptions
- func CancelOnError() TaskOptions
- func Name(name string) TaskOptions
- func StartAfter(delay time.Duration) TaskOptions
- func StartAt(startTime time.Time) TaskOptions
- func TaskHooks(hooks ...TaskHook) TaskOptions
- func WithDelay(repeatDelay time.Duration) TaskOptions
Constants ¶
const ( ModeFixedRate = iota ModeFixedDelay ModeRunOnce ModeDynamic )
Variables ¶
This section is empty.
Functions ¶
func AddDefaultHook ¶
func AddDefaultHook(hooks ...TaskHook)
func EnableTracing ¶ added in v0.14.0
func EnableTracing(tracer opentracing.Tracer)
EnableTracing add a default hook with provided openstracing.Tracer start/end/propagate spans during execution
Types ¶
type TaskCanceller ¶
type TaskCanceller interface { Cancelled() <-chan error Cancel() }
func Cron ¶
func Cron(expr string, taskFunc TaskFunc, opts ...TaskOptions) (TaskCanceller, error)
Cron schedules a task using CRON expression Supported CRON expression is "<second> <minutes> <hours> <day of month> <month> [day of week]", where "day of week" is optional Note 1: do not support 'L' Note 2: any options affecting start time and repeat rate (StartAt, AtRate, etc.) would take no effect
func Repeat ¶
func Repeat(taskFunc TaskFunc, opts ...TaskOptions) (TaskCanceller, error)
Repeat schedules a takes that repeat at specified time
func RunOnce ¶
func RunOnce(taskFunc TaskFunc, opts ...TaskOptions) (TaskCanceller, error)
RunOnce schedules a task that run only once at specified time Note: any options affecting repeat rate (AtRate, WithDelay, etc.) would take no effect
type TaskHook ¶
type TaskHook interface { // BeforeTrigger is invoked before each time the task is triggered. TaskHook can modify execution context BeforeTrigger(ctx context.Context, id string) context.Context // AfterTrigger is invoked after the task is triggered and executed AfterTrigger(ctx context.Context, id string, err error) }
type TaskOption ¶
type TaskOption struct {
// contains filtered or unexported fields
}
type TaskOptions ¶
type TaskOptions func(opt *TaskOption) error
func AtRate ¶
func AtRate(repeatInterval time.Duration) TaskOptions
AtRate option for "Fixed Interval" mode. Triggered every given interval. Long-running tasks overlap each other. Exclusive with WithDelay
func CancelOnError ¶
func CancelOnError() TaskOptions
CancelOnError option that automatically cancel the scheduled task if any execution returns non-nil error
func StartAfter ¶
func StartAfter(delay time.Duration) TaskOptions
StartAfter option to set task's initial trigger delay, should be positive duration Exclusive with StartAt
func StartAt ¶
func StartAt(startTime time.Time) TaskOptions
StartAt option to set task's initial trigger time, should be future time Exclusive with StartAfter
func WithDelay ¶
func WithDelay(repeatDelay time.Duration) TaskOptions
WithDelay option for "Fixed Delay" mode. Triggered with given delay after previous task finished Long-running tasks will never overlap Exclusive with AtRate