# `Phoenix.PubSub.Adapter`
[🔗](https://github.com/phoenixframework/phoenix_pubsub/blob/v2.3.0/lib/phoenix/pubsub/adapter.ex#L1)

Specification to implement a custom PubSub adapter.

# `adapter_name`

```elixir
@type adapter_name() :: atom()
```

# `broadcast`

```elixir
@callback broadcast(
  adapter_name(),
  topic :: Phoenix.PubSub.topic(),
  message :: Phoenix.PubSub.message(),
  dispatcher :: Phoenix.PubSub.dispatcher()
) :: :ok | {:error, term()}
```

Broadcasts the given topic, message, and dispatcher to
all nodes in the cluster (except the current node itself).

# `child_spec`

```elixir
@callback child_spec(keyword()) :: Supervisor.child_spec()
```

Returns a child specification that mounts the processes
required for the adapter.

`child_spec` will receive all options given `Phoenix.PubSub`.
Note, however, that the `:name` under options is the name
of the complete PubSub system. The reserved key space to
be used by the adapter is under the `:adapter_name` key.

# `direct_broadcast`

```elixir
@callback direct_broadcast(
  adapter_name(),
  node_name :: Phoenix.PubSub.node_name(),
  topic :: Phoenix.PubSub.topic(),
  message :: Phoenix.PubSub.message(),
  dispatcher :: Phoenix.PubSub.dispatcher()
) :: :ok | {:error, term()}
```

Broadcasts the given topic, message, and dispatcher to
given node in the cluster (it may point to itself).

# `node_name`

```elixir
@callback node_name(adapter_name()) :: Phoenix.PubSub.node_name()
```

Returns the node name as an atom or a binary.

---

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