yggdrasil v3.3.3 Yggdrasil.Distributor.Backend 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.()}: When a subscriber connects to a channel successfully. See connected/2 function.
  • {:Y_DISCONNECTED, Channel.()}; When a subscriber disconnects from a channel successfully. See disconnected/2 function.
  • {:Y_EVENT, Channel.t(), message()} when message: term(): When a subscriber gets a new messages from the adapter. See publish/2 function.

Link to this section Summary

Functions

Sends a {:Y_CONNECTED, Channel.t()} message to all the subscribers of the channel or optionally to a single pìd

Sends a {:Y_DISCONNECTED, Channel.t()} message to all the subscribers of the channel or optionally to a single pìd

Publishes a message in a channel

Subscribes to a channel

Unsubscribes from a channel

Link to this section Functions

Link to this function connected(channel, pid \\ nil) View Source
connected(Yggdrasil.Channel.t(), pid()) :: :ok

Sends a {:Y_CONNECTED, Channel.t()} message to all the subscribers of the channel or optionally to a single pìd.

Link to this function disconnected(channel, pid \\ nil) View Source
disconnected(Yggdrasil.Channel.t(), pid()) :: :ok

Sends a {:Y_DISCONNECTED, Channel.t()} message to all the subscribers of the channel or optionally to a single pìd.

Link to this function publish(channel, message) View Source
publish(Yggdrasil.Channel.t(), term()) :: :ok | {:error, term()}

Publishes a message in a channel.

Link to this function subscribe(channel) View Source
subscribe(Yggdrasil.Channel.t()) :: :ok | {:error, term()}

Subscribes to a channel.

Link to this function unsubscribe(channel) View Source
unsubscribe(Yggdrasil.Channel.t()) :: :ok | {:error, term()}

Unsubscribes from a channel.