PgFlowDashboard.Queries.Workers (PgFlow v0.1.0)

Copy Markdown View Source

Database queries for worker-related data.

Summary

Functions

Counts workers matching the given filters.

Gets the adjacent worker (next or previous by last_heartbeat_at).

Gets a single worker with details.

Lists tasks processed by a specific worker.

Lists workers with load information.

Functions

count_workers(repo, opts \\ [])

@spec count_workers(
  module(),
  keyword()
) :: integer()

Counts workers matching the given filters.

Options

  • :flow_slug - Filter by flow slug
  • :health_status - Filter by health (healthy, stale, dead)

get_adjacent_worker(repo, worker_id, direction)

@spec get_adjacent_worker(module(), String.t(), :next | :prev) ::
  {:ok, String.t()} | {:error, :not_found}

Gets the adjacent worker (next or previous by last_heartbeat_at).

Direction can be :next or :prev. Returns {:ok, worker_id} or {:error, :not_found}.

get_worker(repo, worker_id)

@spec get_worker(module(), String.t()) :: {:ok, map()} | {:error, :not_found | term()}

Gets a single worker with details.

list_worker_tasks(repo, worker_id, opts \\ [])

@spec list_worker_tasks(module(), String.t(), keyword()) :: [map()]

Lists tasks processed by a specific worker.

list_workers(repo, opts \\ [])

@spec list_workers(
  module(),
  keyword()
) :: [map()]

Lists workers with load information.

Options

  • :flow_slug - Filter by flow slug
  • :health_status - Filter by health (healthy, stale, dead)
  • :limit - Maximum number of workers to return
  • :cursor - Worker ID to start after for pagination