pub struct ContainerManager { /* private fields */ }Expand description
Container lifecycle manager.
When the containers feature is enabled, this uses bollard
for Docker API access. Without the feature, all operations
return ContainerError::DockerNotAvailable.
Implementations§
Source§impl ContainerManager
impl ContainerManager
Sourcepub fn new(config: ContainerConfig) -> Self
pub fn new(config: ContainerConfig) -> Self
Create a new container manager.
Does NOT attempt to connect to Docker at construction time. Connection is deferred to the first operation that needs it.
Sourcepub fn config(&self) -> &ContainerConfig
pub fn config(&self) -> &ContainerConfig
Get the container configuration.
Sourcepub fn configure(
&self,
spec: ManagedContainer,
) -> Result<String, ContainerError>
pub fn configure( &self, spec: ManagedContainer, ) -> Result<String, ContainerError>
Configure and validate a container image, registering it for management.
Validates the specification (image name must be non-empty, port
numbers must be valid, container name must be non-empty) and
registers it in the Stopped state. Returns the container name
as its identifier.
§Errors
Returns ContainerError::InvalidConfig when validation fails.
Sourcepub fn register(&self, spec: ManagedContainer)
pub fn register(&self, spec: ManagedContainer)
Register a container specification for management.
This does not start the container; it only registers it
for tracking. Call start_container to actually start it.
Sourcepub fn start_container(&self, name: &str) -> Result<(), ContainerError>
pub fn start_container(&self, name: &str) -> Result<(), ContainerError>
Start a managed container by transitioning its state to Running.
In a production environment this would shell out to docker run
or podman run. The current implementation simulates the state
transition so the integration between ContainerManager and the
kernel ServiceRegistry / HealthSystem can be tested without a
container runtime installed.
§Errors
Returns ContainerError::ContainerNotFound if the name is
not registered, or ContainerError::StartFailed if the
container is in a state that cannot be started.
Sourcepub fn stop_container(&self, name: &str) -> Result<(), ContainerError>
pub fn stop_container(&self, name: &str) -> Result<(), ContainerError>
Stop a managed container.
Transitions the container from any active state to Stopped.
Sourcepub fn container_state(&self, name: &str) -> Option<ContainerState>
pub fn container_state(&self, name: &str) -> Option<ContainerState>
Get the state of a managed container.
Sourcepub fn list_containers(&self) -> Vec<(String, ContainerState)>
pub fn list_containers(&self) -> Vec<(String, ContainerState)>
List all managed containers with their states.
Sourcepub fn health_check(&self, name: &str) -> Result<HealthStatus, ContainerError>
pub fn health_check(&self, name: &str) -> Result<HealthStatus, ContainerError>
Health check for a specific container, returning a HealthStatus.
Sourcepub fn container_health(
&self,
name: &str,
) -> Result<ContainerHealth, ContainerError>
pub fn container_health( &self, name: &str, ) -> Result<ContainerHealth, ContainerError>
Detailed health report for a specific container.
Auto Trait Implementations§
impl Freeze for ContainerManager
impl !RefUnwindSafe for ContainerManager
impl Send for ContainerManager
impl Sync for ContainerManager
impl Unpin for ContainerManager
impl UnsafeUnpin for ContainerManager
impl UnwindSafe for ContainerManager
Blanket Implementations§
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> 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 more