Phoenix.PubSub.Local
PubSub implementation for handling local-node process groups
This modules is used by Phoenix pubsub adapters to handle their
local node topic subscriptions. See Phoenix.PubSub.PG2
for an example integration.
Summary↑
| broadcast(local_server, from, topic, msg) | Sends a message to allow subscribers of a topic |
| start_link(server_name) | Starts the server |
| subscribe(local_server, pid, topic, opts \\ []) | Subscribes the pid to the topic |
| subscribers(local_server, topic) | Returns the |
| unsubscribe(local_server, pid, topic) | Unsubscribes the pid from the topic |
Functions
Sends a message to allow subscribers of a topic
local_server- The registered server name or pidtopic- The string topic, ie “users:123”
Examples
iex> broadcast(:local_server, self, "foo")
:ok
iex> broadcast(:local_server, :none, "bar")
:no_topic
Starts the server
server_name- The name to registered the server under
Subscribes the pid to the topic
local_server- The registered server name or pidpid- The subscriber Pidtopic- The string topic, ie “users:123”opts- The optional list of options. Supported optionsonly include `:link` to link the subscriber to the pubsub adapter
Examples
iex> subscribe(:local_server, self, "foo")
:ok
Returns the HashSet of subscribers pids for the given topic
local_server- The registered server name or pidtopic- The string topic, ie “users:123”
Examples
iex> subscribers(:local_server, "foo")
#HashSet<[]>
Unsubscribes the pid from the topic
local_server- The registered server name or pidpid- The subscriber Pidtopic- The string topic, ie “users:123”
Examples
iex> unsubscribe(:local_server, self, "foo")
:ok