ExESDB.Commanded.ProjectionsRebuilder (ex_esdb_commanded v0.9.0)

Generic projection rebuilder for ExESDB Commanded applications.

Provides facilities for:

  • Rebuilding specific projections
  • Rebuilding all projections
  • Tracking rebuild progress
  • Handling rebuild failures
  • Supporting concurrent rebuilds

Summary

Functions

Returns a specification to start this module under a supervisor.

Rebuilds all projections for the configured Commanded application.

Rebuilds specific projections.

Starts the rebuilder for a specific Commanded application.

Gets the current status of projection rebuilds.

Types

projection_info()

@type projection_info() :: %{
  name: module(),
  status: rebuild_status(),
  started_at: DateTime.t() | nil,
  completed_at: DateTime.t() | nil,
  error: any()
}

rebuild_opts()

@type rebuild_opts() :: [
  application: module(),
  timeout: non_neg_integer(),
  batch_size: pos_integer(),
  concurrency: pos_integer()
]

rebuild_status()

@type rebuild_status() :: :not_started | :in_progress | :completed | :failed

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

rebuild_all(opts \\ [])

@spec rebuild_all(rebuild_opts()) :: {:ok, [projection_info()]} | {:error, term()}

Rebuilds all projections for the configured Commanded application.

rebuild_projections(projections, opts \\ [])

@spec rebuild_projections([module()], rebuild_opts()) ::
  {:ok, [projection_info()]} | {:error, term()}

Rebuilds specific projections.

Options:

  • :timeout - Maximum time to wait for rebuild (default: 30_000ms)
  • :batch_size - Events to process in each batch (default: 1000)
  • :concurrency - Number of concurrent rebuilds (default: 1)

start_link(opts)

Starts the rebuilder for a specific Commanded application.

status(opts \\ [])

@spec status(keyword()) :: %{projections: [projection_info()]}

Gets the current status of projection rebuilds.