View Source Teiserver.Registry (Teiserver v0.0.1)
Local process storage for Teiserver instances. Heavily copied from Oban
Summary
Functions
Fetch the config for an Teiserver supervisor instance.
Find the {pid, value}
pair for a registered Teiserver process.
Build a via tuple suitable for calls to a supervised Teiserver process.
Returns the pid of a supervised Teiserver process, or nil
if the process can't be found.
Types
@type key() :: Teiserver.name() | {Teiserver.name(), role()}
@type role() :: term()
@type value() :: term()
Functions
@spec config(Teiserver.name()) :: Teiserver.Config.t()
Fetch the config for an Teiserver supervisor instance.
Example
Get the default instance config:
Teiserver.Registry.config(Teiserver)
Get config for a custom named instance:
Teiserver.Registry.config(MyApp.Teiserver)
@spec lookup(Teiserver.name(), role()) :: nil | {pid(), value()}
Find the {pid, value}
pair for a registered Teiserver process.
Example
Get the default instance config:
Teiserver.Registry.lookup(Teiserver)
Get a supervised module's pid:
Teiserver.Registry.lookup(Teiserver, Teiserver.Notifier)
@spec via(Teiserver.name(), role(), value()) :: {:via, Registry, {Teiserver.Registry, key()}}
Build a via tuple suitable for calls to a supervised Teiserver process.
Example
For an Teiserver supervisor:
Teiserver.Registry.via(Teiserver)
For a supervised module:
Teiserver.Registry.via(Teiserver, Teiserver.Notifier)
For a plugin:
Teiserver.Registry.via(Teiserver, {:plugin, Teiserver.Plugins.Cron})
@spec whereis(Teiserver.name(), role()) :: pid() | {atom(), node()} | nil
Returns the pid of a supervised Teiserver process, or nil
if the process can't be found.
Example
Get the Teiserver supervisor's pid:
Teiserver.Registry.whereis(Teiserver)
Get a supervised module's pid:
Teiserver.Registry.whereis(Teiserver, Teiserver.Notifier)
Get the pid for a plugin:
Teiserver.Registry.whereis(Teiserver, {:plugin, MyApp.Teiserver.Plugin})
Get the pid for a queue's producer:
Teiserver.Registry.whereis(Teiserver, {:producer, "default"})