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 currentstate
we wantdata
to have.data
- thedata
forpid
that has astate
field.pid
- the fallback RPC client pid, used to update the state ofdata
towards thecurrent_goal
ifpid_by_transition
does not have an entry for transition fromdata
state
tocurrent_goal
.pid_by_transition
- Looks up pid to use to update fromdata
state
tocurrent_goal
. Ifpid_by_transition
does not have an entry fordata
state
tocurrent_goal
, thenpid
is used.predecessor_by_state
- thestate
that can transition to keystate
previous_goals
- a list of the previouscurrent_goal
s that couldn’t be transitioned to directly because the predecessor inprecessor_by_state
was notdata
’sstate
.update
- callback that takest
and 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 currentstate
we wantdata
to have.data
- thedata
forpid
that has astate
field.pid
- the fallback RPC client pid, used to update the state ofdata
towards thecurrent_goal
ifpid_by_transition
does not have an entry for transition fromdata
state
tocurrent_goal
.pid_by_transition
- Looks up pid to use to update fromdata
state
tocurrent_goal
. Ifpid_by_transition
does not have an entry fordata
state
tocurrent_goal
, thenpid
is used.predecessor_by_state
- thestate
that can transition to keystate
previous_goals
- a list of the previouscurrent_goal
s that couldn’t be transitioned to directly because the predecessor inprecessor_by_state
was notdata
’sstate
.update
- callback that takest
and 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()