Skip to content

Commit 4354d34

Browse files
committed
add status
1 parent 12e6127 commit 4354d34

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

examples/bluesky-firehose-to-s2.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,8 @@ console.log("Press Ctrl+C to stop.\n");
101101

102102
let submitted = 0;
103103
let acked = 0;
104+
let lastLogTime = Date.now();
105+
let lastSubmitted = 0;
104106

105107
// Transform that filters posts and converts to AppendRecord.
106108
const toAppendRecord = new TransformStream<JetstreamEvent, AppendRecord>({
@@ -139,8 +141,13 @@ const ackLoop = (async () => {
139141
})();
140142

141143
const logInterval = setInterval(() => {
144+
const now = Date.now();
145+
const elapsed = (now - lastLogTime) / 1000;
146+
const rate = ((submitted - lastSubmitted) / elapsed).toFixed(1);
147+
lastLogTime = now;
148+
lastSubmitted = submitted;
142149
console.log(
143-
`submitted=${submitted} acked=${acked} inflight=${submitted - acked}`,
150+
`submitted=${submitted} acked=${acked} inflight=${submitted - acked} (${rate} msg/s)`,
144151
);
145152
}, 1000);
146153

0 commit comments

Comments
 (0)