pub struct SystemRef { /* private fields */ }Expand description
Cloneable, thread-safe handle to the actor system.
Use this to create root actors, spawn event sinks, and shut down the system. Cloning is cheap — all clones share the same underlying system state.
Implementations§
Source§impl SystemRef
impl SystemRef
Sourcepub fn subscribe_system_events(&self) -> Receiver<SystemEvent>
pub fn subscribe_system_events(&self) -> Receiver<SystemEvent>
Returns a broadcast receiver for system-level events such as root actor errors and shutdown.
Sourcepub async fn get_actor<A>(&self, path: &ActorPath) -> Result<ActorRef<A>, Error>
pub async fn get_actor<A>(&self, path: &ActorPath) -> Result<ActorRef<A>, Error>
Returns the ActorRef for the actor at path, or Error::NotFound if no actor is registered there.
Sourcepub async fn create_root_actor<A, I>(
&self,
name: &str,
actor_init: I,
) -> Result<ActorRef<A>, Error>
pub async fn create_root_actor<A, I>( &self, name: &str, actor_init: I, ) -> Result<ActorRef<A>, Error>
Spawns a top-level actor under /user/{name} and returns an ActorRef to it.
actor_init can be the actor itself for NotPersistentActor
types, or any other value implementing IntoActor, such as
InitializedActor<A> from ave-actors-store.
Returns Error::Exists if a root actor with the same name already exists, or
Error::SystemStopped if the system is shutting down.
Sourcepub fn stop_system(&self)
pub fn stop_system(&self)
Initiates graceful shutdown, stopping all root actors and causing SystemRunner::run to return ShutdownReason::Graceful.
Sourcepub fn crash_system(&self)
pub fn crash_system(&self)
Initiates a crash shutdown, causing SystemRunner::run to return ShutdownReason::Crash with exit code 1.
Sourcepub async fn children(&self, path: &ActorPath) -> Vec<ActorPath>
pub async fn children(&self, path: &ActorPath) -> Vec<ActorPath>
Returns the paths of all currently registered direct children of the actor at path.
Sourcepub async fn add_helper<H>(&self, name: &str, helper: H)
pub async fn add_helper<H>(&self, name: &str, helper: H)
Stores a shared resource (e.g. a database pool or config object) under name for retrieval by any actor.
Sourcepub async fn get_helper<H>(&self, name: &str) -> Option<H>
pub async fn get_helper<H>(&self, name: &str) -> Option<H>
Returns the helper stored under name, or None if not found or if the type does not match.