# `Commanded.PubSub.Adapter`
[🔗](https://github.com/commanded/commanded/blob/v1.4.12/lib/commanded/pubsub/adapter.ex#L1)

Pub/sub behaviour for use by Commanded to subscribe to and broadcast messages.

# `adapter_meta`

```elixir
@type adapter_meta() :: map()
```

# `application`

```elixir
@type application() :: Commanded.Application.t()
```

# `broadcast`

```elixir
@callback broadcast(adapter_meta(), topic :: String.t(), message :: term()) ::
  :ok | {:error, term()}
```

Broadcasts message on given topic.

  * `topic` - The topic to broadcast to, ie: `"users:123"`
  * `message` - The payload of the broadcast

# `child_spec`

```elixir
@callback child_spec(application(), config :: Keyword.t()) ::
  {:ok, [:supervisor.child_spec() | {module(), term()} | module()],
   adapter_meta()}
```

Return an optional supervisor spec for pub/sub.

# `list`

```elixir
@callback list(adapter_meta(), topic :: String.t()) :: [{term(), pid()}]
```

List tracked PIDs for a given topic.

# `subscribe`

```elixir
@callback subscribe(adapter_meta(), topic :: String.t()) :: :ok | {:error, term()}
```

Subscribes the caller to the PubSub adapter's topic.

# `track`

```elixir
@callback track(adapter_meta(), topic :: String.t(), key :: term()) ::
  :ok | {:error, term()}
```

Track the current process under the given `topic`, uniquely identified by
`key`.

---

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