yggdrasil v3.3.1 Yggdrasil.Subscriber.Adapter.Redis View Source

Yggdrasil subscriber adapter for Redis. The name of the channel must be a binary e.g:

Subscription to channel:

iex(2)> channel = %Yggdrasil.Channel{name: "redis_channel", adapter: :redis}
iex(3)> Yggdrasil.subscribe(channel)
:ok
iex(4)> flush()
{:Y_CONNECTED, %Yggdrasil.Channel{name: "redis_channel", (...)}}

Publishing message:

iex(5)> Yggdrasil.publish(channel, "foo")
:ok

Subscriber receiving message:

iex(6)> flush()
{:Y_EVENT, %Yggdrasil.Channel{name: "redis_channel", (...)}, "foo"}

The subscriber can also unsubscribe from the channel:

iex(7)> Yggdrasil.unsubscribe(channel)
:ok
iex(8)> flush()
{:Y_DISCONNECTED, %Yggdrasil.Channel{name: "redis_channel", (...)}}

Link to this section Summary

Functions

Returns a specification to start this module under a supervisor

Starts a Redis distributor adapter in a channel with some distributor publisher and optionally GenServer options

Stops the Redis adapter with its pid

Link to this section Functions

Returns a specification to start this module under a supervisor.

See Supervisor.

Link to this function start_link(channel, publisher, options \\ []) View Source

Starts a Redis distributor adapter in a channel with some distributor publisher and optionally GenServer options.

Stops the Redis adapter with its pid.