Sagents.ProcessRegistry (Sagents v0.5.1)
Copy MarkdownAbstraction over process registry implementations.
Supports two backends:
:local— Elixir's built-inRegistry(single-node, zero extra deps):horde—Horde.Registry(distributed, requires the:hordedependency)
Configuration
# config/config.exs (or runtime.exs)
# Single-node (default — no config needed)
config :sagents, :distribution, :local
# Distributed cluster
config :sagents, :distribution, :hordeWhen :horde is selected, Horde.Registry is started with members: :auto
so it automatically discovers other nodes in the Erlang cluster.
Summary
Functions
Returns the child spec for the configured registry backend.
Returns the count of all registered entries.
Returns the keys for the given process pid.
Look up a process by key.
Returns the registry module (Registry or Horde.Registry).
Returns the registry name atom (Sagents.Registry).
Select processes matching a match specification.
Returns a :via tuple for registering or looking up a process by key.
Functions
Returns the child spec for the configured registry backend.
Used in Sagents.Application supervision tree.
Returns the count of all registered entries.
Returns the keys for the given process pid.
Examples
Sagents.ProcessRegistry.keys(pid)
# => [{:agent_supervisor, "agent-123"}]
Look up a process by key.
Returns [{pid, value}] if found, [] otherwise.
Examples
[{pid, _}] = Sagents.ProcessRegistry.lookup({:agent_server, "agent-123"})
Returns the registry module (Registry or Horde.Registry).
Returns the registry name atom (Sagents.Registry).
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"]}
])
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"}}}