Phoenix.PubSub.Local

PubSub implementation for handling local-node process groups.

This module is used by Phoenix pubsub adapters to handle their local node subscriptions and it is usually not accessed directly. See Phoenix.PubSub.PG2 for an example integration.

Source

Summary

broadcast(local_server, from, topic, msg)

Sends a message to all subscribers of a topic

start_link(server_name)
subscribe(local_server, pid, topic, opts \\ [])

Subscribes the pid to the topic

subscribers(local_server, topic)

Returns a set of subscribers pids for the given topic

subscribers_with_fastlanes(local_server, topic)

Returns a set of subscribers pids for the given topic with fastlane tuples. See subscribers/1 for more information

unsubscribe(local_server, pid, topic)

Unsubscribes the pid from the topic

Functions

broadcast(local_server, from, topic, msg)

Sends a message to all subscribers of a topic.

  • local_server - The registered server name or pid
  • topic - The string topic, for example “users:123”

Examples

iex> broadcast(:local_server, self, "foo")
:ok
iex> broadcast(:local_server, :none, "bar")
:ok
Source
start_link(server_name)
Source
subscribe(local_server, pid, topic, opts \\ [])

Subscribes the pid to the topic.

  • local_server - The registered server name or pid
  • pid - The subscriber pid
  • topic - The string topic, for example “users:123”
  • opts - The optional list of options. Supported options only include :link to link the subscriber to local

Examples

iex> subscribe(:local_server, self, "foo")
:ok
Source
subscribers(local_server, topic)

Returns a set of subscribers pids for the given topic.

  • local_server - The registered server name or pid
  • topic - The string topic, for example “users:123”

Examples

iex> subscribers(:local_server, "foo")
[#PID<0.48.0>, #PID<0.49.0>]
Source
subscribers_with_fastlanes(local_server, topic)

Returns a set of subscribers pids for the given topic with fastlane tuples. See subscribers/1 for more information.

Source
unsubscribe(local_server, pid, topic)

Unsubscribes the pid from the topic.

  • local_server - The registered server name or pid
  • pid - The subscriber pid
  • topic - The string topic, for example “users:123”

Examples

iex> unsubscribe(:local_server, self, "foo")
:ok
Source