Module actr_ref

Module actr_ref 

Source
Expand description

ActrRef - Lightweight reference to a running Actor

§Design Philosophy

ActrRef is the primary handle for interacting with a running Actor. It provides:

  • RPC calls: Call Actor methods (Shell → Workload)
  • Event subscription: Subscribe to Actor events (Workload → Shell)
  • Lifecycle control: Shutdown and wait for completion

§Key Characteristics

  • Cloneable: Can be shared across tasks
  • Lightweight: Contains only an Arc to shared state
  • Auto-cleanup: Last ActrRef drop triggers resource cleanup
  • Code-gen friendly: RPC methods will be generated and bound to this type

§Usage

let actr = node.start().await?;

// Clone and use in different tasks
let actr1 = actr.clone();
tokio::spawn(async move {
    actr1.call(SomeRequest { ... }).await?;
});

// Subscribe to events
let mut events = actr.events();
while let Some(event) = events.next().await {
    println!("Event: {:?}", event);
}

// Shutdown
actr.shutdown();
actr.wait_for_shutdown().await;

Structs§

ActrRef
ActrRef - Lightweight reference to a running Actor