# `PgFlow.Queries.Workers`
[🔗](https://github.com/agoodway/pgflow/blob/v0.1.0/lib/pgflow/queries/workers.ex#L1)

SQL query interface for pgflow worker operations.

Provides functions for registering workers and managing their lifecycle.

# `mark_worker_stopped`

```elixir
@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`

```elixir
@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

---

*Consult [api-reference.md](api-reference.md) for complete listing*
