# `OzMcp.PubSub.PG`
[🔗](https://github.com/oz-elixir/oz_mcp/blob/v0.9.0/lib/oz_mcp/pubsub/pg.ex#L1)

An `OzMcp.PubSub` that uses `:pg` (Erlang process groups).

The module sends a broadcast to the sessions of all the nodes that are
connected and run the same instance. Set it in the child spec:

    {OzMcp, server: MyApp.McpServer, pubsub: OzMcp.PubSub.PG, ...}

Rules:

  * The instance has the same name on every node.
  * The nodes are connected (Erlang distribution). OzMcp does not connect
    them.
  * The delivery is "at most once". There is no acknowledgement and no
    order between two senders. A node that has just joined the cluster can
    miss a broadcast for a short time, until `:pg` has synchronised its
    groups.
  * A node that is cut from the cluster gets no broadcast. The sessions of
    the other nodes get it. The groups are synchronised again when the
    nodes connect.

`OzMcp.Sessions.list_principal/2` and `OzMcp.Sessions.terminate_principal/2`
read the sessions of the local node only.

# `scope`

```elixir
@spec scope(atom()) :: atom()
```

The name of the `:pg` scope of the instance.

---

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