Search documentation of Finitomata

# View Source Infinitomata (Finitomata v0.22.1)

The sibling of `Finitomata`, but runs transparently in the cluster.

If you want to use a stateful consistent hash ring like `libring`, implement the behaviour `Finitomata.ClusterInfo` wrapping calls to it and invoke `Finitomata.ClusterInfo.init(Impl)` before using `Infinitomata.start_fsm/4`.

The example of such an implementation for `libring` (assuming the named ring `@ring` has been started in the supervision tree) follows.

    defmodule MyApp.ClusterInfo do
      @moduledoc false
      @behaviour Finitomata.ClusterInfo

      @impl Finitomata.ClusterInfo
      def nodes, do: HashRing.nodes(@ring)

      @impl Finitomata.ClusterInfo
      def whois(id), do: HashRing.key_to_node(@ring, id)
    end

# Summary

## Functions

all(id \\ nil)

The full state with all te children, might be a heavy map

child_spec(id \\ nil)
count(id \\ nil)

Count of children

random(id \\ nil)

Returns the random FSM from the pool

start_fsm(id \\ nil, target, implementation, payload)

Starts the FSM somewhere in the cluster.

start_link(id \\ nil, nodes \\ Node.list())
state(id \\ nil, target, reload? \\ :full)

The state of the FSM in the cluster.

synch(id \\ nil)

Synchronizes the local `Infinitomata` instance with the cluster

transition(id \\ nil, target, event_payload, delay \\ 0)

Initiates the transition in the cluster.

# Functions

Link to this function

# all(id \\ nil)

View Source (since 0.16.0)

The full state with all te children, might be a heavy map

Link to this function

# child_spec(id \\ nil)

View Source (since 0.16.0)
Link to this function

# count(id \\ nil)

View Source (since 0.16.0)

Count of children

Link to this function

# random(id \\ nil)

View Source (since 0.18.0)

Returns the random FSM from the pool

Link to this function

# start_fsm(id \\ nil, target, implementation, payload)

View Source (since 0.15.0)

    @spec start_fsm(Finitomata.id(), Finitomata.fsm_name(), module(), any()) ::
      DynamicSupervisor.on_start_child()

Starts the FSM somewhere in the cluster.

See `Finitomata.start_fsm/4`.

Link to this function

# start_link(id \\ nil, nodes \\ Node.list())

View Source (since 0.16.0)
Link to this function

# state(id \\ nil, target, reload? \\ :full)

View Source (since 0.15.0)

The state of the FSM in the cluster.

See `Finitomata.state/3`.

Link to this function

# synch(id \\ nil)

View Source (since 0.19.0)

Synchronizes the local `Infinitomata` instance with the cluster

Link to this function

# transition(id \\ nil, target, event_payload, delay \\ 0)

View Source (since 0.15.0)

    @spec transition(
      Finitomata.id(),
      Finitomata.fsm_name(),
      Finitomata.Transition.event()
      | {Finitomata.Transition.event(), Finitomata.State.payload()},
      non_neg_integer()
    ) :: :ok

Initiates the transition in the cluster.

See `Finitomata.transition/4`.