@rotorsoft/act 0.30.0 → 0.30.1
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 +1 -1
- package/dist/.tsbuildinfo +1 -1
- package/dist/@types/act.d.ts +43 -5
- package/dist/@types/act.d.ts.map +1 -1
- package/dist/@types/types/ports.d.ts +10 -4
- package/dist/@types/types/ports.d.ts.map +1 -1
- package/dist/@types/types/reaction.d.ts +4 -1
- package/dist/@types/types/reaction.d.ts.map +1 -1
- package/dist/index.cjs +52 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +52 -8
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1622,6 +1622,46 @@ var Act = class {
|
|
|
1622
1622
|
this._settle_timer = void 0;
|
|
1623
1623
|
}
|
|
1624
1624
|
}
|
|
1625
|
+
/**
|
|
1626
|
+
* Reset reaction stream watermarks and request a drain on the next
|
|
1627
|
+
* `drain()` / `settle()` cycle.
|
|
1628
|
+
*
|
|
1629
|
+
* Use this to replay events through projections (or other reaction targets)
|
|
1630
|
+
* after changing handler logic. Equivalent to calling `store().reset(streams)`
|
|
1631
|
+
* directly, but also raises the orchestrator's internal "needs drain" flag —
|
|
1632
|
+
* `store().reset(...)` alone leaves the flag untouched, so a settled app
|
|
1633
|
+
* would short-circuit and skip the replay.
|
|
1634
|
+
*
|
|
1635
|
+
* Pair with `app.settle()` (or a single `app.drain()` for small streams).
|
|
1636
|
+
* `settle()` loops correlate→drain until no progress is made, so one call
|
|
1637
|
+
* fully catches up paginated streams without forcing callers to roll
|
|
1638
|
+
* their own loop.
|
|
1639
|
+
*
|
|
1640
|
+
* @param streams - Reaction target streams (e.g., projection names) to reset
|
|
1641
|
+
* @returns Count of streams that were actually reset
|
|
1642
|
+
*
|
|
1643
|
+
* @example Rebuild a projection (production)
|
|
1644
|
+
* ```typescript
|
|
1645
|
+
* await app.reset(["my-projection"]);
|
|
1646
|
+
* app.settle({ eventLimit: 1000 }); // emits "settled" when fully replayed
|
|
1647
|
+
* ```
|
|
1648
|
+
*
|
|
1649
|
+
* @example Rebuild a projection (tests / scripts)
|
|
1650
|
+
* ```typescript
|
|
1651
|
+
* await app.reset(["my-projection"]);
|
|
1652
|
+
* await app.drain({ eventLimit: 1000 }); // small streams: one pass is enough
|
|
1653
|
+
* ```
|
|
1654
|
+
*
|
|
1655
|
+
* @see {@link Store.reset} for the underlying store primitive
|
|
1656
|
+
* @see {@link settle} for the debounced full-catch-up loop
|
|
1657
|
+
*/
|
|
1658
|
+
async reset(streams) {
|
|
1659
|
+
const count = await store().reset(streams);
|
|
1660
|
+
if (count > 0 && this._reactive_events.size > 0) {
|
|
1661
|
+
this._needs_drain = true;
|
|
1662
|
+
}
|
|
1663
|
+
return count;
|
|
1664
|
+
}
|
|
1625
1665
|
/**
|
|
1626
1666
|
* Close the books — guard, archive, truncate, and optionally restart streams.
|
|
1627
1667
|
*
|
|
@@ -1789,15 +1829,19 @@ var Act = class {
|
|
|
1789
1829
|
/**
|
|
1790
1830
|
* Debounced, non-blocking correlate→drain cycle.
|
|
1791
1831
|
*
|
|
1792
|
-
* Call this after `app.do()` to schedule a background
|
|
1793
|
-
* calls within the debounce window are coalesced
|
|
1794
|
-
* correlate→drain in a loop until
|
|
1795
|
-
*
|
|
1832
|
+
* Call this after `app.do()` (or `app.reset()`) to schedule a background
|
|
1833
|
+
* drain. Multiple rapid calls within the debounce window are coalesced
|
|
1834
|
+
* into a single cycle. Runs correlate→drain in a loop until a pass makes
|
|
1835
|
+
* no progress — no new subscriptions, no acks, no blocks — then emits
|
|
1836
|
+
* the `"settled"` lifecycle event. This means a single `settle()` call
|
|
1837
|
+
* fully catches up paginated streams (e.g. after `reset()` on a long
|
|
1838
|
+
* projection) without forcing callers to loop.
|
|
1796
1839
|
*
|
|
1797
1840
|
* @param options - Settle configuration options
|
|
1798
1841
|
* @param options.debounceMs - Debounce window in milliseconds (default: 10)
|
|
1799
1842
|
* @param options.correlate - Query filter for correlation scans (default: `{ after: -1, limit: 100 }`)
|
|
1800
|
-
* @param options.maxPasses -
|
|
1843
|
+
* @param options.maxPasses - Cap on correlate→drain loops (default: `Infinity`).
|
|
1844
|
+
* Early-exit on no-progress means the cap only matters in pathological cases.
|
|
1801
1845
|
* @param options.streamLimit - Maximum streams per drain cycle (default: 10)
|
|
1802
1846
|
* @param options.eventLimit - Maximum events per stream (default: 10)
|
|
1803
1847
|
* @param options.leaseMillis - Lease duration in milliseconds (default: 10000)
|
|
@@ -1819,7 +1863,7 @@ var Act = class {
|
|
|
1819
1863
|
const {
|
|
1820
1864
|
debounceMs = 10,
|
|
1821
1865
|
correlate: correlateQuery = { after: -1, limit: 100 },
|
|
1822
|
-
maxPasses =
|
|
1866
|
+
maxPasses = Infinity,
|
|
1823
1867
|
...drainOptions
|
|
1824
1868
|
} = options;
|
|
1825
1869
|
if (this._settle_timer) clearTimeout(this._settle_timer);
|
|
@@ -1835,9 +1879,9 @@ var Act = class {
|
|
|
1835
1879
|
...correlateQuery,
|
|
1836
1880
|
after: this._correlation_checkpoint
|
|
1837
1881
|
});
|
|
1838
|
-
if (subscribed === 0 && i > 0) break;
|
|
1839
1882
|
lastDrain = await this.drain(drainOptions);
|
|
1840
|
-
|
|
1883
|
+
const made_progress = subscribed > 0 || lastDrain.acked.length > 0 || lastDrain.blocked.length > 0;
|
|
1884
|
+
if (!made_progress) break;
|
|
1841
1885
|
}
|
|
1842
1886
|
if (lastDrain) this.emit("settled", lastDrain);
|
|
1843
1887
|
})().catch((err) => logger3.error(err)).finally(() => {
|