pub struct DockerContainerMachine<S> {
pub nats: Option<Client>,
pub docker: Docker,
pub metadata: ContainerMetadata,
pub state: S,
}Expand description
The core state machine representing a Docker container’s lifecycle.
Fields§
§nats: Option<Client>The NATS client used for messaging, if available.
docker: DockerThe Docker client.
metadata: ContainerMetadataMetadata associated with this container execution.
state: SThe current state of the machine.
Implementations§
Source§impl<S> DockerContainerMachine<S>
impl<S> DockerContainerMachine<S>
Sourcepub async fn get_network_mode(&self) -> Option<String>
pub async fn get_network_mode(&self) -> Option<String>
Attempts to detect the Docker network mode the runner is operating in.
Sourcepub fn build_container_config(
&self,
spec: &CommonContainerSpec,
mounts: Vec<Mount>,
network_mode: Option<String>,
storage_names: &[String],
) -> Result<Config<String>>
pub fn build_container_config( &self, spec: &CommonContainerSpec, mounts: Vec<Mount>, network_mode: Option<String>, storage_names: &[String], ) -> Result<Config<String>>
Builds the Docker container configuration based on the provided specifications.
Sourcepub fn parse_cpu_to_quota(&self, cpu: &str) -> Option<i64>
pub fn parse_cpu_to_quota(&self, cpu: &str) -> Option<i64>
Parses a CPU string limit to Docker CPU quota representation.
Sourcepub fn parse_memory_to_bytes(&self, memory: &str) -> Option<i64>
pub fn parse_memory_to_bytes(&self, memory: &str) -> Option<i64>
Parses a memory string limit into bytes.
Source§impl DockerContainerMachine<Finished>
impl DockerContainerMachine<Finished>
Sourcepub fn into_result(self) -> ContainerState
pub fn into_result(self) -> ContainerState
Consumes the state machine, returning the final ContainerState result.
Source§impl DockerContainerMachine<Initialized>
impl DockerContainerMachine<Initialized>
Sourcepub fn adopt(self, container_name: String) -> DockerContainerMachine<Running>
pub fn adopt(self, container_name: String) -> DockerContainerMachine<Running>
Adopts an already-running container by name, transitioning the state machine to Running.
Sourcepub async fn clean_up(self, container_name: &str) -> Result<()>
pub async fn clean_up(self, container_name: &str) -> Result<()>
Cleans up an orphaned container without running it through the state machine.
Sourcepub async fn start(self) -> Result<StartResult>
pub async fn start(self) -> Result<StartResult>
Starts a new Docker container, pulling images and unparking storage as necessary.
Source§impl DockerContainerMachine<Running>
impl DockerContainerMachine<Running>
Sourcepub async fn wait(self) -> Result<DockerContainerMachine<Finished>>
pub async fn wait(self) -> Result<DockerContainerMachine<Finished>>
Waits for the running container to finish executing, collects metrics and artifacts, and cleans it up.
Trait Implementations§
Source§impl<S: Clone> Clone for DockerContainerMachine<S>
impl<S: Clone> Clone for DockerContainerMachine<S>
Source§fn clone(&self) -> DockerContainerMachine<S>
fn clone(&self) -> DockerContainerMachine<S>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl<S> Freeze for DockerContainerMachine<S>where
S: Freeze,
impl<S> !RefUnwindSafe for DockerContainerMachine<S>
impl<S> Send for DockerContainerMachine<S>where
S: Send,
impl<S> Sync for DockerContainerMachine<S>where
S: Sync,
impl<S> Unpin for DockerContainerMachine<S>where
S: Unpin,
impl<S> UnsafeUnpin for DockerContainerMachine<S>where
S: UnsafeUnpin,
impl<S> !UnwindSafe for DockerContainerMachine<S>
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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