Yggdrasil for PostgreSQL v5.0.0 Yggdrasil.Subscriber.Adapter.Postgres View Source

Yggdrasil adapter for PostgreSQL. The name of the channel must be a string e.g:

Subscription to channel:

iex(1)> channel = [name: "pg_channel", adapter: :postgres]
iex(2)> Yggdrasil.subscribe(channel)
:ok
iex(3)> flush()
{:Y_CONNECTED, %Yggdrasil.Channel{name: "pg_channel", (...)}}

Publishing message:

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

Subscriber receiving message:

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

The subscriber can also unsubscribe from the channel:

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

Link to this section Summary

Functions

Returns a specification to start this module under a supervisor.

Starts Elixir.Yggdrasil.Subscriber.Adapter.Postgres with a channel and optional options.

Link to this section Functions

Returns a specification to start this module under a supervisor.

See Supervisor.

Starts Elixir.Yggdrasil.Subscriber.Adapter.Postgres with a channel and optional options.