@isoloop/bus 0.1.0-next.6 → 0.1.0-next.7
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/bus-worker.js +42 -0
- package/dist/index.js +42 -0
- package/package.json +3 -3
package/dist/bus-worker.js
CHANGED
|
@@ -967,6 +967,12 @@ var Broker = class {
|
|
|
967
967
|
#conns = /* @__PURE__ */ new Map();
|
|
968
968
|
#groups = /* @__PURE__ */ new Map();
|
|
969
969
|
#requests = /* @__PURE__ */ new Map();
|
|
970
|
+
/**
|
|
971
|
+
* Open request offsets per topic that may not be delivered yet, and the
|
|
972
|
+
* tail last seen there: when retention moves the tail past one nobody was
|
|
973
|
+
* handed, its caller gets `dropped` (ADR 0018, decision 5).
|
|
974
|
+
*/
|
|
975
|
+
#undelivered = /* @__PURE__ */ new Map();
|
|
970
976
|
/** Consumers whose offsets were dropped by `detach { keepOffsets: false }`, per topic. */
|
|
971
977
|
#forgotten = /* @__PURE__ */ new Set();
|
|
972
978
|
#rejected = {};
|
|
@@ -1548,6 +1554,7 @@ var Broker = class {
|
|
|
1548
1554
|
ok: true,
|
|
1549
1555
|
value: { offset }
|
|
1550
1556
|
});
|
|
1557
|
+
this.#dropEvicted(name);
|
|
1551
1558
|
this.#fanOut(name);
|
|
1552
1559
|
this.#wake(name);
|
|
1553
1560
|
this.#follow(name, {
|
|
@@ -1660,6 +1667,41 @@ var Broker = class {
|
|
|
1660
1667
|
recipients: /* @__PURE__ */ new Set(),
|
|
1661
1668
|
done: false
|
|
1662
1669
|
});
|
|
1670
|
+
let u = this.#undelivered.get(topic);
|
|
1671
|
+
if (!u) {
|
|
1672
|
+
u = {
|
|
1673
|
+
offsets: [],
|
|
1674
|
+
tail: this.#engine.tail(topic)
|
|
1675
|
+
};
|
|
1676
|
+
this.#undelivered.set(topic, u);
|
|
1677
|
+
}
|
|
1678
|
+
u.offsets.push(offset);
|
|
1679
|
+
}
|
|
1680
|
+
/**
|
|
1681
|
+
* Answers `dropped` to each caller whose request retention removed before
|
|
1682
|
+
* the bus delivered it to any subscriber (ADR 0018, decision 5). A request
|
|
1683
|
+
* already delivered stays its responder's to answer. Runs only when the
|
|
1684
|
+
* topic's tail has moved.
|
|
1685
|
+
*/
|
|
1686
|
+
#dropEvicted(topic) {
|
|
1687
|
+
const u = this.#undelivered.get(topic);
|
|
1688
|
+
if (!u) return;
|
|
1689
|
+
const tail = this.#engine.tail(topic);
|
|
1690
|
+
if (tail === u.tail) return;
|
|
1691
|
+
u.tail = tail;
|
|
1692
|
+
const kept = [];
|
|
1693
|
+
for (const offset of u.offsets) {
|
|
1694
|
+
if (offset >= tail) {
|
|
1695
|
+
kept.push(offset);
|
|
1696
|
+
continue;
|
|
1697
|
+
}
|
|
1698
|
+
const req = this.#requests.get(reqKey(topic, offset));
|
|
1699
|
+
if (!req || req.done || req.recipients.size > 0) continue;
|
|
1700
|
+
req.done = true;
|
|
1701
|
+
if (req.caller.host === true || this.#conns.get(req.caller.isolateId) === req.caller) this.#post(req.caller, req.id, fail("dropped", "the request was dropped: the topic's retention was full; retry or raise retention"));
|
|
1702
|
+
}
|
|
1703
|
+
if (kept.length === 0) this.#undelivered.delete(topic);
|
|
1704
|
+
else u.offsets = kept;
|
|
1663
1705
|
}
|
|
1664
1706
|
#reply(conn, name, offset, value, settle) {
|
|
1665
1707
|
const topic = this.#topics.get(name);
|
package/dist/index.js
CHANGED
|
@@ -966,6 +966,12 @@ var Broker = class {
|
|
|
966
966
|
#conns = /* @__PURE__ */ new Map();
|
|
967
967
|
#groups = /* @__PURE__ */ new Map();
|
|
968
968
|
#requests = /* @__PURE__ */ new Map();
|
|
969
|
+
/**
|
|
970
|
+
* Open request offsets per topic that may not be delivered yet, and the
|
|
971
|
+
* tail last seen there: when retention moves the tail past one nobody was
|
|
972
|
+
* handed, its caller gets `dropped` (ADR 0018, decision 5).
|
|
973
|
+
*/
|
|
974
|
+
#undelivered = /* @__PURE__ */ new Map();
|
|
969
975
|
/** Consumers whose offsets were dropped by `detach { keepOffsets: false }`, per topic. */
|
|
970
976
|
#forgotten = /* @__PURE__ */ new Set();
|
|
971
977
|
#rejected = {};
|
|
@@ -1547,6 +1553,7 @@ var Broker = class {
|
|
|
1547
1553
|
ok: true,
|
|
1548
1554
|
value: { offset }
|
|
1549
1555
|
});
|
|
1556
|
+
this.#dropEvicted(name);
|
|
1550
1557
|
this.#fanOut(name);
|
|
1551
1558
|
this.#wake(name);
|
|
1552
1559
|
this.#follow(name, {
|
|
@@ -1659,6 +1666,41 @@ var Broker = class {
|
|
|
1659
1666
|
recipients: /* @__PURE__ */ new Set(),
|
|
1660
1667
|
done: false
|
|
1661
1668
|
});
|
|
1669
|
+
let u = this.#undelivered.get(topic);
|
|
1670
|
+
if (!u) {
|
|
1671
|
+
u = {
|
|
1672
|
+
offsets: [],
|
|
1673
|
+
tail: this.#engine.tail(topic)
|
|
1674
|
+
};
|
|
1675
|
+
this.#undelivered.set(topic, u);
|
|
1676
|
+
}
|
|
1677
|
+
u.offsets.push(offset);
|
|
1678
|
+
}
|
|
1679
|
+
/**
|
|
1680
|
+
* Answers `dropped` to each caller whose request retention removed before
|
|
1681
|
+
* the bus delivered it to any subscriber (ADR 0018, decision 5). A request
|
|
1682
|
+
* already delivered stays its responder's to answer. Runs only when the
|
|
1683
|
+
* topic's tail has moved.
|
|
1684
|
+
*/
|
|
1685
|
+
#dropEvicted(topic) {
|
|
1686
|
+
const u = this.#undelivered.get(topic);
|
|
1687
|
+
if (!u) return;
|
|
1688
|
+
const tail = this.#engine.tail(topic);
|
|
1689
|
+
if (tail === u.tail) return;
|
|
1690
|
+
u.tail = tail;
|
|
1691
|
+
const kept = [];
|
|
1692
|
+
for (const offset of u.offsets) {
|
|
1693
|
+
if (offset >= tail) {
|
|
1694
|
+
kept.push(offset);
|
|
1695
|
+
continue;
|
|
1696
|
+
}
|
|
1697
|
+
const req = this.#requests.get(reqKey(topic, offset));
|
|
1698
|
+
if (!req || req.done || req.recipients.size > 0) continue;
|
|
1699
|
+
req.done = true;
|
|
1700
|
+
if (req.caller.host === true || this.#conns.get(req.caller.isolateId) === req.caller) this.#post(req.caller, req.id, fail("dropped", "the request was dropped: the topic's retention was full; retry or raise retention"));
|
|
1701
|
+
}
|
|
1702
|
+
if (kept.length === 0) this.#undelivered.delete(topic);
|
|
1703
|
+
else u.offsets = kept;
|
|
1662
1704
|
}
|
|
1663
1705
|
#reply(conn, name, offset, value, settle) {
|
|
1664
1706
|
const topic = this.#topics.get(name);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@isoloop/bus",
|
|
3
|
-
"version": "0.1.0-next.
|
|
3
|
+
"version": "0.1.0-next.7",
|
|
4
4
|
"description": "Log bus that runs in its own worker: topics, schemas, offsets, replay.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -27,8 +27,8 @@
|
|
|
27
27
|
}
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@isoloop/codec": "0.1.0-next.
|
|
31
|
-
"@isoloop/protocol": "0.1.0-next.
|
|
30
|
+
"@isoloop/codec": "0.1.0-next.7",
|
|
31
|
+
"@isoloop/protocol": "0.1.0-next.7"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"fast-check": "4.10.2",
|