Erlang-style actor primitives on tokio.
Provides a process registry with named processes, bidirectional linking, monitors, signals, and supervision trees. Processes are native tokio tasks — no WASM, no message boxing, no runtime overhead beyond what tokio gives you.
- Process Registry — spawn named async tasks, look them up, send signals
- Linking — bidirectional: when one linked process dies abnormally, the other
gets killed (configurable via
die_when_link_dies) - Monitors — unidirectional: get notified when a watched process dies, without dying yourself
- Signals — Kill, Shutdown (with grace period), LinkDied, and Custom
- Supervision — OneForOne, OneForAll, and RestForOne restart strategies with rate limiting
use clanker_actor::{ProcessRegistry, Signal, DeathReason};
use std::time::Duration;
#[tokio::main]
async fn main() {
let registry = ProcessRegistry::new();
// Spawn a named process
let id = registry.spawn("worker", async {
loop { tokio::time::sleep(Duration::from_secs(1)).await; }
}).await;
// Look it up
assert!(registry.lookup("worker").is_some());
// Shut it down
registry.send_signal(id, Signal::Shutdown).await;
}MIT