scamper/actor
OTP actor wrapper for scamper FSMs.
Provides a thin wrapper around gleam/otp/actor to run a state machine
as an OTP-compatible process. Events are serialized (processed one at a
time) and the pure FSM logic remains fully testable without OTP.
Types
Values
pub fn get_context(
subject: process.Subject(Message(state, context, event)),
timeout timeout: Int,
) -> context
Query the current context of the FSM actor.
pub fn get_machine(
subject: process.Subject(Message(state, context, event)),
timeout timeout: Int,
) -> scamper.Machine(state, context, event)
Get the full machine from the actor.
pub fn get_state(
subject: process.Subject(Message(state, context, event)),
timeout timeout: Int,
) -> state
Query the current state of the FSM actor.
pub fn send_event(
subject: process.Subject(Message(state, context, event)),
event: event,
timeout timeout: Int,
) -> Result(
scamper.Machine(state, context, event),
error.TransitionError(state, event),
)
Send an event to the FSM actor and wait for the result.
Times out after timeout milliseconds.
pub fn start(
config: config.Config(state, context, event),
initial_state: state,
context: context,
) -> Result(
actor.Started(process.Subject(Message(state, context, event))),
actor.StartError,
)
Start an FSM actor process. Returns the actor’s subject for sending messages.