@secondlayer/sdk 12.1.0 → 12.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +11 -0
- package/dist/index.js +7 -3
- package/dist/index.js.map +5 -5
- package/dist/streams/index.d.ts +11 -0
- package/dist/streams/index.js +7 -3
- package/dist/streams/index.js.map +5 -5
- package/dist/subgraphs/index.d.ts +11 -0
- package/dist/subgraphs/index.js +7 -3
- package/dist/subgraphs/index.js.map +4 -4
- package/package.json +3 -3
|
@@ -950,6 +950,17 @@ type StreamsEventsConsumeParams<
|
|
|
950
950
|
maxPages?: number;
|
|
951
951
|
maxEmptyPolls?: number;
|
|
952
952
|
signal?: AbortSignal;
|
|
953
|
+
/**
|
|
954
|
+
* Cuts the empty-poll backoff short: on an empty page, the loop races
|
|
955
|
+
* `emptyBackoffMs` against this promise instead of sleeping the full
|
|
956
|
+
* amount. Pass a function that resolves once when new data MIGHT be
|
|
957
|
+
* available (e.g. a Postgres NOTIFY listener) — it is called fresh on
|
|
958
|
+
* every empty page, never awaited more than once concurrently per page.
|
|
959
|
+
* The backoff timer still runs underneath, so a wake source that never
|
|
960
|
+
* resolves (or a `wake` this call omits) degrades to the same polling
|
|
961
|
+
* behavior as before.
|
|
962
|
+
*/
|
|
963
|
+
wake?: () => Promise<void>;
|
|
953
964
|
};
|
|
954
965
|
/**
|
|
955
966
|
* One yielded page from {@link StreamsClient.consume} — the
|
package/dist/subgraphs/index.js
CHANGED
|
@@ -1431,7 +1431,10 @@ async function consumeStreamsEvents(opts) {
|
|
|
1431
1431
|
if (mode === "bounded") {
|
|
1432
1432
|
return { cursor, pages, emptyPolls };
|
|
1433
1433
|
}
|
|
1434
|
-
await
|
|
1434
|
+
await (opts.wake ? Promise.race([
|
|
1435
|
+
sleep(emptyBackoffMs, opts.signal),
|
|
1436
|
+
opts.wake().catch(() => new Promise(() => {}))
|
|
1437
|
+
]) : sleep(emptyBackoffMs, opts.signal));
|
|
1435
1438
|
continue;
|
|
1436
1439
|
}
|
|
1437
1440
|
return { cursor, pages, emptyPolls };
|
|
@@ -2392,7 +2395,8 @@ function createStreamsClient(options) {
|
|
|
2392
2395
|
signal: params.signal,
|
|
2393
2396
|
retryCount: params.retryCount,
|
|
2394
2397
|
retryDelay: params.retryDelay,
|
|
2395
|
-
onError: params.onError
|
|
2398
|
+
onError: params.onError,
|
|
2399
|
+
wake: params.wake
|
|
2396
2400
|
});
|
|
2397
2401
|
}
|
|
2398
2402
|
return {
|
|
@@ -2669,5 +2673,5 @@ export {
|
|
|
2669
2673
|
getSubgraph
|
|
2670
2674
|
};
|
|
2671
2675
|
|
|
2672
|
-
//# debugId=
|
|
2676
|
+
//# debugId=0A45A9108BCFA89A64756E2164756E21
|
|
2673
2677
|
//# sourceMappingURL=index.js.map
|