pub struct ServiceRegistry { /* private fields */ }Expand description
Holds the daemon’s registered services and routes control-socket envelopes
to them by name.
Implementations§
Source§impl ServiceRegistry
impl ServiceRegistry
Sourcepub fn register(&mut self, service: Arc<dyn DaemonService>)
pub fn register(&mut self, service: Arc<dyn DaemonService>)
Adds a service. Lookups match by DaemonService::name and the first
registration wins; a second service sharing a name would be dead code
for routing and would double-count in status/menu iteration, so it is
rejected with a warning rather than silently kept.
Sourcepub fn get(&self, name: &str) -> Option<&Arc<dyn DaemonService>>
pub fn get(&self, name: &str) -> Option<&Arc<dyn DaemonService>>
Returns the registered service with the given name, if any.
Sourcepub fn services(&self) -> &[Arc<dyn DaemonService>]
pub fn services(&self) -> &[Arc<dyn DaemonService>]
All registered services, in registration order.
Sourcepub async fn dispatch(
&self,
service: &str,
op: &str,
payload: Value,
) -> Result<Value>
pub async fn dispatch( &self, service: &str, op: &str, payload: Value, ) -> Result<Value>
Routes an operation to the named service, erroring if no such service is registered.
Sourcepub fn subscribe(
&self,
service: &str,
op: &str,
payload: &Value,
) -> Option<Box<dyn ServiceStream>>
pub fn subscribe( &self, service: &str, op: &str, payload: &Value, ) -> Option<Box<dyn ServiceStream>>
Opens a push subscription on the named service for a streaming op, or
None when the service is unknown or does not stream that op — in which
case the caller falls back to the normal dispatch
request→reply path (#1267).
Sourcepub async fn statuses(&self) -> Vec<ServiceStatus>
pub async fn statuses(&self) -> Vec<ServiceStatus>
Collects status from every service, in registration order.
Sourcepub async fn shutdown_all(&self)
pub async fn shutdown_all(&self)
Gracefully shuts down every service, in registration order.
Trait Implementations§
Source§impl Clone for ServiceRegistry
impl Clone for ServiceRegistry
Source§fn clone(&self) -> ServiceRegistry
fn clone(&self) -> ServiceRegistry
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more