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
current_goal- the currentstatewe wantdatato have.data- thedataforpidthat has astatefield.pid- the fallback RPC client pid, used to update the state ofdatatowards thecurrent_goalifpid_by_transitiondoes not have an entry for transition fromdatastatetocurrent_goal.pid_by_transition- Looks up pid to use to update fromdatastatetocurrent_goal. Ifpid_by_transitiondoes not have an entry fordatastatetocurrent_goal, thenpidis used.predecessor_by_state- thestatethat can transition to keystateprevious_goals- a list of the previouscurrent_goals that couldn’t be transitioned to directly because the predecessor inprecessor_by_statewas notdata’sstate.update- callback that takestand updates the state tocurrent_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 currentstatewe wantdatato have.data- thedataforpidthat has astatefield.pid- the fallback RPC client pid, used to update the state ofdatatowards thecurrent_goalifpid_by_transitiondoes not have an entry for transition fromdatastatetocurrent_goal.pid_by_transition- Looks up pid to use to update fromdatastatetocurrent_goal. Ifpid_by_transitiondoes not have an entry fordatastatetocurrent_goal, thenpidis used.predecessor_by_state- thestatethat can transition to keystateprevious_goals- a list of the previouscurrent_goals that couldn’t be transitioned to directly because the predecessor inprecessor_by_statewas notdata’sstate.update- callback that takestand updates the state tocurrent_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()