View Source Finitomata.Accessible (Finitomata v0.29.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

t()

The convenience struct representing the Finitomata.Supervisor with Access

Functions

Looks up the Finitomata.Accessible instance for the given id

Supervision tree embedder.

Types

t()

(since 0.26.0)
@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

lookup(id)

(since 0.26.0)
@spec lookup(Finitomata.id()) :: t()

Looks up the Finitomata.Accessible instance for the given id

start_link(opts \\ [])

(since 0.26.0)

Supervision tree embedder.

  • :type - The actual Finitomata.Supervisor implementation (typically, Finitomata or Infinitomata) The default value is Infinitomata.

  • :implementation (atom/0) - Required. The actual implementation of FSM (the module, having use Finitomata clause)

  • :id (term/0) - The unique ID of this Finitomata “branch,” when nil the implementation value would be used The default value is nil.