Yggdrasil for PostgreSQL v5.0.1 Yggdrasil.Adapter.Postgres View Source

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

Subscription to channel:

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

Publishing message:

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

Subscriber receiving message:

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

The subscriber can also unsubscribe from the channel:

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

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.

Start task to register the adapter in the Registry.

Link to this section Functions

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.

Link to this function

get_backend()

View Source
get_backend() :: atom()

Gets default backend.

Link to this function

get_publisher_module()

View Source
get_publisher_module() :: {:ok, module()} | {:error, term()}

Gets publisher module.

Link to this function

get_publisher_module(module)

View Source
get_publisher_module(nil | module()) :: {:ok, module()} | {:error, term()}

Gets publisher module only if the given module exists.

Link to this function

get_subscriber_module()

View Source
get_subscriber_module() :: {:ok, module()} | {:error, term()}

Gets subscriber module.

Link to this function

get_subscriber_module(module)

View Source
get_subscriber_module(nil | module()) :: {:ok, module()} | {:error, term()}

Gets subscriber module only if the given module exists.

Link to this function

get_transformer()

View Source
get_transformer() :: atom()

Gets default transformer.

Link to this function

register()

View Source
register() :: :ok

Registers adapter in Registry.

Link to this function

start_link(_)

View Source
start_link(term()) :: {:ok, pid()}

Start task to register the adapter in the Registry.