Yggdrasil v5.0.0 Yggdrasil.Adapter.Bridge View Source
Yggdrasil bridge adapter. The name of the channel is a valid remote Yggdrasil.Channel e.g:
First we subscribe to a channel:
iex> channel = [name: [name: "remote_channel"], adapter: :bridge]
iex> Yggdrasil.subscribe(channel)
:ok
iex> flush()
{:Y_CONNECTED, ...}
Once connected, you can publish a message in that channel:
iex> Yggdrasil.publish(channel, "foo")
:ok
And the subscriber should receive the message:
iex> flush()
{:Y_EVENT, ..., "foo"}
Additionally, the subscriber can also unsubscribe from the channel:
iex> Yggdrasil.unsubscribe(channel)
:ok
iex> flush()
{:Y_DISCONNECTED, ...}
Link to this section Summary
Functions
Returns a specification to start this module under a supervisor.
Gets default backend.
Gets publisher module.
Gets publisher module only if the given module exists.
Gets subscriber module.
Gets subscriber module only if the given module exists.
Gets default transformer.
Registers adapter in Registry
.
Splits channels in a bridge
channel.
Start task to register the adapter in the Registry
.
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.
get_backend()
View Source
get_backend() :: atom()
get_backend() :: atom()
Gets default backend.
get_publisher_module() View Source
Gets publisher module.
get_publisher_module(module) View Source
Gets publisher module only if the given module exists.
get_subscriber_module() View Source
Gets subscriber module.
get_subscriber_module(module) View Source
Gets subscriber module only if the given module exists.
get_transformer()
View Source
get_transformer() :: atom()
get_transformer() :: atom()
Gets default transformer.
register()
View Source
register() :: :ok
register() :: :ok
Registers adapter in Registry
.
split_channels(bridge)
View Source
split_channels(Yggdrasil.Channel.t()) ::
{:ok, {Yggdrasil.Channel.t(), Yggdrasil.Channel.t()}} | {:error, term()}
split_channels(Yggdrasil.Channel.t()) :: {:ok, {Yggdrasil.Channel.t(), Yggdrasil.Channel.t()}} | {:error, term()}
Splits channels in a bridge
channel.
start_link(_) View Source
Start task to register the adapter in the Registry
.