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
Link to this function
child_spec(init_arg) View Source
Returns a specification to start this module under a supervisor.
See Supervisor
.
Link to this function
start_link(channel, options \\ [])
View Source
start_link(channel, options \\ [])
View Source
start_link(Yggdrasil.Channel.t(), GenServer.options()) :: GenServer.on_start()
start_link(Yggdrasil.Channel.t(), GenServer.options()) :: GenServer.on_start()
Starts Elixir.Yggdrasil.Subscriber.Adapter.Postgres with a channel
and optional options
.