Cizen v0.12.5 Cizen.Saga behaviour View Source

The saga behaviour

Example

defmodule SomeSaga do
  @behaviour Cizen.Saga
  defstruct []

  @impl true
  def init(_id, %__MODULE__{}) do
    saga
  end

  @impl true
  def handle_event(_id, _event, state) do
    state
  end
end

Link to this section Summary

Functions

Returns a specification to start this module under a supervisor

Starts a saga which finishes when the current process exits

Returns the module for a saga

Starts a saga linked to the current process

Callbacks

Invoked when the saga receives an event

Invoked when the saga is started. Saga.Started event will be dispatched after this callback

Link to this section Types

Link to this section Functions

Returns a specification to start this module under a supervisor.

See Supervisor.

Starts a saga which finishes when the current process exits.

Link to this function module(saga) View Source
module(t()) :: module()

Returns the module for a saga.

Link to this function start_link(saga) View Source
start_link(t()) :: GenServer.on_start()

Starts a saga linked to the current process

Link to this function start_saga(id, saga, lifetime) View Source

Link to this section Callbacks

Link to this callback handle_event(arg0, arg1, state) View Source
handle_event(Cizen.SagaID.t(), Cizen.Event.t(), state()) :: state()

Invoked when the saga receives an event.

Returned value will be used as the next state to pass handle_event/3 callback.

Invoked when the saga is started. Saga.Started event will be dispatched after this callback.

Returned value will be used as the next state to pass handle_event/3 callback.