pub struct ServiceManager { /* private fields */ }Expand description
Owns every supervised service’s runtime. Empty/inert until
start_service is called — mirrors McpServerManager’s
always-constructed-but-lazy lifecycle. Cheap to construct (DashMap::new,
no I/O), so AppState builds exactly one and shares it via Arc.
Implementations§
Source§impl ServiceManager
impl ServiceManager
pub fn new() -> Self
Sourcepub async fn start_service(
&self,
config: ServiceRuntimeConfig,
) -> Result<(), ServiceManagerError>
pub async fn start_service( &self, config: ServiceRuntimeConfig, ) -> Result<(), ServiceManagerError>
Start supervising config.id. Spawns the child (or fails fast and
enters the restart-backoff loop immediately if the very first spawn
fails — matching plugin_installer’s “best-effort start, ownership
is still recorded” contract for MCP servers) and returns as soon as
the supervisor task is scheduled — does NOT wait for the child to
actually come up (the caller reads Self::status for that).
Sourcepub async fn stop_service(&self, id: &str) -> Result<(), ServiceManagerError>
pub async fn stop_service(&self, id: &str) -> Result<(), ServiceManagerError>
Stop id: marks the runtime shutdown (so the supervisor never
restarts it), cancels its stop token (waking it out of any
health-check wait / backoff sleep / child.wait()), performs the
graceful-signal → timeout → hard-kill sequence (see
bamboo_plugin::manifest::GracefulShutdown), and awaits the
supervisor task’s exit before returning. Idempotent-adjacent: a
second call on an already-removed id returns
ServiceManagerError::NotRunning rather than panicking, so callers
(uninstall/upgrade drop-diff, rollback) can treat it as best-effort
exactly like mcp_manager.stop_server.
pub fn is_running(&self, id: &str) -> bool
pub async fn status(&self, id: &str) -> Option<ServiceStatusSnapshot>
Sourcepub async fn list_status(&self) -> Vec<ServiceStatusSnapshot>
pub async fn list_status(&self) -> Vec<ServiceStatusSnapshot>
Snapshot of every currently-supervised service (regardless of which
plugin owns it) — the raw material handlers::agent::plugin’s list
handler groups back by plugin_id into
InstalledPluginView::service_status.