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

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

@type t() :: module()

The module, implementing this behaviour

Callbacks

Link to this callback

alive?(id, fsm_name)

View Source (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

@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

Link to this callback

child_spec(id)

View Source (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”

Link to this callback

start_fsm(id, fsm_name, implementation, payload)

View Source (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

Link to this callback

state(id, fsm_name, reload?)

View Source (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

Link to this callback

timer_tick(id, fsm_name)

View Source (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

Link to this callback

transition(id, fsm_name, event_payload, delay)

View Source (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

Link to this function

child_spec(init_arg)

View Source (since 0.26.0)

Returns a specification to start this module under a supervisor.

See Supervisor.