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 fn set_github_rate_limit(&mut self, cache: Arc<RateLimitCache>)
pub fn set_github_rate_limit(&mut self, cache: Arc<RateLimitCache>)
Wires in the GitHub rate-limit monitor’s cache (#1375), so the built-in
status op can surface budget usage. Called once at daemon start with the
same Arc the worktrees service’s poller writes.
Sourcepub fn github_rate_limit(&self) -> Option<RateLimitSnapshot>
pub fn github_rate_limit(&self) -> Option<RateLimitSnapshot>
The latest GitHub rate-limit snapshot, or None when the monitor is
unwired or has not polled successfully yet.
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