PgFlow.Queries.Workers (PgFlow v0.1.0)

Copy Markdown View Source

SQL query interface for pgflow worker operations.

Provides functions for registering workers and managing their lifecycle.

Summary

Functions

mark_worker_stopped(repo, worker_id)

@spec mark_worker_stopped(Ecto.Repo.t(), String.t()) :: {:ok, nil} | {:error, term()}

Marks a worker as stopped.

Sets the stopped_at timestamp for graceful shutdown signaling.

Parameters

  • repo - The Ecto repository
  • worker_id - The worker identifier (UUID string)

Returns

  • {:ok, nil} - Success
  • {:error, reason} - Error details if the operation fails

register_worker(repo, worker_id, queue_name, function_name)

@spec register_worker(Ecto.Repo.t(), String.t(), String.t(), String.t()) ::
  {:ok, nil} | {:error, term()}

Registers a worker in the database.

Creates a new worker record or updates the heartbeat if the worker already exists.

Parameters

  • repo - The Ecto repository
  • worker_id - The worker identifier (UUID string)
  • queue_name - The queue name (flow_slug)
  • function_name - The function name (e.g., "elixir:MyApp.Flows.MyFlow")

Returns

  • {:ok, nil} - Success
  • {:error, reason} - Error details if the operation fails