Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrNoNameSpecified = errs.Error("no name specified") ErrDurationLTEZero = errs.Error("duration less than or equal to zero") ErrNotFound = errs.Error("task not found") )
View Source
var TASKER_CONTEXT_KEY = contextKey{}
Functions ¶
This section is empty.
Types ¶
type Task ¶
type Task struct { Name string Func func(ctx context.Context) error OnError func(error) Duration time.Duration OnDequeue func(ctx context.Context) error }
Public facing task structure.
This can be used to configure the task to run.
type Tasker ¶
type Tasker interface { // Enqueue a task periodically by name. // If there is an error, it will be of type: // - ErrNoNameSpecified // - ErrDurationLTEZero Enqueue(task Task) error // Execute a task after the duration has passed, or immediately if the duration is 0. // If duration is zero, the task will be executed immediately in a goroutine, but the function will return ErrDurationLTEZero. // If the task name is provided, the task will be reset to the new duration. // If the task name is not provided, the task will be executed once after the duration has passed. After(task Task) error // Dequeue a task by name. // If there is an error, it will be of types: // - ErrNoNameSpecified // - ErrNotFound Dequeue(taskName string) error }
Tasker interface.
Click to show internal directories.
Click to hide internal directories.