Yggdrasil v5.0.0 Yggdrasil.Backend.Default View Source
Distributor backend to subscribe, unsubscribe and publish messages. Uses
Phoenix.PubSub
for message distribution.
This module contains helper functions used by the adapters to broadcast their messages. The possible messages are:
{:Y_CONNECTED, Channel.t()}
: When a subscriber connects to a channel successfully. Seeconnected/2
function.{:Y_DISCONNECTED, Channel.()}
; When a subscriber disconnects from a channel successfully. Seedisconnected/2
function.{:Y_EVENT, Channel.t(), term()} when message: term()
: When a subscriber gets a new messages from the adapter. Seepublish/2
function.
Link to this section Summary
Functions
Returns a specification to start this module under a supervisor.
Broadcast a connection message in a channel
and optionally to a pid
.
Broadcast a disconnection message in a channel
and optionally to a
pid
.
Broadcasts a message
in a channel
with some metadata
.
Registers backend in Registry
.
Start task to register the backend in the Registry
.
Subscribes to channel
.
Unsubscribe to channel
.
Link to this section Functions
child_spec(arg) View Source
Returns a specification to start this module under a supervisor.
arg
is passed as the argument to Task.start_link/1
in the :start
field
of the spec.
For more information, see the Supervisor
module,
the Supervisor.child_spec/2
function and the Supervisor.child_spec/0
type.
connected(channel, pid)
View Source
connected(Yggdrasil.Channel.t(), nil | pid()) :: :ok | {:error, term()}
connected(Yggdrasil.Channel.t(), nil | pid()) :: :ok | {:error, term()}
Broadcast a connection message in a channel
and optionally to a pid
.
disconnected(channel, pid)
View Source
disconnected(Yggdrasil.Channel.t(), nil | pid()) :: :ok | {:error, term()}
disconnected(Yggdrasil.Channel.t(), nil | pid()) :: :ok | {:error, term()}
Broadcast a disconnection message in a channel
and optionally to a
pid
.
publish(channel, message, metadata)
View Source
publish(Yggdrasil.Channel.t(), term(), term()) :: :ok | {:error, term()}
publish(Yggdrasil.Channel.t(), term(), term()) :: :ok | {:error, term()}
Broadcasts a message
in a channel
with some metadata
.
register()
View Source
register() :: :ok
register() :: :ok
Registers backend in Registry
.
start_link(_) View Source
Start task to register the backend in the Registry
.
subscribe(channel)
View Source
subscribe(Yggdrasil.Channel.t()) :: :ok | {:error, term()}
subscribe(Yggdrasil.Channel.t()) :: :ok | {:error, term()}
Subscribes to channel
.
unsubscribe(channel)
View Source
unsubscribe(Yggdrasil.Channel.t()) :: :ok | {:error, term()}
unsubscribe(Yggdrasil.Channel.t()) :: :ok | {:error, term()}
Unsubscribe to channel
.