testcontainer_formulas/redis

Redis formula. Defaults to redis:7-alpine with no auth.

use cache <- testcontainer.with_formula(
  redis.new() |> redis.formula(),
)

// cache.url, cache.host, cache.port

Types

Redis-specific configuration. Build with new/0 + with_*.

pub opaque type RedisConfig

Typed output handed to the body of testcontainer.with_formula/2.

pub type RedisContainer {
  RedisContainer(
    container: container.Container,
    url: String,
    host: String,
    port: Int,
  )
}

Constructors

Values

pub fn formula(c: RedisConfig) -> formula.Formula(RedisContainer)

Builds the Formula(RedisContainer) ready to pass to testcontainer.with_formula/2.

pub fn new() -> RedisConfig

Sensible default: redis:7-alpine, no auth, no persistence.

pub fn on_network(
  c: RedisConfig,
  net: network.Network,
) -> RedisConfig
pub fn on_network_name(
  c: RedisConfig,
  net: String,
) -> RedisConfig

Same as on_network/2 when you already have the Docker network name.

pub fn with_extra_wait(
  c: RedisConfig,
  s: wait.WaitStrategy,
) -> RedisConfig

Adds an extra wait strategy on top of the default log("Ready to accept connections").

pub fn with_image(c: RedisConfig, image: String) -> RedisConfig

Replaces the image entirely.

pub fn with_name(c: RedisConfig, n: String) -> RedisConfig
pub fn with_password(c: RedisConfig, pass: String) -> RedisConfig

Enables Redis auth by starting redis-server --requirepass <password>.

pub fn with_secret_password(
  c: RedisConfig,
  pass: cowl.Secret(String),
) -> RedisConfig

Same as with_password/2 when the value is already a cowl.Secret.

pub fn with_version(
  c: RedisConfig,
  version: String,
) -> RedisConfig

Shorthand for redis:<version>.

pub fn without_password(c: RedisConfig) -> RedisConfig

Disables Redis auth (default behaviour).

Search Document