reflow_actor
Actor trait, message types, ports, state, and stream handles used by the Reflow runtime.
Most users should depend on
reflow_rtwhich re-exports this crate asreflow_rt::actor_runtimeand exposes the common types throughreflow_rt::prelude. Depend directly onreflow_actoronly if you are writing an actor library or a runtime component that must not pull in the whole facade.
What it provides
Actortrait,ActorBehavior,ActorContext,ActorConfig,ActorLoad,ActorPayload.- Message types:
Message,EncodableValue. - Port types:
Port,ActorChannel. - State:
ActorState,MemoryState. - Streams:
StreamHandle,StreamFrame, and the stream registry for out-of-band frame transport.
Quick glance
Most actors are declared with #[actor(...)] from reflow_actor_macro. It
generates the Actor impl, port setup, and registration glue.
use ;
use actor;
use Error;
use HashMap;
/// Doubles every `number` packet and emits the result on `doubled`.
pub async
Key ideas the example shows:
- Named ports.
inports/outportsdeclare the schema; the network routes packets to this actor only on listed ports. - Selective emission. Returning
{"doubled": …}means "emit one packet on thedoubledport". Return an emptyHashMapto consume inputs silently. - State.
state(MemoryState)gives each actor instance its own mutable scratch area; swap for a customActorStateto persist across ticks. - Backpressure.
inports::<50>sizes the per-port channel — bound it low for latency-sensitive flows, high for burst-friendly pipelines.
Use StreamHandle when moving large or continuous payloads (e.g. raw video
frames) — handles are cheap to copy through the message bus while the bytes
travel out-of-band.
Relationship to other crates
- Used by every Reflow actor, including all actors in
reflow_components,reflow_api_services,reflow_ml_ops,reflow_cv_ops. - Paired with
reflow_actor_macrofor declaring actors ergonomically.
License
MIT OR Apache-2.0.