cross-tab-worker-databus 0.20.66 → 0.20.68
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 +12 -0
- package/dist/centrifuge.js +1 -1
- package/dist/{chunk-KKSZ5GUC.js → chunk-X6JTPZYW.js} +16 -3
- package/dist/chunk-X6JTPZYW.js.map +7 -0
- package/dist/cjs/centrifuge.cjs +15 -2
- package/dist/cjs/centrifuge.cjs.map +2 -2
- package/dist/cjs/index.cjs +15 -2
- package/dist/cjs/index.cjs.map +2 -2
- package/dist/core/cluster.d.ts +8 -0
- package/dist/core/cluster.d.ts.map +1 -1
- package/dist/core/data-bus.d.ts +5 -0
- package/dist/core/data-bus.d.ts.map +1 -1
- package/dist/core/types.d.ts +8 -0
- package/dist/core/types.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/docs/roadmap.md +16 -1
- package/docs/zh/roadmap.md +16 -1
- package/package.json +1 -1
- package/dist/chunk-KKSZ5GUC.js.map +0 -7
package/dist/cjs/index.cjs
CHANGED
|
@@ -321,6 +321,7 @@ var BatchingStorageWriter = class {
|
|
|
321
321
|
};
|
|
322
322
|
|
|
323
323
|
// src/core/cluster.ts
|
|
324
|
+
var CLUSTER_PROTOCOL_VERSION = 1;
|
|
324
325
|
var DEFAULT_HEARTBEAT_INTERVAL_MS = 3e3;
|
|
325
326
|
var DEFAULT_WORKER_TTL_MS = 1e4;
|
|
326
327
|
var DEFAULT_STORAGE_PREFIX = "cross-tab-worker-databus";
|
|
@@ -381,6 +382,8 @@ var WorkerClusterRuntime = class {
|
|
|
381
382
|
routeOwnerCacheMax;
|
|
382
383
|
routeOwnerCacheHits = 0;
|
|
383
384
|
routeOwnerCacheMisses = 0;
|
|
385
|
+
unknownMessageCount = 0;
|
|
386
|
+
lastUnknownMessageType = null;
|
|
384
387
|
touchRouteOwnerCache(topicKey, value) {
|
|
385
388
|
if (this.routeOwnerCache.has(topicKey)) this.routeOwnerCache.delete(topicKey);
|
|
386
389
|
this.routeOwnerCache.set(topicKey, value);
|
|
@@ -737,6 +740,10 @@ var WorkerClusterRuntime = class {
|
|
|
737
740
|
}
|
|
738
741
|
return false;
|
|
739
742
|
}
|
|
743
|
+
/** Count and last type of unknown protocol messages observed. */
|
|
744
|
+
getUnknownMessageStats() {
|
|
745
|
+
return { count: this.unknownMessageCount, lastType: this.lastUnknownMessageType };
|
|
746
|
+
}
|
|
740
747
|
/** Read-only snapshot of the cluster state (workers, routes, assignments). */
|
|
741
748
|
getSnapshot() {
|
|
742
749
|
const routes = this.storage ? readAllByPrefix(this.storage, this.routePrefix).map(({ value }) => ({
|
|
@@ -744,6 +751,7 @@ var WorkerClusterRuntime = class {
|
|
|
744
751
|
topic: this.knownTopics.get(value.topicKey) ?? null
|
|
745
752
|
})) : [];
|
|
746
753
|
return {
|
|
754
|
+
protocolVersion: CLUSTER_PROTOCOL_VERSION,
|
|
747
755
|
coordinated: Boolean(this.storage && this.channel),
|
|
748
756
|
suspended: this.suspended,
|
|
749
757
|
currentWorker: { ...this.currentRecord },
|
|
@@ -800,9 +808,13 @@ var WorkerClusterRuntime = class {
|
|
|
800
808
|
case "REGISTRY":
|
|
801
809
|
this.reconcile();
|
|
802
810
|
return;
|
|
803
|
-
default:
|
|
811
|
+
default: {
|
|
812
|
+
this.unknownMessageCount += 1;
|
|
813
|
+
const unknown = message;
|
|
814
|
+
this.lastUnknownMessageType = typeof unknown.type === "string" ? unknown.type : null;
|
|
804
815
|
this.handlers.onUnknownMessage?.(message);
|
|
805
816
|
return;
|
|
817
|
+
}
|
|
806
818
|
}
|
|
807
819
|
};
|
|
808
820
|
/** Handle a point-to-point CONTROL message (SUBSCRIBE / UNSUBSCRIBE / PUBLISH). */
|
|
@@ -996,7 +1008,7 @@ var WorkerClusterRuntime = class {
|
|
|
996
1008
|
send(message) {
|
|
997
1009
|
if (!this.channel) return false;
|
|
998
1010
|
try {
|
|
999
|
-
this.channel.postMessage(message);
|
|
1011
|
+
this.channel.postMessage({ ...message, protocolVersion: CLUSTER_PROTOCOL_VERSION });
|
|
1000
1012
|
return true;
|
|
1001
1013
|
} catch {
|
|
1002
1014
|
return false;
|
|
@@ -1908,6 +1920,7 @@ var CrossTabDataBus = class {
|
|
|
1908
1920
|
recovery: this.getRecoveryStats(),
|
|
1909
1921
|
dedup: this.getDedupStats(),
|
|
1910
1922
|
replay: { enabled: Boolean(this.replayBuffers), topics: this.replayBuffers?.size ?? 0, messages },
|
|
1923
|
+
protocol: { version: this.cluster.getSnapshot().protocolVersion, unknownMessages: this.cluster.getUnknownMessageStats().count, lastUnknownMessageType: this.cluster.getUnknownMessageStats().lastType },
|
|
1911
1924
|
cluster: this.cluster.getSnapshot()
|
|
1912
1925
|
};
|
|
1913
1926
|
}
|