Snakepit.Worker.LifecycleConfig (Snakepit v0.13.0)

Copy Markdown View Source

Canonical configuration for lifecycle-managed workers.

Pools assemble rich worker_config maps that flow through the worker pipeline. The lifecycle manager only needs a stable subset of those values to make recycling decisions and to start replacement workers. This module normalizes that subset into a struct so the contract is explicit and tested.

Summary

Functions

Ensures lifecycle config is represented as a %LifecycleConfig{} struct.

Builds a worker_config map for a replacement worker using the canonical data.

Types

t()

@type t() :: %Snakepit.Worker.LifecycleConfig{
  adapter_args: list(),
  adapter_env: list(),
  adapter_module: module(),
  base_worker_config: map(),
  memory_threshold_mb: nil | pos_integer(),
  pool_identifier: atom() | nil,
  pool_name: term(),
  profile_module: module(),
  raw_worker_ttl: term(),
  worker_max_requests: :infinity | pos_integer(),
  worker_module: module(),
  worker_profile: atom() | module(),
  worker_ttl_seconds: :infinity | non_neg_integer()
}

Functions

ensure(pool_name, config, opts \\ [])

@spec ensure(term(), map() | t(), keyword()) :: t()

Ensures lifecycle config is represented as a %LifecycleConfig{} struct.

Accepts either an existing struct or a worker_config map. The optional pool_name argument acts as a fallback when the map does not include one.

to_worker_config(config, worker_id)

@spec to_worker_config(t(), String.t()) :: map()

Builds a worker_config map for a replacement worker using the canonical data.