@rotorsoft/act 1.32.19 → 1.32.20
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/README.md +2 -2
- package/dist/.tsbuildinfo +1 -1
- package/dist/@types/act.d.ts +18 -21
- package/dist/@types/act.d.ts.map +1 -1
- package/dist/@types/internal/correlate-cycle.d.ts +7 -1
- package/dist/@types/internal/correlate-cycle.d.ts.map +1 -1
- package/dist/index.cjs +22 -22
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +22 -22
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1665,13 +1665,14 @@ var CorrelateCycle = class {
|
|
|
1665
1665
|
cd,
|
|
1666
1666
|
max_subscribed_streams,
|
|
1667
1667
|
declared_lanes,
|
|
1668
|
+
shard,
|
|
1668
1669
|
on_init,
|
|
1669
1670
|
on_init_async,
|
|
1670
1671
|
cold_start_back_scan = DEFAULT_COLD_START_BACK_SCAN,
|
|
1671
1672
|
lease_millis = DEFAULT_CORRELATION_LEASE_MS
|
|
1672
1673
|
}) {
|
|
1673
1674
|
this._lease_millis = lease_millis;
|
|
1674
|
-
this._key = registry_key(registry.events);
|
|
1675
|
+
this._key = shard ? `${registry_key(registry.events)}:${[...shard].sort().join(",")}` : registry_key(registry.events);
|
|
1675
1676
|
this._dynamic_subscriptions = new LruMap(max_subscribed_streams);
|
|
1676
1677
|
this._registry = registry;
|
|
1677
1678
|
this._declared_lanes = declared_lanes;
|
|
@@ -3671,6 +3672,8 @@ var Act = class {
|
|
|
3671
3672
|
// Declared lanes (not active ones): a lane another process claims is
|
|
3672
3673
|
// still a valid destination.
|
|
3673
3674
|
declared_lanes: new Set(this._declared_lanes),
|
|
3675
|
+
// Built after the controllers, so their keys are the active lanes.
|
|
3676
|
+
shard: this._drain_controllers.size < this._declared_lanes.length ? [...this._drain_controllers.keys()] : void 0,
|
|
3674
3677
|
on_init: () => {
|
|
3675
3678
|
if (this._drain && this._reactive_events.size > 0) this._arm_all();
|
|
3676
3679
|
},
|
|
@@ -4367,11 +4370,11 @@ var Act = class {
|
|
|
4367
4370
|
});
|
|
4368
4371
|
}
|
|
4369
4372
|
/**
|
|
4370
|
-
* Atomically wipe the store and rebuild it from an
|
|
4371
|
-
*
|
|
4372
|
-
* `
|
|
4373
|
-
*
|
|
4374
|
-
*
|
|
4373
|
+
* Atomically wipe the store and rebuild it from an event source. The
|
|
4374
|
+
* framework owns iteration, validation, `drop_snapshots` filtering,
|
|
4375
|
+
* `on_progress`, and the per-call `old → new` causation remap; the
|
|
4376
|
+
* adapter's {@link Store.restore} driver supplies the transaction
|
|
4377
|
+
* lifecycle and per-event insert.
|
|
4375
4378
|
*
|
|
4376
4379
|
* Throws if the adapter has no restore capability. Throws on the
|
|
4377
4380
|
* first invalid event (negative version, malformed `created`) with
|
|
@@ -4379,33 +4382,30 @@ var Act = class {
|
|
|
4379
4382
|
* the adapter means a failing restore leaves the store byte-for-byte
|
|
4380
4383
|
* unchanged.
|
|
4381
4384
|
*
|
|
4382
|
-
* @param source -
|
|
4383
|
-
* rather than buffered so
|
|
4384
|
-
* Each event's original `id`
|
|
4385
|
-
* never written through —
|
|
4385
|
+
* @param source - Any {@link EventSource}: a `CsvFile` backup or
|
|
4386
|
+
* another store. Read in batches rather than buffered, so
|
|
4387
|
+
* multi-million-event backups don't OOM. Each event's original `id`
|
|
4388
|
+
* is used as a causation lookup key but never written through —
|
|
4389
|
+
* adapters renumber densely.
|
|
4386
4390
|
* @param opts - {@link ScanOptions}. `drop_snapshots` skips
|
|
4387
4391
|
* `__snapshot__` events (counted in the result); `on_progress`
|
|
4388
4392
|
* fires once per event.
|
|
4393
|
+
* @param sink - Where the events land. Defaults to this Act's store.
|
|
4389
4394
|
* @returns {@link ScanResult} with `kept`, `duration_ms`, and
|
|
4390
4395
|
* `dropped` per-category counters.
|
|
4391
4396
|
*
|
|
4392
|
-
* @example
|
|
4397
|
+
* @example Restore a CSV backup into the connected store
|
|
4393
4398
|
* ```typescript
|
|
4394
|
-
*
|
|
4395
|
-
* for (const line of blob.split("\n").slice(1)) {
|
|
4396
|
-
* const [id, name, data, stream, version, created, meta] = parse(line);
|
|
4397
|
-
* yield {
|
|
4398
|
-
* id: +id, name, data: JSON.parse(data), stream,
|
|
4399
|
-
* version: +version, created: new Date(created),
|
|
4400
|
-
* meta: JSON.parse(meta),
|
|
4401
|
-
* };
|
|
4402
|
-
* }
|
|
4403
|
-
* }
|
|
4404
|
-
* const result = await app.restore(parseCsv(csvBlob), {});
|
|
4399
|
+
* const result = await app.restore(new CsvFile({ path: "./backup.csv" }));
|
|
4405
4400
|
* console.log(`Restored ${result.kept} events in ${result.duration_ms}ms`);
|
|
4406
4401
|
* await cache().clear(); // operator's responsibility
|
|
4407
4402
|
* ```
|
|
4408
4403
|
*
|
|
4404
|
+
* @example Copy one store into another
|
|
4405
|
+
* ```typescript
|
|
4406
|
+
* await app.restore(pg, {}, sqlite);
|
|
4407
|
+
* ```
|
|
4408
|
+
*
|
|
4409
4409
|
* @see {@link Store.restore} for the underlying driver-pattern primitive.
|
|
4410
4410
|
*/
|
|
4411
4411
|
async restore(source, opts = {}, sink) {
|