Snakepit.Pool.WorkerSupervisor (Snakepit v0.6.10)

View Source

DynamicSupervisor for pool worker processes.

This supervisor manages the lifecycle of workers:

  • Starts workers on demand
  • Handles crashes with automatic restarts
  • Provides clean shutdown of workers

Summary

Functions

Returns a specification to start this module under a supervisor.

Lists all supervised workers.

Restarts a worker by ID.

Starts the worker supervisor.

Stops a worker gracefully.

Returns the count of active workers.

Functions

child_spec(arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

list_workers()

Lists all supervised workers.

restart_worker(worker_id)

Restarts a worker by ID.

start_link(init_arg)

Starts the worker supervisor.

start_worker(worker_id, worker_module \\ Snakepit.GRPCWorker, adapter_module \\ nil, pool_name \\ nil, worker_config \\ %{})

Starts a new pool worker with the given ID.

Examples

iex> Snakepit.Pool.WorkerSupervisor.start_worker("worker_123")
{:ok, #PID<0.123.0>}

stop_worker(worker_pid)

Stops a worker gracefully.

worker_count()

Returns the count of active workers.