melon/container

Types

The type that holds information about a container.

pub opaque type Container

The error type to represent a reason why the health status of a container could not be obtained.

pub type ContainerHealthStatusFailure {
  CannotObtainHealthStatusOfContainerThatIsNotRunning
  CouldNotObtainHealthStatus(reason: String)
  ContainerIsUnhealthy
}

Constructors

  • CannotObtainHealthStatusOfContainerThatIsNotRunning
  • CouldNotObtainHealthStatus(reason: String)
  • ContainerIsUnhealthy

The error type to represent a reason why a mapped port of a container could not be found.

pub type ContainerMappedPortFailure {
  CannotObtainMappedPortOfContainerThatIsNotRunning
  CouldNotFindMappedPort
}

Constructors

  • CannotObtainMappedPortOfContainerThatIsNotRunning
  • CouldNotFindMappedPort

The error type to represent the reason why a container could not be started.

pub type ContainerStartFailure {
  CouldNotStartContainer(reason: String)
}

Constructors

  • CouldNotStartContainer(reason: String)

The error type to represent a reason why a container could not be stopped.

pub type ContainerStopFailure {
  CannotStopContainerThatIsNotRunning
  CouldNotStopContainer(reason: String)
}

Constructors

  • CannotStopContainerThatIsNotRunning
  • CouldNotStopContainer(reason: String)

The type to represent a memory unit.

pub type MemoryUnit {
  Byte
  Kilobyte
  Megabyte
  Gigabyte
}

Constructors

  • Byte
  • Kilobyte
  • Megabyte
  • Gigabyte

The type that holds information about a port.

pub type Port {
  Port(host: String, value: Int, protocol: PortProtocol)
}

Constructors

  • Port(host: String, value: Int, protocol: PortProtocol)

The type to specify the protocol a port is exposed via.

pub type PortProtocol {
  Tcp
  Udp
  Sctp
}

Constructors

  • Tcp
  • Udp
  • Sctp

The type to represent a time unit.

pub type TimeUnit {
  Second
  Minute
}

Constructors

  • Second
  • Minute

Functions

pub fn add_env(
  container: Container,
  name identifier: String,
  value value: String,
) -> Container

Adds an environment variable to the given container.

pub fn add_exposed_port(
  container: Container,
  host host: String,
  port port: Int,
  protocol protocol: PortProtocol,
) -> Container

Adds an exposed port to the given container.

pub fn mapped_port(
  container: Container,
  port port: Int,
  protocol protocol: PortProtocol,
) -> Result(Port, ContainerMappedPortFailure)

Returns a mapped port of the given container.

pub fn new(image: String) -> Container

Creates a new container using the given image.

Remaining properties of the container can be configured via various setter functions in this module.

pub fn set_command(
  container: Container,
  command: List(String),
) -> Container

Sets the command of the given container.

pub fn set_entrypoint(
  container: Container,
  entrypoint: String,
) -> Container

Sets the entrypoint of the given container.

pub fn set_env_file(
  container: Container,
  env_file: String,
) -> Container

Sets the environment file of a given container.

pub fn set_health_check_command(
  container: Container,
  command: List(String),
) -> Container

Sets the health check command of the given container.

pub fn set_health_check_interval(
  container: Container,
  interval interval: Int,
  unit unit: TimeUnit,
) -> Container

Sets the health check interval of the given container.

pub fn set_health_check_retries(
  container: Container,
  retries: Int,
) -> Container

Sets the health check retry count of the given container.

pub fn set_health_check_start_period(
  container: Container,
  start_period start_period: Int,
  unit unit: TimeUnit,
) -> Container

Sets the health check start period of the given container.

pub fn set_health_check_timeout(
  container: Container,
  timeout timeout: Int,
  unit unit: TimeUnit,
) -> Container

Sets the health check timeout of the given container.

pub fn set_memory_limit(
  container: Container,
  limit limit: Int,
  unit unit: MemoryUnit,
) -> Container

Sets the memory limit of the given container.

pub fn set_user(container: Container, user: String) -> Container

Sets the user of the given container.

pub fn set_working_directory(
  container: Container,
  working_directory: String,
) -> Container

Sets the working directory of the given container.

pub fn start(
  container: Container,
) -> Result(Container, ContainerStartFailure)

Starts the given container.

pub fn stop(
  container: Container,
) -> Result(Container, ContainerStopFailure)

Stops the given container.

pub fn wait_until_healthy(
  container: Container,
  retries retries: Int,
) -> Result(Container, ContainerHealthStatusFailure)

Waits until the given container is healthy. It fails if all retries are exhausted.

Search Document