@rotorsoft/act 1.32.11 → 1.32.12
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 +30 -60
- package/dist/@types/act.d.ts.map +1 -1
- package/dist/@types/internal/correlate-cycle.d.ts +1 -19
- package/dist/@types/internal/correlate-cycle.d.ts.map +1 -1
- package/dist/index.cjs +44 -110
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +44 -110
- package/dist/index.js.map +1 -1
- package/package.json +2 -6
package/dist/@types/act.d.ts
CHANGED
|
@@ -256,6 +256,10 @@ export declare class Act<TSchemaReg extends SchemaRegister<TActions>, TEvents ex
|
|
|
256
256
|
private readonly _correlate;
|
|
257
257
|
/** Debounced correlate→drain catch-up loop. */
|
|
258
258
|
private readonly _settle;
|
|
259
|
+
/** Timer behind {@link start_correlations}. */
|
|
260
|
+
private _poll;
|
|
261
|
+
/** The deprecated `start_correlations` callback, while the poll runs. */
|
|
262
|
+
private _on_discovered;
|
|
259
263
|
/**
|
|
260
264
|
* Disposer for the cross-process notify subscription, set up eagerly
|
|
261
265
|
* during construction. Held as a promise because the subscription
|
|
@@ -893,74 +897,40 @@ export declare class Act<TSchemaReg extends SchemaRegister<TActions>, TEvents ex
|
|
|
893
897
|
*/
|
|
894
898
|
private _correlate_scanned;
|
|
895
899
|
/**
|
|
896
|
-
* Starts
|
|
900
|
+
* Starts a background poll that settles on a timer: each tick looks for
|
|
901
|
+
* new events, subscribes the streams their reactions target, and drains
|
|
902
|
+
* them.
|
|
903
|
+
*
|
|
904
|
+
* Use it when this process can miss commits — another process writes to a
|
|
905
|
+
* store without `notify`, or a notification is lost. It is the safety net
|
|
906
|
+
* under `notify`: a missed wakeup costs at most one `frequency` of latency.
|
|
907
|
+
*
|
|
908
|
+
* Only one poll runs per Act instance. On a writer-only instance
|
|
909
|
+
* (`drain: false`) each tick is a no-op, like `settle()`.
|
|
910
|
+
*
|
|
911
|
+
* @param query - Only `limit` is used: the most events each correlate pass
|
|
912
|
+
* reads (default 100). The scan always starts at the correlation
|
|
913
|
+
* checkpoint, so `after` is ignored.
|
|
914
|
+
* @param frequency - Milliseconds between ticks (default: 10000)
|
|
915
|
+
* @param callback - Called with the number of newly subscribed streams
|
|
916
|
+
* after each correlate pass that found some.
|
|
917
|
+
* @deprecated Listen to the `"settled"` lifecycle event instead.
|
|
918
|
+
* @returns `true` if the poll started, `false` if one is already running
|
|
897
919
|
*
|
|
898
|
-
*
|
|
899
|
-
* new target streams based on reaction resolvers. It maintains a sliding window that
|
|
900
|
-
* advances with each scan, ensuring all events are eventually correlated.
|
|
901
|
-
*
|
|
902
|
-
* This is useful for dynamic stream creation patterns where you don't know all streams
|
|
903
|
-
* upfront - they're discovered as events arrive.
|
|
904
|
-
*
|
|
905
|
-
* **Note:** Only one correlation worker can run at a time per Act instance.
|
|
906
|
-
*
|
|
907
|
-
* @param query - Query filter for correlation scans — see {@link Query}
|
|
908
|
-
* (typically `{ after: -1, limit: 100 }`)
|
|
909
|
-
* @param frequency - Correlation frequency in milliseconds (default: 10000)
|
|
910
|
-
* @param callback - Optional callback invoked with newly discovered streams
|
|
911
|
-
* @returns `true` if worker started, `false` if already running
|
|
912
|
-
*
|
|
913
|
-
* @example Start automatic correlation
|
|
920
|
+
* @example
|
|
914
921
|
* ```typescript
|
|
915
|
-
*
|
|
916
|
-
*
|
|
917
|
-
* { after: 0, limit: 100 },
|
|
918
|
-
* 5000,
|
|
919
|
-
* (leased) => {
|
|
920
|
-
* console.log(`Discovered ${leased.length} new streams`);
|
|
921
|
-
* }
|
|
922
|
-
* );
|
|
923
|
-
*
|
|
924
|
-
* // Later, stop it
|
|
922
|
+
* app.start_correlations({ limit: 100 }, 5000);
|
|
923
|
+
* // later
|
|
925
924
|
* app.stop_correlations();
|
|
926
925
|
* ```
|
|
927
926
|
*
|
|
928
|
-
* @
|
|
929
|
-
*
|
|
930
|
-
* // Load last checkpoint
|
|
931
|
-
* const lastId = await loadCheckpoint();
|
|
932
|
-
*
|
|
933
|
-
* app.start_correlations(
|
|
934
|
-
* { after: lastId, limit: 100 },
|
|
935
|
-
* 10000,
|
|
936
|
-
* async (leased) => {
|
|
937
|
-
* // Save checkpoint for next restart
|
|
938
|
-
* if (leased.length) {
|
|
939
|
-
* const maxId = Math.max(...leased.map(l => l.at));
|
|
940
|
-
* await saveCheckpoint(maxId);
|
|
941
|
-
* }
|
|
942
|
-
* }
|
|
943
|
-
* );
|
|
944
|
-
* ```
|
|
945
|
-
*
|
|
946
|
-
* @see {@link correlate} for manual one-time correlation
|
|
947
|
-
* @see {@link stop_correlations} to stop the worker
|
|
927
|
+
* @see {@link settle} for what each tick runs
|
|
928
|
+
* @see {@link stop_correlations} to stop the poll
|
|
948
929
|
*/
|
|
949
930
|
start_correlations(query?: Query, frequency?: number, callback?: (subscribed: number) => void): boolean;
|
|
950
931
|
/**
|
|
951
|
-
* Stops the
|
|
952
|
-
*
|
|
953
|
-
* Call this to stop the background correlation worker started by {@link start_correlations}.
|
|
954
|
-
* This is automatically called when the Act instance is disposed.
|
|
955
|
-
*
|
|
956
|
-
* @example
|
|
957
|
-
* ```typescript
|
|
958
|
-
* // Start correlation
|
|
959
|
-
* app.start_correlations();
|
|
960
|
-
*
|
|
961
|
-
* // Later, stop it
|
|
962
|
-
* app.stop_correlations();
|
|
963
|
-
* ```
|
|
932
|
+
* Stops the poll started by {@link start_correlations}. Idempotent, and
|
|
933
|
+
* called by `shutdown()`.
|
|
964
934
|
*
|
|
965
935
|
* @see {@link start_correlations}
|
|
966
936
|
*/
|
package/dist/@types/act.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"act.d.ts","sourceRoot":"","sources":["../../src/act.ts"],"names":[],"mappings":"AAWA,OAAO,EAOL,KAAK,qBAAqB,EAC1B,KAAK,YAAY,EAYjB,KAAK,OAAO,EAWb,MAAM,qBAAqB,CAAC;AAQ7B,YAAY,E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,OAAO,CAAC,cAAc,EAAE,CAAC,CAW5B;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAwCG;IACI,KAAK,CACV,UAAU,CAAC,EAAE,aAAa,EAAE,EAC5B,OAAO,CAAC,EAAE,YAAY,GACrB,aAAa,CAAC,YAAY,CAAC,CAe7B;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAqCG;IACG,UAAU,CAAC,MAAM,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAExE;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAyDG;IACH;;;;OAIG;IACH;;;;;;;;;;;OAWG;YACW,qBAAqB;IAgBnC;;;;;;;;;;;;;;;OAeG;IACH,OAAO,CAAC,4BAA4B;IAO9B,KAAK,CAAC,OAAO,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC,WAAW,CAAC,CA0BxD;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA6BG;IACH,MAAM,CAAC,OAAO,GAAE,aAAkB,GAAG,IAAI,CASxC;CACF"}
|
|
@@ -59,7 +59,6 @@ export type CorrelateCycleDeps<TSchemaReg extends SchemaRegister<TActions>, TEve
|
|
|
59
59
|
* claimant, so correlate reroutes it here (#1564).
|
|
60
60
|
*/
|
|
61
61
|
declared_lanes: ReadonlySet<string>;
|
|
62
|
-
run_scoped: <T>(fn: () => Promise<T>) => Promise<T>;
|
|
63
62
|
on_init?: () => void;
|
|
64
63
|
on_init_async?: () => Promise<void>;
|
|
65
64
|
cold_start_back_scan?: number;
|
|
@@ -110,7 +109,6 @@ export declare class CorrelateCycle<TSchemaReg extends SchemaRegister<TActions>,
|
|
|
110
109
|
private _armed;
|
|
111
110
|
/** In-flight init, memoized for single-flight and cleared on failure. */
|
|
112
111
|
private _init_promise;
|
|
113
|
-
private _timer;
|
|
114
112
|
private readonly _dynamic_subscriptions;
|
|
115
113
|
/**
|
|
116
114
|
* What each static target was subscribed at by `init`. A plain map, never
|
|
@@ -144,14 +142,6 @@ export declare class CorrelateCycle<TSchemaReg extends SchemaRegister<TActions>,
|
|
|
144
142
|
* guarantee without a second gate on the Act side.
|
|
145
143
|
*/
|
|
146
144
|
private readonly _on_init_async;
|
|
147
|
-
/**
|
|
148
|
-
* Scope runner (#1191). The periodic `start_polling` timer fires
|
|
149
|
-
* outside any caller frame, so its `correlate()` must be re-wrapped in
|
|
150
|
-
* the Act's `_scoped` bag or `store()`/`cache()` resolve to the
|
|
151
|
-
* singleton for a scoped Act. The orchestrator always threads its
|
|
152
|
-
* `_scoped` (identity for a non-scoped Act), so it's required.
|
|
153
|
-
*/
|
|
154
|
-
private readonly _run_scoped;
|
|
155
145
|
/**
|
|
156
146
|
* Tail re-scan window applied to the cold-start checkpoint (ACT-1207).
|
|
157
147
|
* See {@link DEFAULT_COLD_START_BACK_SCAN}. Constructor arg (not a
|
|
@@ -166,7 +156,7 @@ export declare class CorrelateCycle<TSchemaReg extends SchemaRegister<TActions>,
|
|
|
166
156
|
* module: `internal/` holds no module-level state.
|
|
167
157
|
*/
|
|
168
158
|
private readonly _reported;
|
|
169
|
-
constructor({ registry, static_targets, cd, max_subscribed_streams, declared_lanes,
|
|
159
|
+
constructor({ registry, static_targets, cd, max_subscribed_streams, declared_lanes, on_init, on_init_async, cold_start_back_scan, lease_millis, }: CorrelateCycleDeps<TSchemaReg, TEvents, TActions>);
|
|
170
160
|
/** Last correlated event id. */
|
|
171
161
|
get checkpoint(): number;
|
|
172
162
|
/**
|
|
@@ -254,13 +244,6 @@ export declare class CorrelateCycle<TSchemaReg extends SchemaRegister<TActions>,
|
|
|
254
244
|
/** False when the pass was disarmed and returned without a store read. */
|
|
255
245
|
scanned: boolean;
|
|
256
246
|
}>;
|
|
257
|
-
/**
|
|
258
|
-
* Start a periodic correlation worker. Returns false if one is already
|
|
259
|
-
* running. Errors from `correlate()` are routed through `log()` so they
|
|
260
|
-
* land in the configured logger (the timer keeps running on failure).
|
|
261
|
-
*/
|
|
262
|
-
start_polling(query?: Query, frequency?: number, callback?: (subscribed: number) => void): boolean;
|
|
263
|
-
/** Stop the periodic correlation worker. Idempotent. */
|
|
264
247
|
/**
|
|
265
248
|
* Hand the correlation lease back early.
|
|
266
249
|
*
|
|
@@ -278,6 +261,5 @@ export declare class CorrelateCycle<TSchemaReg extends SchemaRegister<TActions>,
|
|
|
278
261
|
* what would have happened had the process died instead.
|
|
279
262
|
*/
|
|
280
263
|
release_correlation(): Promise<void>;
|
|
281
|
-
stop_polling(): void;
|
|
282
264
|
}
|
|
283
265
|
//# sourceMappingURL=correlate-cycle.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"correlate-cycle.d.ts","sourceRoot":"","sources":["../../../src/internal/correlate-cycle.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAIH,OAAO,KAAK,EAEV,KAAK,EACL,QAAQ,EACR,cAAc,EACd,OAAO,EAER,MAAM,mBAAmB,CAAC;AAE3B,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAuF3C;;;;;;;;;GASG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC;AAgDF;;;;;GAKG;AACH;;;;;GAKG;AACH,MAAM,MAAM,kBAAkB,CAC5B,UAAU,SAAS,cAAc,CAAC,QAAQ,CAAC,EAC3C,OAAO,SAAS,OAAO,EACvB,QAAQ,SAAS,OAAO,IACtB;IACF,QAAQ,EAAE,QAAQ,CAAC,UAAU,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;IAClD,c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AY,EACV,QAAQ,EACR,cAAc,EACd,EAAE,EACF,sBAAsB,EACtB,cAAc,EACd,OAAO,EACP,aAAa,EACb,oBAAmD,EACnD,YAA2C,GAC5C,EAAE,kBAAkB,CAAC,UAAU,EAAE,OAAO,EAAE,QAAQ,CAAC,EAWnD;IAED,gCAAgC;IAChC,IAAI,UAAU,IAAI,MAAM,CAEvB;IAED;;;;OAIG;IACH,GAAG,IAAI,IAAI,CAEV;IAED;;;;;;;;;OASG;IACG,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAiB1B;YAEa,SAAS;IAsCvB;;;;;;;;;;;;;;OAcG;IACH;;;;;;;;;OASG;IACH,OAAO,IAAI,IAAI,CAOd;IAED,iBAAiB,CAAC,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,GAAG,IAAI,CAEjD;IAED;;;;;;OAMG;IACH,OAAO,CAAC,gBAAgB;IAcxB;;;;;;;;;OASG;IACG,SAAS,CACb,KAAK,GAAE,KAAgC;IACvC;;;;;;;;;;;;;OAaG;IACH,KAAK,UAAQ,GACZ,OAAO,CAAC;QACT,UAAU,EAAE,MAAM,CAAC;QACnB,OAAO,EAAE,MAAM,CAAC;QAChB,MAAM,EAAE,MAAM,CAAC;QACf,0EAA0E;QAC1E,OAAO,EAAE,OAAO,CAAC;KAClB,CAAC,CA8PD;IAED;;;;;;;;;;;;;;;OAeG;IACG,mBAAmB,IAAI,OAAO,CAAC,IAAI,CAAC,CAgCzC;CACF"}
|
package/dist/index.cjs
CHANGED
|
@@ -3247,7 +3247,6 @@ var CorrelateCycle = class {
|
|
|
3247
3247
|
_armed = true;
|
|
3248
3248
|
/** In-flight init, memoized for single-flight and cleared on failure. */
|
|
3249
3249
|
_init_promise;
|
|
3250
|
-
_timer = void 0;
|
|
3251
3250
|
// Dynamically discovered targets → what each was last subscribed at,
|
|
3252
3251
|
// bounded by `maxSubscribedStreams`. The static half lives in
|
|
3253
3252
|
// `_static_subscriptions` below, which is deliberately not evictable.
|
|
@@ -3291,14 +3290,6 @@ var CorrelateCycle = class {
|
|
|
3291
3290
|
* guarantee without a second gate on the Act side.
|
|
3292
3291
|
*/
|
|
3293
3292
|
_on_init_async;
|
|
3294
|
-
/**
|
|
3295
|
-
* Scope runner (#1191). The periodic `start_polling` timer fires
|
|
3296
|
-
* outside any caller frame, so its `correlate()` must be re-wrapped in
|
|
3297
|
-
* the Act's `_scoped` bag or `store()`/`cache()` resolve to the
|
|
3298
|
-
* singleton for a scoped Act. The orchestrator always threads its
|
|
3299
|
-
* `_scoped` (identity for a non-scoped Act), so it's required.
|
|
3300
|
-
*/
|
|
3301
|
-
_run_scoped;
|
|
3302
3293
|
/**
|
|
3303
3294
|
* Tail re-scan window applied to the cold-start checkpoint (ACT-1207).
|
|
3304
3295
|
* See {@link DEFAULT_COLD_START_BACK_SCAN}. Constructor arg (not a
|
|
@@ -3319,7 +3310,6 @@ var CorrelateCycle = class {
|
|
|
3319
3310
|
cd,
|
|
3320
3311
|
max_subscribed_streams,
|
|
3321
3312
|
declared_lanes,
|
|
3322
|
-
run_scoped,
|
|
3323
3313
|
on_init,
|
|
3324
3314
|
on_init_async,
|
|
3325
3315
|
cold_start_back_scan = DEFAULT_COLD_START_BACK_SCAN,
|
|
@@ -3333,7 +3323,6 @@ var CorrelateCycle = class {
|
|
|
3333
3323
|
this._static_targets = static_targets;
|
|
3334
3324
|
this._cd = cd;
|
|
3335
3325
|
this._on_init = on_init;
|
|
3336
|
-
this._run_scoped = run_scoped;
|
|
3337
3326
|
this._on_init_async = on_init_async;
|
|
3338
3327
|
this._cold_start_back_scan = cold_start_back_scan;
|
|
3339
3328
|
}
|
|
@@ -3581,33 +3570,6 @@ var CorrelateCycle = class {
|
|
|
3581
3570
|
this._armed = found === query.limit;
|
|
3582
3571
|
return { subscribed: 0, last_id, marked: 0, scanned: true };
|
|
3583
3572
|
}
|
|
3584
|
-
/**
|
|
3585
|
-
* Start a periodic correlation worker. Returns false if one is already
|
|
3586
|
-
* running. Errors from `correlate()` are routed through `log()` so they
|
|
3587
|
-
* land in the configured logger (the timer keeps running on failure).
|
|
3588
|
-
*/
|
|
3589
|
-
start_polling(query = {}, frequency = 1e4, callback) {
|
|
3590
|
-
if (this._timer) return false;
|
|
3591
|
-
const limit = query.limit || 100;
|
|
3592
|
-
this._timer = setInterval(
|
|
3593
|
-
() => this._run_scoped(() => {
|
|
3594
|
-
this.arm();
|
|
3595
|
-
return this.correlate(
|
|
3596
|
-
{
|
|
3597
|
-
...query,
|
|
3598
|
-
after: this._checkpoint,
|
|
3599
|
-
limit
|
|
3600
|
-
},
|
|
3601
|
-
true
|
|
3602
|
-
);
|
|
3603
|
-
}).then((result) => {
|
|
3604
|
-
if (callback && result.subscribed) callback(result.subscribed);
|
|
3605
|
-
}).catch((err) => log().error(err)),
|
|
3606
|
-
frequency
|
|
3607
|
-
);
|
|
3608
|
-
return true;
|
|
3609
|
-
}
|
|
3610
|
-
/** Stop the periodic correlation worker. Idempotent. */
|
|
3611
3573
|
/**
|
|
3612
3574
|
* Hand the correlation lease back early.
|
|
3613
3575
|
*
|
|
@@ -3638,12 +3600,6 @@ var CorrelateCycle = class {
|
|
|
3638
3600
|
);
|
|
3639
3601
|
}
|
|
3640
3602
|
}
|
|
3641
|
-
stop_polling() {
|
|
3642
|
-
if (this._timer) {
|
|
3643
|
-
clearInterval(this._timer);
|
|
3644
|
-
this._timer = void 0;
|
|
3645
|
-
}
|
|
3646
|
-
}
|
|
3647
3603
|
};
|
|
3648
3604
|
|
|
3649
3605
|
// src/internal/correlator.ts
|
|
@@ -5146,6 +5102,10 @@ var Act = class {
|
|
|
5146
5102
|
_correlate;
|
|
5147
5103
|
/** Debounced correlate→drain catch-up loop. */
|
|
5148
5104
|
_settle;
|
|
5105
|
+
/** Timer behind {@link start_correlations}. */
|
|
5106
|
+
_poll;
|
|
5107
|
+
/** The deprecated `start_correlations` callback, while the poll runs. */
|
|
5108
|
+
_on_discovered;
|
|
5149
5109
|
/**
|
|
5150
5110
|
* Disposer for the cross-process notify subscription, set up eagerly
|
|
5151
5111
|
* during construction. Held as a promise because the subscription
|
|
@@ -5555,9 +5515,6 @@ var Act = class {
|
|
|
5555
5515
|
on_init: () => {
|
|
5556
5516
|
if (this._drain && this._reactive_events.size > 0) this._arm_all();
|
|
5557
5517
|
},
|
|
5558
|
-
// Re-scope the background `start_correlations` timer so its
|
|
5559
|
-
// correlate resolves the scoped ports, not the singleton (#1191).
|
|
5560
|
-
run_scoped: this._scoped,
|
|
5561
5518
|
// Cold-start defer re-seed (#1221). Skipped on writer-only instances
|
|
5562
5519
|
// (`drain: false`) — they run no local controllers to re-arm.
|
|
5563
5520
|
on_init_async: this._drain ? () => this._seed_persisted_defers() : void 0
|
|
@@ -6147,86 +6104,63 @@ var Act = class {
|
|
|
6147
6104
|
const { subscribed, last_id, marked, scanned } = await this._correlate.correlate(query, lease);
|
|
6148
6105
|
if ((subscribed > 0 || marked > 0) && this._reactive_events.size > 0)
|
|
6149
6106
|
this._arm_all();
|
|
6107
|
+
if (subscribed > 0) this._on_discovered?.(subscribed);
|
|
6150
6108
|
return { subscribed, last_id, scanned };
|
|
6151
6109
|
});
|
|
6152
6110
|
}
|
|
6153
6111
|
/**
|
|
6154
|
-
* Starts
|
|
6155
|
-
*
|
|
6156
|
-
*
|
|
6157
|
-
*
|
|
6158
|
-
*
|
|
6159
|
-
*
|
|
6160
|
-
*
|
|
6161
|
-
*
|
|
6162
|
-
*
|
|
6163
|
-
*
|
|
6164
|
-
*
|
|
6165
|
-
* @param query -
|
|
6166
|
-
* (
|
|
6167
|
-
*
|
|
6168
|
-
* @param
|
|
6169
|
-
* @
|
|
6112
|
+
* Starts a background poll that settles on a timer: each tick looks for
|
|
6113
|
+
* new events, subscribes the streams their reactions target, and drains
|
|
6114
|
+
* them.
|
|
6115
|
+
*
|
|
6116
|
+
* Use it when this process can miss commits — another process writes to a
|
|
6117
|
+
* store without `notify`, or a notification is lost. It is the safety net
|
|
6118
|
+
* under `notify`: a missed wakeup costs at most one `frequency` of latency.
|
|
6119
|
+
*
|
|
6120
|
+
* Only one poll runs per Act instance. On a writer-only instance
|
|
6121
|
+
* (`drain: false`) each tick is a no-op, like `settle()`.
|
|
6122
|
+
*
|
|
6123
|
+
* @param query - Only `limit` is used: the most events each correlate pass
|
|
6124
|
+
* reads (default 100). The scan always starts at the correlation
|
|
6125
|
+
* checkpoint, so `after` is ignored.
|
|
6126
|
+
* @param frequency - Milliseconds between ticks (default: 10000)
|
|
6127
|
+
* @param callback - Called with the number of newly subscribed streams
|
|
6128
|
+
* after each correlate pass that found some.
|
|
6129
|
+
* @deprecated Listen to the `"settled"` lifecycle event instead.
|
|
6130
|
+
* @returns `true` if the poll started, `false` if one is already running
|
|
6170
6131
|
*
|
|
6171
|
-
* @example
|
|
6132
|
+
* @example
|
|
6172
6133
|
* ```typescript
|
|
6173
|
-
*
|
|
6174
|
-
*
|
|
6175
|
-
* { after: 0, limit: 100 },
|
|
6176
|
-
* 5000,
|
|
6177
|
-
* (leased) => {
|
|
6178
|
-
* console.log(`Discovered ${leased.length} new streams`);
|
|
6179
|
-
* }
|
|
6180
|
-
* );
|
|
6181
|
-
*
|
|
6182
|
-
* // Later, stop it
|
|
6134
|
+
* app.start_correlations({ limit: 100 }, 5000);
|
|
6135
|
+
* // later
|
|
6183
6136
|
* app.stop_correlations();
|
|
6184
6137
|
* ```
|
|
6185
6138
|
*
|
|
6186
|
-
* @
|
|
6187
|
-
*
|
|
6188
|
-
* // Load last checkpoint
|
|
6189
|
-
* const lastId = await loadCheckpoint();
|
|
6190
|
-
*
|
|
6191
|
-
* app.start_correlations(
|
|
6192
|
-
* { after: lastId, limit: 100 },
|
|
6193
|
-
* 10000,
|
|
6194
|
-
* async (leased) => {
|
|
6195
|
-
* // Save checkpoint for next restart
|
|
6196
|
-
* if (leased.length) {
|
|
6197
|
-
* const maxId = Math.max(...leased.map(l => l.at));
|
|
6198
|
-
* await saveCheckpoint(maxId);
|
|
6199
|
-
* }
|
|
6200
|
-
* }
|
|
6201
|
-
* );
|
|
6202
|
-
* ```
|
|
6203
|
-
*
|
|
6204
|
-
* @see {@link correlate} for manual one-time correlation
|
|
6205
|
-
* @see {@link stop_correlations} to stop the worker
|
|
6139
|
+
* @see {@link settle} for what each tick runs
|
|
6140
|
+
* @see {@link stop_correlations} to stop the poll
|
|
6206
6141
|
*/
|
|
6207
6142
|
start_correlations(query = {}, frequency = 1e4, callback) {
|
|
6208
|
-
|
|
6209
|
-
|
|
6143
|
+
if (this._poll) return false;
|
|
6144
|
+
this._on_discovered = callback;
|
|
6145
|
+
const correlate = { limit: query.limit || 100 };
|
|
6146
|
+
this._poll = setInterval(() => {
|
|
6147
|
+
this._correlate.arm();
|
|
6148
|
+
this.settle({ debounceMs: 0, correlate });
|
|
6149
|
+
}, frequency);
|
|
6150
|
+
return true;
|
|
6210
6151
|
}
|
|
6211
6152
|
/**
|
|
6212
|
-
* Stops the
|
|
6213
|
-
*
|
|
6214
|
-
* Call this to stop the background correlation worker started by {@link start_correlations}.
|
|
6215
|
-
* This is automatically called when the Act instance is disposed.
|
|
6216
|
-
*
|
|
6217
|
-
* @example
|
|
6218
|
-
* ```typescript
|
|
6219
|
-
* // Start correlation
|
|
6220
|
-
* app.start_correlations();
|
|
6221
|
-
*
|
|
6222
|
-
* // Later, stop it
|
|
6223
|
-
* app.stop_correlations();
|
|
6224
|
-
* ```
|
|
6153
|
+
* Stops the poll started by {@link start_correlations}. Idempotent, and
|
|
6154
|
+
* called by `shutdown()`.
|
|
6225
6155
|
*
|
|
6226
6156
|
* @see {@link start_correlations}
|
|
6227
6157
|
*/
|
|
6228
6158
|
stop_correlations() {
|
|
6229
|
-
this.
|
|
6159
|
+
if (this._poll) {
|
|
6160
|
+
clearInterval(this._poll);
|
|
6161
|
+
this._poll = void 0;
|
|
6162
|
+
}
|
|
6163
|
+
this._on_discovered = void 0;
|
|
6230
6164
|
void this._scoped(() => this._correlate.release_correlation());
|
|
6231
6165
|
}
|
|
6232
6166
|
/**
|