View Source Protean.Interpreter (Protean v0.1.0-alpha.1)
Execution logic for a Protean machine.
Link to this section Summary
Functions
Return the current machine context.
Handle an event, executing any transitions, actions, and side-effects associated with the current machine context.
Create a new Interpreter
. The returned interpreter will still need to be started, which could
result in additional side-effects. See start/1
.
Whether the interpreter has been started and can accept events.
Entrypoint for the interpreter that must be called before the interpreter will be in a state where it can handle external events. This is necessary in order to handle any initializing actions, invokes, or automatic transitions.
Stop an interpreter, preventing further event processing and terminating any invoked processes.
Link to this section Types
@type invoked() :: %{required(invoked_id()) => invoked_service()}
@type invoked_id() :: String.t()
@opaque invoked_service()
@type t() :: %Protean.Interpreter{ config: Protean.MachineConfig.t(), context: Protean.Context.t(), internal_queue: :queue.queue(), invoked: invoked(), parent: pid(), running: boolean(), subscribers: %{required(reference()) => %{pid: pid(), to: :all | :replies}}, supervisor: Supervisor.supervisor() }
Link to this section Functions
@spec context(t()) :: Protean.Context.t()
Return the current machine context.
@spec handle_event(t(), Protean.event()) :: {t(), [term()]}
Handle an event, executing any transitions, actions, and side-effects associated with the current machine context.
Returns a tuple of the interpreter and any replies resulting from actions that were run.
@spec new([Protean.machine_option()]) :: t()
Create a new Interpreter
. The returned interpreter will still need to be started, which could
result in additional side-effects. See start/1
.
Whether the interpreter has been started and can accept events.
Entrypoint for the interpreter that must be called before the interpreter will be in a state where it can handle external events. This is necessary in order to handle any initializing actions, invokes, or automatic transitions.
Calling start/1
on an already-running interpreter is a no-op.
Stop an interpreter, preventing further event processing and terminating any invoked processes.