View Source Finitomata.Supervisor behaviour (Finitomata v0.29.0)

THe behaviour for actual FSM implementations across Finitomata framework.

It ships with two predefined implementations, Finitomata for local applications and Infinitomata for distributed ones.

Summary

Types

t()

The module, implementing this behaviour

Callbacks

Returns whether the FSM instance under id “branch” and with fsm_name name is alive

Returns all the active FSM instances under the id “branch,” it might be a heavy map

The Finitomata “branch” child specification, used from supervision trees to start supervised FSM “branchs”

Starts the new FSM instance under id “branch,” the semantics is similar to DynamicSupervisor.start_child/2

Returns the state of the FSM instance under id “branch” with fsm_name name

Effectively initiates the on_timer/2 callback imminently, resetting the timer

Sends the event with an optional payload to the running FSM instance to initiate a transition

Functions

Returns a specification to start this module under a supervisor.

Types

t()

(since 0.26.0)
@type t() :: module()

The module, implementing this behaviour

Callbacks

alive?(id, fsm_name)

(since 0.26.0)
@callback alive?(id :: Finitomata.id(), fsm_name :: Finitomata.fsm_name()) :: boolean()

Returns whether the FSM instance under id “branch” and with fsm_name name is alive

all(id)

(since 0.26.0)
@callback all(Finitomata.id()) :: %{
  optional(Finitomata.fsm_name()) => %{
    optional(:node) => node(),
    optional(:reference) => reference(),
    optional(:module) => Finitomata.implementation(),
    pid: pid()
  }
}

Returns all the active FSM instances under the id “branch,” it might be a heavy map

child_spec(id)

(since 0.26.0)
@callback child_spec(id :: Finitomata.id()) :: Supervisor.child_spec()

The Finitomata “branch” child specification, used from supervision trees to start supervised FSM “branchs”

start_fsm(id, fsm_name, implementation, payload)

(since 0.26.0)
@callback start_fsm(
  id :: Finitomata.id(),
  fsm_name :: Finitomata.fsm_name(),
  implementation :: Finitomata.implementation(),
  payload :: Finitomata.payload()
) :: DynamicSupervisor.on_start_child()

Starts the new FSM instance under id “branch,” the semantics is similar to DynamicSupervisor.start_child/2

state(id, fsm_name, reload?)

(since 0.26.0)
@callback state(
  id :: Finitomata.id(),
  fsm_name :: Finitomata.fsm_name(),
  reload? ::
    :cached | :payload | :state | :full | (Finitomata.State.t() -> any())
) :: nil | Finitomata.State.t() | Finitomata.State.payload() | any()

Returns the state of the FSM instance under id “branch” with fsm_name name

timer_tick(id, fsm_name)

(since 0.26.0)
@callback timer_tick(id :: Finitomata.id(), fsm_name :: Finitomata.fsm_name()) :: :ok

Effectively initiates the on_timer/2 callback imminently, resetting the timer

transition(id, fsm_name, event_payload, delay)

(since 0.26.0)
@callback transition(
  id :: Finitomata.id(),
  fsm_name :: Finitomata.fsm_name(),
  event_payload ::
    Finitomata.Transition.event()
    | {Finitomata.Transition.event(), Finitomata.State.payload()},
  delay :: non_neg_integer()
) :: :ok

Sends the event with an optional payload to the running FSM instance to initiate a transition

Functions

child_spec(init_arg)

(since 0.26.0)

Returns a specification to start this module under a supervisor.

See Supervisor.