View Source Bella.PeriodicTask (bella v0.0.7)

Register periodically run tasks. Use for running tasks as a part of reconciling a CRD with a lifetime, duration, or interval field.

Note: Must be started by your operator.

Add Bella.PeriodicTask.sttart_link(:ok) to your application.

Functions are expected to return one of:

  • :ok - task will be passed to subsequent calls
  • {:ok, new_state} state field will be updated in task and provided to next call
  • {:stop, reason} task will be removed from execution loop. Use for tasks opting out of being re-run
  • any() - any other result is treated as an error, and the execution loop will be halted

examples

Examples

Registering a task

iex> Bella.PeriodicTask.new(:pod_evictor, {PodEvictor, :evict, [reconcile_payload_map]}, 5000)

Unregistering a task

iex> Bella.PeriodicTask.unregister(:pod_evictor)

Link to this section Summary

Functions

Returns a specification to start this module under a supervisor.

Registers and starts a new task given Bella.PeriodicTask attributes

Registers and starts a new Bella.PeriodicTask

Unregisters and stops a Bella.PeriodicTask

Link to this section Types

Specs

t() :: %Bella.PeriodicTask{
  handler: (... -> any()) | mfa(),
  id: binary(),
  interval: pos_integer(),
  jitter: float(),
  state: any()
}

Link to this section Functions

Returns a specification to start this module under a supervisor.

See Supervisor.

Link to this function

new(id, handler, interval \\ 5000)

View Source

Specs

new(binary(), (... -> any()) | {atom(), atom(), byte()}, pos_integer()) ::
  {:error, any()} | {:ok, pid()}

Registers and starts a new task given Bella.PeriodicTask attributes

Specs

register(t()) :: {:ok, pid()} | {:error, term()}

Registers and starts a new Bella.PeriodicTask

Specs

start_link(any()) :: :ignore | {:error, any()} | {:ok, pid()}

Specs

unregister(t() | atom()) :: any()

Unregisters and stops a Bella.PeriodicTask