PgFlow.WorkerSupervisor (PgFlow v0.1.0)

Copy Markdown View Source

Supervisor for PgFlow workers.

This module manages worker processes that poll for and execute flow tasks. Each flow can have one or more workers processing its tasks.

Workers are GenServer processes that:

  • Poll pgmq for pending messages
  • Execute step handlers concurrently via Task.Supervisor
  • Report task completion/failure back to pgflow
  • Handle graceful shutdown

Summary

Functions

Returns a specification to start this module under a supervisor.

Lists all running workers.

Starts the WorkerSupervisor.

Starts a worker for the given flow.

Stops a worker for the given flow.

Functions

child_spec(arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

list_workers()

@spec list_workers() :: [%{pid: pid(), status: :running}]

Lists all running workers.

Returns a list of maps with worker information.

start_link(config)

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

Starts the WorkerSupervisor.

start_worker(flow_module, opts \\ [])

@spec start_worker(
  module(),
  keyword()
) :: {:ok, pid()} | {:error, term()}

Starts a worker for the given flow.

Options

  • :repo - The Ecto repository (optional, defaults to configured repo)

Returns {:ok, pid} on success or {:error, reason} on failure.

stop_worker(flow_module)

@spec stop_worker(module()) :: :ok | {:error, :not_found}

Stops a worker for the given flow.

Gracefully stops the worker, waiting for active tasks to complete.