pub struct ServiceManager { /* private fields */ }Expand description
Service manager for multiple services
Implementations§
Source§impl ServiceManager
impl ServiceManager
Sourcepub fn builder(runtime: Arc<dyn Runtime + Send + Sync>) -> ServiceManagerBuilder
pub fn builder(runtime: Arc<dyn Runtime + Send + Sync>) -> ServiceManagerBuilder
Create a ServiceManagerBuilder for constructing a ServiceManager.
This is the preferred way to construct a ServiceManager since v0.2.0.
§Example
let manager = ServiceManager::builder(runtime)
.overlay_manager(om)
.proxy_manager(proxy)
.build();Sourcepub fn new(runtime: Arc<dyn Runtime + Send + Sync>) -> Self
👎Deprecated since 0.2.0: use ServiceManager::builder() instead
pub fn new(runtime: Arc<dyn Runtime + Send + Sync>) -> Self
use ServiceManager::builder() instead
Create a new service manager
Sourcepub fn with_overlay(
runtime: Arc<dyn Runtime + Send + Sync>,
overlay_manager: Arc<RwLock<OverlayManager>>,
) -> Self
👎Deprecated since 0.2.0: use ServiceManager::builder() instead
pub fn with_overlay( runtime: Arc<dyn Runtime + Send + Sync>, overlay_manager: Arc<RwLock<OverlayManager>>, ) -> Self
use ServiceManager::builder() instead
Create a service manager with overlay network support
Sourcepub fn with_full_config(
runtime: Arc<dyn Runtime + Send + Sync>,
overlay_manager: Arc<RwLock<OverlayManager>>,
deployment_name: String,
) -> Self
👎Deprecated since 0.2.0: use ServiceManager::builder() instead
pub fn with_full_config( runtime: Arc<dyn Runtime + Send + Sync>, overlay_manager: Arc<RwLock<OverlayManager>>, deployment_name: String, ) -> Self
use ServiceManager::builder() instead
Create a fully-configured service manager with overlay and proxy support
Sourcepub fn health_states(&self) -> Arc<RwLock<HashMap<String, HealthState>>> ⓘ
pub fn health_states(&self) -> Arc<RwLock<HashMap<String, HealthState>>> ⓘ
Get the health states map for external monitoring
Sourcepub async fn update_health_state(&self, service_name: &str, state: HealthState)
pub async fn update_health_state(&self, service_name: &str, state: HealthState)
Update health state for a service
Sourcepub fn set_deployment_name(&mut self, name: String)
👎Deprecated since 0.2.0: use ServiceManager::builder() instead
pub fn set_deployment_name(&mut self, name: String)
use ServiceManager::builder() instead
Set the deployment name (used for generating hostnames)
Sourcepub fn set_stream_registry(&mut self, registry: Arc<StreamRegistry>)
👎Deprecated since 0.2.0: use ServiceManager::builder() instead
pub fn set_stream_registry(&mut self, registry: Arc<StreamRegistry>)
use ServiceManager::builder() instead
Set the stream registry for L4 proxy integration (TCP/UDP)
Sourcepub fn with_stream_registry(self, registry: Arc<StreamRegistry>) -> Self
👎Deprecated since 0.2.0: use ServiceManager::builder() instead
pub fn with_stream_registry(self, registry: Arc<StreamRegistry>) -> Self
use ServiceManager::builder() instead
Builder pattern: add stream registry for L4 proxy integration
Sourcepub fn stream_registry(&self) -> Option<&Arc<StreamRegistry>>
pub fn stream_registry(&self) -> Option<&Arc<StreamRegistry>>
Get the stream registry (if configured)
Sourcepub fn set_overlay_manager(&mut self, manager: Arc<RwLock<OverlayManager>>)
👎Deprecated since 0.2.0: use ServiceManager::builder() instead
pub fn set_overlay_manager(&mut self, manager: Arc<RwLock<OverlayManager>>)
use ServiceManager::builder() instead
Set the overlay manager for container networking
Sourcepub fn set_proxy_manager(&mut self, proxy: Arc<ProxyManager>)
👎Deprecated since 0.2.0: use ServiceManager::builder() instead
pub fn set_proxy_manager(&mut self, proxy: Arc<ProxyManager>)
use ServiceManager::builder() instead
Set the proxy manager for health-aware load balancing
Sourcepub fn with_proxy_manager(self, proxy: Arc<ProxyManager>) -> Self
👎Deprecated since 0.2.0: use ServiceManager::builder() instead
pub fn with_proxy_manager(self, proxy: Arc<ProxyManager>) -> Self
use ServiceManager::builder() instead
Builder pattern: add proxy manager for health-aware load balancing
Sourcepub fn proxy_manager(&self) -> Option<&Arc<ProxyManager>>
pub fn proxy_manager(&self) -> Option<&Arc<ProxyManager>>
Get the proxy manager (if configured)
Sourcepub fn set_dns_server(&mut self, dns: Arc<DnsServer>)
👎Deprecated since 0.2.0: use ServiceManager::builder() instead
pub fn set_dns_server(&mut self, dns: Arc<DnsServer>)
use ServiceManager::builder() instead
Set the DNS server for service discovery
Sourcepub fn with_dns_server(self, dns: Arc<DnsServer>) -> Self
👎Deprecated since 0.2.0: use ServiceManager::builder() instead
pub fn with_dns_server(self, dns: Arc<DnsServer>) -> Self
use ServiceManager::builder() instead
Builder pattern: add DNS server for service discovery
Sourcepub fn dns_server(&self) -> Option<&Arc<DnsServer>>
pub fn dns_server(&self) -> Option<&Arc<DnsServer>>
Get the DNS server (if configured)
Sourcepub fn set_job_executor(&mut self, executor: Arc<JobExecutor>)
👎Deprecated since 0.2.0: use ServiceManager::builder() instead
pub fn set_job_executor(&mut self, executor: Arc<JobExecutor>)
use ServiceManager::builder() instead
Set the job executor for run-to-completion workloads
Sourcepub fn set_cron_scheduler(&mut self, scheduler: Arc<CronScheduler>)
👎Deprecated since 0.2.0: use ServiceManager::builder() instead
pub fn set_cron_scheduler(&mut self, scheduler: Arc<CronScheduler>)
use ServiceManager::builder() instead
Set the cron scheduler for time-based job triggers
Sourcepub fn with_job_executor(self, executor: Arc<JobExecutor>) -> Self
👎Deprecated since 0.2.0: use ServiceManager::builder() instead
pub fn with_job_executor(self, executor: Arc<JobExecutor>) -> Self
use ServiceManager::builder() instead
Builder pattern: add job executor
Sourcepub fn with_cron_scheduler(self, scheduler: Arc<CronScheduler>) -> Self
👎Deprecated since 0.2.0: use ServiceManager::builder() instead
pub fn with_cron_scheduler(self, scheduler: Arc<CronScheduler>) -> Self
use ServiceManager::builder() instead
Builder pattern: add cron scheduler
Sourcepub fn job_executor(&self) -> Option<&Arc<JobExecutor>>
pub fn job_executor(&self) -> Option<&Arc<JobExecutor>>
Get the job executor (if configured)
Sourcepub fn cron_scheduler(&self) -> Option<&Arc<CronScheduler>>
pub fn cron_scheduler(&self) -> Option<&Arc<CronScheduler>>
Get the cron scheduler (if configured)
Sourcepub fn set_container_supervisor(&mut self, supervisor: Arc<ContainerSupervisor>)
👎Deprecated since 0.2.0: use ServiceManager::builder() instead
pub fn set_container_supervisor(&mut self, supervisor: Arc<ContainerSupervisor>)
use ServiceManager::builder() instead
Set the container supervisor for crash/panic policy enforcement
Sourcepub fn with_container_supervisor(
self,
supervisor: Arc<ContainerSupervisor>,
) -> Self
👎Deprecated since 0.2.0: use ServiceManager::builder() instead
pub fn with_container_supervisor( self, supervisor: Arc<ContainerSupervisor>, ) -> Self
use ServiceManager::builder() instead
Builder pattern: add container supervisor
Sourcepub fn container_supervisor(&self) -> Option<&Arc<ContainerSupervisor>>
pub fn container_supervisor(&self) -> Option<&Arc<ContainerSupervisor>>
Get the container supervisor (if configured)
Sourcepub fn start_container_supervisor(&self) -> Result<JoinHandle<()>>
pub fn start_container_supervisor(&self) -> Result<JoinHandle<()>>
Sourcepub fn shutdown_container_supervisor(&self)
pub fn shutdown_container_supervisor(&self)
Shutdown the container supervisor
Sourcepub async fn get_container_supervised_state(
&self,
container_id: &ContainerId,
) -> Option<SupervisedState>
pub async fn get_container_supervised_state( &self, container_id: &ContainerId, ) -> Option<SupervisedState>
Get the supervised state of a container
Sourcepub async fn take_supervisor_events(&self) -> Option<Receiver<SupervisorEvent>>
pub async fn take_supervisor_events(&self) -> Option<Receiver<SupervisorEvent>>
Get supervisor events receiver
Note: This can only be called once; the receiver is moved to the caller.
Sourcepub async fn deploy_with_dependencies(
&self,
services: HashMap<String, ServiceSpec>,
) -> Result<()>
pub async fn deploy_with_dependencies( &self, services: HashMap<String, ServiceSpec>, ) -> Result<()>
Deploy multiple services respecting their dependency order
This method:
- Builds a dependency graph from the services
- Validates no cycles exist
- Computes topological order (services with no deps first)
- For each service in order, waits for dependencies then starts the service
§Arguments
services- Map of service name to service specification
§Errors
- Returns
AgentError::InvalidSpecif there are cyclic dependencies - Returns
AgentError::DependencyTimeoutif a dependency times out withon_timeout: fail
Sourcepub async fn check_dependencies(&self, deps: &[DependsSpec]) -> Result<bool>
pub async fn check_dependencies(&self, deps: &[DependsSpec]) -> Result<bool>
Check if all dependencies for a service are currently satisfied
This is a one-shot check (no waiting). Useful for pre-flight validation.
§Errors
Returns an error if a dependency check fails unexpectedly.
Sourcepub async fn upsert_service(
&self,
name: String,
spec: ServiceSpec,
) -> Result<()>
pub async fn upsert_service( &self, name: String, spec: ServiceSpec, ) -> Result<()>
Add or update a workload (service, job, or cron)
This method handles different resource types appropriately:
- Service: Traditional long-running containers with scaling and health checks
- Job: Run-to-completion workloads triggered on-demand (stores spec for later)
- Cron: Scheduled run-to-completion workloads (registers with cron scheduler)
§Errors
Returns an error if service creation, scaling, or cron registration fails.
Sourcepub async fn scale_service(&self, name: &str, replicas: u32) -> Result<()>
pub async fn scale_service(&self, name: &str, replicas: u32) -> Result<()>
Scale a service to desired replica count
§Errors
Returns an error if the service is not found or scaling fails.
Sourcepub async fn service_replica_count(&self, name: &str) -> Result<usize>
pub async fn service_replica_count(&self, name: &str) -> Result<usize>
Sourcepub async fn remove_service(&self, name: &str) -> Result<()>
pub async fn remove_service(&self, name: &str) -> Result<()>
Remove a workload (service, job, or cron)
This method handles cleanup for different resource types:
- Service: Unregisters proxy routes, supervisor, and removes from service map
- Job: Unregisters from job executor
- Cron: Unregisters from cron scheduler
§Errors
Returns an error if the service cannot be removed or scale-down fails.
Sourcepub async fn service_infrastructure(
&self,
name: &str,
) -> Option<(bool, bool, bool)>
pub async fn service_infrastructure( &self, name: &str, ) -> Option<(bool, bool, bool)>
Introspect service infrastructure wiring.
Returns (has_overlay, has_proxy, has_dns), or None if service not found.
Sourcepub async fn list_services(&self) -> Vec<String>
pub async fn list_services(&self) -> Vec<String>
List all services
Sourcepub async fn get_service_logs(
&self,
service_name: &str,
tail: usize,
instance: Option<&str>,
) -> Result<Vec<LogEntry>>
pub async fn get_service_logs( &self, service_name: &str, tail: usize, instance: Option<&str>, ) -> Result<Vec<LogEntry>>
Get logs for a service, aggregated from all container replicas.
§Arguments
service_name- Name of the service to fetch logs fortail- Number of lines to return per container (0 = all)instance- Optional specific instance (container ID suffix like “1”, “2”)
§Errors
Returns an error if the service or instance is not found.
§Returns
Structured log entries from all (or specific) container replicas. Each
entry has its service and deployment fields populated when available.
Sourcepub async fn get_service_containers(
&self,
service_name: &str,
) -> Vec<ContainerId>
pub async fn get_service_containers( &self, service_name: &str, ) -> Vec<ContainerId>
Sourcepub async fn exec_in_container(
&self,
service_name: &str,
replica: Option<u32>,
cmd: &[String],
) -> Result<(i32, String, String)>
pub async fn exec_in_container( &self, service_name: &str, replica: Option<u32>, cmd: &[String], ) -> Result<(i32, String, String)>
Execute a command inside a running container for a service
Picks a specific replica if provided, otherwise uses the first available container.
§Arguments
service_name- Name of the servicereplica- Optional replica number to targetcmd- Command and arguments to execute
§Errors
Returns an error if the service or replica is not found, or if exec fails.
§Panics
Panics if no replica is specified and the container list is unexpectedly empty after the emptiness check (should not happen in practice).
§Returns
Tuple of (exit_code, stdout, stderr)
Sourcepub async fn trigger_job(
&self,
name: &str,
trigger: JobTrigger,
) -> Result<JobExecutionId>
pub async fn trigger_job( &self, name: &str, trigger: JobTrigger, ) -> Result<JobExecutionId>
Sourcepub async fn get_job_execution(
&self,
id: &JobExecutionId,
) -> Option<JobExecution>
pub async fn get_job_execution( &self, id: &JobExecutionId, ) -> Option<JobExecution>
Sourcepub async fn list_job_executions(&self, name: &str) -> Vec<JobExecution>
pub async fn list_job_executions(&self, name: &str) -> Vec<JobExecution>
Sourcepub async fn cancel_job(&self, id: &JobExecutionId) -> Result<()>
pub async fn cancel_job(&self, id: &JobExecutionId) -> Result<()>
Sourcepub async fn trigger_cron(&self, name: &str) -> Result<JobExecutionId>
pub async fn trigger_cron(&self, name: &str) -> Result<JobExecutionId>
Sourcepub async fn set_cron_enabled(&self, name: &str, enabled: bool)
pub async fn set_cron_enabled(&self, name: &str, enabled: bool)
Enable or disable a cron job
§Arguments
name- Name of the cron jobenabled- Whether to enable or disable the job
Sourcepub async fn list_cron_jobs(&self) -> Vec<CronJobInfo>
pub async fn list_cron_jobs(&self) -> Vec<CronJobInfo>
List all registered cron jobs
Sourcepub fn start_cron_scheduler(&self) -> Result<JoinHandle<()>>
pub fn start_cron_scheduler(&self) -> Result<JoinHandle<()>>
Start the cron scheduler background task
This spawns a background task that checks for due cron jobs every second.
Returns a JoinHandle that can be used to wait for the scheduler to stop.
§Errors
Returns error if cron scheduler is not configured
Sourcepub fn shutdown_cron(&self)
pub fn shutdown_cron(&self)
Shutdown the cron scheduler
Auto Trait Implementations§
impl !Freeze for ServiceManager
impl !RefUnwindSafe for ServiceManager
impl Send for ServiceManager
impl Sync for ServiceManager
impl Unpin for ServiceManager
impl UnsafeUnpin for ServiceManager
impl !UnwindSafe for ServiceManager
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::RequestSource§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ServiceExt for T
impl<T> ServiceExt for T
Source§fn propagate_header(self, header: HeaderName) -> PropagateHeader<Self>where
Self: Sized,
fn propagate_header(self, header: HeaderName) -> PropagateHeader<Self>where
Self: Sized,
Source§fn add_extension<T>(self, value: T) -> AddExtension<Self, T>where
Self: Sized,
fn add_extension<T>(self, value: T) -> AddExtension<Self, T>where
Self: Sized,
Source§fn map_request_body<F>(self, f: F) -> MapRequestBody<Self, F>where
Self: Sized,
fn map_request_body<F>(self, f: F) -> MapRequestBody<Self, F>where
Self: Sized,
Source§fn map_response_body<F>(self, f: F) -> MapResponseBody<Self, F>where
Self: Sized,
fn map_response_body<F>(self, f: F) -> MapResponseBody<Self, F>where
Self: Sized,
Source§fn compression(self) -> Compression<Self>where
Self: Sized,
fn compression(self) -> Compression<Self>where
Self: Sized,
Source§fn decompression(self) -> Decompression<Self>where
Self: Sized,
fn decompression(self) -> Decompression<Self>where
Self: Sized,
Source§fn trace_for_http(self) -> Trace<Self, SharedClassifier<ServerErrorsAsFailures>>where
Self: Sized,
fn trace_for_http(self) -> Trace<Self, SharedClassifier<ServerErrorsAsFailures>>where
Self: Sized,
Source§fn trace_for_grpc(self) -> Trace<Self, SharedClassifier<GrpcErrorsAsFailures>>where
Self: Sized,
fn trace_for_grpc(self) -> Trace<Self, SharedClassifier<GrpcErrorsAsFailures>>where
Self: Sized,
Source§fn follow_redirects(self) -> FollowRedirect<Self>where
Self: Sized,
fn follow_redirects(self) -> FollowRedirect<Self>where
Self: Sized,
Source§fn sensitive_headers(
self,
headers: impl IntoIterator<Item = HeaderName>,
) -> SetSensitiveRequestHeaders<SetSensitiveResponseHeaders<Self>>where
Self: Sized,
fn sensitive_headers(
self,
headers: impl IntoIterator<Item = HeaderName>,
) -> SetSensitiveRequestHeaders<SetSensitiveResponseHeaders<Self>>where
Self: Sized,
Source§fn sensitive_request_headers(
self,
headers: impl IntoIterator<Item = HeaderName>,
) -> SetSensitiveRequestHeaders<Self>where
Self: Sized,
fn sensitive_request_headers(
self,
headers: impl IntoIterator<Item = HeaderName>,
) -> SetSensitiveRequestHeaders<Self>where
Self: Sized,
Source§fn sensitive_response_headers(
self,
headers: impl IntoIterator<Item = HeaderName>,
) -> SetSensitiveResponseHeaders<Self>where
Self: Sized,
fn sensitive_response_headers(
self,
headers: impl IntoIterator<Item = HeaderName>,
) -> SetSensitiveResponseHeaders<Self>where
Self: Sized,
Source§fn override_request_header<M>(
self,
header_name: HeaderName,
make: M,
) -> SetRequestHeader<Self, M>where
Self: Sized,
fn override_request_header<M>(
self,
header_name: HeaderName,
make: M,
) -> SetRequestHeader<Self, M>where
Self: Sized,
Source§fn append_request_header<M>(
self,
header_name: HeaderName,
make: M,
) -> SetRequestHeader<Self, M>where
Self: Sized,
fn append_request_header<M>(
self,
header_name: HeaderName,
make: M,
) -> SetRequestHeader<Self, M>where
Self: Sized,
Source§fn insert_request_header_if_not_present<M>(
self,
header_name: HeaderName,
make: M,
) -> SetRequestHeader<Self, M>where
Self: Sized,
fn insert_request_header_if_not_present<M>(
self,
header_name: HeaderName,
make: M,
) -> SetRequestHeader<Self, M>where
Self: Sized,
Source§fn override_response_header<M>(
self,
header_name: HeaderName,
make: M,
) -> SetResponseHeader<Self, M>where
Self: Sized,
fn override_response_header<M>(
self,
header_name: HeaderName,
make: M,
) -> SetResponseHeader<Self, M>where
Self: Sized,
Source§fn append_response_header<M>(
self,
header_name: HeaderName,
make: M,
) -> SetResponseHeader<Self, M>where
Self: Sized,
fn append_response_header<M>(
self,
header_name: HeaderName,
make: M,
) -> SetResponseHeader<Self, M>where
Self: Sized,
Source§fn insert_response_header_if_not_present<M>(
self,
header_name: HeaderName,
make: M,
) -> SetResponseHeader<Self, M>where
Self: Sized,
fn insert_response_header_if_not_present<M>(
self,
header_name: HeaderName,
make: M,
) -> SetResponseHeader<Self, M>where
Self: Sized,
Source§fn set_request_id<M>(
self,
header_name: HeaderName,
make_request_id: M,
) -> SetRequestId<Self, M>where
Self: Sized,
M: MakeRequestId,
fn set_request_id<M>(
self,
header_name: HeaderName,
make_request_id: M,
) -> SetRequestId<Self, M>where
Self: Sized,
M: MakeRequestId,
Source§fn set_x_request_id<M>(self, make_request_id: M) -> SetRequestId<Self, M>where
Self: Sized,
M: MakeRequestId,
fn set_x_request_id<M>(self, make_request_id: M) -> SetRequestId<Self, M>where
Self: Sized,
M: MakeRequestId,
x-request-id as the header name. Read moreSource§fn propagate_request_id(
self,
header_name: HeaderName,
) -> PropagateRequestId<Self>where
Self: Sized,
fn propagate_request_id(
self,
header_name: HeaderName,
) -> PropagateRequestId<Self>where
Self: Sized,
Source§fn propagate_x_request_id(self) -> PropagateRequestId<Self>where
Self: Sized,
fn propagate_x_request_id(self) -> PropagateRequestId<Self>where
Self: Sized,
x-request-id as the header name. Read moreSource§fn catch_panic(self) -> CatchPanic<Self, DefaultResponseForPanic>where
Self: Sized,
fn catch_panic(self) -> CatchPanic<Self, DefaultResponseForPanic>where
Self: Sized,
500 Internal Server responses. Read moreSource§fn request_body_limit(self, limit: usize) -> RequestBodyLimit<Self>where
Self: Sized,
fn request_body_limit(self, limit: usize) -> RequestBodyLimit<Self>where
Self: Sized,
413 Payload Too Large responses. Read more