@rotorsoft/act 1.32.14 → 1.32.16
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 +98 -152
- package/dist/@types/act.d.ts.map +1 -1
- package/dist/@types/adapters/in-memory-store.d.ts +3 -3
- package/dist/@types/adapters/in-memory-store.d.ts.map +1 -1
- package/dist/@types/builders/act-builder.d.ts +3 -3
- package/dist/@types/builders/act-builder.d.ts.map +1 -1
- package/dist/@types/builders/build-classify.d.ts +1 -1
- package/dist/@types/builders/builder-base.d.ts +3 -3
- package/dist/@types/builders/builder-utils.d.ts +1 -1
- package/dist/@types/builders/event-builder.d.ts +1 -1
- package/dist/@types/builders/merge.d.ts +1 -1
- package/dist/@types/builders/reaction-builder.d.ts +1 -1
- package/dist/@types/builders/slice-builder.d.ts +2 -2
- package/dist/@types/builders/state-builder.d.ts +3 -4
- package/dist/@types/builders/state-builder.d.ts.map +1 -1
- package/dist/@types/csv.d.ts +1 -1
- package/dist/@types/disposers.d.ts.map +1 -1
- package/dist/@types/internal/audit.d.ts +12 -42
- package/dist/@types/internal/audit.d.ts.map +1 -1
- package/dist/@types/internal/autoclose-policy.d.ts +3 -3
- package/dist/@types/internal/autoclose-reaction.d.ts +2 -2
- package/dist/@types/internal/autoclose-window.d.ts +1 -1
- package/dist/@types/internal/close-cycle.d.ts +10 -31
- package/dist/@types/internal/close-cycle.d.ts.map +1 -1
- package/dist/@types/internal/close-signal.d.ts +3 -3
- package/dist/@types/internal/config.d.ts +3 -3
- package/dist/@types/internal/config.d.ts.map +1 -1
- package/dist/@types/internal/correlate-cycle.d.ts +39 -86
- package/dist/@types/internal/correlate-cycle.d.ts.map +1 -1
- package/dist/@types/internal/correlator.d.ts +1 -1
- package/dist/@types/internal/date-reviver.d.ts +1 -1
- package/dist/@types/internal/defer-config.d.ts +2 -2
- package/dist/@types/internal/defer-signal.d.ts +2 -2
- package/dist/@types/internal/defer-timer.d.ts +3 -3
- package/dist/@types/internal/drain-cycle.d.ts +44 -88
- package/dist/@types/internal/drain-cycle.d.ts.map +1 -1
- package/dist/@types/internal/event-sourcing.d.ts +8 -19
- package/dist/@types/internal/event-sourcing.d.ts.map +1 -1
- package/dist/@types/internal/event-versions.d.ts +1 -1
- package/dist/@types/internal/projection-fold.d.ts +2 -2
- package/dist/@types/internal/report-once.d.ts +3 -3
- package/dist/@types/internal/sensitive.d.ts +2 -2
- package/dist/@types/internal/settle.d.ts +6 -19
- package/dist/@types/internal/settle.d.ts.map +1 -1
- package/dist/@types/ports.d.ts +3 -3
- package/dist/@types/scoped.d.ts +6 -6
- package/dist/@types/scoped.d.ts.map +1 -1
- package/dist/@types/types/action.d.ts +23 -25
- package/dist/@types/types/action.d.ts.map +1 -1
- package/dist/@types/types/audit.d.ts +1 -1
- package/dist/@types/types/ports.d.ts +22 -26
- package/dist/@types/types/ports.d.ts.map +1 -1
- package/dist/@types/types/reaction.d.ts +15 -20
- package/dist/@types/types/reaction.d.ts.map +1 -1
- package/dist/@types/types/registry.d.ts +1 -1
- package/dist/@types/types/schemas.d.ts +2 -2
- package/dist/@types/utils.d.ts +1 -1
- package/dist/{chunk-FVJFR7GH.js → chunk-JRTZGWVS.js} +1 -1
- package/dist/chunk-JRTZGWVS.js.map +1 -0
- package/dist/{chunk-JPPO3LZ3.js → chunk-PZP5ZEZ4.js} +9 -9
- package/dist/chunk-PZP5ZEZ4.js.map +1 -0
- package/dist/index.cjs +152 -372
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +147 -367
- package/dist/index.js.map +1 -1
- package/dist/test/index.cjs +7 -7
- package/dist/test/index.cjs.map +1 -1
- package/dist/test/index.js +2 -2
- package/dist/types/index.cjs.map +1 -1
- package/dist/types/index.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-FVJFR7GH.js.map +0 -1
- package/dist/chunk-JPPO3LZ3.js.map +0 -1
|
@@ -3,11 +3,10 @@
|
|
|
3
3
|
* @category Internal
|
|
4
4
|
*
|
|
5
5
|
* Correlation — the discovery half of the correlate→drain pair. Owns the
|
|
6
|
-
* lazy init (subscribe static targets, read cold-start watermark)
|
|
7
|
-
* scan that resolves each event to its target streams
|
|
8
|
-
* timer that drives background discovery.
|
|
6
|
+
* lazy init (subscribe static targets, read cold-start watermark) and the
|
|
7
|
+
* scan that resolves each event to its target streams.
|
|
9
8
|
*
|
|
10
|
-
* The scan is also the **producer of the work mark
|
|
9
|
+
* The scan is also the **producer of the work mark**: every target
|
|
11
10
|
* an event resolves to is subscribed with `correlated_at` = that event's
|
|
12
11
|
* id, which is how `claim` answers "does this stream have work?" off the
|
|
13
12
|
* subscription row instead of probing the event log.
|
|
@@ -35,18 +34,7 @@ export type StaticTarget = {
|
|
|
35
34
|
readonly priority?: number;
|
|
36
35
|
readonly lane?: string;
|
|
37
36
|
};
|
|
38
|
-
/**
|
|
39
|
-
* Drives correlation for one Act instance. Owns the checkpoint, the
|
|
40
|
-
* subscribed-streams LRU, and the periodic timer.
|
|
41
|
-
*
|
|
42
|
-
* @internal
|
|
43
|
-
*/
|
|
44
|
-
/**
|
|
45
|
-
* Constructor dependencies for {@link CorrelateCycle}. A named bag rather
|
|
46
|
-
* than a positional list: the trailing hooks (`on_init`, `on_init_async`)
|
|
47
|
-
* plus `cold_start_back_scan` are all optional and easy to transpose
|
|
48
|
-
* positionally, so callers pass them by name.
|
|
49
|
-
*/
|
|
37
|
+
/** Constructor dependencies for {@link CorrelateCycle}. */
|
|
50
38
|
export type CorrelateCycleDeps<TSchemaReg extends SchemaRegister<TActions>, TEvents extends Schemas, TActions extends Schemas> = {
|
|
51
39
|
registry: Registry<TSchemaReg, TEvents, TActions>;
|
|
52
40
|
static_targets: ReadonlyArray<StaticTarget>;
|
|
@@ -56,7 +44,7 @@ export type CorrelateCycleDeps<TSchemaReg extends SchemaRegister<TActions>, TEve
|
|
|
56
44
|
* Every lane a controller exists for — `"default"` plus each
|
|
57
45
|
* `.withLane({name})`. Injected rather than derived: `internal/` receives
|
|
58
46
|
* what it needs. A resolution naming anything outside this set has no
|
|
59
|
-
* claimant, so correlate reroutes it here
|
|
47
|
+
* claimant, so correlate reroutes it here.
|
|
60
48
|
*/
|
|
61
49
|
declared_lanes: ReadonlySet<string>;
|
|
62
50
|
on_init?: () => void;
|
|
@@ -64,11 +52,17 @@ export type CorrelateCycleDeps<TSchemaReg extends SchemaRegister<TActions>, TEve
|
|
|
64
52
|
cold_start_back_scan?: number;
|
|
65
53
|
lease_millis?: number;
|
|
66
54
|
};
|
|
55
|
+
/**
|
|
56
|
+
* Drives correlation for one Act instance. Owns the checkpoint, the
|
|
57
|
+
* correlation lease and the subscription records.
|
|
58
|
+
*
|
|
59
|
+
* @internal
|
|
60
|
+
*/
|
|
67
61
|
export declare class CorrelateCycle<TSchemaReg extends SchemaRegister<TActions>, TEvents extends Schemas, TActions extends Schemas> {
|
|
68
62
|
private _checkpoint;
|
|
69
63
|
private _initialized;
|
|
70
64
|
/**
|
|
71
|
-
* This worker's identity for the correlation lease
|
|
65
|
+
* This worker's identity for the correlation lease. A per-instance
|
|
72
66
|
* UUID, matching the drain's convention, so a renewal is recognised as the
|
|
73
67
|
* same holder and a restarted process never inherits a stale claim.
|
|
74
68
|
*/
|
|
@@ -84,24 +78,15 @@ export declare class CorrelateCycle<TSchemaReg extends SchemaRegister<TActions>,
|
|
|
84
78
|
* When this worker's correlation lease runs out, as a local clock reading,
|
|
85
79
|
* or 0 when it holds none.
|
|
86
80
|
*
|
|
87
|
-
*
|
|
88
|
-
*
|
|
89
|
-
*
|
|
90
|
-
* The act-sqlite perf gate caught that as a 1.5x regression on
|
|
91
|
-
* correlate+drain, which is the shape an embedded app runs constantly.
|
|
92
|
-
*
|
|
93
|
-
* Believing this while the store disagrees is safe in the one direction it
|
|
94
|
-
* can fail. A worker that scans without really holding the lease produces
|
|
95
|
-
* the duplicate scan that existed before the lease, and the marks are
|
|
96
|
-
* idempotent — so a stale belief costs work, never correctness.
|
|
81
|
+
* Cached so the holder doesn't ask the store on every pass. A stale belief
|
|
82
|
+
* can only cause a duplicate scan, and marks are idempotent, so it costs
|
|
83
|
+
* work, never correctness.
|
|
97
84
|
*/
|
|
98
85
|
private _lease_until;
|
|
99
86
|
/**
|
|
100
|
-
* Whether a scan might find anything
|
|
101
|
-
*
|
|
102
|
-
*
|
|
103
|
-
* equivalent, so a settle pass always scanned, including the final pass
|
|
104
|
-
* whose only job is to confirm nothing changed (#1510).
|
|
87
|
+
* Whether a scan might find anything, like the drain's flag: a commit or
|
|
88
|
+
* notification raises it, a short page lowers it, and a disarmed scan
|
|
89
|
+
* returns without touching the store.
|
|
105
90
|
*
|
|
106
91
|
* Starts armed: the log may already hold events this process has never
|
|
107
92
|
* correlated, and only a scan can find out.
|
|
@@ -116,14 +101,8 @@ export declare class CorrelateCycle<TSchemaReg extends SchemaRegister<TActions>,
|
|
|
116
101
|
* is already bounded by the registry and costs nothing the registry does
|
|
117
102
|
* not already hold.
|
|
118
103
|
*
|
|
119
|
-
*
|
|
120
|
-
*
|
|
121
|
-
* churn of dynamic targets could evict a static record, and the next
|
|
122
|
-
* dynamic resolution to that target found no record, took the
|
|
123
|
-
* first-discovery branch, and re-subscribed the target with its own
|
|
124
|
-
* priority and lane — silently re-laning a stream whose lane the
|
|
125
|
-
* build-time subscribe owns, and starving it wherever `onlyLanes` had
|
|
126
|
-
* provisioned a worker for the declared lane.
|
|
104
|
+
* Kept out of the LRU so eviction can never drop a static target's
|
|
105
|
+
* `+Infinity` floor and let a dynamic resolution re-lane it.
|
|
127
106
|
*/
|
|
128
107
|
private readonly _static_subscriptions;
|
|
129
108
|
/** Compiled pattern sources, bounded by {@link PATTERN_CACHE_SIZE}. */
|
|
@@ -133,17 +112,13 @@ export declare class CorrelateCycle<TSchemaReg extends SchemaRegister<TActions>,
|
|
|
133
112
|
private readonly _cd;
|
|
134
113
|
private readonly _on_init;
|
|
135
114
|
/**
|
|
136
|
-
* Async cold-start hook
|
|
137
|
-
*
|
|
138
|
-
*
|
|
139
|
-
* an idle deferred stream re-arms its drain across a restart. Kept
|
|
140
|
-
* separate from `on_init` because seeding is an async store read; `init`
|
|
141
|
-
* already awaits, so folding it in here preserves the "runs exactly once"
|
|
142
|
-
* guarantee without a second gate on the Act side.
|
|
115
|
+
* Async cold-start hook, run once after `on_init` inside `init()`. The
|
|
116
|
+
* orchestrator re-seeds its defer timers from the persisted `deferred_at`
|
|
117
|
+
* here, so an idle deferred stream re-arms across a restart.
|
|
143
118
|
*/
|
|
144
119
|
private readonly _on_init_async;
|
|
145
120
|
/**
|
|
146
|
-
* Tail re-scan window applied to the cold-start checkpoint
|
|
121
|
+
* Tail re-scan window applied to the cold-start checkpoint.
|
|
147
122
|
* See {@link DEFAULT_COLD_START_BACK_SCAN}. Constructor arg (not a
|
|
148
123
|
* public option) so tests can shrink it; defaults otherwise.
|
|
149
124
|
*/
|
|
@@ -170,28 +145,13 @@ export declare class CorrelateCycle<TSchemaReg extends SchemaRegister<TActions>,
|
|
|
170
145
|
* - Reads the durable correlate checkpoint (and max(at)) from the store,
|
|
171
146
|
* flooring a first boot at `watermark - back_scan` so an event
|
|
172
147
|
* committed-but-not-correlated before a crash is re-scanned on
|
|
173
|
-
* restart instead of skipped
|
|
148
|
+
* restart instead of skipped
|
|
174
149
|
* - Subscribes static resolver targets (idempotent upsert)
|
|
175
150
|
* - Populates the subscribed-streams LRU
|
|
176
151
|
* - Fires `on_init` once (Act uses this to flag a cold-start drain)
|
|
177
152
|
*/
|
|
178
153
|
init(): Promise<void>;
|
|
179
154
|
private _run_init;
|
|
180
|
-
/**
|
|
181
|
-
* Forget targets whose subscription rows no longer exist, so a later
|
|
182
|
-
* scan can re-subscribe them.
|
|
183
|
-
*
|
|
184
|
-
* A full close deletes the closed stream's subscription row. The
|
|
185
|
-
* in-process dedup would otherwise still believe the target is
|
|
186
|
-
* subscribed and never re-issue `subscribe()`, silently stopping
|
|
187
|
-
* delivery for any reaction whose target is named after the stream —
|
|
188
|
-
* the documented per-aggregate shape `.to(e => ({target: e.stream}))`
|
|
189
|
-
* makes those two namespaces collide by construction (#1398).
|
|
190
|
-
*
|
|
191
|
-
* Static targets are left alone: their record lives in
|
|
192
|
-
* `_static_subscriptions`, which this never touches, so they stay pinned
|
|
193
|
-
* at +Infinity and the dynamic path never re-opens them.
|
|
194
|
-
*/
|
|
195
155
|
/**
|
|
196
156
|
* Start correlation over after the event log was replaced wholesale
|
|
197
157
|
* (`restore`). The restored log is renumbered from the start and its
|
|
@@ -200,9 +160,14 @@ export declare class CorrelateCycle<TSchemaReg extends SchemaRegister<TActions>,
|
|
|
200
160
|
* and the init latch makes the next pass run cold-start again: static
|
|
201
161
|
* targets are re-subscribed, the checkpoint is re-read from the store
|
|
202
162
|
* (which `restore` reset), and dynamic targets are rediscovered by the
|
|
203
|
-
* scan
|
|
163
|
+
* scan.
|
|
204
164
|
*/
|
|
205
165
|
restart(): void;
|
|
166
|
+
/**
|
|
167
|
+
* Forget dynamic targets whose subscription rows no longer exist (a full
|
|
168
|
+
* close deletes the row), so a later scan re-subscribes them. Static
|
|
169
|
+
* targets keep their records.
|
|
170
|
+
*/
|
|
206
171
|
forget_subscribed(streams: Iterable<string>): void;
|
|
207
172
|
/**
|
|
208
173
|
* Would an event from `stream` be fetched for a target subscribed with
|
|
@@ -216,7 +181,7 @@ export declare class CorrelateCycle<TSchemaReg extends SchemaRegister<TActions>,
|
|
|
216
181
|
* Scan the events past the checkpoint, resolve each to its target
|
|
217
182
|
* streams, and record what it found through `cd.subscribe` — new dynamic
|
|
218
183
|
* targets get registered, and every target an event resolved to gets its
|
|
219
|
-
* **work mark** raised to that event's id
|
|
184
|
+
* **work mark** raised to that event's id.
|
|
220
185
|
*
|
|
221
186
|
* Both resolver kinds are walked. A static target is already subscribed
|
|
222
187
|
* at init, but marking it is what makes it claimable without probing the
|
|
@@ -224,18 +189,15 @@ export declare class CorrelateCycle<TSchemaReg extends SchemaRegister<TActions>,
|
|
|
224
189
|
*/
|
|
225
190
|
correlate(query?: Query,
|
|
226
191
|
/**
|
|
227
|
-
* Whether to honour the correlation lease
|
|
192
|
+
* Whether to honour the correlation lease.
|
|
228
193
|
*
|
|
229
194
|
* True only on the automatic paths — the settle loop and the poller —
|
|
230
195
|
* where the question is "should *someone* scan?" and one worker doing it
|
|
231
196
|
* serves all of them.
|
|
232
197
|
*
|
|
233
|
-
* An explicit `app.correlate()` means "scan now"
|
|
234
|
-
*
|
|
235
|
-
*
|
|
236
|
-
* so a blocked scan would make it give up and cap its prune at a stale
|
|
237
|
-
* position — pruning far less than the retention window asked for, with
|
|
238
|
-
* nothing to explain why.
|
|
198
|
+
* An explicit `app.correlate()` means "scan now" and ignores the lease:
|
|
199
|
+
* `close` catches up by looping until the checkpoint moves, and a
|
|
200
|
+
* lease-blocked scan would cap its prune at a stale position.
|
|
239
201
|
*/
|
|
240
202
|
lease?: boolean): Promise<{
|
|
241
203
|
subscribed: number;
|
|
@@ -247,18 +209,9 @@ export declare class CorrelateCycle<TSchemaReg extends SchemaRegister<TActions>,
|
|
|
247
209
|
/**
|
|
248
210
|
* Hand the correlation lease back early.
|
|
249
211
|
*
|
|
250
|
-
*
|
|
251
|
-
*
|
|
252
|
-
*
|
|
253
|
-
* holder renews, and renewing to a millisecond is a release in all but
|
|
254
|
-
* name.
|
|
255
|
-
*
|
|
256
|
-
* Without this a worker that stops cleanly still blocks discovery for the
|
|
257
|
-
* rest of its lease — invisible in a long-lived deployment, very visible
|
|
258
|
-
* anywhere Acts are created and dropped inside one process.
|
|
259
|
-
*
|
|
260
|
-
* Best-effort: failing here costs the lease's remaining lifetime, which is
|
|
261
|
-
* what would have happened had the process died instead.
|
|
212
|
+
* The port has no release verb; re-acquiring as the same holder with a
|
|
213
|
+
* zero duration releases it. Best-effort: a failure costs the lease's
|
|
214
|
+
* remaining lifetime, as a crash would.
|
|
262
215
|
*/
|
|
263
216
|
release_correlation(): Promise<void>;
|
|
264
217
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"correlate-cycle.d.ts","sourceRoot":"","sources":["../../../src/internal/correlate-cycle.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"correlate-cycle.d.ts","sourceRoot":"","sources":["../../../src/internal/correlate-cycle.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAIH,OAAO,KAAK,EAEV,KAAK,EACL,QAAQ,EACR,cAAc,EACd,OAAO,EAER,MAAM,mBAAmB,CAAC;AAE3B,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAwE3C;;;;;;;;;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,2DAA2D;AAC3D,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,cAAc,EAAE,aAAa,CAAC,YAAY,CAAC,CAAC;IAC5C,EAAE,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAC;IACtB,sBAAsB,EAAE,MAAM,CAAC;IAC/B;;;;;OAKG;IACH,cAAc,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IACpC,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,aAAa,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IACpC,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC;AAiEF;;;;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,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,CAa1B;YAEa,SAAS;IA0BvB;;;;;;;;;OASG;IACH,OAAO,IAAI,IAAI,CAOd;IAED;;;;OAIG;IACH,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;;;;;;;;;;OAUG;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,CAmMD;IAED;;;;;;OAMG;IACG,mBAAmB,IAAI,OAAO,CAAC,IAAI,CAAC,CAiBzC;CACF"}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* @module correlator
|
|
3
3
|
* @category Internal
|
|
4
4
|
*
|
|
5
|
-
* Correlation-id generator and the default implementation
|
|
5
|
+
* Correlation-id generator and the default implementation.
|
|
6
6
|
*
|
|
7
7
|
* The default produces a readable, time-monotonic-within-window, lowercase
|
|
8
8
|
* id like `coun-incr-lwxk9p3a` — short enough to scan in logs, structured
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
*
|
|
19
19
|
* The shape-based {@link dateReviver} in `utils.ts` is the predecessor this
|
|
20
20
|
* replaced — it revived anything ISO-8601-looking, including fields declared
|
|
21
|
-
* `z.string()
|
|
21
|
+
* `z.string()`.
|
|
22
22
|
*
|
|
23
23
|
* @internal
|
|
24
24
|
*/
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* @module defer-config
|
|
3
3
|
* @category Internal
|
|
4
4
|
*
|
|
5
|
-
* The `when` options for the public `defer` surface
|
|
5
|
+
* The `when` options for the public `defer` surface. A
|
|
6
6
|
* reaction defers itself to a future time either declaratively (the
|
|
7
7
|
* `.defer(when)` builder step) or imperatively (`throw new DeferSignal(when)`
|
|
8
8
|
* inside a handler); both resolve `when` through here.
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
*
|
|
18
18
|
* Validation follows the config-schema standard (CLAUDE.md): an internal
|
|
19
19
|
* `*OptionsSchema` const, a public inferred type, and a resolver. Slice 2
|
|
20
|
-
* ships `after` / `at`; recurrence (`every`) extends this in Slice 3
|
|
20
|
+
* ships `after` / `at`; recurrence (`every`) extends this in Slice 3.
|
|
21
21
|
*
|
|
22
22
|
* @internal
|
|
23
23
|
*/
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* @module defer-signal
|
|
3
3
|
* @category Internal
|
|
4
4
|
*
|
|
5
|
-
* The control-flow signal a reaction handler throws to *defer* itself
|
|
6
|
-
*
|
|
5
|
+
* The control-flow signal a reaction handler throws to *defer* itself.
|
|
6
|
+
* Unlike an error, a defer is not a failure: the dispatcher
|
|
7
7
|
* ({@link "reaction-builder".build_handle}) catches it and produces a
|
|
8
8
|
* `HandleResult.defer` — the triggering events stay pending (watermark not
|
|
9
9
|
* advanced), `retry` is not bumped, and the drain re-visits the stream at the
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* @module defer-timer
|
|
3
3
|
* @category Internal
|
|
4
4
|
*
|
|
5
|
-
* The shared "next visit time" primitive
|
|
5
|
+
* The shared "next visit time" primitive. A `DeferTimer` holds a
|
|
6
6
|
* `stream → due-time` map and a single collapsed wake timer: it parks
|
|
7
7
|
* streams that should be re-visited later and fires one `on_wake` callback
|
|
8
8
|
* at the earliest pending due-time, garbage-collecting the entries that have
|
|
@@ -23,8 +23,8 @@
|
|
|
23
23
|
* *derived* from (an un-advanced watermark, an event's `created` timestamp),
|
|
24
24
|
* not from the map. A restart empties the map, so the cold-start rebuild is
|
|
25
25
|
* explicit: `CorrelateCycle.init` seeds each still-future `deferred_at` back
|
|
26
|
-
* onto the owning lane's timer via {@link "drain-cycle".DrainController.seed_defer}
|
|
27
|
-
*
|
|
26
|
+
* onto the owning lane's timer via {@link "drain-cycle".DrainController.seed_defer},
|
|
27
|
+
* so an idle deferred stream re-arms at its due-time with no
|
|
28
28
|
* intervening commit.
|
|
29
29
|
*
|
|
30
30
|
* @internal
|
|
@@ -9,8 +9,7 @@
|
|
|
9
9
|
* Reusable for property tests and standalone benchmarks.
|
|
10
10
|
*
|
|
11
11
|
* - {@link DrainController} — stateful driver that owns the armed flag,
|
|
12
|
-
* the concurrency lock, and the adaptive lag/lead ratio.
|
|
13
|
-
* `run_drain_cycle` with the lifecycle decisions Act used to make inline.
|
|
12
|
+
* the concurrency lock, and the adaptive lag/lead ratio.
|
|
14
13
|
*
|
|
15
14
|
* @internal
|
|
16
15
|
*/
|
|
@@ -27,11 +26,8 @@ export type HandleResult = Readonly<{
|
|
|
27
26
|
lease: Lease;
|
|
28
27
|
handled: number;
|
|
29
28
|
/**
|
|
30
|
-
* Event id at which the ack would land
|
|
31
|
-
*
|
|
32
|
-
* `acked_at` to pair symmetrically with {@link failed_at} and to keep
|
|
33
|
-
* it visually distinct from `Lease.at` (the pre-cycle watermark — same
|
|
34
|
-
* field name across types but a different semantic).
|
|
29
|
+
* Event id at which the ack would land: the last *successful* event id,
|
|
30
|
+
* or `lease.at` when the batch had no work.
|
|
35
31
|
*/
|
|
36
32
|
acked_at: number;
|
|
37
33
|
error?: string;
|
|
@@ -44,25 +40,16 @@ export type HandleResult = Readonly<{
|
|
|
44
40
|
*/
|
|
45
41
|
next_attempt_at?: number;
|
|
46
42
|
/**
|
|
47
|
-
* Wall-clock timestamp (ms since epoch) at which
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
* the stream until `defer` elapses, then redelivers so the handler can
|
|
52
|
-
* re-evaluate. This is the timing primitive autoclose rides (#1090);
|
|
53
|
-
* unlike {@link next_attempt_at} (a retry-only backoff), a defer carries
|
|
54
|
-
* no error and never blocks. When present, the result is excluded from
|
|
55
|
-
* ack and block — it neither advances nor terminates the watermark.
|
|
43
|
+
* Wall-clock timestamp (ms since epoch) at which to re-visit a stream
|
|
44
|
+
* whose handler *deferred*: the triggering events stay pending, `retry`
|
|
45
|
+
* is not bumped, and the drain redelivers once `defer` elapses. Unlike
|
|
46
|
+
* {@link next_attempt_at}, a defer carries no error and never blocks.
|
|
56
47
|
*/
|
|
57
48
|
defer?: number;
|
|
58
49
|
/**
|
|
59
|
-
* Close request
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
* drain hands this {@link CloseTarget} to the orchestrator's `on_close`,
|
|
63
|
-
* which runs `run_close_cycle`. Carries the optional archiver from the
|
|
64
|
-
* signal. Distinct from {@link defer} (hold for later) — a close advances
|
|
65
|
-
* and retires.
|
|
50
|
+
* Close request from a handler that threw `CloseSignal`. The triggering
|
|
51
|
+
* event is acked (so the close guard doesn't see the reaction as in
|
|
52
|
+
* flight), then the drain hands this {@link CloseTarget} to `on_close`.
|
|
66
53
|
*/
|
|
67
54
|
close?: CloseTarget;
|
|
68
55
|
/**
|
|
@@ -97,9 +84,19 @@ export type DrainCycle<TEvents extends Schemas> = {
|
|
|
97
84
|
readonly handled: HandleResult[];
|
|
98
85
|
readonly acked: Lease[];
|
|
99
86
|
readonly blocked: BlockedLease[];
|
|
100
|
-
/** Streams a handler asked to close this cycle
|
|
87
|
+
/** Streams a handler asked to close this cycle — handed to `on_close`. */
|
|
101
88
|
readonly closeable: CloseTarget[];
|
|
102
89
|
};
|
|
90
|
+
/** One cycle's sizing and per-pass state, from {@link DrainController}. */
|
|
91
|
+
type CycleInput = {
|
|
92
|
+
readonly lagging: number;
|
|
93
|
+
readonly leading: number;
|
|
94
|
+
readonly eventLimit: number;
|
|
95
|
+
readonly leaseMillis: number;
|
|
96
|
+
readonly misrouted: Set<string>;
|
|
97
|
+
/** The store failed on the previous pass — see {@link budget_exhausted}. */
|
|
98
|
+
readonly store_failing: boolean;
|
|
99
|
+
};
|
|
103
100
|
/**
|
|
104
101
|
* Run one drain cycle: claim streams, fetch their events, dispatch
|
|
105
102
|
* matching reactions, ack the successes, block the retries-exhausted.
|
|
@@ -113,17 +110,7 @@ export type DrainCycle<TEvents extends Schemas> = {
|
|
|
113
110
|
*
|
|
114
111
|
* @internal
|
|
115
112
|
*/
|
|
116
|
-
export declare function run_drain_cycle<TEvents extends Schemas, TActions extends Schemas, TSchemaReg extends SchemaRegister<TActions>>(
|
|
117
|
-
/** The store failed on the previous pass — see {@link budget_exhausted}. */
|
|
118
|
-
store_failing: boolean, handle: Handle<TEvents>, handle_batch: HandleBatch<TEvents>, lagging: number, leading: number, eventLimit: number, leaseMillis: number,
|
|
119
|
-
/**
|
|
120
|
-
* Emitted as soon as `block` confirms, BEFORE the `ack` that follows.
|
|
121
|
-
* A block is terminal: every adapter gates `block` on `blocked = false`
|
|
122
|
-
* and excludes a blocked stream from `claim`, so it never runs again for
|
|
123
|
-
* that stream. If the emit waited until the end of the cycle, an `ack`
|
|
124
|
-
* failure in between would lose the `blocked` event permanently (#1390).
|
|
125
|
-
*/
|
|
126
|
-
on_blocked: (blocked: BlockedLease[]) => void, lane?: string): Promise<DrainCycle<TEvents> | undefined>;
|
|
113
|
+
export declare function run_drain_cycle<TEvents extends Schemas, TActions extends Schemas, TSchemaReg extends SchemaRegister<TActions>>(deps: DrainControllerDeps<TEvents, TActions, TSchemaReg>, cycle: CycleInput): Promise<DrainCycle<TEvents> | undefined>;
|
|
127
114
|
/**
|
|
128
115
|
* Dependencies the {@link DrainController} needs from the orchestrator.
|
|
129
116
|
* The lifecycle event sinks (`on_acked` / `on_blocked`) are callbacks so
|
|
@@ -141,29 +128,21 @@ export type DrainControllerDeps<TEvents extends Schemas, TActions extends Schema
|
|
|
141
128
|
readonly on_acked: (acked: Lease[]) => void;
|
|
142
129
|
readonly on_blocked: (blocked: BlockedLease[]) => void;
|
|
143
130
|
/**
|
|
144
|
-
*
|
|
145
|
-
*
|
|
146
|
-
* it to its `run_close_cycle` machinery (same path as `app.close`). Awaited so
|
|
147
|
-
* a slow close doesn't overlap the next cycle's claim on the controller.
|
|
131
|
+
* Runs the cycle's reaction-requested closes after acks/blocks land.
|
|
132
|
+
* Awaited so a slow close doesn't overlap the next claim.
|
|
148
133
|
*/
|
|
149
134
|
readonly on_close: (targets: CloseTarget[]) => Promise<void>;
|
|
150
135
|
/**
|
|
151
|
-
* Shared
|
|
152
|
-
*
|
|
153
|
-
* backend; closed/half-open let attempts through. It also surfaces each
|
|
154
|
-
* failure (via its own `on_error`, wired by the orchestrator to the
|
|
155
|
-
* `error` lifecycle event), so callers just `failed(now, error)`.
|
|
136
|
+
* Shared circuit breaker. Opens after repeated store failures so the
|
|
137
|
+
* drain stops hammering a down backend, and surfaces each failure.
|
|
156
138
|
*/
|
|
157
139
|
readonly breaker: CircuitBreaker;
|
|
158
140
|
/**
|
|
159
|
-
*
|
|
160
|
-
* any caller frame, so its
|
|
161
|
-
* `_scoped` bag or `store()`/`cache()` resolve to the singleton for a
|
|
162
|
-
* scoped Act. The orchestrator always threads its `_scoped` (identity
|
|
163
|
-
* for a non-scoped Act), so it's required.
|
|
141
|
+
* Runs a body in the Act's ports frame. The per-lane worker ticks outside
|
|
142
|
+
* any caller frame, so its drain must be re-scoped.
|
|
164
143
|
*/
|
|
165
144
|
readonly run_scoped: <T>(fn: () => Promise<T>) => Promise<T>;
|
|
166
|
-
/** Lane this controller drains. Undefined
|
|
145
|
+
/** Lane this controller drains. Undefined spans all lanes. */
|
|
167
146
|
readonly lane?: string;
|
|
168
147
|
/** Per-lane defaults applied when caller doesn't override via DrainOptions. */
|
|
169
148
|
readonly defaults?: {
|
|
@@ -190,30 +169,23 @@ export declare class DrainController<TEvents extends Schemas, TActions extends S
|
|
|
190
169
|
private _locked;
|
|
191
170
|
private _ratio;
|
|
192
171
|
/**
|
|
193
|
-
*
|
|
194
|
-
*
|
|
195
|
-
*
|
|
196
|
-
* process memory — per-worker pacing by design (see {@link BackoffOptions}
|
|
197
|
-
* for the multi-worker trade-off). Its wake re-arms drain at the earliest
|
|
198
|
-
* pending visit.
|
|
172
|
+
* Local wake for streams this worker parked (backoff or defer). The
|
|
173
|
+
* schedule itself is persisted in the store; this only re-arms the drain
|
|
174
|
+
* at the earliest pending visit.
|
|
199
175
|
*/
|
|
200
176
|
private readonly _defer;
|
|
201
|
-
/** Worker timer
|
|
177
|
+
/** Worker timer. Set when `start()` is active, undefined otherwise. */
|
|
202
178
|
private _worker;
|
|
203
179
|
/**
|
|
204
|
-
* Misroutings this controller has reported
|
|
180
|
+
* Misroutings this controller has reported. A resolver returning a
|
|
205
181
|
* projection's target does so for every matching event; one line per event
|
|
206
182
|
* would bury the signal it exists to raise.
|
|
207
183
|
*/
|
|
208
184
|
private readonly _misrouted;
|
|
209
185
|
private _stopped;
|
|
210
186
|
/**
|
|
211
|
-
* Resolves when the cycle
|
|
212
|
-
*
|
|
213
|
-
* the overlap guard; this answers "tell me when it is done" for a graceful
|
|
214
|
-
* shutdown, which needs to await the handler rather than abandon it
|
|
215
|
-
* mid-`await` with the stream still leased. Never rejects — `drain()`
|
|
216
|
-
* contains its own errors — so awaiting it is always safe.
|
|
187
|
+
* Resolves when the cycle in flight finishes, so a graceful shutdown can
|
|
188
|
+
* wait for it. Never rejects.
|
|
217
189
|
*/
|
|
218
190
|
private _inflight;
|
|
219
191
|
private _inflight_done;
|
|
@@ -226,39 +198,22 @@ export declare class DrainController<TEvents extends Schemas, TActions extends S
|
|
|
226
198
|
*/
|
|
227
199
|
arm(): void;
|
|
228
200
|
/**
|
|
229
|
-
* Re-seed a persisted
|
|
230
|
-
*
|
|
231
|
-
*
|
|
232
|
-
* autoclose aggregate) is durable in the store's `deferred_at` but has
|
|
233
|
-
* nothing in memory to re-arm the drain at the due-time. The orchestrator
|
|
234
|
-
* reads the persisted `deferred_at` for this controller's lane and calls
|
|
235
|
-
* this to park the stream + (re)schedule the shared wake — so the drain
|
|
236
|
-
* re-arms at the due-time with no intervening commit. `schedule()`
|
|
237
|
-
* collapses many seeds into one timer, so callers may seed in a loop and
|
|
238
|
-
* let the earliest due-time win.
|
|
201
|
+
* Re-seed a persisted `deferred_at` into the local wake at cold start, so
|
|
202
|
+
* an idle deferred stream re-arms at its due-time with no new commit.
|
|
203
|
+
* Seeds collapse into one timer; the earliest wins.
|
|
239
204
|
*/
|
|
240
205
|
seed_defer(stream: string, at: number): void;
|
|
241
206
|
/** Read-only flag — true while a commit / reset is unprocessed. */
|
|
242
207
|
get armed(): boolean;
|
|
243
|
-
/**
|
|
244
|
-
* The cycle currently in flight, or `undefined` when idle (#1442). A
|
|
245
|
-
* graceful shutdown awaits this so an in-flight handler reaches its `ack`
|
|
246
|
-
* — which releases the stream's lease — instead of being abandoned with
|
|
247
|
-
* the lease held until it expires.
|
|
248
|
-
*/
|
|
208
|
+
/** The cycle in flight, or `undefined` when idle. */
|
|
249
209
|
get inflight(): Promise<void> | undefined;
|
|
250
|
-
/**
|
|
251
|
-
* This lane's configured lease budget, or `undefined` when the lane didn't
|
|
252
|
-
* pin one. It is the operator's own statement of how long a handler may
|
|
253
|
-
* legitimately hold a stream, which makes it the right basis for a
|
|
254
|
-
* shutdown grace budget (#1442).
|
|
255
|
-
*/
|
|
210
|
+
/** This lane's configured lease, or `undefined`; the shutdown grace basis. */
|
|
256
211
|
get lease_millis(): number | undefined;
|
|
257
|
-
/** Lane this controller drains (undefined
|
|
212
|
+
/** Lane this controller drains (undefined spans all lanes). */
|
|
258
213
|
get lane(): string | undefined;
|
|
259
214
|
/**
|
|
260
215
|
* Start a per-lane worker that drains at the lane's `cycleMs`
|
|
261
|
-
* cadence
|
|
216
|
+
* cadence. When armed, the worker calls `drain()` on every
|
|
262
217
|
* tick and re-schedules; when not armed, it still re-schedules at
|
|
263
218
|
* `cycleMs` so a future `arm()` is picked up on the next tick.
|
|
264
219
|
*
|
|
@@ -271,4 +226,5 @@ export declare class DrainController<TEvents extends Schemas, TActions extends S
|
|
|
271
226
|
/** Run one drain pass. Short-circuits when not armed or already running. */
|
|
272
227
|
drain(options?: DrainOptions): Promise<Drain<TEvents>>;
|
|
273
228
|
}
|
|
229
|
+
export {};
|
|
274
230
|
//# sourceMappingURL=drain-cycle.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"drain-cycle.d.ts","sourceRoot":"","sources":["../../../src/internal/drain-cycle.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"drain-cycle.d.ts","sourceRoot":"","sources":["../../../src/internal/drain-cycle.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAIH,OAAO,KAAK,EACV,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,KAAK,EACL,YAAY,EACZ,KAAK,EACL,KAAK,EACL,MAAM,EAEN,eAAe,EACf,QAAQ,EACR,cAAc,EACd,OAAO,EACR,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAO3D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAK3C;;;;;GAKG;AACH,MAAM,MAAM,YAAY,GAAG,QAAQ,CAAC;IAClC,KAAK,EAAE,KAAK,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB;;;;;OAKG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;;;;;OAKG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;;OAIG;IACH,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB;;;;;;OAMG;IACH,SAAS,CAAC,E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AG,SAAS,CAExC;IAED,8EAA8E;IAC9E,IAAI,YAAY,IAAI,MAAM,GAAG,SAAS,CAErC;IAED,+DAA+D;IAC/D,IAAI,IAAI,IAAI,MAAM,GAAG,SAAS,CAE7B;IAED;;;;;;;;OAQG;IACH,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAa3B;IAED,4CAA4C;IAC5C,IAAI,IAAI,IAAI,CAOX;IAED,4EAA4E;IACtE,KAAK,CAAC,OAAO,GAAE,YAAiB,GAAG,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAiG/D;CACF"}
|
|
@@ -33,7 +33,7 @@ import type { Committed, DoOptions, EventSource, LoadTarget, ScanOptions, ScanRe
|
|
|
33
33
|
* {@link "tracing".build_es}) — never branched per event:
|
|
34
34
|
*
|
|
35
35
|
* - {@link bare_patch} — the default. Literally `patch(state, partial)`,
|
|
36
|
-
* no wrapper.
|
|
36
|
+
* no wrapper. No validation cost on the hot path.
|
|
37
37
|
* - {@link validating_patch} — the opt-in `ActOptions.validateFoldedState`
|
|
38
38
|
* path. Merges, then parses the merged full state against the state's
|
|
39
39
|
* declared Zod schema.
|
|
@@ -48,7 +48,7 @@ import type { Committed, DoOptions, EventSource, LoadTarget, ScanOptions, ScanRe
|
|
|
48
48
|
export type PatchFn = <TState extends Schema, TEvents extends Schemas, TActions extends Schemas>(me: State<TState, TEvents, TActions>, state: TState, partial: Readonly<Patch<TState>>, event: Committed<TEvents, keyof TEvents>) => TState;
|
|
49
49
|
/**
|
|
50
50
|
* The default patch step: a bare `patch()` merge with no wrapper and no
|
|
51
|
-
* branch. The off-path is
|
|
51
|
+
* branch. The off-path is a plain reduction, so an
|
|
52
52
|
* app that leaves `validateFoldedState` off pays nothing — not even a
|
|
53
53
|
* comparison.
|
|
54
54
|
*
|
|
@@ -56,10 +56,10 @@ export type PatchFn = <TState extends Schema, TEvents extends Schemas, TActions
|
|
|
56
56
|
*/
|
|
57
57
|
export declare const bare_patch: PatchFn;
|
|
58
58
|
/**
|
|
59
|
-
* The opt-in patch step
|
|
59
|
+
* The opt-in patch step: merge the partial into state, then
|
|
60
60
|
* parse the merged full state against the owning state's declared Zod
|
|
61
61
|
* schema. A reducer that produces schema-violating state (the calculator
|
|
62
|
-
* divide-by-zero NaN class
|
|
62
|
+
* divide-by-zero NaN class) fails here, at the triggering event,
|
|
63
63
|
* instead of propagating and surfacing hops later as a confusing
|
|
64
64
|
* downstream error.
|
|
65
65
|
*
|
|
@@ -123,21 +123,10 @@ export declare function tombstone(stream: string, expectedVersion: number, corre
|
|
|
123
123
|
* causation remap; adapters supply only the per-event insert
|
|
124
124
|
* `callback` via the driver pattern (see {@link Store.restore}).
|
|
125
125
|
*
|
|
126
|
-
*
|
|
127
|
-
* `
|
|
128
|
-
*
|
|
129
|
-
*
|
|
130
|
-
* that ignore the filter (`CsvFile`) stream everything in one call
|
|
131
|
-
* and the loop exits after the first batch when `got > BATCH`. The
|
|
132
|
-
* source's own per-event `await Promise.resolve(callback(event))`
|
|
133
|
-
* provides backpressure — no separate mailbox needed.
|
|
134
|
-
*
|
|
135
|
-
* Throws on the first invalid event (negative version, malformed
|
|
136
|
-
* `created`) with the running index in the message.
|
|
137
|
-
*
|
|
138
|
-
* Returns the partial {@link ScanResult} (without `duration_ms`)
|
|
139
|
-
* — {@link Act.restore} wraps the call with its own timing so the
|
|
140
|
-
* duration covers transaction setup and commit, not just iteration.
|
|
126
|
+
* Pages the source with `limit`/`after`; a source that ignores the
|
|
127
|
+
* filter (`CsvFile`) returns everything at once and the loop ends. Throws
|
|
128
|
+
* on the first invalid event. Returns the result without `duration_ms`,
|
|
129
|
+
* which {@link Act.restore} adds.
|
|
141
130
|
*
|
|
142
131
|
* @internal
|
|
143
132
|
*/
|