@rotorsoft/act-tck 1.30.5 → 1.32.0
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/store-tck.d.ts +16 -0
- package/dist/@types/store-tck.d.ts.map +1 -1
- package/dist/index.cjs +140 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +140 -0
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -1759,6 +1759,146 @@ var runStoreTck = (options) => {
|
|
|
1759
1759
|
await store.subscribe([{ stream: s }]);
|
|
1760
1760
|
expect8(await read()).toBe(0);
|
|
1761
1761
|
});
|
|
1762
|
+
describe8("correlate checkpoint", () => {
|
|
1763
|
+
const peek = async () => (await store.subscribe([])).correlated_at;
|
|
1764
|
+
it7("round-trips an advance through subscribe", async () => {
|
|
1765
|
+
const base = await peek();
|
|
1766
|
+
expect8((await store.subscribe([], base + 10)).correlated_at).toBe(
|
|
1767
|
+
base + 10
|
|
1768
|
+
);
|
|
1769
|
+
expect8(await peek()).toBe(base + 10);
|
|
1770
|
+
});
|
|
1771
|
+
it7("persists only when greater than the stored value", async () => {
|
|
1772
|
+
const base = await peek();
|
|
1773
|
+
await store.subscribe([], base - 5);
|
|
1774
|
+
expect8(await peek()).toBe(base);
|
|
1775
|
+
await store.subscribe([], base);
|
|
1776
|
+
expect8(await peek()).toBe(base);
|
|
1777
|
+
await store.subscribe([], base + 3);
|
|
1778
|
+
expect8(await peek()).toBe(base + 3);
|
|
1779
|
+
});
|
|
1780
|
+
it7("is left untouched when subscribe omits it", async () => {
|
|
1781
|
+
const base = await peek();
|
|
1782
|
+
await store.subscribe([]);
|
|
1783
|
+
expect8(await peek()).toBe(base);
|
|
1784
|
+
});
|
|
1785
|
+
it7("advances in the same call that registers discovered targets", async () => {
|
|
1786
|
+
const base = await peek();
|
|
1787
|
+
const s = `cp-sub-${uid()}`;
|
|
1788
|
+
const { subscribed, correlated_at } = await store.subscribe(
|
|
1789
|
+
[{ stream: s }],
|
|
1790
|
+
base + 7
|
|
1791
|
+
);
|
|
1792
|
+
expect8(subscribed).toBe(1);
|
|
1793
|
+
expect8(correlated_at).toBe(base + 7);
|
|
1794
|
+
});
|
|
1795
|
+
it7("is invisible to every stream-scoped surface", async () => {
|
|
1796
|
+
const seen = [];
|
|
1797
|
+
await store.query_streams((p) => seen.push(p.stream), {});
|
|
1798
|
+
expect8(seen.some((n) => n.startsWith("__correlate"))).toBe(false);
|
|
1799
|
+
expect8(seen).not.toContain("correlated");
|
|
1800
|
+
});
|
|
1801
|
+
});
|
|
1802
|
+
describe8.skipIf(!caps.work_set)("subscription work set", () => {
|
|
1803
|
+
const claimable = async (stream) => {
|
|
1804
|
+
const leased = await store.claim(100, 0, `w-${uid()}`, 1);
|
|
1805
|
+
const mine = leased.find((l) => l.stream === stream);
|
|
1806
|
+
if (mine) await store.ack([{ ...mine, at: mine.at }]);
|
|
1807
|
+
return mine !== void 0;
|
|
1808
|
+
};
|
|
1809
|
+
it7("claims a marked stream without probing the event log", async () => {
|
|
1810
|
+
const s = `ws-mark-${uid()}`;
|
|
1811
|
+
await store.subscribe([{ stream: s, source: `ws-src-${uid()}` }]);
|
|
1812
|
+
expect8(await claimable(s)).toBe(false);
|
|
1813
|
+
await store.subscribe([{ stream: s, correlated_at: 7 }]);
|
|
1814
|
+
expect8(await claimable(s)).toBe(true);
|
|
1815
|
+
const s2 = `ws-mark-nosrc-${uid()}`;
|
|
1816
|
+
await store.subscribe([{ stream: s2, correlated_at: 7 }]);
|
|
1817
|
+
expect8(await claimable(s2)).toBe(true);
|
|
1818
|
+
});
|
|
1819
|
+
it7("never regresses the mark, for every value on the number line", async () => {
|
|
1820
|
+
const s = `ws-mono-${uid()}`;
|
|
1821
|
+
await store.subscribe([
|
|
1822
|
+
{ stream: s, source: `ws-none-${uid()}`, correlated_at: 10 }
|
|
1823
|
+
]);
|
|
1824
|
+
const leased = await store.claim(100, 0, `w-${uid()}`, 1e4);
|
|
1825
|
+
await store.ack([
|
|
1826
|
+
{ ...leased.find((l) => l.stream === s), at: 5 }
|
|
1827
|
+
]);
|
|
1828
|
+
expect8(await claimable(s)).toBe(true);
|
|
1829
|
+
await store.subscribe([{ stream: s, correlated_at: 4 }]);
|
|
1830
|
+
expect8(await claimable(s)).toBe(true);
|
|
1831
|
+
await store.subscribe([{ stream: s, correlated_at: 5 }]);
|
|
1832
|
+
expect8(await claimable(s)).toBe(true);
|
|
1833
|
+
await store.subscribe([{ stream: s, correlated_at: -3 }]);
|
|
1834
|
+
expect8(await claimable(s)).toBe(true);
|
|
1835
|
+
await store.subscribe([{ stream: s, correlated_at: 0 }]);
|
|
1836
|
+
expect8(await claimable(s)).toBe(true);
|
|
1837
|
+
const leased2 = await store.claim(100, 0, `w-${uid()}`, 1e4);
|
|
1838
|
+
await store.ack([
|
|
1839
|
+
{ ...leased2.find((l) => l.stream === s), at: 10 }
|
|
1840
|
+
]);
|
|
1841
|
+
expect8(await claimable(s)).toBe(false);
|
|
1842
|
+
await store.subscribe([{ stream: s, correlated_at: 11 }]);
|
|
1843
|
+
expect8(await claimable(s)).toBe(true);
|
|
1844
|
+
});
|
|
1845
|
+
it7("retires a stream when ack catches the watermark up to the mark", async () => {
|
|
1846
|
+
const s = `ws-retire-${uid()}`;
|
|
1847
|
+
await store.subscribe([
|
|
1848
|
+
{ stream: s, source: `ws-none-${uid()}`, correlated_at: 5 }
|
|
1849
|
+
]);
|
|
1850
|
+
const leased = await store.claim(100, 0, `w-${uid()}`, 1e4);
|
|
1851
|
+
const mine = leased.find((l) => l.stream === s);
|
|
1852
|
+
expect8(mine).toBeDefined();
|
|
1853
|
+
await store.ack([{ ...mine, at: 5 }]);
|
|
1854
|
+
expect8(await claimable(s)).toBe(false);
|
|
1855
|
+
await store.subscribe([{ stream: s, correlated_at: 6 }]);
|
|
1856
|
+
expect8(await claimable(s)).toBe(true);
|
|
1857
|
+
});
|
|
1858
|
+
it7("keeps the mark across reset, so a rebuild is claimable", async () => {
|
|
1859
|
+
const s = `ws-reset-${uid()}`;
|
|
1860
|
+
await store.subscribe([
|
|
1861
|
+
{ stream: s, source: `ws-none-${uid()}`, correlated_at: 3 }
|
|
1862
|
+
]);
|
|
1863
|
+
const leased = await store.claim(100, 0, `w-${uid()}`, 1e4);
|
|
1864
|
+
await store.ack([
|
|
1865
|
+
{ ...leased.find((l) => l.stream === s), at: 3 }
|
|
1866
|
+
]);
|
|
1867
|
+
expect8(await claimable(s)).toBe(false);
|
|
1868
|
+
await store.reset([s]);
|
|
1869
|
+
expect8(await claimable(s)).toBe(true);
|
|
1870
|
+
});
|
|
1871
|
+
it7("keeps the mark across unblock, defer, and prioritize", async () => {
|
|
1872
|
+
const s = `ws-ops-${uid()}`;
|
|
1873
|
+
await store.subscribe([
|
|
1874
|
+
{ stream: s, source: `ws-none-${uid()}`, correlated_at: 9 }
|
|
1875
|
+
]);
|
|
1876
|
+
const leased = await store.claim(100, 0, `w-${uid()}`, 1e4);
|
|
1877
|
+
const mine = leased.find((l) => l.stream === s);
|
|
1878
|
+
await store.block([{ ...mine, error: "poison" }]);
|
|
1879
|
+
expect8(await claimable(s)).toBe(false);
|
|
1880
|
+
expect8(await store.unblock([s])).toBe(1);
|
|
1881
|
+
expect8(await claimable(s)).toBe(true);
|
|
1882
|
+
await store.defer([s], Date.now() + 6e4);
|
|
1883
|
+
expect8(await claimable(s)).toBe(false);
|
|
1884
|
+
await store.defer([s], Date.now() - 1);
|
|
1885
|
+
expect8(await claimable(s)).toBe(true);
|
|
1886
|
+
await store.prioritize({ stream: s, stream_exact: true }, 5);
|
|
1887
|
+
expect8(await claimable(s)).toBe(true);
|
|
1888
|
+
});
|
|
1889
|
+
it7("falls back to the legacy probe for an unmarked stream", async () => {
|
|
1890
|
+
const s = `ws-legacy-${uid()}`;
|
|
1891
|
+
const src = `ws-legacy-src-${uid()}`;
|
|
1892
|
+
await store.subscribe([{ stream: s, source: src }]);
|
|
1893
|
+
expect8(await claimable(s)).toBe(false);
|
|
1894
|
+
await store.commit(
|
|
1895
|
+
src,
|
|
1896
|
+
[inc(1)],
|
|
1897
|
+
make_meta({ stream: src })
|
|
1898
|
+
);
|
|
1899
|
+
expect8(await claimable(s)).toBe(true);
|
|
1900
|
+
});
|
|
1901
|
+
});
|
|
1762
1902
|
it7("claims a subscribed stream and ack releases the lease", async () => {
|
|
1763
1903
|
const s = `claim-${uid()}`;
|
|
1764
1904
|
await store.subscribe([{ stream: s }]);
|