@rotorsoft/act 1.31.17 → 1.31.19
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 +5 -0
- package/dist/@types/act.d.ts.map +1 -1
- package/dist/@types/adapters/in-memory-store.d.ts.map +1 -1
- package/dist/@types/builders/act-builder.d.ts.map +1 -1
- package/dist/@types/internal/autoclose-reaction.d.ts +12 -2
- package/dist/@types/internal/autoclose-reaction.d.ts.map +1 -1
- package/dist/@types/scoped.d.ts +37 -2
- package/dist/@types/scoped.d.ts.map +1 -1
- package/dist/@types/types/ports.d.ts +10 -3
- package/dist/@types/types/ports.d.ts.map +1 -1
- package/dist/{chunk-LTA7FYBC.js → chunk-34WL4DPW.js} +9 -7
- package/dist/chunk-34WL4DPW.js.map +1 -0
- package/dist/index.cjs +35 -17
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +30 -12
- package/dist/index.js.map +1 -1
- package/dist/test/index.cjs +4 -6
- package/dist/test/index.cjs.map +1 -1
- package/dist/test/index.js +1 -1
- package/package.json +2 -2
- package/dist/chunk-LTA7FYBC.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
TOMBSTONE_EVENT,
|
|
11
11
|
cache,
|
|
12
12
|
config,
|
|
13
|
+
current_autoclose_window,
|
|
13
14
|
current_reacting,
|
|
14
15
|
dateReviver,
|
|
15
16
|
default_scope,
|
|
@@ -25,7 +26,7 @@ import {
|
|
|
25
26
|
sleep,
|
|
26
27
|
store,
|
|
27
28
|
validate
|
|
28
|
-
} from "./chunk-
|
|
29
|
+
} from "./chunk-34WL4DPW.js";
|
|
29
30
|
import {
|
|
30
31
|
ActorSchema,
|
|
31
32
|
CausationEventSchema,
|
|
@@ -805,7 +806,7 @@ var DeferSignal = class extends Error {
|
|
|
805
806
|
|
|
806
807
|
// src/internal/autoclose-reaction.ts
|
|
807
808
|
var AUTOCLOSE_TARGET_PREFIX = "__autoclose__:";
|
|
808
|
-
function synthesize_autoclose_reactions(registry, states,
|
|
809
|
+
function synthesize_autoclose_reactions(registry, states, read_window) {
|
|
809
810
|
for (const st of states.values()) {
|
|
810
811
|
const predicate = st.autoclose;
|
|
811
812
|
if (!predicate) continue;
|
|
@@ -828,10 +829,9 @@ function synthesize_autoclose_reactions(registry, states, config2) {
|
|
|
828
829
|
options: { blockOnError: false, maxRetries: 3 },
|
|
829
830
|
handler: async (event) => {
|
|
830
831
|
const aggregate = event.stream;
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
});
|
|
832
|
+
const window = read_window();
|
|
833
|
+
if (!in_autoclose_window(window, /* @__PURE__ */ new Date()))
|
|
834
|
+
throw new DeferSignal({ at: next_window_open(window, /* @__PURE__ */ new Date()) });
|
|
835
835
|
const stats = await store().query_stats([aggregate], {
|
|
836
836
|
count: true,
|
|
837
837
|
tail: keep_days !== void 0 ? true : void 0,
|
|
@@ -3521,7 +3521,20 @@ var Act = class {
|
|
|
3521
3521
|
this._lanes = lanes;
|
|
3522
3522
|
validate_only_lanes(options, lanes);
|
|
3523
3523
|
this._ports = options.scoped ?? default_scope();
|
|
3524
|
-
|
|
3524
|
+
const ports = this._ports;
|
|
3525
|
+
this._scoped = make_run_scoped({
|
|
3526
|
+
// Delegating getters, NOT a spread: `default_scope()` resolves the
|
|
3527
|
+
// process singletons lazily, so copying its properties would freeze
|
|
3528
|
+
// whichever adapters happened to be installed at construction and
|
|
3529
|
+
// ignore a later `store(...)` / `cache(...)`.
|
|
3530
|
+
get store() {
|
|
3531
|
+
return ports.store;
|
|
3532
|
+
},
|
|
3533
|
+
get cache() {
|
|
3534
|
+
return ports.cache;
|
|
3535
|
+
},
|
|
3536
|
+
autoclose_window: resolveAutocloseConfig(options).autocloseWindow
|
|
3537
|
+
});
|
|
3525
3538
|
this._correlator = options.correlator ?? default_correlator;
|
|
3526
3539
|
this._es = build_es(this._logger, this._correlator, patch_fn);
|
|
3527
3540
|
this._cd = build_drain(this._logger);
|
|
@@ -3798,13 +3811,13 @@ var Act = class {
|
|
|
3798
3811
|
resolveShutdownConfig(options);
|
|
3799
3812
|
this._shutdown_promise = (async () => {
|
|
3800
3813
|
this.stop_correlations();
|
|
3801
|
-
await this._scoped(() => this._correlate.release_correlation());
|
|
3802
3814
|
const disposer = await this._notify_disposer;
|
|
3803
3815
|
if (disposer) await disposer();
|
|
3804
3816
|
this.stop_settling();
|
|
3805
3817
|
this._breaker.stop();
|
|
3806
3818
|
for (const c of this._drain_controllers.values()) c.stop();
|
|
3807
3819
|
await this._await_inflight(options?.graceMs);
|
|
3820
|
+
await this._scoped(() => this._correlate.release_correlation());
|
|
3808
3821
|
this._emitter.removeAllListeners();
|
|
3809
3822
|
})();
|
|
3810
3823
|
}
|
|
@@ -3822,9 +3835,14 @@ var Act = class {
|
|
|
3822
3835
|
* lane that pinned no lease contributes `drain()`'s own fallback, and the
|
|
3823
3836
|
* whole thing is capped so a long-leased lane cannot hold a deploy open.
|
|
3824
3837
|
* Idle lanes do not count — nothing is running on them to wait for.
|
|
3838
|
+
*
|
|
3839
|
+
* An in-flight settle counts the same way, on the same fallback (#1617).
|
|
3840
|
+
* It is waited on like any cycle, and deriving from the lanes alone gave
|
|
3841
|
+
* it a budget of `0` whenever it was the only thing running — which
|
|
3842
|
+
* returned before the wait it was about to be added to.
|
|
3825
3843
|
*/
|
|
3826
|
-
_derive_grace_ms(running) {
|
|
3827
|
-
let max = 0;
|
|
3844
|
+
_derive_grace_ms(running, settling) {
|
|
3845
|
+
let max = settling ? DEFAULT_SHUTDOWN_GRACE_MS : 0;
|
|
3828
3846
|
for (const c of running)
|
|
3829
3847
|
max = Math.max(max, c.lease_millis ?? DEFAULT_SHUTDOWN_GRACE_MS);
|
|
3830
3848
|
return Math.min(max, MAX_SHUTDOWN_GRACE_MS);
|
|
@@ -3835,7 +3853,7 @@ var Act = class {
|
|
|
3835
3853
|
);
|
|
3836
3854
|
const settling = this._settle.inflight;
|
|
3837
3855
|
if (running.length === 0 && !settling) return;
|
|
3838
|
-
const grace = grace_ms ?? this._derive_grace_ms(running);
|
|
3856
|
+
const grace = grace_ms ?? this._derive_grace_ms(running, !!settling);
|
|
3839
3857
|
if (grace <= 0) return;
|
|
3840
3858
|
const inflight = running.map((c) => c.inflight);
|
|
3841
3859
|
if (settling) inflight.push(settling);
|
|
@@ -5313,7 +5331,7 @@ function act() {
|
|
|
5313
5331
|
synthesize_autoclose_reactions(
|
|
5314
5332
|
registry,
|
|
5315
5333
|
states,
|
|
5316
|
-
|
|
5334
|
+
current_autoclose_window
|
|
5317
5335
|
);
|
|
5318
5336
|
Object.freeze(registry.actions);
|
|
5319
5337
|
Object.freeze(registry.events);
|