@rotorsoft/act 1.32.24 → 1.32.26
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 +20 -155
- package/dist/@types/act.d.ts.map +1 -1
- package/dist/@types/adapters/in-memory-store.d.ts +10 -190
- package/dist/@types/adapters/in-memory-store.d.ts.map +1 -1
- package/dist/@types/internal/close-cycle.d.ts +0 -8
- package/dist/@types/internal/close-cycle.d.ts.map +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/@types/internal/event-sourcing.d.ts.map +1 -1
- package/dist/@types/internal/index.d.ts +1 -1
- package/dist/@types/internal/index.d.ts.map +1 -1
- package/dist/{chunk-OG5O36AJ.js → chunk-QXW3JV2H.js} +21 -240
- package/dist/chunk-QXW3JV2H.js.map +1 -0
- package/dist/index.cjs +153 -488
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +135 -251
- package/dist/index.js.map +1 -1
- package/dist/test/index.cjs +20 -239
- package/dist/test/index.cjs.map +1 -1
- package/dist/test/index.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-OG5O36AJ.js.map +0 -1
package/dist/@types/act.d.ts
CHANGED
|
@@ -228,41 +228,23 @@ export type ActOptions<TLanes extends string = string> = {
|
|
|
228
228
|
*/
|
|
229
229
|
export declare class Act<TSchemaReg extends SchemaRegister<TActions>, TEvents extends Schemas, TActions extends Schemas, TStateMap extends Record<string, Schema> = Record<string, never>, TActor extends Actor = Actor> implements IAct<TEvents, TActions, TActor, TSchemaReg> {
|
|
230
230
|
private _emitter;
|
|
231
|
-
/** Circuit breaker shared by all drain lanes. */
|
|
232
231
|
private readonly _breaker;
|
|
233
|
-
/** Whether this instance subscribes to `Store.notify`. */
|
|
234
232
|
private readonly _listen;
|
|
235
|
-
/** Whether this instance runs reactions (drain, settle, correlate). */
|
|
236
233
|
private readonly _drain;
|
|
237
|
-
/** Event names with at least one registered reaction (computed at build time) */
|
|
238
234
|
private readonly _reactive_events;
|
|
239
|
-
/** One DrainController per active lane, keyed by lane name. */
|
|
240
235
|
private readonly _drain_controllers;
|
|
241
|
-
/** Correlation: lazy init and the scan that marks work. */
|
|
242
236
|
private readonly _correlate;
|
|
243
|
-
/** Debounced correlate→drain catch-up loop. */
|
|
244
237
|
private readonly _settle;
|
|
245
|
-
/** Timer behind {@link start_correlations}. */
|
|
246
238
|
private _poll;
|
|
247
239
|
/** The deprecated `start_correlations` callback, while the poll runs. */
|
|
248
240
|
private _on_discovered;
|
|
249
241
|
/**
|
|
250
|
-
*
|
|
251
|
-
*
|
|
252
|
-
* itself may be async (the PG adapter checks out a dedicated client
|
|
253
|
-
* and runs `LISTEN` before resolving). Resolves to `undefined` when
|
|
254
|
-
* the store doesn't implement `notify` or there are no registered
|
|
255
|
-
* reactions.
|
|
256
|
-
*
|
|
257
|
-
* **Contract:** the configured store must be injected via
|
|
258
|
-
* {@link store}`(adapter)` *before* calling `act()...build()`. The
|
|
259
|
-
* orchestrator wires notify against whatever store is current at
|
|
260
|
-
* construction time — late injection after build is unsupported.
|
|
242
|
+
* Wired at construction against the store current then, so a store
|
|
243
|
+
* injected after `build()` is never notified.
|
|
261
244
|
*/
|
|
262
245
|
private readonly _notify_disposer;
|
|
263
246
|
/** Public registry — kept as-is per the no-prefix-on-public convention. */
|
|
264
247
|
readonly registry: Registry<TSchemaReg, TEvents, TActions, keyof TStateMap & string>;
|
|
265
|
-
/** Map of state name → state definition; populated by the builder. */
|
|
266
248
|
private readonly _states;
|
|
267
249
|
/**
|
|
268
250
|
* Emit a lifecycle event. The payload type is inferred from the event name
|
|
@@ -278,15 +260,9 @@ export declare class Act<TSchemaReg extends SchemaRegister<TActions>, TEvents ex
|
|
|
278
260
|
*/
|
|
279
261
|
emit<E extends keyof ActLifecycleEvents<TSchemaReg, TEvents, TActions>>(event: E, args: ActLifecycleEvents<TSchemaReg, TEvents, TActions>[E]): boolean;
|
|
280
262
|
/**
|
|
281
|
-
* The
|
|
282
|
-
*
|
|
283
|
-
*
|
|
284
|
-
* `breaker.failed(now, error)` and never log or emit themselves.
|
|
285
|
-
*
|
|
286
|
-
* The emit is guarded against Node's `EventEmitter` contract that an
|
|
287
|
-
* unhandled `"error"` emission is rethrown (which would crash the process
|
|
288
|
-
* from inside the drain catch); logging is unconditional so failures are
|
|
289
|
-
* never silent.
|
|
263
|
+
* The one place a store failure is logged and emitted (the breaker's
|
|
264
|
+
* `on_error`). The emit is guarded: an unhandled `"error"` emission
|
|
265
|
+
* would crash the process.
|
|
290
266
|
*/
|
|
291
267
|
private _emit_error;
|
|
292
268
|
/**
|
|
@@ -298,120 +274,47 @@ export declare class Act<TSchemaReg extends SchemaRegister<TActions>, TEvents ex
|
|
|
298
274
|
* Remove a previously registered lifecycle listener.
|
|
299
275
|
*/
|
|
300
276
|
off<E extends keyof ActLifecycleEvents<TSchemaReg, TEvents, TActions>>(event: E, listener: (args: ActLifecycleEvents<TSchemaReg, TEvents, TActions>[E]) => void): this;
|
|
301
|
-
/** Batch handlers for static-target projections (target → handler) */
|
|
302
277
|
private readonly _batch_handlers;
|
|
303
|
-
/** Event-sourcing handlers, optionally wrapped with trace decorators */
|
|
304
278
|
private readonly _es;
|
|
305
|
-
/** Correlate/drain pipeline ops, optionally wrapped with trace decorators */
|
|
306
279
|
private readonly _cd;
|
|
307
|
-
/**
|
|
308
|
-
* Event-name → owning state, computed at build time. The duplicate-event
|
|
309
|
-
* guard in merge.ts ensures one event name maps to at most one state, so
|
|
310
|
-
* this lookup is unambiguous. Used by `close()` to pick the right reducer
|
|
311
|
-
* set when seeding a `restart` snapshot in multi-state apps.
|
|
312
|
-
*/
|
|
280
|
+
/** Unambiguous: merge rejects an event name declared by two states. */
|
|
313
281
|
private readonly _event_to_state;
|
|
314
|
-
/**
|
|
315
|
-
* Event-name → lane fan-in for selective arming. Built by
|
|
316
|
-
* `classify_registry` once per build. `"all"` means at least one of
|
|
317
|
-
* the event's reactions is a dynamic resolver (lane opaque until
|
|
318
|
-
* runtime); a `Set<string>` lists the static lanes only that event's
|
|
319
|
-
* reactions target.
|
|
320
|
-
*/
|
|
282
|
+
/** Lanes to arm per event; `"all"` when a dynamic resolver hides the lane. */
|
|
321
283
|
private readonly _event_to_lanes;
|
|
322
|
-
/** What `internal/audit.ts` needs, built once at construction. */
|
|
323
284
|
private readonly _audit_deps;
|
|
324
|
-
/** Logger resolved at construction time (after user port configuration) */
|
|
325
285
|
private readonly _logger;
|
|
326
286
|
/** This Act's ports: its own bag, or the singleton adapters. */
|
|
327
287
|
private readonly _ports;
|
|
328
|
-
/**
|
|
329
|
-
* Runs a body inside this Act's ports frame, so internal
|
|
330
|
-
* `store()`/`cache()` calls resolve to `_ports`.
|
|
331
|
-
*/
|
|
288
|
+
/** Runs a body so internal `store()`/`cache()` calls resolve to `_ports`. */
|
|
332
289
|
private readonly _scoped;
|
|
333
|
-
/**
|
|
334
|
-
* Correlation-id generator for originating actions. Bound at
|
|
335
|
-
* construction from `options.correlator ?? default_correlator`. The
|
|
336
|
-
* `do()` path passes this into the `_es.action` closure; close-cycle
|
|
337
|
-
* uses it via {@link close_correlation}.
|
|
338
|
-
*/
|
|
339
290
|
private readonly _correlator;
|
|
340
|
-
/** Pre-bound IAct methods reused across drain cycles. Only `do` varies per
|
|
341
|
-
* payload (it captures the triggering event for reactingTo auto-inject). */
|
|
342
291
|
private readonly _bound_do;
|
|
343
292
|
private readonly _bound_load;
|
|
344
293
|
private readonly _bound_query;
|
|
345
294
|
private readonly _bound_query_array;
|
|
346
295
|
private readonly _bound_forget;
|
|
347
|
-
/** Reaction dispatchers built once and handed to run_drain_cycle each cycle. */
|
|
348
296
|
private readonly _handle;
|
|
349
297
|
private readonly _handle_batch;
|
|
350
|
-
/** Declared drain lanes. */
|
|
351
298
|
private readonly _lanes;
|
|
352
|
-
/** Serializes close critical sections per stream. */
|
|
353
299
|
private readonly _close_lock;
|
|
354
300
|
/** Every lane a controller can exist for: `"default"` plus each declared one. */
|
|
355
301
|
private readonly _declared_lanes;
|
|
356
302
|
/** Drain lanes declared via `.withLane(...)`. Implicit default not included. */
|
|
357
303
|
get lanes(): ReadonlyArray<LaneConfig>;
|
|
358
|
-
/**
|
|
359
|
-
* Create a new Act orchestrator. Prefer the {@link act} builder over
|
|
360
|
-
* direct construction — `act()...build()` wires the registry, merges
|
|
361
|
-
* partial states, and collects batch handlers from registered slices
|
|
362
|
-
* and projections in one pass.
|
|
363
|
-
*
|
|
364
|
-
* @param registry Schemas for every event and action across registered states
|
|
365
|
-
* @param states Merged map of state name → state definition
|
|
366
|
-
* @param batch_handlers Static-target projection batch handlers (target → handler)
|
|
367
|
-
* @param options Tuning knobs — see {@link ActOptions}
|
|
368
|
-
* @param lanes Declared drain lanes. The builder collects
|
|
369
|
-
* these from `.withLane(...)` calls; one `DrainController` runs
|
|
370
|
-
* per lane, plus the implicit `"default"`.
|
|
371
|
-
* @param patch_fn The per-event patch step selected once by the builder
|
|
372
|
-
* from `ActOptions.validateFoldedState` — `bare_patch` by
|
|
373
|
-
* default, `validating_patch` when the flag is on. The builder uses
|
|
374
|
-
* the same value for its projection-fold handlers, so there is a
|
|
375
|
-
* single selection site. Defaults to `bare_patch` for direct
|
|
376
|
-
* construction.
|
|
377
|
-
*/
|
|
304
|
+
/** Use the {@link act} builder rather than constructing directly. */
|
|
378
305
|
constructor(registry: Registry<TSchemaReg, TEvents, TActions, keyof TStateMap & string>, states?: Map<string, State<any, any, any>>, batch_handlers?: Map<string, BatchHandler<any>>, options?: ActOptions, lanes?: ReadonlyArray<LaneConfig>, patch_fn?: PatchFn);
|
|
379
|
-
/**
|
|
380
|
-
* Circuit breaker shared by every store-polling loop (drain, the settle
|
|
381
|
-
* correlate, autoclose). Validates the knobs eagerly so out-of-range
|
|
382
|
-
* values throw at build time, not on the first cycle tick.
|
|
383
|
-
*/
|
|
306
|
+
/** Shared by drain, settle and autoclose; bad knobs throw at build. */
|
|
384
307
|
private _build_breaker;
|
|
385
|
-
/**
|
|
386
|
-
* One DrainController per active lane, plus the implicit "default" unless
|
|
387
|
-
* `onlyLanes` excludes it. Apps that declare no lanes pass no lane filter
|
|
388
|
-
* to `claim`.
|
|
389
|
-
*/
|
|
308
|
+
/** Apps that declare no lanes pass no lane filter to `claim`. */
|
|
390
309
|
private _build_drain_controllers;
|
|
391
|
-
/**
|
|
392
|
-
* Startup advisory naming declared lanes that `onlyLanes` leaves without a
|
|
393
|
-
* controller here. One process can't check that the cluster covers every
|
|
394
|
-
* lane, so it reports its own gaps.
|
|
395
|
-
*/
|
|
310
|
+
/** One process can't see the cluster, so it reports its own lane gaps. */
|
|
396
311
|
private _advise_orphaned_lanes;
|
|
397
312
|
/** Audit deps, built after the controllers so the lane set is final. */
|
|
398
313
|
private _build_audit_deps;
|
|
399
|
-
/**
|
|
400
|
-
* Correlate cycle over the classified registry. The cold-start callback
|
|
401
|
-
* arms every controller — historical events may need processing —
|
|
402
|
-
* except on writer-only instances (`drain: false`).
|
|
403
|
-
*/
|
|
404
314
|
private _build_correlate;
|
|
405
|
-
/**
|
|
406
|
-
* At cold start, re-seed each lane controller's local wake from the
|
|
407
|
-
* persisted future `deferred_at`, so an idle deferred stream (an
|
|
408
|
-
* autoclose waiting out its window) still fires on time. Streams on lanes
|
|
409
|
-
* this instance doesn't run are skipped.
|
|
410
|
-
*/
|
|
315
|
+
/** Cold start: an idle deferred stream still fires on time after a restart. */
|
|
411
316
|
private _seed_persisted_defers;
|
|
412
|
-
/** Settle loop driving correlate + drain to quiescence. */
|
|
413
317
|
private _build_settle;
|
|
414
|
-
/** True after the first `shutdown()` call. Guards idempotency. */
|
|
415
318
|
private _shutdown_promise;
|
|
416
319
|
/**
|
|
417
320
|
* Per-instance teardown: stop scheduling new work, give drain cycles
|
|
@@ -435,23 +338,12 @@ export declare class Act<TSchemaReg extends SchemaRegister<TActions>, TEvents ex
|
|
|
435
338
|
*/
|
|
436
339
|
shutdown(options?: ShutdownOptions): Promise<void>;
|
|
437
340
|
/**
|
|
438
|
-
*
|
|
439
|
-
*
|
|
440
|
-
* its own errors), so this never throws.
|
|
441
|
-
*
|
|
442
|
-
* An omitted budget is the largest `leaseMillis` among lanes with a cycle
|
|
443
|
-
* in flight (the drain's fallback for lanes that pinned none, or pinned
|
|
444
|
-
* 0, which is the same as none), with an in-flight settle counting on the
|
|
445
|
-
* fallback, capped at the maximum. Idle lanes don't count.
|
|
341
|
+
* The largest `leaseMillis` among lanes with a cycle in flight (the
|
|
342
|
+
* default for none or 0, and for a running settle), capped.
|
|
446
343
|
*/
|
|
447
344
|
private _derive_grace_ms;
|
|
448
345
|
private _await_inflight;
|
|
449
|
-
/**
|
|
450
|
-
* Subscribe to {@link Store.notify} when both the store and the
|
|
451
|
-
* registry support it. Returns the disposer (or `undefined` when no
|
|
452
|
-
* subscription was made). Errors during subscription are logged but
|
|
453
|
-
* never thrown — `notify` is a hint, not a contract.
|
|
454
|
-
*/
|
|
346
|
+
/** Failures are logged, never thrown: `notify` is a hint. */
|
|
455
347
|
private _wire_notify;
|
|
456
348
|
/**
|
|
457
349
|
* Executes an action on a state instance, committing resulting events.
|
|
@@ -716,26 +608,10 @@ export declare class Act<TSchemaReg extends SchemaRegister<TActions>, TEvents ex
|
|
|
716
608
|
* @see {@link start_correlations} for automatic correlation
|
|
717
609
|
*/
|
|
718
610
|
drain(options?: DrainOptions): Promise<Drain<TEvents>>;
|
|
719
|
-
/** Arm every active lane controller. */
|
|
720
611
|
private _arm_all;
|
|
721
|
-
/**
|
|
722
|
-
* Arm only the lane controllers whose reactions match the supplied
|
|
723
|
-
* event names (selective arming). Events with any dynamic
|
|
724
|
-
* resolver fall back to `_arm_all()` via the `"all"` sentinel — the
|
|
725
|
-
* resolver's lane isn't known until correlate runs the function.
|
|
726
|
-
* Events with no reactions are skipped; `_event_to_lanes` doesn't
|
|
727
|
-
* carry them. Returns true when any controller was armed (used by
|
|
728
|
-
* the notify handler to decide whether to schedule a settle).
|
|
729
|
-
*/
|
|
612
|
+
/** Arms only the lanes these events react on; true when any was armed. */
|
|
730
613
|
private _arm_for_event_names;
|
|
731
|
-
/**
|
|
732
|
-
*
|
|
733
|
-
* Parallel — not sequential — so a slow lane's in-flight handler does
|
|
734
|
-
* not block a fast lane's claim/dispatch/ack cycle. Each controller's
|
|
735
|
-
* `claim()` is independent (filtered by lane); the store's
|
|
736
|
-
* `SKIP LOCKED` keeps cross-controller races safe. Lifecycle events
|
|
737
|
-
* (`acked`, `blocked`) may interleave by lane — listeners filter via
|
|
738
|
-
* `lease.lane`. */
|
|
614
|
+
/** In parallel, so a slow lane never holds up a fast one. */
|
|
739
615
|
private _drain_all;
|
|
740
616
|
/**
|
|
741
617
|
* Discovers and registers new streams dynamically based on reaction resolvers.
|
|
@@ -786,14 +662,7 @@ export declare class Act<TSchemaReg extends SchemaRegister<TActions>, TEvents ex
|
|
|
786
662
|
subscribed: number;
|
|
787
663
|
last_id: number;
|
|
788
664
|
}>;
|
|
789
|
-
/**
|
|
790
|
-
* `correlate` plus whether the pass actually read the store.
|
|
791
|
-
*
|
|
792
|
-
* The settle loop needs that extra bit to decide whether the pass carries a
|
|
793
|
-
* circuit-breaker health signal, and a disarmed pass carries none. It stays
|
|
794
|
-
* internal rather than widening the public `correlate` return, which is
|
|
795
|
-
* charter-covered and has no use for it.
|
|
796
|
-
*/
|
|
665
|
+
/** `correlate` plus `scanned`, which settle needs for the breaker. */
|
|
797
666
|
private _correlate_scanned;
|
|
798
667
|
/**
|
|
799
668
|
* Starts a background poll that settles on a timer: each tick looks for
|
|
@@ -1049,11 +918,7 @@ export declare class Act<TSchemaReg extends SchemaRegister<TActions>, TEvents ex
|
|
|
1049
918
|
* @see {@link claim} for how priority biases scheduling
|
|
1050
919
|
*/
|
|
1051
920
|
prioritize(filter: StreamFilter, priority: number): Promise<number>;
|
|
1052
|
-
/**
|
|
1053
|
-
* Run one close: the cycle with this Act's ports, then emit `closed`. Shared by `close()` and the drain's
|
|
1054
|
-
* reaction-requested closes. The close actor lets a custom correlator
|
|
1055
|
-
* still tag tenant context or trace ids.
|
|
1056
|
-
*/
|
|
921
|
+
/** Shared by `close()` and reaction-requested closes. */
|
|
1057
922
|
private _run_close;
|
|
1058
923
|
/**
|
|
1059
924
|
* Close the books — guard, archive, truncate, and optionally restart streams.
|
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,
|
|
1
|
+
{"version":3,"file":"act.d.ts","sourceRoot":"","sources":["../../src/act.ts"],"names":[],"mappings":"AAWA,OAAO,EAOL,KAAK,qBAAqB,EAC1B,KAAK,YAAY,EAgBjB,KAAK,OAAO,EAWb,MAAM,qBAAqB,CAAC;AAQ7B,YAAY,EAAE,qBAAqB,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAE/E,OAAO,EAA6B,KAAK,MAAM,EAAS,MAAM,YAAY,CAAC;AAE3E,OAAO,KAAK,EACV,KAAK,EACL,IAAI,EACJ,aAAa,EACb,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,WAAW,EACX,SAAS,EACT,UAAU,EACV,SAAS,EACT,KAAK,EACL,YAAY,EACZ,SAAS,EACT,WAAW,EACX,IAAI,EACJ,UAAU,EACV,KAAK,EACL,UAAU,EAEV,KAAK,EACL,QAAQ,EACR,WAAW,EACX,UAAU,EACV,MAAM,EACN,cAAc,EACd,OAAO,EACP,aAAa,EACb,eAAe,EACf,QAAQ,EACR,KAAK,EAEL,iBAAiB,EACjB,YAAY,EACZ,cAAc,EACd,MAAM,EACP,MAAM,kBAAkB,CAAC;AAO1B,OAAO,EACL,KAAK,eAAe,EACpB,KAAK,eAAe,EACpB,+BAA+B,EAC/B,wBAAwB,EACxB,sBAAsB,EACtB,8BAA8B,EA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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAyDG;IACG,KAAK,CAAC,OAAO,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC,WAAW,CAAC,CAIxD;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA6BG;IACH,MAAM,CAAC,OAAO,GAAE,aAAkB,GAAG,IAAI,CAOxC;CACF"}
|
|
@@ -1,38 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @packageDocumentation
|
|
3
3
|
* @module act/adapters
|
|
4
|
-
* In-memory event store adapter for
|
|
5
|
-
*
|
|
6
|
-
* This adapter implements the Store interface and is suitable for development, testing, and demonstration purposes.
|
|
7
|
-
* All data is stored in memory and lost on process exit.
|
|
4
|
+
* In-memory event store adapter for development and tests.
|
|
8
5
|
*
|
|
9
6
|
* @category Adapters
|
|
10
7
|
*/
|
|
11
8
|
import type { BlockedLease, Committed, EventMeta, Lease, Message, Query, QueryStatsOptions, QueryStreams, QueryStreamsResult, Schema, Schemas, Store, StreamFilter, StreamPosition, StreamStats, SubscribeInput } from "../types/index.js";
|
|
12
9
|
/**
|
|
13
|
-
* In-memory event store
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
* It stores all events in memory and is suitable for:
|
|
17
|
-
* - Development and prototyping
|
|
18
|
-
* - Unit and integration testing
|
|
19
|
-
* - Demonstrations and examples
|
|
20
|
-
*
|
|
21
|
-
* **Not suitable for production** - all data is lost when the process exits.
|
|
22
|
-
* Use {@link PostgresStore} for production deployments.
|
|
23
|
-
*
|
|
24
|
-
* The in-memory store provides:
|
|
25
|
-
* - Full {@link Store} interface implementation
|
|
26
|
-
* - Optimistic concurrency control
|
|
27
|
-
* - Stream leasing for distributed processing simulation
|
|
28
|
-
* - Snapshot support
|
|
29
|
-
* - Fast performance (no I/O overhead)
|
|
10
|
+
* In-memory event store: the default when no other store is injected.
|
|
11
|
+
* For development, tests and examples; all data is lost when the process
|
|
12
|
+
* exits. Use {@link PostgresStore} in production.
|
|
30
13
|
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
* `do()`. An in-memory store is single-process by definition, so there is
|
|
34
|
-
* no remote writer to be notified of. The {@link Act} orchestrator
|
|
35
|
-
* detects the absence and falls back to the existing debounce/poll path.
|
|
14
|
+
* `Store.notify` is not implemented: a single process has no remote writer
|
|
15
|
+
* to hear from, and local commits already arm the drain.
|
|
36
16
|
*
|
|
37
17
|
* @example Using in tests
|
|
38
18
|
* ```typescript
|
|
@@ -85,15 +65,7 @@ export declare class InMemoryStore implements Store {
|
|
|
85
65
|
private _streams;
|
|
86
66
|
/** Correlate checkpoint: how far the log has been READ. */
|
|
87
67
|
private _correlated_at;
|
|
88
|
-
/**
|
|
89
|
-
* Per-correlator checkpoint and lease, keyed by correlator.
|
|
90
|
-
*
|
|
91
|
-
* Keyed rather than singular because correlators that look for different
|
|
92
|
-
* things read the log for different reasons: sharing one position lets a
|
|
93
|
-
* partial-behaviour worker inherit another's, and sharing one lease lets
|
|
94
|
-
* one starve the other. Callers that supply no correlator use
|
|
95
|
-
* `_correlated_at` instead, the shared checkpoint.
|
|
96
|
-
*/
|
|
68
|
+
/** Per-correlator checkpoint and lease; keyless callers use `_correlated_at`. */
|
|
97
69
|
private _correlators;
|
|
98
70
|
private _stream_versions;
|
|
99
71
|
private _pii;
|
|
@@ -101,66 +73,16 @@ export declare class InMemoryStore implements Store {
|
|
|
101
73
|
private _put_pii;
|
|
102
74
|
private _first_index_after;
|
|
103
75
|
private _with_pii;
|
|
104
|
-
/**
|
|
105
|
-
* Dispose of the store and clear all events.
|
|
106
|
-
* @returns Promise that resolves when disposal is complete.
|
|
107
|
-
*/
|
|
108
76
|
dispose(): Promise<void>;
|
|
109
|
-
/**
|
|
110
|
-
* Seed the store with initial data (no-op for in-memory).
|
|
111
|
-
* @returns Promise that resolves when seeding is complete.
|
|
112
|
-
*/
|
|
113
77
|
seed(): Promise<void>;
|
|
114
|
-
/**
|
|
115
|
-
* Drop all data from the store.
|
|
116
|
-
* @returns Promise that resolves when the store is cleared.
|
|
117
|
-
*/
|
|
118
78
|
drop(): Promise<void>;
|
|
119
79
|
private in_query;
|
|
120
80
|
private _stream_matches;
|
|
121
|
-
/**
|
|
122
|
-
* Index of the latest snapshot of the queried stream, or -1. `with_snaps`
|
|
123
|
-
* on an exact single stream resumes there, so earlier events aren't read.
|
|
124
|
-
* The orchestrator asks only for unbounded current-state loads, so the
|
|
125
|
-
* floor applies whenever asked; an explicit `after` wins over it.
|
|
126
|
-
*/
|
|
81
|
+
/** Index of the stream's latest snapshot, or -1; an explicit `after` wins. */
|
|
127
82
|
private _snap_floor;
|
|
128
|
-
/**
|
|
129
|
-
* Query events in the store, optionally filtered by query options.
|
|
130
|
-
* @param callback - Function to call for each event.
|
|
131
|
-
* @param query - Optional query options.
|
|
132
|
-
* @returns The number of events processed.
|
|
133
|
-
*/
|
|
134
83
|
query<E extends Schemas>(callback: (event: Committed<E, keyof E>) => void, query?: Query): Promise<number>;
|
|
135
|
-
/**
|
|
136
|
-
* Commit one or more events to a stream.
|
|
137
|
-
* @param stream - The stream name.
|
|
138
|
-
* @param msgs - The events/messages to commit.
|
|
139
|
-
* @param meta - Event metadata.
|
|
140
|
-
* @param expectedVersion - Optional optimistic concurrency check.
|
|
141
|
-
* @returns The committed events with metadata.
|
|
142
|
-
* @throws ConcurrencyError if expectedVersion does not match.
|
|
143
|
-
*/
|
|
144
84
|
commit<E extends Schemas>(stream: string, msgs: Message<E, keyof E>[], meta: EventMeta, expectedVersion?: number): Promise<Committed<E, keyof E>[]>;
|
|
145
|
-
/**
|
|
146
|
-
* Atomically discovers and leases streams for processing.
|
|
147
|
-
* Fuses poll + lease into a single operation.
|
|
148
|
-
* @param lagging - Max streams from lagging frontier.
|
|
149
|
-
* @param leading - Max streams from leading frontier.
|
|
150
|
-
* @param by - Lease holder identifier.
|
|
151
|
-
* @param millis - Lease duration in milliseconds.
|
|
152
|
-
* @returns Granted leases.
|
|
153
|
-
*/
|
|
154
85
|
claim(lagging: number, leading: number, by: string, millis: number, lane?: string): Promise<Lease[]>;
|
|
155
|
-
/**
|
|
156
|
-
* Registers streams for event processing. When the same stream is
|
|
157
|
-
* resubscribed with a different priority, the **maximum** wins — so
|
|
158
|
-
* the highest-priority registered reaction sets the scheduling lane.
|
|
159
|
-
* Use {@link prioritize} for operator runtime overrides.
|
|
160
|
-
*
|
|
161
|
-
* @param streams - Streams to register with optional source + priority.
|
|
162
|
-
* @returns subscribed count and current max watermark.
|
|
163
|
-
*/
|
|
164
86
|
subscribe(streams: SubscribeInput[], correlated_at?: number, correlator?: {
|
|
165
87
|
key: string;
|
|
166
88
|
by: string;
|
|
@@ -171,10 +93,6 @@ export declare class InMemoryStore implements Store {
|
|
|
171
93
|
correlated_at: number;
|
|
172
94
|
correlating?: boolean | undefined;
|
|
173
95
|
}>;
|
|
174
|
-
/**
|
|
175
|
-
* Acknowledge completion of processing for leased streams.
|
|
176
|
-
* @param leases - Leases to acknowledge, including last processed watermark and lease holder.
|
|
177
|
-
*/
|
|
178
96
|
ack(leases: Lease[]): Promise<{
|
|
179
97
|
stream: string;
|
|
180
98
|
source: string | undefined;
|
|
@@ -184,11 +102,6 @@ export declare class InMemoryStore implements Store {
|
|
|
184
102
|
lagging: boolean;
|
|
185
103
|
lane: string;
|
|
186
104
|
}[]>;
|
|
187
|
-
/**
|
|
188
|
-
* Block a stream for processing after failing to process and reaching max retries with blocking enabled.
|
|
189
|
-
* @param leases - Leases to block, including lease holder and last error message.
|
|
190
|
-
* @returns Blocked leases.
|
|
191
|
-
*/
|
|
192
105
|
block(leases: BlockedLease[]): Promise<{
|
|
193
106
|
stream: string;
|
|
194
107
|
source: string | undefined;
|
|
@@ -199,98 +112,16 @@ export declare class InMemoryStore implements Store {
|
|
|
199
112
|
lagging: boolean;
|
|
200
113
|
lane: string;
|
|
201
114
|
}[]>;
|
|
202
|
-
/**
|
|
203
|
-
* Hold the matched streams out of {@link claim} until `deferred_at`
|
|
204
|
-
* (ms since epoch) — see {@link Store.defer}. Accepts an explicit list
|
|
205
|
-
* of names or a {@link StreamFilter}, mirroring {@link reset}/{@link unblock}.
|
|
206
|
-
* Persisted store state (unlike in-process backoff), so the skip is honored
|
|
207
|
-
* by every competing worker. Unknown names are silently skipped.
|
|
208
|
-
*
|
|
209
|
-
* @returns Count of streams whose `deferred_at` was set.
|
|
210
|
-
*/
|
|
211
115
|
defer(input: string[] | StreamFilter, deferred_at: number): Promise<number>;
|
|
212
|
-
/**
|
|
213
|
-
* The streams named by `input`: an explicit list (de-duplicated, so a
|
|
214
|
-
* repeated name counts once, matching the SQL adapters' set-based
|
|
215
|
-
* `stream = ANY(...)`; unknown names are skipped) or a {@link StreamFilter}.
|
|
216
|
-
*/
|
|
116
|
+
/** De-duplicated like the SQL `stream = ANY(...)`; unknown names skipped. */
|
|
217
117
|
private _select;
|
|
218
|
-
/**
|
|
219
|
-
* Build a predicate from a {@link StreamFilter}. Compiled regexes are
|
|
220
|
-
* cached in the closure so callers can apply it across the streams
|
|
221
|
-
* map without re-compiling per iteration.
|
|
222
|
-
*/
|
|
223
118
|
private _filter_predicate;
|
|
224
|
-
/**
|
|
225
|
-
* Reset watermarks to -1, clearing retry, blocked, error, and lease
|
|
226
|
-
* state so the matched streams can be replayed from the beginning.
|
|
227
|
-
* Accepts either an explicit list of names or a {@link StreamFilter}.
|
|
228
|
-
*
|
|
229
|
-
* @param input - Stream names or a filter selecting the streams to reset.
|
|
230
|
-
* @returns Count of streams that were actually reset.
|
|
231
|
-
*/
|
|
232
119
|
reset(input: string[] | StreamFilter): Promise<number>;
|
|
233
|
-
/**
|
|
234
|
-
* Wipe the sensitive-data payload for every event on the stream — see
|
|
235
|
-
* {@link Store.forget_pii}. O(1) drop of the stream's inner Map; the size of
|
|
236
|
-
* that Map is the count of events that had PII. Idempotent: a second call
|
|
237
|
-
* finds no inner Map and returns `0`.
|
|
238
|
-
*
|
|
239
|
-
* @param stream - Target stream.
|
|
240
|
-
* @returns Count of events whose isolated PII payload was deleted.
|
|
241
|
-
*/
|
|
242
120
|
forget_pii(stream: string): Promise<number>;
|
|
243
|
-
/**
|
|
244
|
-
* Clear the blocked flag (and retry / error / lease) on the matched
|
|
245
|
-
* streams without touching the watermark. Streams that aren't blocked
|
|
246
|
-
* at call time are silently skipped. Accepts either an explicit list
|
|
247
|
-
* of names or a {@link StreamFilter}. The filter form always restricts
|
|
248
|
-
* to blocked streams — passing `blocked: false` matches nothing.
|
|
249
|
-
* See {@link Store.unblock}.
|
|
250
|
-
*
|
|
251
|
-
* @param input - Stream names or a filter selecting the streams to unblock.
|
|
252
|
-
* @returns Count of streams that were actually flipped (were blocked).
|
|
253
|
-
*/
|
|
254
121
|
unblock(input: string[] | StreamFilter): Promise<number>;
|
|
255
|
-
/**
|
|
256
|
-
* Bulk-update priority of streams matching `filter`. Mirrors
|
|
257
|
-
* {@link query_streams}'s filter semantics — see {@link Store.prioritize}.
|
|
258
|
-
* Unlike {@link subscribe} (which keeps `max()` of registered
|
|
259
|
-
* priorities), this sets the priority outright — operator override
|
|
260
|
-
* for the build-time scheduling policy.
|
|
261
|
-
*
|
|
262
|
-
* @returns Count of streams whose priority changed.
|
|
263
|
-
*/
|
|
264
122
|
prioritize(filter: StreamFilter, priority: number): Promise<number>;
|
|
265
|
-
/**
|
|
266
|
-
* Streams registered subscription positions to the callback, ordered by
|
|
267
|
-
* stream name. Returns the highest event id in the store and the count
|
|
268
|
-
* of positions emitted.
|
|
269
|
-
*/
|
|
270
123
|
query_streams(callback: (position: StreamPosition) => void, query?: QueryStreams): Promise<QueryStreamsResult>;
|
|
271
|
-
/**
|
|
272
|
-
* Per-stream aggregated stats — see {@link Store.query_stats}.
|
|
273
|
-
*
|
|
274
|
-
* Single forward scan over the in-memory event list, accumulating per
|
|
275
|
-
* stream. The "cheap heads" cost tier from durable adapters doesn't
|
|
276
|
-
* apply here (InMemory has no indexes); correctness is the goal, perf
|
|
277
|
-
* is a non-issue.
|
|
278
|
-
*
|
|
279
|
-
* Scope rules:
|
|
280
|
-
* - Array `input` — explicit stream names, regardless of subscription.
|
|
281
|
-
* - Filter `input` — `stream`/`stream_exact` match against event-bearing
|
|
282
|
-
* stream names. Empty filter `{}` matches every event-bearing stream.
|
|
283
|
-
*/
|
|
284
124
|
query_stats<E extends Schemas>(input: string[] | Pick<StreamFilter, "stream" | "stream_exact">, options?: QueryStatsOptions<E>): Promise<Map<string, StreamStats<E>>>;
|
|
285
|
-
/**
|
|
286
|
-
* Atomically truncates streams and seeds each with a snapshot or tombstone.
|
|
287
|
-
* Windowed targets (`before` set) prune the prefix below the closest safe
|
|
288
|
-
* `__snapshot__` instead — no seed, subscriptions untouched, no-op when no
|
|
289
|
-
* snapshot qualifies.
|
|
290
|
-
* @param targets - Streams to truncate with optional snapshot state and meta,
|
|
291
|
-
* or a `before`/`max_id` boundary for a windowed prefix delete.
|
|
292
|
-
* @returns Map keyed by stream name, each entry with `deleted` count and `committed` event.
|
|
293
|
-
*/
|
|
294
125
|
truncate(targets: Array<{
|
|
295
126
|
stream: string;
|
|
296
127
|
snapshot?: Schema;
|
|
@@ -302,18 +133,7 @@ export declare class InMemoryStore implements Store {
|
|
|
302
133
|
committed: Committed<Schemas, keyof Schemas>;
|
|
303
134
|
before?: Date;
|
|
304
135
|
}>>;
|
|
305
|
-
/**
|
|
306
|
-
* Atomically wipe-and-rebuild the store under an in-process snapshot.
|
|
307
|
-
*
|
|
308
|
-
* Captures every index state up front, clears it, then hands the
|
|
309
|
-
* orchestrator a per-event insert `callback` via the driver. Any
|
|
310
|
-
* throw inside the driver restores the snapshot, leaving the store
|
|
311
|
-
* byte-for-byte unchanged from the operator's perspective.
|
|
312
|
-
*
|
|
313
|
-
* `id`s are reassigned `0..N-1` as events arrive (dense — the
|
|
314
|
-
* monotonic id counter restarts at 0 for the rebuild). `created` is
|
|
315
|
-
* preserved verbatim from the source.
|
|
316
|
-
*/
|
|
136
|
+
/** A throw inside the driver restores the captured state. Ids restart at 0. */
|
|
317
137
|
restore(driver: (callback: (event: Committed<Schemas, keyof Schemas>) => Promise<number>) => Promise<void>): Promise<void>;
|
|
318
138
|
}
|
|
319
139
|
//# sourceMappingURL=in-memory-store.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"in-memory-store.d.ts","sourceRoot":"","sources":["../../../src/adapters/in-memory-store.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"in-memory-store.d.ts","sourceRoot":"","sources":["../../../src/adapters/in-memory-store.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,OAAO,KAAK,EACV,YAAY,EACZ,SAAS,EACT,SAAS,EACT,KAAK,EACL,OAAO,EACP,KAAK,EACL,iBAAiB,EACjB,YAAY,EACZ,kBAAkB,EAClB,MAAM,EACN,OAAO,EACP,KAAK,EACL,YAAY,EACZ,cAAc,EACd,WAAW,EACX,cAAc,EACf,MAAM,mBAAmB,CAAC;AAqM3B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoDG;AACH,qBAAa,aAAc,YAAW,KAAK;IACzC,OAAO,CAAC,OAAO,CAA2C;IAE1D,OAAO,CAAC,QAAQ,CAAK;IACrB,OAAO,CAAC,QAAQ,CAA0C;IAC1D,2DAA2D;IAC3D,OAAO,CAAC,cAAc,CAAM;IAC5B,iFAAiF;IACjF,OAAO,CAAC,YAAY,CAGhB;IACJ,OAAO,CAAC,gBAAgB,CAAkC;IAG1D,OAAO,CAAC,IAAI,CAAgE;IAE5E,OAAO,CAAC,cAAc;IAStB,OAAO,CAAC,QAAQ;IAUhB,OAAO,CAAC,kBAAkB;IAY1B,OAAO,CAAC,SAAS;IASX,OAAO,kBAGZ;IAEK,IAAI,kBAET;IAEK,IAAI,kBAIT;IAED,OAAO,CAAC,QAAQ;IAiBhB,OAAO,CAAC,eAAe;IAMvB,8EAA8E;IAC9E,OAAO,CAAC,WAAW;IAeb,KAAK,CAAC,CAAC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ACjB,QAAQ,EAAE,CAAC,QAAQ,EAAE,cAAc,KAAK,IAAI,EAC5C,KAAK,CAAC,EAAE,YAAY,GACnB,OAAO,CAAC,kBAAkB,CAAC,CAkD7B;IAEK,WAAW,CAAC,CAAC,SAAS,OAAO,EACjC,KAAK,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC,YAAY,EAAE,QAAQ,GAAG,cAAc,CAAC,EAC/D,OAAO,CAAC,EAAE,iBAAiB,CAAC,CAAC,CAAC,GAC7B,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CA+EtC;IAEK,QAAQ,CACZ,OAAO,EAAE,KAAK,CAAC;QACb,MAAM,EAAE,MAAM,CAAC;QACf,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,IAAI,CAAC,EAAE,SAAS,CAAC;QACjB,MAAM,CAAC,EAAE,IAAI,CAAC;QACd,MAAM,CAAC,EAAE,MAAM,CAAC;KACjB,CAAC;iBAMW,MAAM;mBACJ,SAAS,CAAC,OAAO,EAAE,MAAM,OAAO,CAAC;iBACnC,IAAI;QA2DlB;IAED,+EAA+E;IACzE,OAAO,CACX,MAAM,EAAE,CACN,QAAQ,EAAE,CAAC,KAAK,EAAE,SAAS,CAAC,OAAO,EAAE,MAAM,OAAO,CAAC,KAAK,OAAO,CAAC,MAAM,CAAC,KACpE,OAAO,CAAC,IAAI,CAAC,GACjB,OAAO,CAAC,IAAI,CAAC,CAyCf;CACF"}
|
|
@@ -67,14 +67,6 @@ export type CloseCycleDeps = {
|
|
|
67
67
|
*/
|
|
68
68
|
readonly forget_subscribed?: (streams: string[]) => void;
|
|
69
69
|
};
|
|
70
|
-
/**
|
|
71
|
-
* Scan window and pass cap for {@link catch_up_correlation}. Bounded, so a
|
|
72
|
-
* close behind a large backlog skips the stream (the documented retryable
|
|
73
|
-
* outcome) rather than scanning the whole log inside an operator call.
|
|
74
|
-
*
|
|
75
|
-
* @internal
|
|
76
|
-
*/
|
|
77
|
-
export declare const CLOSE_CATCH_UP_LIMIT = 1000;
|
|
78
70
|
/**
|
|
79
71
|
* Advance correlation until the read cursor reaches `until`, and report
|
|
80
72
|
* where it landed. The safety probe cannot judge a subscription's pending
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"close-cycle.d.ts","sourceRoot":"","sources":["../../../src/internal/close-cycle.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,KAAK,EACV,WAAW,EACX,WAAW,EACX,MAAM,EAEN,KAAK,EACN,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"close-cycle.d.ts","sourceRoot":"","sources":["../../../src/internal/close-cycle.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,KAAK,EACV,WAAW,EACX,WAAW,EACX,MAAM,EAEN,KAAK,EACN,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAGjD;;;;;GAKG;AACH,MAAM,MAAM,cAAc,GAAG;IAC3B,QAAQ,CAAC,oBAAoB,EAAE,MAAM,CAAC;IACtC,QAAQ,CAAC,cAAc,EAAE,WAAW,CAAC,MAAM,EAAE,KAAK,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;IACnE,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAC7B,QAAQ,CAAC,SAAS,EAAE,KAAK,CAAC,WAAW,CAAC,CAAC;IACvC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB;;;;;OAKG;IACH,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B;;;;OAIG;IACH,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,CAAC;IAClC;;;;;;;;;OASG;IACH,QAAQ,CAAC,oBAA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