postgleam/notifications

Types

A notification received from PostgreSQL

pub type Notification {
  Notification(channel: String, payload: String, pg_pid: Int)
}

Constructors

  • Notification(channel: String, payload: String, pg_pid: Int)

Values

pub fn listen(
  state: connection.ConnectionState,
  channel: String,
  timeout: Int,
) -> Result(connection.ConnectionState, error.Error)

Listen on a channel

pub fn notify(
  state: connection.ConnectionState,
  channel: String,
  payload: String,
  timeout: Int,
) -> Result(connection.ConnectionState, error.Error)

Send a notification on a channel

pub fn receive_notifications(
  state: connection.ConnectionState,
  timeout: Int,
) -> Result(
  #(List(Notification), connection.ConnectionState),
  error.Error,
)

Check for pending notifications. Sends a lightweight query to flush any queued notifications from the server. Returns a list of notifications that arrived, plus the updated state.

pub fn unlisten(
  state: connection.ConnectionState,
  channel: String,
  timeout: Int,
) -> Result(connection.ConnectionState, error.Error)

Stop listening on a channel

Search Document