Commanded scheduler v0.2.1 Commanded.Scheduler View Source
One-off command scheduler for Commanded CQRS/ES applications.
Link to this section Summary
Functions
Cancel a one-off or recurring schedule.
Schedule multiple one-off commands in a single batch.
Schedule a uniquely identified one-off job using the given command to dispatch at the specified date/time.
Link to this section Types
Link to this type
due_at()
View Source
due_at()
View Source
due_at() :: DateTime.t() | NaiveDateTime.t()
due_at() :: DateTime.t() | NaiveDateTime.t()
Link to this type
schedule_uuid()
View Source
schedule_uuid()
View Source
schedule_uuid() :: String.t()
schedule_uuid() :: String.t()
Link to this section Functions
Link to this function
cancel_schedule(schedule_uuid, opts \\ [])
View Source
cancel_schedule(schedule_uuid, opts \\ [])
View Source
cancel_schedule(schedule_uuid(), [{:name, String.t()}]) ::
:ok | {:error, term()}
cancel_schedule(schedule_uuid(), [{:name, String.t()}]) :: :ok | {:error, term()}
Cancel a one-off or recurring schedule.
Link to this function
schedule_batch(batch)
View Source
schedule_batch(batch)
View Source
schedule_batch(Commanded.Scheduler.ScheduleBatch.t()) :: :ok | {:error, term()}
schedule_batch(Commanded.Scheduler.ScheduleBatch.t()) :: :ok | {:error, term()}
Schedule multiple one-off commands in a single batch.
This guarantees that all, or none, of the commands are scheduled.
Example
alias Commanded.Scheduler
alias Commanded.Scheduler.Batch
batch =
reservation_id
|> Batch.new()
|> Batch.schedule_once(%TimeoutReservation{..}, timeout_due_at, name: "timeout")
|> Batch.schedule_once(%ReleaseSeat{..}, release_due_at, name: "release")
Scheduler.schedule_batch(batch)
Link to this function
schedule_once(schedule_uuid, command, due_at, opts \\ [])
View Source
schedule_once(schedule_uuid, command, due_at, opts \\ [])
View Source
schedule_once(schedule_uuid(), struct(), due_at(), [{:name, String.t()}]) ::
:ok | {:error, term()}
schedule_once(schedule_uuid(), struct(), due_at(), [{:name, String.t()}]) :: :ok | {:error, term()}
Schedule a uniquely identified one-off job using the given command to dispatch at the specified date/time.
Example
Commanded.Scheduler.schedule_once(reservation_id, %TimeoutReservation{..}, ~N[2020-01-01 12:00:00])
Name the scheduled job:
Commanded.Scheduler.schedule_once(reservation_id, %TimeoutReservation{..}, due_at, name: "timeout")