PgFlow.Worker.Bootstrap (PgFlow v0.4.0)

Copy Markdown View Source

Compiles and verifies flow definitions before an Elixir worker registers.

Worker startup always calls upstream pgflow.ensure_flow_compiled/2, preserves Elixir-specific metadata such as flow_type, and only then registers the worker function with pgflow.track_worker_function/2 using the process start mode.

Summary

Functions

Ensures the database definition matches the compiled Elixir definition and registers the worker function for monitoring.

Functions

prepare(repo, definition)

@spec prepare(Ecto.Repo.t(), PgFlow.Flow.Definition.t()) ::
  {:ok, %{queue_name: String.t(), compilation_status: String.t()}}
  | {:error, term()}

Ensures the database definition matches the compiled Elixir definition and registers the worker function for monitoring.

Returns {:ok, %{queue_name: queue_name, compilation_status: status}} when compilation, verification, or local recompilation succeeds. Shape mismatches in production return {:error, {:flow_shape_mismatch, differences}}. Missing or incompatible schema objects return {:error, {:schema_incompatible, key}}.