View Source Finitomata.Accessible (Finitomata v0.26.3)
The convenience module, exposing start_link/1
to embed Finitomata.Supervisor
implementation into a supervision tree in an agnostic way.
This module implements Access
in a contrived way, allowing to deal with underlying
FSM instances in a following way.
iex|🌢|1 ▶ Finitomata.Accessible.start_link(type: Finitomata, implementation: L, id: L1)
{:ok, #PID<0.214.0>}
iex|🌢|2 ▶ sup = Finitomata.Accessible.lookup(L1)
%Finitomata.Accessible{
type: Finitomata,
id: L1,
implementation: Finitomata.Test.Log,
last_event: nil,
cached_pid: #PID<0.214.0>
}
iex|🌢|3 ▶ put_in(sup, ["MyFSM"], :accept)
07:16:34.736 [debug] [→ ↹] […]
07:16:34.738 [debug] [✓ ⇄] with: [current: :*, event: :__start__, event_payload: %{payload: nil, __retries__: 1}, state: %{}]
07:16:34.738 [debug] [← ↹] […]
07:16:34.738 [debug] [→ ↹] […]
07:16:34.739 [debug] [✓ ⇄] with: [current: :idle, event: :accept, event_payload: nil, state: %{}]
07:16:34.739 [debug] [← ↹] […]
%Finitomata.Accessible{
type: Finitomata,
id: L1,
implementation: Finitomata.Test.Log,
last_event: {"MyFSM", :accept},
cached_pid: #PID<0.214.0>
}
iex|🌢|4 ▶ get_in(sup, ["MyFSM"])
#Finitomata<[
name: {Finitomata.L1.Registry, "MyFSM"},
state: [current: :accepted, previous: :idle, payload: %{}],
internals: [errored?: false, persisted?: false, timer: false]
]>
Summary
Types
The convenience struct representing the Finitomata.Supervisor
with Access
Types
@type t() :: %Finitomata.Accessible{ type: Finitomata.Supervisor.t(), id: Finitomata.id(), implementation: module(), last_event: nil | {Finitomata.fsm_name(), Finitomata.event_payload()}, cached_pid: nil | pid() }
The convenience struct representing the Finitomata.Supervisor
with Access
Functions
@spec lookup(Finitomata.id()) :: t()
Looks up the Finitomata.Accessible
instance for the given id
Supervision tree embedder.
Options to Finitomata.Accessible.start_link/1
:type
- The actualFinitomata.Supervisor
implementation (typically,Finitomata
orInfinitomata
) The default value isInfinitomata
.:implementation
(atom/0
) - Required. The actual implementation of FSM (the module, havinguse Finitomata
clause):id
(term/0
) - The uniqueID
of this Finitomata “branch,” whennil
theimplementation
value would be used The default value isnil
.