@rotorsoft/act 1.23.23 → 1.23.25
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/internal/correlate-cycle.d.ts.map +1 -1
- package/dist/@types/internal/drain-cycle.d.ts.map +1 -1
- package/dist/{chunk-4JK4QJIT.js → chunk-ORKHOSH2.js} +2 -23
- package/dist/{chunk-4JK4QJIT.js.map → chunk-ORKHOSH2.js.map} +1 -1
- package/dist/index.cjs +38 -29
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +40 -10
- package/dist/index.js.map +1 -1
- package/dist/test/index.js +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
ExitCodes,
|
|
5
5
|
InMemoryCache,
|
|
6
6
|
InMemoryStore,
|
|
7
|
-
|
|
7
|
+
LruMap,
|
|
8
8
|
PackageSchema,
|
|
9
9
|
SNAP_EVENT,
|
|
10
10
|
TOMBSTONE_EVENT,
|
|
@@ -20,7 +20,7 @@ import {
|
|
|
20
20
|
sleep,
|
|
21
21
|
store,
|
|
22
22
|
validate
|
|
23
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-ORKHOSH2.js";
|
|
24
24
|
import {
|
|
25
25
|
ActorSchema,
|
|
26
26
|
CausationEventSchema,
|
|
@@ -1512,6 +1512,11 @@ var CorrelateCycle = class {
|
|
|
1512
1512
|
_checkpoint = -1;
|
|
1513
1513
|
_initialized = false;
|
|
1514
1514
|
_timer = void 0;
|
|
1515
|
+
// target → the priority it was last subscribed at. A dynamic target is
|
|
1516
|
+
// re-subscribed (so the store's `GREATEST` upsert runs) only when a later
|
|
1517
|
+
// scan resolves a *higher* priority for it — the runtime `max()` invariant
|
|
1518
|
+
// (#1363). Static targets are recorded at +Infinity so a dynamic resolution
|
|
1519
|
+
// never re-opens them (their priority is owned by the build-time subscribe).
|
|
1515
1520
|
_subscribed;
|
|
1516
1521
|
_registry;
|
|
1517
1522
|
_static_targets;
|
|
@@ -1553,7 +1558,7 @@ var CorrelateCycle = class {
|
|
|
1553
1558
|
on_init_async,
|
|
1554
1559
|
cold_start_back_scan = DEFAULT_COLD_START_BACK_SCAN
|
|
1555
1560
|
}) {
|
|
1556
|
-
this._subscribed = new
|
|
1561
|
+
this._subscribed = new LruMap(max_subscribed_streams);
|
|
1557
1562
|
this._registry = registry;
|
|
1558
1563
|
this._static_targets = static_targets;
|
|
1559
1564
|
this._has_dynamic_resolvers = has_dynamic_resolvers;
|
|
@@ -1593,7 +1598,7 @@ var CorrelateCycle = class {
|
|
|
1593
1598
|
this._checkpoint = this._has_dynamic_resolvers ? Math.max(-1, watermark - this._cold_start_back_scan) : watermark;
|
|
1594
1599
|
this._on_init?.();
|
|
1595
1600
|
for (const { stream } of this._static_targets) {
|
|
1596
|
-
this._subscribed.
|
|
1601
|
+
this._subscribed.set(stream, Number.POSITIVE_INFINITY);
|
|
1597
1602
|
}
|
|
1598
1603
|
await this._on_init_async?.();
|
|
1599
1604
|
}
|
|
@@ -1617,7 +1622,7 @@ var CorrelateCycle = class {
|
|
|
1617
1622
|
for (const reaction of register.reactions.values()) {
|
|
1618
1623
|
if (typeof reaction.resolver !== "function") continue;
|
|
1619
1624
|
const resolved = reaction.resolver(event);
|
|
1620
|
-
if (resolved &&
|
|
1625
|
+
if (resolved && (resolved.priority ?? 0) > (this._subscribed.get(resolved.target) ?? Number.NEGATIVE_INFINITY)) {
|
|
1621
1626
|
const incoming_priority = resolved.priority ?? 0;
|
|
1622
1627
|
const entry = correlated.get(resolved.target) || {
|
|
1623
1628
|
source: resolved.source,
|
|
@@ -1653,8 +1658,8 @@ var CorrelateCycle = class {
|
|
|
1653
1658
|
const { subscribed } = await this._cd.subscribe(streams);
|
|
1654
1659
|
this._checkpoint = last_id;
|
|
1655
1660
|
if (subscribed) {
|
|
1656
|
-
for (const { stream } of streams) {
|
|
1657
|
-
this._subscribed.
|
|
1661
|
+
for (const { stream, priority } of streams) {
|
|
1662
|
+
this._subscribed.set(stream, priority);
|
|
1658
1663
|
}
|
|
1659
1664
|
}
|
|
1660
1665
|
return { subscribed, last_id };
|
|
@@ -2490,6 +2495,20 @@ var EMPTY_DRAIN = {
|
|
|
2490
2495
|
acked: [],
|
|
2491
2496
|
blocked: []
|
|
2492
2497
|
};
|
|
2498
|
+
var contain = (logger, sink, fn) => {
|
|
2499
|
+
try {
|
|
2500
|
+
fn();
|
|
2501
|
+
} catch (error) {
|
|
2502
|
+
logger.error(error, `${sink} listener threw`);
|
|
2503
|
+
}
|
|
2504
|
+
};
|
|
2505
|
+
var contain_async = async (logger, sink, fn) => {
|
|
2506
|
+
try {
|
|
2507
|
+
await fn();
|
|
2508
|
+
} catch (error) {
|
|
2509
|
+
logger.error(error, `${sink} listener threw`);
|
|
2510
|
+
}
|
|
2511
|
+
};
|
|
2493
2512
|
var DrainController = class {
|
|
2494
2513
|
_armed = false;
|
|
2495
2514
|
_locked = false;
|
|
@@ -2615,9 +2634,20 @@ var DrainController = class {
|
|
|
2615
2634
|
if (next !== void 0) this._defer.set(h.lease.stream, next);
|
|
2616
2635
|
}
|
|
2617
2636
|
if (this._defer.size > 0) this._defer.schedule();
|
|
2618
|
-
if (acked.length)
|
|
2619
|
-
|
|
2620
|
-
if (
|
|
2637
|
+
if (acked.length)
|
|
2638
|
+
contain(this._deps.logger, "acked", () => this._deps.on_acked(acked));
|
|
2639
|
+
if (blocked.length)
|
|
2640
|
+
contain(
|
|
2641
|
+
this._deps.logger,
|
|
2642
|
+
"blocked",
|
|
2643
|
+
() => this._deps.on_blocked(blocked)
|
|
2644
|
+
);
|
|
2645
|
+
if (closeable.length)
|
|
2646
|
+
await contain_async(
|
|
2647
|
+
this._deps.logger,
|
|
2648
|
+
"close",
|
|
2649
|
+
() => this._deps.on_close(closeable)
|
|
2650
|
+
);
|
|
2621
2651
|
const has_errors = handled.some(({ error }) => error);
|
|
2622
2652
|
if (!acked.length && !blocked.length && !has_errors) this._armed = false;
|
|
2623
2653
|
return { fetched, leased, acked, blocked };
|