# `PgFlow.Telemetry.PubSub`
[🔗](https://github.com/agoodway/pgflow/blob/v0.1.0/lib/pgflow/telemetry/pubsub.ex#L1)

Bridges PgFlow telemetry events to Phoenix.PubSub.

Attaches to all PgFlow telemetry events and broadcasts them as
`{:pgflow, run_id, event_payload}` tuples to per-run and global topics.

## Topics

  * `"pgflow:run:<run_id>"` — all events for a specific run
  * `"pgflow:runs"` — all run lifecycle events (started, completed, failed)
  * `"pgflow:tasks"` — all task events (started, completed, failed)

## Usage

Typically started automatically by `PgFlow.Supervisor` when `:pubsub` is configured:

    children = [
      {PgFlow.Supervisor, pubsub: MyApp.PubSub, ...}
    ]

Can also be attached manually:

    PgFlow.Telemetry.PubSub.attach(pubsub: MyApp.PubSub)

# `attach`

```elixir
@spec attach(keyword()) :: :ok | {:error, :already_exists}
```

Attaches telemetry handlers that broadcast events to PubSub.

## Options

  * `:pubsub` — (required) the Phoenix.PubSub module to broadcast on

# `detach`

```elixir
@spec detach() :: :ok | {:error, :not_found}
```

Detaches the telemetry handlers.

---

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