Quantum.Job (Quantum v3.3.0) View Source
This Struct defines a Job.
Usage
The struct should never be defined by hand. Use Quantum.new_job/1
to create a new job and use the setters mentioned
below to mutate the job.
This is to ensure type safety.
Link to this section Summary
Functions
Sets a job's name.
Sets a job's overlap.
Sets a job's run strategy.
Sets a job's schedule.
Sets a job's state.
Sets a job's task.
Sets a job's timezone.
Link to this section Types
Specs
Specs
schedule() :: Crontab.CronExpression.t()
Specs
state() :: :active | :inactive
Specs
Specs
Specs
timezone() :: :utc | String.t()
Link to this section Functions
Specs
Specs
Sets a job's name.
Parameters
job
- The job struct to modifyname
- The name to set
Examples
iex> Acme.Scheduler.new_job()
...> |> Quantum.Job.set_name(:name)
...> |> Map.get(:name)
:name
Specs
Sets a job's overlap.
Parameters
job
- The job struct to modifyoverlap
- Enable / Disable Overlap
Examples
iex> Acme.Scheduler.new_job()
...> |> Quantum.Job.set_overlap(false)
...> |> Map.get(:overlap)
false
Specs
Sets a job's run strategy.
Parameters
job
- The job struct to modifyrun_strategy
- The run strategy to set
Examples
iex> Acme.Scheduler.new_job()
...> |> Quantum.Job.run_strategy(%Quantum.RunStrategy.All{nodes: [:one, :two]})
...> |> Map.get(:run_strategy)
[:one, :two]
Specs
set_schedule(t(), Crontab.CronExpression.t()) :: t()
Sets a job's schedule.
Parameters
job
- The job struct to modifyschedule
- The schedule to set. May only be of type%Crontab.CronExpression{}
Examples
iex> Acme.Scheduler.new_job()
...> |> Quantum.Job.set_schedule(Crontab.CronExpression.Parser.parse!("*/7"))
...> |> Map.get(:schedule)
Crontab.CronExpression.Parser.parse!("*/7")
Specs
Sets a job's state.
Parameters
job
- The job struct to modifystate
- The state to set
Examples
iex> Acme.Scheduler.new_job()
...> |> Quantum.Job.set_state(:active)
...> |> Map.get(:state)
:active
Specs
Sets a job's task.
Parameters
job
- The job struct to modifytask
- The function to be performed, ex:{Heartbeat, :send, []}
orfn -> :something end
Examples
iex> Acme.Scheduler.new_job()
...> |> Quantum.Job.set_task({Backup, :backup, []})
...> |> Map.get(:task)
{Backup, :backup, []}
Specs
Sets a job's timezone.
Parameters
job
- The job struct to modifytimezone
- The timezone to set.
Examples
iex> Acme.Scheduler.new_job()
...> |> Quantum.Job.set_timezone("Europe/Zurich")
...> |> Map.get(:timezone)
"Europe/Zurich"