# `Snodo.Session.Registry`
[🔗](https://github.com/joshrotenberg/snodo/blob/v0.5.0/lib/snodo/session/registry.ex#L1)

Behaviour for finding an initialize-era session process by its ID.

`Snodo.Session.Manager` uses a registry to map each `Mcp-Session-Id` to the
process that holds the session. The default, `Snodo.Session.Registry.Local`,
keeps that map on the local node. A session process always runs on the node
that handled `initialize`; a registry decides only how a request finds it.
The core performs no cross-node routing, so a deployment with several nodes
needs sticky load balancing that sends every request for a session to the
node that created it, whatever registry it uses.

Configure a registry with the manager's `:registry` option as a module or
`{module, options}`. `options` is passed back unchanged to every callback.

`child_spec/1` returns the process the registry needs, started under the
manager before any session, or `nil` when it needs none. `register/3` runs in
the session process that is registering itself. `unregister/2` runs in that
process as it stops; a registry should also remove an entry when its process
exits, since a killed session process cannot unregister.

# `id`

```elixir
@type id() :: String.t()
```

# `options`

```elixir
@type options() :: term()
```

# `child_spec`

```elixir
@callback child_spec(options()) ::
  Supervisor.child_spec() | Supervisor.module_spec() | nil
```

# `lookup`

```elixir
@callback lookup(options(), id()) :: {:ok, pid()} | :error
```

# `register`

```elixir
@callback register(options(), id(), pid()) :: :ok | {:error, :taken}
```

# `unregister`

```elixir
@callback unregister(options(), id()) :: :ok
```

---

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