yggdrasil v3.3.0 Yggdrasil.Publisher.Adapter.Elixir View Source
Yggdrasil publisher adapter for Elixir. The name of the channel can be any arbitrary term e.g:
Subscription to channel:
iex(2)> channel = %Yggdrasil.Channel{name: "elixir_channel"}
iex(3)> Yggdrasil.subscribe(channel)
:ok
iex(4)> flush()
{:Y_CONNECTED, %Yggdrasil.Channel{name: "elixir_channel", (...)}}
Publishing message:
iex(5)> Yggdrasil.publish(channel, "foo")
:ok
Subscriber receiving message:
iex(6)> flush()
{:Y_EVENT, %Yggdrasil.Channel{name: "elixir_channel", (...)}, "foo"}
The subscriber can also unsubscribe from the channel:
iex(7)> Yggdrasil.unsubscribe(channel)
:ok
iex(8)> flush()
{:Y_DISCONNECTED, %Yggdrasil.Channel{name: "elixir_channel", (...)}}
Link to this section Summary
Link to this section Functions
Returns a specification to start this module under a supervisor.
See Supervisor
.
Link to this function
publish(publisher, channel, message, options \\ [])
View Source
publish(GenServer.server(), Yggdrasil.Channel.t(), term(), Keyword.t()) :: :ok | {:error, term()}
Publishes a message
in a channel
using a publisher
and optional and
unused options
.
Link to this function
start_link(namespace, options \\ [])
View Source
start_link(term(), GenServer.options()) :: GenServer.on_start()
Starts an elixir publisher with a namespace
. Additianally you can add
GenServer
options
.
Stops an elixir publisher
.