postgres/notify
src/postgres/notify.tur
defopaque
Notification
(Notification)
opaque handle to a libpq PGnotify notification.
defn
notify-listen
(notify-listen [^borrow conn : Conn channel : cstr] :)
defn
notify-unlisten
(notify-unlisten [^borrow conn : Conn channel : cstr] :)
unsubscribe from asynchronous notifications on a channel.
Parameters
| conn | connection handle | |
| channel | channel name to stop listening on |
Returns
(Result int int) -- ok carries 0; err carries 0 on failure.
Example
(notify-unlisten conn "my_channel")
Since: PG3
defn
notify-poll
(notify-poll [^borrow conn : Conn] :)
defn
notification-channel
(notification-channel [n : Notification] :)
return the channel name of a PGnotify notification.
Parameters
| n | notification handle (ok-val from notify-poll when non-zero) |
Returns
Channel name as :cstr (valid until PQfreemem is called on n).
Example
(notification-channel notif) ; => "my_channel"
Since: PG3
defn
notification-payload
(notification-payload [n : Notification] :)
return the payload string of a PGnotify notification.
Parameters
| n | notification handle (ok-val from notify-poll when non-zero) |
Returns
Payload as :cstr (valid until PQfreemem is called on n); "" if none.
Example
(notification-payload notif) ; => "hello"
Since: PG3
Internal definitions
__listen-sql-- build "LISTEN channel" as a heap-allocated cstr.__unlisten-sql-- build "UNLISTEN channel" as a heap-allocated cstr.__pq-exec-raw-- execute SQL with no params; returns 1 on success, 0 on failure.__pq-consume-input-- call PQconsumeInput; returns 1 on success, 0 on error.__pq-notifies-- call PQnotifies; returns PGnotify* as :int (0 if none pending).__notify-result-of-rc-- subscribe to asynchronous notifications on a channel.__notify-poll-ok-- poll for a pending notification without blocking.__notify-poll-err