Tasque.Supervisor (Tasque v1.0.0)

View Source

Internal supervisor that manages the process pair for a single Tasque instance: a Task.Supervisor and a Tasque.Queue GenServer.

Internal module

This module is not part of the public API. Use {Tasque, opts} in your supervision tree instead of starting this module directly.

Supervision Strategy

Uses :one_for_all — if either the Task.Supervisor or the Tasque.Queue crashes, both are restarted together. This is necessary because:

  • If the Task.Supervisor crashes, all in-flight tasks are lost and the queue's :pending_refs map would reference dead processes
  • If the Tasque.Queue crashes, the mapping between task refs and callers is lost, so in-flight task results could never be delivered

Restarting both ensures the system returns to a clean, consistent state.

Child Order

The Task.Supervisor is started before the Tasque.Queue so that its registered name is available during queue initialization.

Process Naming

Given a Tasque instance named MyApp.Queue, the following processes are registered:

ProcessRegistered Name
Tasque.SupervisorMyApp.Queue.Supervisor
Task.SupervisorMyApp.Queue.TaskSupervisor
Tasque.QueueMyApp.Queue

For {:global, term} and {:via, module, term} queue names, Tasque uses the same naming strategy for its companion supervisor processes.

Summary

Functions

Returns a specification to start this module under a supervisor.

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

start_link(opts)