Fledex.Scheduler.Job (Fledex_Scheduler v0.1.0)

View Source

A job that determines the behaviour of scheduler. Instead of calling Fledex.Scheduler.run_at/2, Fledex.Scheduler.run_in/2, and Fledex.Scheduler.run_every you can specify your job and use Fledex.Scheduler.run_job/2

Summary

Types

schedule()

@type schedule() :: Crontab.CronExpression.t() | {pos_integer(), unit()}

t()

@type t() :: %Fledex.Scheduler.Job{
  context: map(),
  func: task() | nil,
  name: GenServer.name() | nil,
  opts: keyword(),
  schedule: schedule() | nil
}

task()

@type task() :: (-> any()) | (DateTime.t() -> any())

unit()

@type unit() ::
  :milliseconds
  | :ms
  | :seconds
  | :sec
  | :s
  | :minutes
  | :min
  | :m
  | :hours
  | :h
  | :weeks
  | :w

Functions

new()

@spec new() :: t()

new(name, func, schedule, context, opts)

@spec new(
  GenServer.name(),
  task(),
  Crontab.CronExpression.t() | {pos_integer(), unit()},
  map(),
  keyword()
) :: t()

set_context(job, context)

@spec set_context(t(), map()) :: t()

set_name(job, name)

@spec set_name(t(), GenServer.name()) :: t()

set_overlap(job, overlap)

@spec set_overlap(t(), boolean()) :: t()

set_repeat(job, repeat)

@spec set_repeat(t(), boolean()) :: t()

set_run_once(job, run_once)

@spec set_run_once(t(), boolean()) :: t()

set_schedule(job, schedule)

@spec set_schedule(t(), Crontab.CronExpression.t()) :: t()

set_task(job, func)

@spec set_task(t(), task()) :: t()

set_timezone(job, timezone)

@spec set_timezone(t(), :utc | String.t()) :: t()