Skip to content

Commit

Permalink
Add heartbeat handling to key iteration
Browse files Browse the repository at this point in the history
Introduce a heartbeat case to handle key iteration status updates. This ensures proper key fetching and stops the iteration appropriately upon receiving a heartbeat.

Signed-off-by: Alberto Ricart <[email protected]>
  • Loading branch information
aricart committed Feb 4, 2025
1 parent 3d448c9 commit 92407d9
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions kv/src/kv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -899,6 +899,19 @@ export class Bucket implements KV {
},
});

(async () => {
for await (const s of iter.status()) {
switch (s.type) {
// if we get a heartbeat we got all the keys
case "heartbeat":
keys.push(() => {
keys.stop();
});
break;
}
}
})().then();

iter.closed().then(() => {
keys.push(() => {
keys.stop();
Expand Down

0 comments on commit 92407d9

Please sign in to comment.