Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var Logger *slog.Logger = slog.Default()
Functions ¶
Types ¶
type Scheduler ¶
type Scheduler struct {
// contains filtered or unexported fields
}
Scheduler is the high-level structure to manage the in-memory tasks. Do not create the structure manually. Always use `scheduled.NewScheduler()`
func NewScheduler ¶
func NewScheduler() *Scheduler
NewScheduler creates a new instance of the scheduler with an empty initialised slice of tasks.
To use the scheduler, add a task via `scheduler.RegisterTask` or `scheduler.RunOnce`
func (*Scheduler) GetTask ¶
GetTask returns a task registered under provided uuid.UUID. If the task is not registered, the function returns an error.
func (*Scheduler) RegisterTask ¶
RegisterTask allows for a task to be added within the execution loop of the scheduler
func (*Scheduler) RemoveTask ¶
RemoveTask removes a given task from the scheduler while also stopping its execution if it were already scheduled
type TaskErrFunc ¶
type TaskErrFunc func(err error)
type TaskOpts ¶
type TaskOpts struct { // Underlying function to be ran within the scheduler. Fn TaskFunc // In case of an error in Fn, ErrFn will be executed if provided. ErrFn TaskErrFunc // Offsets the initial startup to a given start time. By default it will start immediately on schedule. StartTime time.Time // Restricts the time boundary of the runtime to an end date. By default it is unbound. EndTime time.Time // Interval for Fn's execution within the scheduler. This is the function's tick. Interval time.Duration // Limits the amount of times a single task can be executed in the runtime. After `MaxIter` steps, it will end. // By default, it is 0 (infinite). Negative values are not allowed. MaxIter int // Allows the scheduling based on a CRON string. Overrides `Interval` Cron string }
Click to show internal directories.
Click to hide internal directories.