# `Sagents.ProcessRegistry`

Abstraction over process registry implementations.

Supports two backends:

- `:local` — Elixir's built-in `Registry` (single-node, zero extra deps)
- `:horde` — `Horde.Registry` (distributed, requires the `:horde` dependency)

## Configuration

    # config/config.exs (or runtime.exs)

    # Single-node (default — no config needed)
    config :sagents, :distribution, :local

    # Distributed cluster
    config :sagents, :distribution, :horde

When `:horde` is selected, Horde.Registry is started with `members: :auto`
so it automatically discovers other nodes in the Erlang cluster.

# `child_spec`

Returns the child spec for the configured registry backend.

Used in `Sagents.Application` supervision tree.

# `count`

Returns the count of all registered entries.

# `keys`

Returns the keys for the given process `pid`.

## Examples

    Sagents.ProcessRegistry.keys(pid)
    # => [{:agent_supervisor, "agent-123"}]

# `lookup`

Look up a process by key.

Returns `[{pid, value}]` if found, `[]` otherwise.

## Examples

    [{pid, _}] = Sagents.ProcessRegistry.lookup({:agent_server, "agent-123"})

# `registry_module`

Returns the registry module (`Registry` or `Horde.Registry`).

# `registry_name`

Returns the registry name atom (`Sagents.Registry`).

# `select`

Select processes matching a match specification.

The match spec format is the same as `Registry.select/2`.

## Examples

    Sagents.ProcessRegistry.select([
      {{{:agent_server, :"$1"}, :_, :_}, [], [:"$1"]}
    ])

# `via_tuple`

Returns a `:via` tuple for registering or looking up a process by key.

## Examples

    Sagents.ProcessRegistry.via_tuple({:agent_server, "agent-123"})
    # => {:via, Registry, {Sagents.Registry, {:agent_server, "agent-123"}}}
    #    or
    # => {:via, Horde.Registry, {Sagents.Registry, {:agent_server, "agent-123"}}}

---

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