Skip to content

Commit

Permalink
fix #30
Browse files Browse the repository at this point in the history
  • Loading branch information
exe-dealer committed Sep 27, 2022
1 parent 12826ad commit d8537b3
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 11 deletions.
14 changes: 7 additions & 7 deletions mod.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,24 +170,24 @@ export interface LogicalReplicationOptions {
}

export interface ReplicationStream extends AsyncIterable<ReplicationChunk> {
/** Confirms receipt of replication packet by lsn.
* Use {@link ReplicationMessage.lsn} to get packet lsn. */
/** Confirms receipt of replication message by lsn.
* Use {@link ReplicationMessage.lsn} to get lsn. */
ack(lsn: string): undefined;
/**
* Decodes {@link ReplicationMessage.data} and yields upgraded pgoutput packets.
* Decodes {@link ReplicationMessage.data} and yields upgraded pgoutput messages.
* Use this method if replication is started with pgoutput slot. */
pgoutputDecode(): AsyncIterable<PgotputChunk>;
}

export interface ReplicationChunk {
readonly endLsn: string;
readonly time: bigint;
readonly messages: ReplicationMessage[];
readonly lastLsn: string;
readonly lastTime: bigint;
}

export interface ReplicationMessage {
/** Log Serial Number of packet.
* Use it for {@link ReplicationStream.ack} to confirm receipt of packet. */
/** Log Serial Number of message.
* Use it for {@link ReplicationStream.ack} to confirm receipt of message. */
readonly lsn: string | null;
readonly endLsn: string | null;
/** microseconds since unix epoch */
Expand Down
2 changes: 1 addition & 1 deletion mod.js
Original file line number Diff line number Diff line change
Expand Up @@ -1605,10 +1605,10 @@ class ReplicationStream extends BinaryReader {
break;
case 'PrimaryKeepaliveMessage':
shouldAck = shouldAck || msg.shouldReply;
// TODO msg.endLsn not exposed
break;
}
if (lastLsn < msg.lsn) lastLsn = msg.lsn;
if (lastLsn < msg.endLsn) lastLsn = msg.endLsn;
if (lastTime < msg.time) lastTime = msg.time;
}
if (shouldAck) {
Expand Down
3 changes: 1 addition & 2 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -458,8 +458,7 @@ for (const notice of out.notices) {

```js
for await (const chunk of replstream.pgoutputDecode()) {

// (string) Lsn of last received message.
// (string) Last valid received lsn.
// Use it for replstream.ack() to confirm receipt of whole chunk.
chunk.lastLsn;
// (bigint) Time of last received message. Microseconds since unix epoch.
Expand Down
2 changes: 1 addition & 1 deletion test/deno.dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM denoland/deno:alpine-1.23.4
FROM denoland/deno:alpine-1.25.4
COPY test_deno.js /tmp/test/
RUN set -x \
&& touch /tmp/mod.js \
Expand Down

0 comments on commit d8537b3

Please sign in to comment.