PhoenixMountable.Backfill.Runner (PhoenixMountable v0.2.1)

Copy Markdown View Source

Runs a library's deferred backfills in the running app.

Add it to the host's supervision tree after the repo, or to the library's PhoenixMountable.children/1:

{PhoenixMountable.Backfill.Runner, migrations: MyLib.Migrations, repo: MyApp.Repo}

On start it runs every pending backfill, batch by batch, recording the cursor after each batch, so a restart resumes where it stopped. On Postgres and MySQL it takes a database lock per backfill, so several nodes can run the runner and each backfill still runs once at a time. A batch that fails marks the backfill failed with the error; it is retried with a backoff.

Options

  • :migrations (required), :repo (required), :prefix
  • :retry_after — milliseconds before retrying a failed backfill. Defaults to 30_000.

Summary

Functions

Runs every pending backfill of migrations to completion, in the caller.

Functions

run_all(migrations, opts)

@spec run_all(module(), keyword()) :: :ok | {:error, [{String.t(), term()}]}

Runs every pending backfill of migrations to completion, in the caller.

Returns :ok, or {:error, failed} with the backfills that failed.