Snakepit.Pool.Worker.Starter (snakepit v0.1.2)

Supervisor wrapper for individual workers that provides automatic restart capability.

This module implements the "Permanent Wrapper" pattern that allows DynamicSupervisor to automatically restart workers when they crash, while keeping the actual worker process as :transient (so it doesn't restart during coordinated shutdown).

Architecture

DynamicSupervisor (WorkerSupervisor)
 Worker.Starter (permanent, one per worker)
     Worker (transient, actual worker process)

When a Worker crashes:

  1. Worker.Starter detects the crash via its :one_for_one strategy
  2. Worker.Starter automatically restarts the Worker (because Worker is :permanent in this context)
  3. Pool is notified via :DOWN message but doesn't need to manage restarts
  4. New Worker re-registers itself automatically

This decouples the Pool from worker replacement logic.

Summary

Functions

Returns a specification to start this module under a supervisor.

Starts a worker starter supervisor.

Returns a via tuple for this starter supervisor.

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

start_link(worker_id)

Starts a worker starter supervisor.

Parameters

  • worker_id - Unique identifier for the worker

via_name(worker_id)

Returns a via tuple for this starter supervisor.