@rotorsoft/act 1.33.13 → 1.33.15
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/.tsbuildinfo +1 -1
- package/dist/@types/act.d.ts +2 -2
- package/dist/@types/act.d.ts.map +1 -1
- package/dist/@types/internal/correlate-cycle.d.ts +19 -8
- package/dist/@types/internal/correlate-cycle.d.ts.map +1 -1
- package/dist/@types/internal/drain-cycle.d.ts +1 -1
- package/dist/@types/internal/drain-cycle.d.ts.map +1 -1
- package/dist/@types/internal/lru-map.d.ts +5 -19
- package/dist/@types/internal/lru-map.d.ts.map +1 -1
- package/dist/@types/internal/settle.d.ts +2 -5
- package/dist/@types/internal/settle.d.ts.map +1 -1
- package/dist/{chunk-MSD67APM.js → chunk-E5H3NRCT.js} +1 -1
- package/dist/chunk-E5H3NRCT.js.map +1 -0
- package/dist/{chunk-U54EW4DX.cjs → chunk-EN2KFJ7W.cjs} +1 -1
- package/dist/chunk-EN2KFJ7W.cjs.map +1 -0
- package/dist/index.cjs +120 -118
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +25 -23
- package/dist/index.js.map +1 -1
- package/dist/test/index.cjs +3 -3
- package/dist/test/index.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-MSD67APM.js.map +0 -1
- package/dist/chunk-U54EW4DX.cjs.map +0 -1
package/dist/index.js
CHANGED
|
@@ -40,7 +40,7 @@ import {
|
|
|
40
40
|
sleep,
|
|
41
41
|
store,
|
|
42
42
|
validate
|
|
43
|
-
} from "./chunk-
|
|
43
|
+
} from "./chunk-E5H3NRCT.js";
|
|
44
44
|
import {
|
|
45
45
|
ActorSchema,
|
|
46
46
|
CausationEventSchema,
|
|
@@ -1259,11 +1259,8 @@ var CorrelateCycle = class {
|
|
|
1259
1259
|
await this._init();
|
|
1260
1260
|
const epoch = this._epoch;
|
|
1261
1261
|
const idle = () => ({
|
|
1262
|
-
|
|
1263
|
-
last_id: this._checkpoint
|
|
1264
|
-
read: false,
|
|
1265
|
-
marked: 0,
|
|
1266
|
-
scanned: false
|
|
1262
|
+
kind: "idle",
|
|
1263
|
+
last_id: this._checkpoint
|
|
1267
1264
|
});
|
|
1268
1265
|
if (this._raised === this._lowered) return idle();
|
|
1269
1266
|
const raised = this._raised;
|
|
@@ -1389,11 +1386,11 @@ var CorrelateCycle = class {
|
|
|
1389
1386
|
lane
|
|
1390
1387
|
});
|
|
1391
1388
|
}
|
|
1392
|
-
return {
|
|
1389
|
+
return { kind: "scanned", last_id, subscribed, marked, read };
|
|
1393
1390
|
}
|
|
1394
1391
|
this._checkpoint = last_id;
|
|
1395
1392
|
if (!stopped && found !== query.limit) this._lowered = raised;
|
|
1396
|
-
return {
|
|
1393
|
+
return { kind: "scanned", last_id, subscribed: 0, marked: 0, read };
|
|
1397
1394
|
}
|
|
1398
1395
|
/**
|
|
1399
1396
|
* Read the row of each target this scan had no record of (new or evicted),
|
|
@@ -2868,11 +2865,12 @@ var SettleLoop = class {
|
|
|
2868
2865
|
this._inflight = (async () => {
|
|
2869
2866
|
const passes = [];
|
|
2870
2867
|
for (let i = 0; i < maxPasses && !this._stopped; i++) {
|
|
2871
|
-
const
|
|
2868
|
+
const pass = await this._deps.correlate(correlate_query);
|
|
2869
|
+
const scanned = pass.kind === "scanned";
|
|
2872
2870
|
if (scanned) this._deps.breaker.passed();
|
|
2873
2871
|
const drain = await this._deps.drain(drain_options);
|
|
2874
2872
|
passes.push(drain);
|
|
2875
|
-
const made_progress =
|
|
2873
|
+
const made_progress = drain.leased.length > 0 || scanned && (pass.subscribed > 0 || pass.read);
|
|
2876
2874
|
if (!made_progress) break;
|
|
2877
2875
|
}
|
|
2878
2876
|
if (passes.length) this._deps.on_settled(merge_drains(passes));
|
|
@@ -3180,7 +3178,7 @@ var Act = class {
|
|
|
3180
3178
|
_build_settle(options) {
|
|
3181
3179
|
return new SettleLoop(
|
|
3182
3180
|
{
|
|
3183
|
-
correlate: (q) => this.
|
|
3181
|
+
correlate: (q) => this._correlate_pass(
|
|
3184
3182
|
{ ...q, limit: q.limit ?? this._poll_limit ?? 100 },
|
|
3185
3183
|
true
|
|
3186
3184
|
),
|
|
@@ -3243,15 +3241,16 @@ var Act = class {
|
|
|
3243
3241
|
if (running.length === 0 && !settling) return;
|
|
3244
3242
|
const grace = grace_ms ?? this._derive_grace_ms(running, !!settling);
|
|
3245
3243
|
if (grace <= 0) return;
|
|
3246
|
-
const inflight = running.map((c) => c.inflight);
|
|
3247
|
-
if (settling) inflight.push(settling);
|
|
3248
3244
|
let timer;
|
|
3249
3245
|
const budget = new Promise((resolve) => {
|
|
3250
3246
|
timer = setTimeout(resolve, grace);
|
|
3251
3247
|
timer.unref();
|
|
3252
3248
|
});
|
|
3253
3249
|
try {
|
|
3254
|
-
await Promise.race([
|
|
3250
|
+
await Promise.race([
|
|
3251
|
+
Promise.all([...running.map((c) => c.inflight), settling]),
|
|
3252
|
+
budget
|
|
3253
|
+
]);
|
|
3255
3254
|
} finally {
|
|
3256
3255
|
clearTimeout(timer);
|
|
3257
3256
|
}
|
|
@@ -3542,17 +3541,20 @@ var Act = class {
|
|
|
3542
3541
|
* @see {@link start_correlations} for automatic periodic correlation
|
|
3543
3542
|
*/
|
|
3544
3543
|
async correlate(query = { after: -1, limit: 10 }) {
|
|
3545
|
-
const
|
|
3546
|
-
return {
|
|
3544
|
+
const pass = await this._correlate_pass(query);
|
|
3545
|
+
return {
|
|
3546
|
+
subscribed: pass.kind === "scanned" ? pass.subscribed : 0,
|
|
3547
|
+
last_id: pass.last_id
|
|
3548
|
+
};
|
|
3547
3549
|
}
|
|
3548
|
-
/**
|
|
3549
|
-
async
|
|
3550
|
-
if (!this._drain)
|
|
3551
|
-
return { subscribed: 0, last_id: -1, read: false, scanned: false };
|
|
3550
|
+
/** One correlate pass; arms every lane when it found work. */
|
|
3551
|
+
async _correlate_pass(query, lease = false) {
|
|
3552
|
+
if (!this._drain) return { kind: "idle", last_id: -1 };
|
|
3552
3553
|
return this._scoped(async () => {
|
|
3553
|
-
const
|
|
3554
|
-
if (subscribed > 0 || marked > 0)
|
|
3555
|
-
|
|
3554
|
+
const pass = await this._correlate.correlate(query, lease);
|
|
3555
|
+
if (pass.kind === "scanned" && (pass.subscribed > 0 || pass.marked > 0))
|
|
3556
|
+
this._arm_all();
|
|
3557
|
+
return pass;
|
|
3556
3558
|
});
|
|
3557
3559
|
}
|
|
3558
3560
|
/**
|