@rotorsoft/act 2.2.2 → 2.2.4
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 +3 -3
- package/dist/@types/act.d.ts.map +1 -1
- package/dist/@types/internal/config.d.ts +2 -2
- package/dist/@types/internal/config.d.ts.map +1 -1
- package/dist/@types/internal/defer-timer.d.ts +5 -0
- package/dist/@types/internal/defer-timer.d.ts.map +1 -1
- package/dist/@types/types/ports.d.ts +3 -3
- package/dist/@types/types/reaction.d.ts +2 -2
- package/dist/adapter.cjs +3 -3
- package/dist/adapter.js +2 -2
- package/dist/{chunk-LHSNV3VN.js → chunk-2CYRPAJN.js} +93 -11
- package/dist/chunk-2CYRPAJN.js.map +1 -0
- package/dist/{chunk-LA2BPKNS.cjs → chunk-4GA3CHQW.cjs} +1 -1
- package/dist/{chunk-LA2BPKNS.cjs.map → chunk-4GA3CHQW.cjs.map} +1 -1
- package/dist/{chunk-GHMCESJA.js → chunk-KTMIRM5Z.js} +2 -2
- package/dist/{chunk-KAUON2M3.js → chunk-ROC62MEU.js} +1 -1
- package/dist/{chunk-KAUON2M3.js.map → chunk-ROC62MEU.js.map} +1 -1
- package/dist/{chunk-K4FF6ZXO.cjs → chunk-XG3UD63Y.cjs} +146 -64
- package/dist/chunk-XG3UD63Y.cjs.map +1 -0
- package/dist/{chunk-QITJ63HG.cjs → chunk-XJZ2PKJH.cjs} +11 -11
- package/dist/{chunk-QITJ63HG.cjs.map → chunk-XJZ2PKJH.cjs.map} +1 -1
- package/dist/index.cjs +468 -544
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +8 -84
- package/dist/index.js.map +1 -1
- package/dist/test/index.cjs +9 -9
- package/dist/test/index.js +3 -3
- package/dist/types/index.cjs +2 -2
- package/dist/types/index.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-K4FF6ZXO.cjs.map +0 -1
- package/dist/chunk-LHSNV3VN.js.map +0 -1
- /package/dist/{chunk-GHMCESJA.js.map → chunk-KTMIRM5Z.js.map} +0 -0
package/dist/index.js
CHANGED
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
DEFAULT_LEASE_MILLIS,
|
|
7
7
|
DEFAULT_MAX_RETRIES,
|
|
8
8
|
DEFAULT_STREAM_LIMIT,
|
|
9
|
+
DeferTimer,
|
|
9
10
|
InMemoryCache,
|
|
10
11
|
InMemoryStore,
|
|
11
12
|
LruMap,
|
|
@@ -27,7 +28,7 @@ import {
|
|
|
27
28
|
store,
|
|
28
29
|
unscoped_ports,
|
|
29
30
|
validate
|
|
30
|
-
} from "./chunk-
|
|
31
|
+
} from "./chunk-2CYRPAJN.js";
|
|
31
32
|
import {
|
|
32
33
|
checkAppends,
|
|
33
34
|
checkVersion,
|
|
@@ -36,7 +37,7 @@ import {
|
|
|
36
37
|
isStreamName,
|
|
37
38
|
parseNotification,
|
|
38
39
|
seedEvent
|
|
39
|
-
} from "./chunk-
|
|
40
|
+
} from "./chunk-KTMIRM5Z.js";
|
|
40
41
|
import {
|
|
41
42
|
ActorSchema,
|
|
42
43
|
CausationEventSchema,
|
|
@@ -66,7 +67,7 @@ import {
|
|
|
66
67
|
ZodEmpty,
|
|
67
68
|
__name,
|
|
68
69
|
sensitive
|
|
69
|
-
} from "./chunk-
|
|
70
|
+
} from "./chunk-ROC62MEU.js";
|
|
70
71
|
|
|
71
72
|
// src/signals.ts
|
|
72
73
|
process.once("SIGINT", async (arg) => {
|
|
@@ -960,84 +961,6 @@ function compute_backoff_delay(retry, opts) {
|
|
|
960
961
|
}
|
|
961
962
|
__name(compute_backoff_delay, "compute_backoff_delay");
|
|
962
963
|
|
|
963
|
-
// src/internal/defer-timer.ts
|
|
964
|
-
var MAX_TIMER_DELAY_MS = 2147483647;
|
|
965
|
-
var DeferTimer = class {
|
|
966
|
-
static {
|
|
967
|
-
__name(this, "DeferTimer");
|
|
968
|
-
}
|
|
969
|
-
_due = /* @__PURE__ */ new Map();
|
|
970
|
-
_timer;
|
|
971
|
-
_on_wake;
|
|
972
|
-
/**
|
|
973
|
-
* @param on_wake - invoked once each time the earliest due-time elapses.
|
|
974
|
-
* The consumer re-schedules for whatever is still parked.
|
|
975
|
-
*/
|
|
976
|
-
constructor(on_wake) {
|
|
977
|
-
this._on_wake = on_wake;
|
|
978
|
-
}
|
|
979
|
-
/** Number of currently parked streams. */
|
|
980
|
-
get size() {
|
|
981
|
-
return this._due.size;
|
|
982
|
-
}
|
|
983
|
-
/**
|
|
984
|
-
* Park `stream` for a re-visit at `at` (ms since epoch). A plain
|
|
985
|
-
* overwrite: the caller computes the authoritative next-visit for the
|
|
986
|
-
* stream (the drain's `handle` already reconciles a stream's reactions
|
|
987
|
-
* into one result per cycle), so there is no stale value to merge against.
|
|
988
|
-
*/
|
|
989
|
-
set(stream, at) {
|
|
990
|
-
this._due.set(stream, at);
|
|
991
|
-
}
|
|
992
|
-
/** Drop `stream` from the parked set (e.g. on a successful ack or block). */
|
|
993
|
-
delete(stream) {
|
|
994
|
-
this._due.delete(stream);
|
|
995
|
-
}
|
|
996
|
-
/**
|
|
997
|
-
* Drop every entry due at or before `before`. The drain calls it when a
|
|
998
|
-
* pass that started at `before` claimed nothing: whatever was due by then
|
|
999
|
-
* was handled elsewhere (another worker) or has no work left, so waking
|
|
1000
|
-
* for it again would spin.
|
|
1001
|
-
*/
|
|
1002
|
-
prune(before) {
|
|
1003
|
-
for (const [stream, at] of this._due)
|
|
1004
|
-
if (at <= before) this._due.delete(stream);
|
|
1005
|
-
}
|
|
1006
|
-
/**
|
|
1007
|
-
* (Re)schedule the wake timer at the earliest pending due-time. Idempotent
|
|
1008
|
-
* — collapses many parked streams into a single timer. A no-op clears any
|
|
1009
|
-
* pending timer when the map is empty.
|
|
1010
|
-
*
|
|
1011
|
-
* The timer is `unref()`-ed so pending re-visits never keep the process
|
|
1012
|
-
* alive on their own.
|
|
1013
|
-
*/
|
|
1014
|
-
schedule() {
|
|
1015
|
-
if (this._timer) clearTimeout(this._timer);
|
|
1016
|
-
if (this._due.size === 0) {
|
|
1017
|
-
this._timer = void 0;
|
|
1018
|
-
return;
|
|
1019
|
-
}
|
|
1020
|
-
let earliest = Number.POSITIVE_INFINITY;
|
|
1021
|
-
for (const t of this._due.values()) if (t < earliest) earliest = t;
|
|
1022
|
-
const delay = Math.min(
|
|
1023
|
-
Math.max(0, earliest - Date.now()),
|
|
1024
|
-
MAX_TIMER_DELAY_MS
|
|
1025
|
-
);
|
|
1026
|
-
this._timer = setTimeout(() => {
|
|
1027
|
-
this._timer = void 0;
|
|
1028
|
-
this._on_wake();
|
|
1029
|
-
}, delay);
|
|
1030
|
-
this._timer.unref();
|
|
1031
|
-
}
|
|
1032
|
-
/** Cancel any pending wake timer. Idempotent. Leaves the parked set intact. */
|
|
1033
|
-
stop() {
|
|
1034
|
-
if (this._timer) {
|
|
1035
|
-
clearTimeout(this._timer);
|
|
1036
|
-
this._timer = void 0;
|
|
1037
|
-
}
|
|
1038
|
-
}
|
|
1039
|
-
};
|
|
1040
|
-
|
|
1041
964
|
// src/internal/drain-ratio.ts
|
|
1042
965
|
var RATIO_MIN = 0.2;
|
|
1043
966
|
var RATIO_MAX = 0.8;
|
|
@@ -4298,8 +4221,9 @@ var Act = class {
|
|
|
4298
4221
|
* lifecycle and per-event insert.
|
|
4299
4222
|
*
|
|
4300
4223
|
* Safe in a live process: restoring into this Act's own store waits
|
|
4301
|
-
* for its correlate passes in flight, replaces the log,
|
|
4302
|
-
*
|
|
4224
|
+
* for its correlate passes in flight, replaces the log, clears the cache
|
|
4225
|
+
* and the state projections' fold caches, then restarts correlation and
|
|
4226
|
+
* settles. A correlate pass that starts meanwhile
|
|
4303
4227
|
* reads nothing. Other processes on the same store keep their
|
|
4304
4228
|
* correlation state and must be restarted.
|
|
4305
4229
|
*
|
|
@@ -4325,7 +4249,6 @@ var Act = class {
|
|
|
4325
4249
|
* ```typescript
|
|
4326
4250
|
* const result = await app.restore(new CsvFile({ path: "./backup.csv" }));
|
|
4327
4251
|
* console.log(`Restored ${result.kept} events in ${result.duration_ms}ms`);
|
|
4328
|
-
* await cache().clear(); // operator's responsibility
|
|
4329
4252
|
* ```
|
|
4330
4253
|
*
|
|
4331
4254
|
* @see {@link Store.restore} for the underlying driver-pattern primitive.
|
|
@@ -4355,6 +4278,7 @@ var Act = class {
|
|
|
4355
4278
|
if (sink) await run();
|
|
4356
4279
|
else {
|
|
4357
4280
|
await this._correlate.restart(run);
|
|
4281
|
+
await cache().clear();
|
|
4358
4282
|
this._reset_folds();
|
|
4359
4283
|
this._wake();
|
|
4360
4284
|
}
|