recurringtask

package
v0.18.0-rc.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 5, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

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:

  1. It does not support running a job at a specific time of day, but only supports the "run every X" idiom.
  2. 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
  3. 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

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[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

func StartMonitor

func StartMonitor[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, erl.Ref, error)

See StartLink

func Stop

func Stop(self erl.PID, task erl.PID, opts ...genserver.ExitOpt) error

Stops the task fun, synchronously. A running TaskFun will complete, possibly after this function returns.

Types

type StartOpt

type StartOpt func(opts *taskOpts) *taskOpts

func SetInterval

func SetInterval(interval time.Duration) StartOpt

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 SetName

func SetName(name erl.Name) StartOpt

Register this task with a name

func SetStartTimeout

func SetStartTimeout(tout time.Duration) StartOpt

How long to wait for this process to start before an error is returned

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL