retort v2.7.0 Retort.Client.StateMachine View Source

Manipulates the remote state machines over RPC

Link to this section Summary

Types

Data

Maps next transition from the current state to the current goal to the pid that is authorized to do that transition

State in data struct

t()
  • current_goal - the current state we want data to have.
  • data - the data for pid that has a state field.
  • pid - the fallback RPC client pid, used to update the state of data towards the current_goal if pid_by_transition does not have an entry for transition from data state to current_goal.
  • pid_by_transition - Looks up pid to use to update from data state to current_goal. If pid_by_transition does not have an entry for data state to current_goal, then pid is used.
  • predecessor_by_state - the state that can transition to key state
  • previous_goals - a list of the previous current_goals that couldn’t be transitioned to directly because the predecessor in precessor_by_state was not data’s state.
  • update - callback that takes t and updates the state to current_goal

Functions

Transitions data’s state to current_goal. If data’s state is a not direct predecessor of current_goal, then a path is found to get data’s state to current_goal using predecessor_by_state

Link to this section Types

Link to this type data() View Source
data() :: %atom(){:state => state(), optional(atom()) => any()}

Data

Link to this type pid_by_transition() View Source
pid_by_transition() :: %{optional(Retort.Client.StateMachine.Transition.t()) => pid()}

Maps next transition from the current state to the current goal to the pid that is authorized to do that transition.

State in data struct.

Link to this type t() View Source
t() :: %Retort.Client.StateMachine{current_goal: String.t(), data: data(), pid: pid() | nil, pid_by_transition: pid_by_transition(), predecessor_by_state: %{}, previous_goals: [state()], timeout: term(), update: (t() -> {:ok, data()} | Retort.Client.Generic.error())}
  • current_goal - the current state we want data to have.
  • data - the data for pid that has a state field.
  • pid - the fallback RPC client pid, used to update the state of data towards the current_goal if pid_by_transition does not have an entry for transition from data state to current_goal.
  • pid_by_transition - Looks up pid to use to update from data state to current_goal. If pid_by_transition does not have an entry for data state to current_goal, then pid is used.
  • predecessor_by_state - the state that can transition to key state
  • previous_goals - a list of the previous current_goals that couldn’t be transitioned to directly because the predecessor in precessor_by_state was not data’s state.
  • update - callback that takes t and updates the state to current_goal.

Link to this section Functions

Link to this function transition(state_machine) View Source
transition(t()) :: {:ok, data()} | Retort.Client.Generic.error()

Transitions data’s state to current_goal. If data’s state is a not direct predecessor of current_goal, then a path is found to get data’s state to current_goal using predecessor_by_state.

Link to this function update(state_machine) View Source
update(t()) ::
  {:ok, data()} |
  Retort.Client.Generic.error() |
  no_return()