Driver

Struct Driver 

Source
pub struct Driver { /* private fields */ }
Expand description

Container driver.

Implementations§

Source§

impl Driver

Source

pub fn from_config( isolation_group_id: String, config: DriverConfig, ) -> Result<Self, GenericError>

Creates a new Driver from the given isolation group ID and configuration.

§Isolation group

The isolation group ID serves as a unique identifier to be used for both the name of the container as well as the shared resources that are created and attached to the container. If two drivers share the same isolation group ID, the containers they spawn will be located in the same network namespace, have access to the same shared Airlock volume, etc.

§Shared volume

The container will have a volume bind-mounted at /airlock that is shared between all containers in the same isolation group. This volume is mounted as world writeable (777) so all containers can freely read and write to it. This makes it easier for containers to share data between one another, but also means that care should be taken to avoid conflicts between trying to write to the same file, etc.

§Errors

If the Docker client cannot be created/configured, an error will be returned.

Source

pub fn with_logging(self, log_dir: PathBuf) -> Self

Configures the driver to capture container logs.

The logs will be stored in the given directory, under a subdirectory named after the isolation group ID. Each container will get a log for standard output and standard error, following the pattern of <container name>.[stdout|stderr].log.

Source

pub fn driver_id(&self) -> &'static str

Returns the string identifier of the driver.

This is generally a shorthand of the application/service, such as dogstatsd or millstone.

Clean up any containers, networks, and volumes related to the given isolation group ID.

This is a free function to facilitate cleaning up resources after a number of drivers are run.

§Errors

If the Docker client cannot be created/configured, or there is an error when finding or removing any of the related resources, an error will be returned.

Source

pub async fn start(&mut self) -> Result<DriverDetails, GenericError>

Starts the container, creating any necessary resources.

§Errors

If there is an error while creating the network or shared volume, while pulling the container image, or while creating or starting the container, it will be returned.

Source

pub async fn wait_for_container_healthy(&mut self) -> Result<(), GenericError>

Waits until the container is marked as healthy.

If the container has no health checks defined, this returns early and does no waiting.

§Errors

If there is an error while inspecting the container, it will be returned.

Source

pub async fn wait_for_container_exit(&self) -> Result<ExitStatus, GenericError>

Waits for the container to finish successfully.

The container’s exit status is returned, indicating success (exit code 0) or failure (exit code != 0), including any error message related to the failure.

§Errors

If an error is encountered while waiting for the container to exit, it will be returned.

Source

pub async fn cleanup(self) -> Result<(), GenericError>

Cleans up the container, stopping and removing it from the system.

§Errors

If there is an error while stopping or removing the container, it will be returned.

Auto Trait Implementations§

§

impl Freeze for Driver

§

impl !RefUnwindSafe for Driver

§

impl Send for Driver

§

impl Sync for Driver

§

impl Unpin for Driver

§

impl !UnwindSafe for Driver

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more