axactor
Tokio actor runtime with local runtime + optional distributed cluster runtime.
Capabilities
#[actor]/#[msg]macro-based API- user/control mailbox split
- restart policy + restart mailbox policy (
Keep/DrainAndDrop) - link / monitor / trap-exit
- lifecycle stream (
Started,Restarted,Stopped) - keyed
Registrywith idle reaper - distributed cluster:
- shard lease ownership + epoch fencing
- ensure/direct routing
- monitor/demonitor/down protocol
- handshake dedup + request/response auth + protocol negotiation
- runtime session ids with authenticated same-logical session rotation
- control/data plane separation
- overlays:
InMemoryOverlay,TcpOverlay
- ref API split:
LocalRef<M>RemoteRef<C: RefContract>AnyRef<C>/Addr<C>
Install
[]
= "0.2.0"
= { = "1", = ["full"] }
Optional Redis lease backend:
= { = "0.2.0", = ["redis-lease"] }
Local Quick Example
use ;
use Arc;
async
Registry
Registry::get_or_spawn(...) -> Result<R, RegistryError>
use ;
use Arc;
let system = new;
let reg: = new;
let cfg = new;
let c = reg.get_or_spawn.await?;
c.inc?;
# Ok::
Cluster Essentials
Secure mode is default:
allow_insecure_auth = falseauth_tokenmust be set (otherwiseClusterNode::start(...)panics)
use ;
use Arc;
let store = new;
let overlay = new;
let cfg = ClusterConfig ;
let _node = start;
NodeId::new("node-a") is the logical node name. ClusterNode::start(...)
derives a runtime wire id by appending @boot-<hex>-session-<n>, and only that
exact suffix shape is treated as a runtime session marker. This avoids
collapsing arbitrary logical names that merely contain @boot-.
Remote non-handshake traffic is trusted only after the peer's current runtime session has completed the hello/auth flow. Session-rotated peers can continue to resolve pending responses after a successful re-handshake, but unauthenticated same-logical spoofing is rejected before host execution.
Use TcpOverlay for multi-process transport:
use ;
use Duration;
let overlay = with_keepalive_options;
Ref API Split
LocalRef<M>: local hot path, no network/serialization branch.
let local: LocalRef = my_actor_ref.as_local_ref;
local.try_send?;
RemoteRef<C>: wire-safe contract (RemoteSafe bounds on Tell/Ask/Reply).
use ;
;
AnyRef<C> / Addr<C>: optional location-transparent wrapper.
AnyRef::monitor() is supported.
For local contracts, attach monitor adapter explicitly:
let local = new
.with_monitor_fn;
Production Notes
InMemoryOverlay+MemoryLeaseStoreare for tests/dev.- For production, use TCP overlay + external lease store (Redis/etcd-equivalent).
- Keep
allow_insecure_auth = falseand set shared auth token (or stronger transport auth). - Validate both the default and reduced feature sets if you maintain trybuild snapshots:
cargo test -p axactorcargo test -p axactor --no-default-featurescargo test -p axactor --all-features
See workspace docs:
License
MIT