Postgrex v0.13.0 Postgrex.Notifications

API for notifications (pub/sub) in Postgres.

Summary

Functions

Listens to an asynchronous notification channel using the LISTEN command. A message {:notification, connection_pid, ref, channel, payload} will be sent to the calling process when a notification is received

Listens to an asynchronous notification channel channel. See listen/2

Start the notification connection process and connect to postgres

Stops listening on the given channel by passing the reference returned from listen/2

Stops listening on the given channel by passing the reference returned from listen/2

Functions

listen(pid, channel, opts \\ [])
listen(pid, String.t, Keyword.t) :: {:ok, reference}

Listens to an asynchronous notification channel using the LISTEN command. A message {:notification, connection_pid, ref, channel, payload} will be sent to the calling process when a notification is received.

Options

  • :timeout - Call timeout (default: 5000)
listen!(pid, channel, opts \\ [])
listen!(pid, String.t, Keyword.t) :: reference

Listens to an asynchronous notification channel channel. See listen/2.

start_link(opts)
start_link(Keyword.t) ::
  {:ok, pid} |
  {:error, Postgrex.Error.t | term}

Start the notification connection process and connect to postgres.

The option that this function accepts are exactly the same accepted by Postgrex.start_link/1.

unlisten(pid, ref, opts \\ [])
unlisten(pid, reference, Keyword.t) :: :ok

Stops listening on the given channel by passing the reference returned from listen/2.

Options

  • :timeout - Call timeout (default: 5000)
unlisten!(pid, ref, opts \\ [])
unlisten!(pid, reference, Keyword.t) :: :ok

Stops listening on the given channel by passing the reference returned from listen/2.