PostgreSQL streaming replication over pgjdbc: log sequence numbers (LSNs), replication-slot management, and logical decoding streams.
A replication connection is a special connection opened with the replication
property set; replication-spec adds the required properties to a db spec.
The server must run with wal_level = logical (and enough max_wal_senders /
max_replication_slots) for logical replication.
PostgreSQL streaming replication over pgjdbc: log sequence numbers (LSNs), replication-slot management, and logical decoding streams. A replication connection is a special connection opened with the `replication` property set; `replication-spec` adds the required properties to a db spec. The server must run with `wal_level = logical` (and enough `max_wal_senders` / `max_replication_slots`) for logical replication.
(close-stream! stream)Close a replication STREAM.
Close a replication STREAM.
(create-logical-slot! conn slot-name plugin)Create a logical replication SLOT-NAME using output PLUGIN (for example
"pgoutput" or "test_decoding"). Returns a slot-info map with
:slot-name, :replication-type, :consistent-point, :snapshot-name, and
:output-plugin.
Create a logical replication SLOT-NAME using output PLUGIN (for example "pgoutput" or "test_decoding"). Returns a slot-info map with `:slot-name`, `:replication-type`, `:consistent-point`, `:snapshot-name`, and `:output-plugin`.
(create-physical-slot! conn slot-name)Create a physical replication SLOT-NAME. Returns a slot-info map.
Create a physical replication SLOT-NAME. Returns a slot-info map.
(drop-slot! conn slot-name)Drop the replication slot SLOT-NAME.
Drop the replication slot SLOT-NAME.
(force-status-update! stream)Send a standby status update to the server immediately.
Send a standby status update to the server immediately.
(last-received-lsn stream)The last LSN received on STREAM.
The last LSN received on STREAM.
(lsn x)Coerce X to a pgjdbc LogSequenceNumber. X is an LSN string like
"16/B374D848", a long, or an existing LogSequenceNumber.
Coerce X to a pgjdbc `LogSequenceNumber`. X is an LSN string like "16/B374D848", a long, or an existing `LogSequenceNumber`.
(lsn->long l)Return the 64-bit long value of an LSN.
Return the 64-bit long value of an LSN.
(lsn->string l)Return the canonical X/Y string form of an LSN.
Return the canonical `X/Y` string form of an LSN.
(read-change stream)Read the next change from STREAM as a java.nio.ByteBuffer, blocking until
one is available.
Read the next change from STREAM as a `java.nio.ByteBuffer`, blocking until one is available.
(read-pending stream)Read the next available change from STREAM as a java.nio.ByteBuffer, or nil
if none is pending right now (non-blocking).
Read the next available change from STREAM as a `java.nio.ByteBuffer`, or nil if none is pending right now (non-blocking).
(replication-api conn)Return pgjdbc's PGReplicationConnection for a connection opened from a
replication-spec.
Return pgjdbc's `PGReplicationConnection` for a connection opened from a `replication-spec`.
(replication-spec spec)Return SPEC with the properties pgjdbc needs to open a replication
connection: :replication "database", simple query mode, and a minimum
server version. Pass the result to next.jdbc/get-connection.
Return SPEC with the properties pgjdbc needs to open a replication connection: `:replication "database"`, simple query mode, and a minimum server version. Pass the result to `next.jdbc/get-connection`.
(set-applied-lsn! stream l)Tell the server STREAM has applied up to L (an LSN).
Tell the server STREAM has applied up to L (an LSN).
(set-flushed-lsn! stream l)Tell the server STREAM has durably flushed up to L (an LSN).
Tell the server STREAM has durably flushed up to L (an LSN).
(start-logical-replication conn
{:keys [slot-name start-lsn status-interval-ms
slot-options]})Start a logical decoding stream on an existing logical slot and return a
pgjdbc PGReplicationStream. OPTS keys:
:slot-name (required) the logical slot to stream from:start-lsn start position (LSN string/long/LogSequenceNumber):status-interval-ms standby status update interval:slot-options a map of output-plugin option name to string valueConsume it with read-pending/read, acknowledge progress with
set-flushed-lsn!/set-applied-lsn!, and close-stream! when done.
Start a logical decoding stream on an existing logical slot and return a pgjdbc `PGReplicationStream`. OPTS keys: - `:slot-name` (required) the logical slot to stream from - `:start-lsn` start position (LSN string/long/LogSequenceNumber) - `:status-interval-ms` standby status update interval - `:slot-options` a map of output-plugin option name to string value Consume it with `read-pending`/`read`, acknowledge progress with `set-flushed-lsn!`/`set-applied-lsn!`, and `close-stream!` when done.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |