Documentation
¶
Overview ¶
A recurringtask is similar to a cronjob; it is designed to be run on a soft schedule dictated by the SetInterval option. However, there are important differences with a cronjob:
- It does not support running a job at a specific time of day, but only supports the "run every X" idiom.
- It is not guaranteed to run every time the schedule is hit. The next run of the TaskFun will occur only AFTER the current execution is finished
- As a side effect of #2, this guarantees that only one TaskFun is executing at any one time.
Under the hood, [<- time.After(dur)] is used to set the schedule, so it is susceptible to time traveling if the system clock changes.
Index ¶
- func Start[S any, A any](self erl.PID, taskFun func(self erl.PID, state S) (S, error), ...) (erl.PID, error)
- func StartLink[S any, A any](self erl.PID, taskFun func(self erl.PID, state S) (S, error), ...) (erl.PID, error)
- func StartMonitor[S any, A any](self erl.PID, taskFun func(self erl.PID, state S) (S, error), ...) (erl.PID, erl.Ref, error)
- func Stop(self erl.PID, task erl.PID, opts ...genserver.ExitOpt) error
- type StartOpt
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Start ¶
func Start[S any, A any](self erl.PID, taskFun func(self erl.PID, state S) (S, error), initFun func(self erl.PID, args A) (S, error), args A, opts ...StartOpt) (erl.PID, error)
See StartLink
func StartLink ¶
func StartLink[S any, A any](self erl.PID, taskFun func(self erl.PID, state S) (S, error), initFun func(self erl.PID, args A) (S, error), args A, opts ...StartOpt) (erl.PID, error)
The [initFun] will run once, when the process starts, then the [taskFun] will run on every `Interval` or every 5m if SetInterval is not used
Types ¶
type StartOpt ¶
type StartOpt func(opts *taskOpts) *taskOpts
func SetInterval ¶
How often the task function should run. It is inclusive of task run time. so if the interval is 5m and the task takes 1m to run, the task will run effectively every 6m
func SetStartTimeout ¶
How long to wait for this process to start before an error is returned