pub struct SpawnManager { /* private fields */ }Expand description
Manages remote actor spawn requests on a node.
When a remote node wants to spawn an actor on this node, it sends a
SpawnRequest to the SpawnManager. The SpawnManager looks up the
actor type in the TypeRegistry,
deserializes the Args, creates the actor, and returns a SpawnResponse.
Implementations§
Source§impl SpawnManager
impl SpawnManager
Sourcepub fn new(type_registry: TypeRegistry) -> Self
pub fn new(type_registry: TypeRegistry) -> Self
Create a new SpawnManager with the given type registry.
Sourcepub fn create_actor(
&self,
request: &SpawnRequest,
) -> Result<Box<dyn Any + Send>, SerializationError>
pub fn create_actor( &self, request: &SpawnRequest, ) -> Result<Box<dyn Any + Send>, SerializationError>
Process a spawn request.
Looks up the actor type in the registry, deserializes Args from bytes,
and returns the constructed actor as Box<dyn Any + Send>. The caller
(runtime) is responsible for actually spawning the actor and assigning
an ActorId.
Sourcepub fn record_spawn(&mut self, id: ActorId)
pub fn record_spawn(&mut self, id: ActorId)
Record that an actor was spawned via remote request.
Sourcepub fn spawned_actors(&self) -> &[ActorId]
pub fn spawned_actors(&self) -> &[ActorId]
List all actors spawned via remote requests.
Sourcepub fn type_registry(&self) -> &TypeRegistry
pub fn type_registry(&self) -> &TypeRegistry
Access the type registry.
Sourcepub fn type_registry_mut(&mut self) -> &mut TypeRegistry
pub fn type_registry_mut(&mut self) -> &mut TypeRegistry
Access the type registry mutably (for registering new factories).