Struct messages::registry::Registry [−][src]
pub struct Registry { /* fields omitted */ }
runtime-tokio
or runtime-async-std
only.Expand description
Registry
is an manager object providing access to the addresses
of Actor
s that implement Service
trait.
Registry
maintains a list of spawned services and when an address
of a service is requested, it checks whether the corresponding actor is
already running. If so, address of this actor is returned. Otherwise,
actor is spawned first.
Stopping and resuming
Services managed by the Registry
may still be stopped via the Address::stop
method.
In that case, actor will not be resumed automatically, but it will be started again
if its adress will be requested one more time.
Examples
#[derive(Default)] // Default trait is required for Registry to automatically creaate actor. struct Ping; #[async_trait] impl Actor for Ping {} #[async_trait] impl Service for Ping { const NAME: &'static str = "PingService"; } #[tokio::main] async fn main() { let mut addr: Address<Ping> = Registry::service().await; }
Implementations
Returns an address of an actor that implements Service
trait.
This function checks whether the corresponding actor is already running. If so, address of this actor is returned. Otherwise, actor is spawned first.
Panics
This method panics if two services having the same name will be attempted to be instantiated. All the names of services are expected to be unique.
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for Registry
impl !UnwindSafe for Registry