@rotorsoft/act 1.23.25 → 1.23.26

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.js CHANGED
@@ -115,6 +115,27 @@ function current_version_of(deprecated_name, all_names) {
115
115
  return highest && highest.version > target.version ? highest.name : void 0;
116
116
  }
117
117
 
118
+ // src/internal/walk-streams.ts
119
+ var DEFAULT_STREAM_PAGE = 500;
120
+ async function walk_streams(store2, callback, query) {
121
+ const page_size = query?.limit ?? DEFAULT_STREAM_PAGE;
122
+ let after = query?.after;
123
+ let total = 0;
124
+ for (; ; ) {
125
+ let last;
126
+ const { count } = await store2.query_streams(
127
+ (position) => {
128
+ last = position.stream;
129
+ callback(position);
130
+ },
131
+ { ...query, after, limit: page_size }
132
+ );
133
+ total += count;
134
+ if (count < page_size) return total;
135
+ after = last;
136
+ }
137
+ }
138
+
118
139
  // src/internal/audit.ts
119
140
  var DEFAULTS = {
120
141
  idle_days: 90,
@@ -151,7 +172,7 @@ async function* audit(deps, categories, options = {}) {
151
172
  }
152
173
  }
153
174
  if (need_streams) {
154
- await deps.store().query_streams((pos) => {
175
+ await walk_streams(deps.store(), (pos) => {
155
176
  for (const p of passes) p.on_stream?.(pos);
156
177
  });
157
178
  }
@@ -3343,7 +3364,7 @@ var Act = class {
3343
3364
  */
3344
3365
  async _seed_persisted_defers() {
3345
3366
  const now = Date.now();
3346
- await store().query_streams((pos) => {
3367
+ await walk_streams(store(), (pos) => {
3347
3368
  if (pos.deferred_at === void 0 || pos.deferred_at <= now) return;
3348
3369
  const controller = this._drain_controllers.get(pos.lane ?? "default");
3349
3370
  controller?.seed_defer(pos.stream, pos.deferred_at);