View Source Testcontainers.Reaper (testcontainers v1.1.0)

A GenServer that manages the lifecycle of the Ryuk container within the Testcontainers ecosystem.

The Reaper is responsible for ensuring that resources are cleaned up properly when test containers are no longer needed. It communicates with the Ryuk container, a tool used by Testcontainers to reap orphaned containers.

Usage

The module is typically used in the context of integration tests where test containers are employed. It starts the Ryuk container and registers filters for cleaning up resources.

It is meant to be started before interacting with any test containers and stopped after all tests are concluded.

Note: This is an internal component and should not be used directly in tests. Instead, it's used by the higher-level Testcontainers APIs.

Summary

Functions

Returns a specification to start this module under a supervisor.

Labels the container so that Ryuk can delete it.

Starts the Reaper process if it is not already running.

Functions

Returns a specification to start this module under a supervisor.

See Supervisor.

Labels the container so that Ryuk can delete it.

Starts the Reaper process if it is not already running.

This function will start the Reaper unlinked (outside of the current supervision tree) and wait until it's registered with the local process registry.

It's particularly useful for scenarios where the Reaper needs to be started without a linked supervision strategy, often before the actual test scenarios are executed.

Examples

iex> Testcontainers.Reaper.start_eager()
{:ok, pid}

Options

The function accepts an optional list of options (opts) that are passed to the GenServer initialization, though in the current implementation, these options are not used.

Errors

If the Reaper fails to start, the function will return an error tuple.

Note

This function is designed to be used in setup scenarios, possibly within test suite setup callbacks.