mule/runtime/queue_supervisor

One queue’s supervision tree — a port of Oban.Queue.Supervisor:

queue_supervisor[q] (OneForAll)
├── foreman[q]   task factory the job processes run under
├── producer[q]  registers itself, resolves the foreman from the registry
└── watchman[q]  child shutdown timeout = grace + margin, so the
                 supervisor waits out the drain (watchman.ex's
                 `shutdown: shutdown + interval`)

One_for_all mirrors queue/supervisor.ex: a crash of any member restarts the trio together, so the producer can never outlive (or predate) its foreman. Registration happens in the start closures, which run in the supervisor’s own process before the next child starts — a one_for_all restart re-runs every registration together.

Types

The per-queue options a start_queue signal (or the configured queue list) carries — the typed subset of queue/supervisor.ex’s opts.

pub type QueueOptions {
  QueueOptions(queue: String, limit: Int, paused: Bool)
}

Constructors

  • QueueOptions(queue: String, limit: Int, paused: Bool)

Values

pub fn start(
  config config: config.Config,
  options options: QueueOptions,
) -> Result(actor.Started(Nil), actor.StartError)

Start the queue’s supervisor and register it as the {:queue, q} row. Shaped as a factory template: the instance foreman (nursery.gleam) starts one of these per queue.

pub fn whereis(
  instance_name instance_name: String,
  queue queue: String,
) -> option.Option(process.Pid)

The queue supervisor’s pid when the queue is running locally — the midwife’s stop target and its duplicate-start guard.

Search Document