Orkestra.Projection.Supervisor (orkestra v0.2.0)

Copy Markdown View Source

Supervisor for Orkestra projectors.

Starts all configured projectors under a one_for_one strategy, ensuring that one projector crashing or halting does not affect others. Each projector runs as an independent Orkestra.Projector.GenServer process.

Halted projectors (those that have exhausted retries after an error) stay alive in an idle state — they do not crash or stop — so the one_for_one supervisor never sees them as failed children. This prevents restart storms (T-03-03).

Usage

Add to your application's supervision tree:

children = [
  MyApp.OrderProjection.Repo,
  {Orkestra.Projection.Supervisor, projectors: [
    MyApp.OrderProjector,
    {MyApp.CustomerProjector, repo: MyApp.CustomerProjection.TestRepo}
  ]}
]

Supervisor.start_link(children, strategy: :one_for_one)

Options

  • :projectors (required) — list of projector modules or {module, opts} tuples. Bare modules use their compile-time defaults; tuple form allows runtime overrides (e.g., a different repo for test vs. prod).
  • :name — registered name for the supervisor process. Defaults to Orkestra.Projection.Supervisor.

Summary

Functions

Returns a specification to start this module under a supervisor.

Starts the projection supervisor linked to the calling process.

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

start_link(opts)

@spec start_link(keyword()) :: Supervisor.on_start()

Starts the projection supervisor linked to the calling process.

Requires a :projectors key in opts. Accepts an optional :name key to register the supervisor process.