cross-tab-worker-databus 0.21.16 → 0.21.17
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/CHANGELOG.md +18 -1
- package/dist/centrifuge.js +1 -1
- package/dist/{chunk-GQ6NYWQL.js → chunk-EZYCSJRS.js} +49 -2
- package/dist/chunk-EZYCSJRS.js.map +7 -0
- package/dist/cjs/centrifuge.cjs +48 -1
- package/dist/cjs/centrifuge.cjs.map +2 -2
- package/dist/cjs/index.cjs +48 -1
- package/dist/cjs/index.cjs.map +2 -2
- package/dist/core/cluster.d.ts +28 -0
- package/dist/core/cluster.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/docs/architecture.md +2 -1
- package/docs/release-checklist.md +1 -1
- package/docs/roadmap.md +28 -1
- package/docs/zh/architecture.md +2 -1
- package/docs/zh/release-checklist.md +1 -0
- package/docs/zh/roadmap.md +25 -1
- package/package.json +1 -1
- package/dist/chunk-GQ6NYWQL.js.map +0 -7
package/dist/cjs/index.cjs
CHANGED
|
@@ -1379,6 +1379,7 @@ var WorkerClusterRuntime = class {
|
|
|
1379
1379
|
reconcile() {
|
|
1380
1380
|
if (!this.started) return;
|
|
1381
1381
|
const workers = this.reconcileWorkers();
|
|
1382
|
+
this.reconcileStrandedSelfRoutes();
|
|
1382
1383
|
const activeWorkers = selectActiveWorkers(workers, this.maxActiveWorkers);
|
|
1383
1384
|
this.reconcileSubscriptions(workers, activeWorkers);
|
|
1384
1385
|
this.reconcileAssignedTopics();
|
|
@@ -1443,6 +1444,52 @@ var WorkerClusterRuntime = class {
|
|
|
1443
1444
|
}
|
|
1444
1445
|
}
|
|
1445
1446
|
}
|
|
1447
|
+
/**
|
|
1448
|
+
* Repair a confirmed route that names this Worker while its assignment is gone.
|
|
1449
|
+
*
|
|
1450
|
+
* Every write that settles ownership stamps the new owner's assignment in the
|
|
1451
|
+
* same task as the confirmation (`confirmRoute()` has exactly three call sites,
|
|
1452
|
+
* each directly after an `assignedTopics.set`), so a route carrying
|
|
1453
|
+
* `confirmedAt` while this map has no entry can only mean the assignment was
|
|
1454
|
+
* taken *after* the route settled. That is what `pause()` does: it clears the
|
|
1455
|
+
* map unconditionally but rewrites only the routes it can hand off, so a
|
|
1456
|
+
* handoff whose final flush is cut short by a storage failure — and the
|
|
1457
|
+
* `discardPending()` that ends the teardown throws the rest away — leaves a
|
|
1458
|
+
* durable route naming this worker. If the same worker id registers again (a
|
|
1459
|
+
* BFCache restore, or a runtime rebuilt with an explicit `workerId`), every
|
|
1460
|
+
* peer reads that route as a live, confirmed owner and stands down, while no
|
|
1461
|
+
* worker holds a transport subscription for the topic any more. Both reconcile
|
|
1462
|
+
* passes miss it by construction: one walks `subscribedTopics`, the other
|
|
1463
|
+
* `assignedTopics`, and the phantom is in neither.
|
|
1464
|
+
*
|
|
1465
|
+
* Acting here is this worker's alone — a peer that elected it is still waiting
|
|
1466
|
+
* for its own CONTROL/SUBSCRIBE to be accepted, and the single-writer rule
|
|
1467
|
+
* recorded in `reconcileSubscriptions()` forbids anyone else rewriting the
|
|
1468
|
+
* record. Reclaim when the local subscription is still live, which restores the
|
|
1469
|
+
* assignment and the transport subscription without touching the route, so the
|
|
1470
|
+
* owner and its generation stay exactly as peers recorded them; release
|
|
1471
|
+
* otherwise, since an owner that has no handler for the topic and never will is
|
|
1472
|
+
* a record nothing can act on.
|
|
1473
|
+
*/
|
|
1474
|
+
reconcileStrandedSelfRoutes() {
|
|
1475
|
+
if (!this.storage) return;
|
|
1476
|
+
let released = false;
|
|
1477
|
+
for (const { key, value: route } of readAllByPrefix(this.storage, this.routePrefix)) {
|
|
1478
|
+
if (route.confirmedAt === void 0 || route.workerId !== this.workerId) continue;
|
|
1479
|
+
if (this.assignedTopics.has(route.topicKey)) continue;
|
|
1480
|
+
const topic = this.knownTopics.get(route.topicKey);
|
|
1481
|
+
if (topic !== void 0 && this.subscribedTopics.has(topic)) {
|
|
1482
|
+
this.sendControl(this.workerId, CONTROL_ACTION.SUBSCRIBE, topic, route.topicKey);
|
|
1483
|
+
continue;
|
|
1484
|
+
}
|
|
1485
|
+
this.removeStorage(key);
|
|
1486
|
+
released = true;
|
|
1487
|
+
}
|
|
1488
|
+
if (released) {
|
|
1489
|
+
this.flushStorage();
|
|
1490
|
+
this.notifyRegistry();
|
|
1491
|
+
}
|
|
1492
|
+
}
|
|
1446
1493
|
/** Drop assignments where the route no longer points to this worker. */
|
|
1447
1494
|
reconcileAssignedTopics() {
|
|
1448
1495
|
for (const [topicKey, topic] of [...this.assignedTopics]) {
|
|
@@ -2505,7 +2552,7 @@ var DedupManager = class {
|
|
|
2505
2552
|
};
|
|
2506
2553
|
|
|
2507
2554
|
// src/core/version.ts
|
|
2508
|
-
var SDK_VERSION = true ? "0.21.
|
|
2555
|
+
var SDK_VERSION = true ? "0.21.17" : "";
|
|
2509
2556
|
|
|
2510
2557
|
// src/core/data-bus.ts
|
|
2511
2558
|
var DEFAULT_REPLAY_MAX_PER_TOPIC = 100;
|