@peerbit/pubsub 5.4.6 → 5.4.8
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/src/index.d.ts +4 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +131 -30
- package/dist/src/index.js.map +1 -1
- package/package.json +4 -4
- package/src/index.ts +165 -36
package/dist/src/index.d.ts
CHANGED
|
@@ -138,6 +138,7 @@ export declare class TopicControlPlane extends DirectStream<PubSubEvents> implem
|
|
|
138
138
|
private readonly nativeTopicControl?;
|
|
139
139
|
private debounceSubscribeAggregator;
|
|
140
140
|
private debounceUnsubscribeAggregator;
|
|
141
|
+
private readonly subscriptionDebounceDelay;
|
|
141
142
|
private readonly shardCount;
|
|
142
143
|
private readonly shardTopicPrefix;
|
|
143
144
|
private readonly topicRootCandidateClaimData;
|
|
@@ -180,6 +181,7 @@ export declare class TopicControlPlane extends DirectStream<PubSubEvents> implem
|
|
|
180
181
|
private pendingTopicRootQueries;
|
|
181
182
|
private nextTopicRootQueryId;
|
|
182
183
|
constructor(components: TopicControlPlaneComponents, props?: TopicControlPlaneOptions);
|
|
184
|
+
private createSubscriptionAggregators;
|
|
183
185
|
/**
|
|
184
186
|
* Return a detached, read-only snapshot of effective runtime settings.
|
|
185
187
|
*/
|
|
@@ -250,7 +252,9 @@ export declare class TopicControlPlane extends DirectStream<PubSubEvents> implem
|
|
|
250
252
|
*/
|
|
251
253
|
private decodePubSubMessage;
|
|
252
254
|
private getTopicRootCandidateGeneration;
|
|
255
|
+
private isTopicControlPlaneActive;
|
|
253
256
|
private assertTopicControlPlaneActive;
|
|
257
|
+
private isFanoutChannelCurrent;
|
|
254
258
|
private syncTopicRootCandidateResolutionSignal;
|
|
255
259
|
private withTopicRootCandidateResolution;
|
|
256
260
|
private normalizePeerTopicRootState;
|
package/dist/src/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRo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,aAAa,CAAC,GAAG,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI;IAWhD,iBAAiB,CAAC,aAAa,EAAE,MAAM;IA2BvD,OAAO,CAAC,wBAAwB;IA8BhC,OAAO,CAAC,gCAAgC;IAoCxC,OAAO,CAAC,mBAAmB;IA8B3B,OAAO,CAAC,yBAAyB;IA0DjC;;;OAGG;IACH,OAAO,CAAC,sBAAsB;IAa9B,OAAO,CAAC,2BAA2B;IAcnC;;;;;;;OAOG;IACH,OAAO,CAAC,uBAAuB;YAqDjB,wBAAwB;YAoCxB,4BAA4B;YA4C5B,0BAA0B;YAiL1B,yBAAyB;IAoNjB,aAAa,CAClC,IAAI,EAAE,aAAa,EACnB,MAAM,EAAE,WAAW,EACnB,OAAO,EAAE,WAAW,EACpB,UAAU,EAAE,MAAM;CAsFnB;AAED,eAAO,MAAM,kBAAkB,GAC9B,QAAQ;IAAE,QAAQ,EAAE;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,CAAA;CAAE,EACxC,aACG,MAAM,GACN,MAAM,EAAE,GACR;IAAE,MAAM,EAAE,YAAY,CAAA;CAAE,GACxB;IAAE,MAAM,EAAE,YAAY,CAAA;CAAE,EAAE,GAC1B,MAAM,GACN,MAAM,EAAE,EACX,OAAO,MAAM,EACb,UAAU;IAAE,MAAM,CAAC,EAAE,WAAW,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,kBAiKpD,CAAC"}
|
package/dist/src/index.js
CHANGED
|
@@ -193,6 +193,7 @@ export class TopicControlPlane extends DirectStream {
|
|
|
193
193
|
nativeTopicControl;
|
|
194
194
|
debounceSubscribeAggregator;
|
|
195
195
|
debounceUnsubscribeAggregator;
|
|
196
|
+
subscriptionDebounceDelay;
|
|
196
197
|
shardCount;
|
|
197
198
|
shardTopicPrefix;
|
|
198
199
|
topicRootCandidateClaimData;
|
|
@@ -309,10 +310,15 @@ export class TopicControlPlane extends DirectStream {
|
|
|
309
310
|
this.fanoutPublishMaxEphemeralChannels = Math.max(0, Math.floor(requestedMaxEphemeral));
|
|
310
311
|
const requestedSubscriberCacheMaxEntries = props?.subscriberCacheMaxEntries ?? SUBSCRIBER_CACHE_DEFAULT_MAX_ENTRIES;
|
|
311
312
|
this.subscriberCacheMaxEntries = Math.min(SUBSCRIBER_CACHE_MAX_ENTRIES_HARD_CAP, Math.max(1, Math.floor(requestedSubscriberCacheMaxEntries)));
|
|
312
|
-
this.
|
|
313
|
+
this.subscriptionDebounceDelay = props?.subscriptionDebounceDelay ?? 50;
|
|
314
|
+
this.createSubscriptionAggregators();
|
|
315
|
+
}
|
|
316
|
+
createSubscriptionAggregators() {
|
|
317
|
+
const lifecycleRevision = this.topicControlPlaneLifecycleRevision;
|
|
318
|
+
this.debounceSubscribeAggregator = debouncedAccumulatorSetCounter((set) => this._subscribe([...set.values()], lifecycleRevision), this.subscriptionDebounceDelay, (error) => logger.error(`Debounced subscribe failed: ${error?.message ?? error}`));
|
|
313
319
|
// NOTE: Unsubscribe should update local state immediately and batch only the
|
|
314
320
|
// best-effort network announcements to avoid teardown stalls (program close).
|
|
315
|
-
this.debounceUnsubscribeAggregator = debouncedAccumulatorSetCounter((set) => this._announceUnsubscribe([...set.values()]),
|
|
321
|
+
this.debounceUnsubscribeAggregator = debouncedAccumulatorSetCounter((set) => this._announceUnsubscribe([...set.values()], lifecycleRevision), this.subscriptionDebounceDelay, (error) => logger.error(`Debounced unsubscribe announce failed: ${error?.message ?? error}`));
|
|
316
322
|
}
|
|
317
323
|
/**
|
|
318
324
|
* Return a detached, read-only snapshot of effective runtime settings.
|
|
@@ -363,6 +369,10 @@ export class TopicControlPlane extends DirectStream {
|
|
|
363
369
|
// self while a signed-protocol peer is connected.
|
|
364
370
|
if (this.started)
|
|
365
371
|
return;
|
|
372
|
+
// close() is terminal. Only a completed stop/start gets a fresh pair;
|
|
373
|
+
// repeated start() must preserve the active pair's queued reference counts.
|
|
374
|
+
if (this.topicControlPlaneStopping)
|
|
375
|
+
this.createSubscriptionAggregators();
|
|
366
376
|
this.topicControlPlaneStopping = false;
|
|
367
377
|
if (this.autoTopicRootCandidates &&
|
|
368
378
|
!this.localSignedTopicRootCandidateClaim) {
|
|
@@ -407,6 +417,8 @@ export class TopicControlPlane extends DirectStream {
|
|
|
407
417
|
this.clearAutoTopicRootCandidateUpdateSchedule();
|
|
408
418
|
this.clearSignedTopicRootCandidateState();
|
|
409
419
|
this.topicControlPlaneLifecycleRevision += 1;
|
|
420
|
+
this.debounceSubscribeAggregator.close();
|
|
421
|
+
this.debounceUnsubscribeAggregator.close();
|
|
410
422
|
this.reconcileShardOverlaysDirty = false;
|
|
411
423
|
for (const opening of this.ensureFanoutChannelInFlight.values()) {
|
|
412
424
|
opening.abortController.abort(new AbortError("topic control plane stopped"));
|
|
@@ -463,8 +475,6 @@ export class TopicControlPlane extends DirectStream {
|
|
|
463
475
|
pending.resolve(undefined);
|
|
464
476
|
}
|
|
465
477
|
this.pendingTopicRootQueries.clear();
|
|
466
|
-
this.debounceSubscribeAggregator.close();
|
|
467
|
-
this.debounceUnsubscribeAggregator.close();
|
|
468
478
|
await super.stop();
|
|
469
479
|
this.reconcileShardOverlaysDirty = false;
|
|
470
480
|
}
|
|
@@ -1477,14 +1487,21 @@ export class TopicControlPlane extends DirectStream {
|
|
|
1477
1487
|
this.topicRootControlPlane.getTopicRootCandidates(),
|
|
1478
1488
|
]);
|
|
1479
1489
|
}
|
|
1490
|
+
isTopicControlPlaneActive(lifecycleRevision) {
|
|
1491
|
+
return (lifecycleRevision === this.topicControlPlaneLifecycleRevision &&
|
|
1492
|
+
this.started &&
|
|
1493
|
+
!this.stopping &&
|
|
1494
|
+
!this.topicControlPlaneStopping);
|
|
1495
|
+
}
|
|
1480
1496
|
assertTopicControlPlaneActive(lifecycleRevision) {
|
|
1481
|
-
if (
|
|
1482
|
-
!this.started ||
|
|
1483
|
-
this.stopping ||
|
|
1484
|
-
this.topicControlPlaneStopping) {
|
|
1497
|
+
if (!this.isTopicControlPlaneActive(lifecycleRevision)) {
|
|
1485
1498
|
throw new NotStartedError();
|
|
1486
1499
|
}
|
|
1487
1500
|
}
|
|
1501
|
+
isFanoutChannelCurrent(shardTopic, channel, lifecycleRevision) {
|
|
1502
|
+
return (this.isTopicControlPlaneActive(lifecycleRevision) &&
|
|
1503
|
+
this.fanoutChannels.get(shardTopic)?.channel === channel);
|
|
1504
|
+
}
|
|
1488
1505
|
syncTopicRootCandidateResolutionSignal(candidateGeneration = this.getTopicRootCandidateGeneration()) {
|
|
1489
1506
|
if (this.topicRootCandidateResolutionGeneration === undefined) {
|
|
1490
1507
|
this.topicRootCandidateResolutionGeneration = candidateGeneration;
|
|
@@ -2077,7 +2094,10 @@ export class TopicControlPlane extends DirectStream {
|
|
|
2077
2094
|
return;
|
|
2078
2095
|
}
|
|
2079
2096
|
const channel = new FanoutChannel(this.fanout, { topic: t, root });
|
|
2097
|
+
const isCurrent = () => this.isFanoutChannelCurrent(t, channel, lifecycleRevision);
|
|
2080
2098
|
const onPayload = (payload) => {
|
|
2099
|
+
if (!isCurrent())
|
|
2100
|
+
return;
|
|
2081
2101
|
let dm;
|
|
2082
2102
|
try {
|
|
2083
2103
|
dm = DataMessage.from(new Uint8ArrayList(payload));
|
|
@@ -2131,24 +2151,41 @@ export class TopicControlPlane extends DirectStream {
|
|
|
2131
2151
|
}
|
|
2132
2152
|
void (async () => {
|
|
2133
2153
|
const msgId = await getMsgId(payload);
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2154
|
+
if (!isCurrent())
|
|
2155
|
+
return;
|
|
2156
|
+
const previouslySeen = this.seenCache.get(msgId);
|
|
2157
|
+
if (previouslySeen) {
|
|
2158
|
+
this.seenCache.add(msgId, previouslySeen + 1);
|
|
2137
2159
|
return;
|
|
2160
|
+
}
|
|
2138
2161
|
// fanout-delivered frames bypass the inbound stream decode, so
|
|
2139
2162
|
// the nested envelope is verified natively here when possible
|
|
2140
2163
|
this.seedNativeWireVerification(dm, payload);
|
|
2141
|
-
if ((await this.verifyAndProcess(dm)) === false) {
|
|
2164
|
+
if ((await this.verifyAndProcess(dm, isCurrent)) === false) {
|
|
2142
2165
|
return;
|
|
2143
2166
|
}
|
|
2167
|
+
if (!isCurrent())
|
|
2168
|
+
return;
|
|
2169
|
+
// Only a verified frame owned by this exact channel may consume the
|
|
2170
|
+
// shared dedupe slot. A stale verifier cannot suppress its replacement's
|
|
2171
|
+
// copy. Concurrent verifiers recheck here before dispatching once.
|
|
2172
|
+
const seen = this.seenCache.get(msgId);
|
|
2173
|
+
this.seenCache.add(msgId, seen ? seen + 1 : 1);
|
|
2174
|
+
if (seen)
|
|
2175
|
+
return;
|
|
2144
2176
|
const sender = dm.header.signatures.signatures[0].publicKey;
|
|
2145
2177
|
await this.processShardPubSubMessage({
|
|
2146
2178
|
pubsubMessage,
|
|
2147
2179
|
message: dm,
|
|
2148
2180
|
from: sender,
|
|
2149
2181
|
shardTopic: t,
|
|
2182
|
+
isCurrent,
|
|
2150
2183
|
});
|
|
2151
|
-
})()
|
|
2184
|
+
})().catch((error) => {
|
|
2185
|
+
if (error instanceof NotStartedError && !isCurrent())
|
|
2186
|
+
return;
|
|
2187
|
+
logError(error);
|
|
2188
|
+
});
|
|
2152
2189
|
};
|
|
2153
2190
|
const onData = (ev) => {
|
|
2154
2191
|
const detail = ev?.detail;
|
|
@@ -2259,6 +2296,11 @@ export class TopicControlPlane extends DirectStream {
|
|
|
2259
2296
|
return;
|
|
2260
2297
|
this.fanoutChannels.delete(t);
|
|
2261
2298
|
this.clearFanoutIdleClose(st);
|
|
2299
|
+
const pendingResponse = this.pendingSubscriberResponses.get(t);
|
|
2300
|
+
if (pendingResponse) {
|
|
2301
|
+
clearTimeout(pendingResponse.timer);
|
|
2302
|
+
this.pendingSubscriberResponses.delete(t);
|
|
2303
|
+
}
|
|
2262
2304
|
try {
|
|
2263
2305
|
st.channel.removeEventListener("data", st.onData);
|
|
2264
2306
|
}
|
|
@@ -2367,9 +2409,11 @@ export class TopicControlPlane extends DirectStream {
|
|
|
2367
2409
|
this.initializeTopic(topic);
|
|
2368
2410
|
return this.debounceSubscribeAggregator.add({ key: topic });
|
|
2369
2411
|
}
|
|
2370
|
-
async _subscribe(topics) {
|
|
2412
|
+
async _subscribe(topics, lifecycleRevision = this.topicControlPlaneLifecycleRevision) {
|
|
2371
2413
|
if (!this.started)
|
|
2372
2414
|
throw new NotStartedError();
|
|
2415
|
+
if (!this.isTopicControlPlaneActive(lifecycleRevision))
|
|
2416
|
+
return;
|
|
2373
2417
|
if (topics.length === 0)
|
|
2374
2418
|
return;
|
|
2375
2419
|
const byShard = new Map();
|
|
@@ -2390,10 +2434,15 @@ export class TopicControlPlane extends DirectStream {
|
|
|
2390
2434
|
joins.push(this.ensureFanoutChannel(shardTopic));
|
|
2391
2435
|
}
|
|
2392
2436
|
await Promise.all(joins);
|
|
2437
|
+
if (!this.isTopicControlPlaneActive(lifecycleRevision))
|
|
2438
|
+
return;
|
|
2393
2439
|
// Announce subscriptions per shard overlay.
|
|
2394
2440
|
await Promise.all([...byShard.entries()].map(async ([shardTopic, userTopics]) => {
|
|
2395
2441
|
if (userTopics.length === 0)
|
|
2396
2442
|
return;
|
|
2443
|
+
const st = this.fanoutChannels.get(shardTopic);
|
|
2444
|
+
if (!st)
|
|
2445
|
+
throw new Error(`Fanout channel missing for shard: ${shardTopic}`);
|
|
2397
2446
|
const msg = new Subscribe({
|
|
2398
2447
|
topics: userTopics,
|
|
2399
2448
|
requestSubscribers: true,
|
|
@@ -2403,11 +2452,11 @@ export class TopicControlPlane extends DirectStream {
|
|
|
2403
2452
|
priority: 1,
|
|
2404
2453
|
skipRecipientValidation: true,
|
|
2405
2454
|
});
|
|
2406
|
-
|
|
2407
|
-
|
|
2408
|
-
throw new Error(`Fanout channel missing for shard: ${shardTopic}`);
|
|
2455
|
+
if (!this.isFanoutChannelCurrent(shardTopic, st.channel, lifecycleRevision))
|
|
2456
|
+
return;
|
|
2409
2457
|
await st.channel.publish(toUint8Array(embedded.bytes()));
|
|
2410
|
-
this.
|
|
2458
|
+
if (this.isFanoutChannelCurrent(shardTopic, st.channel, lifecycleRevision))
|
|
2459
|
+
this.touchFanoutChannel(shardTopic);
|
|
2411
2460
|
}));
|
|
2412
2461
|
}
|
|
2413
2462
|
async unsubscribe(topic, options) {
|
|
@@ -2450,9 +2499,11 @@ export class TopicControlPlane extends DirectStream {
|
|
|
2450
2499
|
.catch(logErrorIfStarted);
|
|
2451
2500
|
return true;
|
|
2452
2501
|
}
|
|
2453
|
-
async _announceUnsubscribe(topics) {
|
|
2502
|
+
async _announceUnsubscribe(topics, lifecycleRevision = this.topicControlPlaneLifecycleRevision) {
|
|
2454
2503
|
if (!this.started)
|
|
2455
2504
|
throw new NotStartedError();
|
|
2505
|
+
if (!this.isTopicControlPlaneActive(lifecycleRevision))
|
|
2506
|
+
return;
|
|
2456
2507
|
const byShard = new Map();
|
|
2457
2508
|
for (const { key: topic } of topics) {
|
|
2458
2509
|
// If the topic got re-subscribed before this debounced batch ran, skip.
|
|
@@ -2464,6 +2515,9 @@ export class TopicControlPlane extends DirectStream {
|
|
|
2464
2515
|
await Promise.all([...byShard.entries()].map(async ([shardTopic, userTopics]) => {
|
|
2465
2516
|
if (userTopics.length === 0)
|
|
2466
2517
|
return;
|
|
2518
|
+
const st = this.fanoutChannels.get(shardTopic);
|
|
2519
|
+
if (!st)
|
|
2520
|
+
return;
|
|
2467
2521
|
// Announce first.
|
|
2468
2522
|
try {
|
|
2469
2523
|
const msg = new Unsubscribe({ topics: userTopics });
|
|
@@ -2472,20 +2526,21 @@ export class TopicControlPlane extends DirectStream {
|
|
|
2472
2526
|
priority: 1,
|
|
2473
2527
|
skipRecipientValidation: true,
|
|
2474
2528
|
});
|
|
2475
|
-
|
|
2476
|
-
if (st) {
|
|
2529
|
+
if (this.isFanoutChannelCurrent(shardTopic, st.channel, lifecycleRevision)) {
|
|
2477
2530
|
// Best-effort: do not let a stuck proxy publish stall teardown.
|
|
2478
2531
|
void st.channel
|
|
2479
2532
|
.publish(toUint8Array(embedded.bytes()))
|
|
2480
2533
|
.catch(() => { });
|
|
2481
|
-
this.
|
|
2534
|
+
if (this.isFanoutChannelCurrent(shardTopic, st.channel, lifecycleRevision))
|
|
2535
|
+
this.touchFanoutChannel(shardTopic);
|
|
2482
2536
|
}
|
|
2483
2537
|
}
|
|
2484
2538
|
catch {
|
|
2485
2539
|
// best-effort
|
|
2486
2540
|
}
|
|
2487
2541
|
// Close shard overlay if no local topics remain.
|
|
2488
|
-
if (
|
|
2542
|
+
if (this.isFanoutChannelCurrent(shardTopic, st.channel, lifecycleRevision) &&
|
|
2543
|
+
(this.shardRefCounts.get(shardTopic) ?? 0) <= 0) {
|
|
2489
2544
|
try {
|
|
2490
2545
|
// Shutdown should be bounded and not depend on network I/O.
|
|
2491
2546
|
await this.closeFanoutChannel(shardTopic);
|
|
@@ -2975,16 +3030,37 @@ export class TopicControlPlane extends DirectStream {
|
|
|
2975
3030
|
* unicasts whose cold route resolutions flood the shard tree.
|
|
2976
3031
|
*/
|
|
2977
3032
|
queueSubscriberResponse(shardTopic, targetHash, topics) {
|
|
3033
|
+
const lifecycleRevision = this.topicControlPlaneLifecycleRevision;
|
|
3034
|
+
const st = this.fanoutChannels.get(shardTopic);
|
|
3035
|
+
if (!st)
|
|
3036
|
+
return;
|
|
3037
|
+
const isCurrent = () => this.isFanoutChannelCurrent(shardTopic, st.channel, lifecycleRevision);
|
|
3038
|
+
if (!isCurrent())
|
|
3039
|
+
return;
|
|
3040
|
+
const onError = (error) => {
|
|
3041
|
+
if (error instanceof NotStartedError && !isCurrent())
|
|
3042
|
+
return;
|
|
3043
|
+
logError(error);
|
|
3044
|
+
};
|
|
2978
3045
|
let entry = this.pendingSubscriberResponses.get(shardTopic);
|
|
3046
|
+
if (entry && !entry.isCurrent()) {
|
|
3047
|
+
clearTimeout(entry.timer);
|
|
3048
|
+
this.pendingSubscriberResponses.delete(shardTopic);
|
|
3049
|
+
entry = undefined;
|
|
3050
|
+
}
|
|
2979
3051
|
if (!entry) {
|
|
2980
3052
|
const created = {
|
|
2981
3053
|
targets: new Set(),
|
|
2982
3054
|
topics: new Set(),
|
|
3055
|
+
isCurrent,
|
|
2983
3056
|
timer: setTimeout(() => {
|
|
3057
|
+
if (this.pendingSubscriberResponses.get(shardTopic) !== created) {
|
|
3058
|
+
return;
|
|
3059
|
+
}
|
|
2984
3060
|
this.pendingSubscriberResponses.delete(shardTopic);
|
|
2985
|
-
if (created.targets.size === 0)
|
|
3061
|
+
if (!isCurrent() || created.targets.size === 0)
|
|
2986
3062
|
return;
|
|
2987
|
-
void this.flushSubscriberResponses(shardTopic, created).catch(
|
|
3063
|
+
void this.flushSubscriberResponses(shardTopic, created).catch(onError);
|
|
2988
3064
|
}, 150 + Math.floor(Math.random() * 150)),
|
|
2989
3065
|
};
|
|
2990
3066
|
this.pendingSubscriberResponses.set(shardTopic, created);
|
|
@@ -2992,7 +3068,8 @@ export class TopicControlPlane extends DirectStream {
|
|
|
2992
3068
|
void this.flushSubscriberResponses(shardTopic, {
|
|
2993
3069
|
targets: new Set([targetHash]),
|
|
2994
3070
|
topics: new Set(topics),
|
|
2995
|
-
|
|
3071
|
+
isCurrent,
|
|
3072
|
+
}).catch(onError);
|
|
2996
3073
|
return;
|
|
2997
3074
|
}
|
|
2998
3075
|
entry.targets.add(targetHash);
|
|
@@ -3000,7 +3077,7 @@ export class TopicControlPlane extends DirectStream {
|
|
|
3000
3077
|
entry.topics.add(t);
|
|
3001
3078
|
}
|
|
3002
3079
|
async flushSubscriberResponses(shardTopic, entry) {
|
|
3003
|
-
if (!
|
|
3080
|
+
if (!entry.isCurrent())
|
|
3004
3081
|
return;
|
|
3005
3082
|
// Re-filter: our subscriptions may have changed within the window.
|
|
3006
3083
|
const topics = this.getSubscriptionOverlap([...entry.topics]);
|
|
@@ -3015,6 +3092,8 @@ export class TopicControlPlane extends DirectStream {
|
|
|
3015
3092
|
priority: 1,
|
|
3016
3093
|
skipRecipientValidation: true,
|
|
3017
3094
|
});
|
|
3095
|
+
if (!entry.isCurrent())
|
|
3096
|
+
return;
|
|
3018
3097
|
const payload = toUint8Array(embedded.bytes());
|
|
3019
3098
|
const [firstTarget] = entry.targets;
|
|
3020
3099
|
if (entry.targets.size === 1 && firstTarget) {
|
|
@@ -3027,9 +3106,13 @@ export class TopicControlPlane extends DirectStream {
|
|
|
3027
3106
|
await st.channel.publishMaybe(payload);
|
|
3028
3107
|
}
|
|
3029
3108
|
async sendFanoutUnicastOrBroadcast(shardTopic, targetHash, payload) {
|
|
3109
|
+
const lifecycleRevision = this.topicControlPlaneLifecycleRevision;
|
|
3030
3110
|
const st = this.fanoutChannels.get(shardTopic);
|
|
3031
3111
|
if (!st)
|
|
3032
3112
|
return;
|
|
3113
|
+
const isCurrent = () => this.isFanoutChannelCurrent(shardTopic, st.channel, lifecycleRevision);
|
|
3114
|
+
if (!isCurrent())
|
|
3115
|
+
return;
|
|
3033
3116
|
const hints = this.getUnifiedRouteHints(shardTopic, targetHash);
|
|
3034
3117
|
const fanoutHint = hints.find((hint) => hint.kind === "fanout-token");
|
|
3035
3118
|
if (fanoutHint) {
|
|
@@ -3039,7 +3122,12 @@ export class TopicControlPlane extends DirectStream {
|
|
|
3039
3122
|
});
|
|
3040
3123
|
return;
|
|
3041
3124
|
}
|
|
3042
|
-
catch {
|
|
3125
|
+
catch (error) {
|
|
3126
|
+
if (!isCurrent()) {
|
|
3127
|
+
if (error instanceof NotStartedError)
|
|
3128
|
+
return;
|
|
3129
|
+
throw error;
|
|
3130
|
+
}
|
|
3043
3131
|
// ignore and fall back
|
|
3044
3132
|
}
|
|
3045
3133
|
}
|
|
@@ -3047,9 +3135,16 @@ export class TopicControlPlane extends DirectStream {
|
|
|
3047
3135
|
await st.channel.unicastToAck(targetHash, payload, { timeoutMs: 5_000 });
|
|
3048
3136
|
return;
|
|
3049
3137
|
}
|
|
3050
|
-
catch {
|
|
3138
|
+
catch (error) {
|
|
3139
|
+
if (!isCurrent()) {
|
|
3140
|
+
if (error instanceof NotStartedError)
|
|
3141
|
+
return;
|
|
3142
|
+
throw error;
|
|
3143
|
+
}
|
|
3051
3144
|
// ignore and fall back
|
|
3052
3145
|
}
|
|
3146
|
+
if (!isCurrent())
|
|
3147
|
+
return;
|
|
3053
3148
|
await st.channel.publishMaybe(payload);
|
|
3054
3149
|
}
|
|
3055
3150
|
async processDirectPubSubMessage(input) {
|
|
@@ -3176,7 +3271,9 @@ export class TopicControlPlane extends DirectStream {
|
|
|
3176
3271
|
}
|
|
3177
3272
|
}
|
|
3178
3273
|
async processShardPubSubMessage(input) {
|
|
3179
|
-
const { pubsubMessage, message, from, shardTopic } = input;
|
|
3274
|
+
const { pubsubMessage, message, from, shardTopic, isCurrent } = input;
|
|
3275
|
+
if (isCurrent?.() === false)
|
|
3276
|
+
return;
|
|
3180
3277
|
if (pubsubMessage instanceof PubSubData) {
|
|
3181
3278
|
this.dispatchEvent(new CustomEvent("data", {
|
|
3182
3279
|
detail: new DataEvent({
|
|
@@ -3223,6 +3320,8 @@ export class TopicControlPlane extends DirectStream {
|
|
|
3223
3320
|
}));
|
|
3224
3321
|
}
|
|
3225
3322
|
}
|
|
3323
|
+
if (isCurrent?.() === false)
|
|
3324
|
+
return;
|
|
3226
3325
|
if (pubsubMessage.requestSubscribers) {
|
|
3227
3326
|
const overlap = this.getSubscriptionOverlap(pubsubMessage.topics);
|
|
3228
3327
|
if (overlap.length > 0) {
|
|
@@ -3322,6 +3421,8 @@ export class TopicControlPlane extends DirectStream {
|
|
|
3322
3421
|
skipRecipientValidation: true,
|
|
3323
3422
|
});
|
|
3324
3423
|
const payload = toUint8Array(embedded.bytes());
|
|
3424
|
+
if (isCurrent?.() === false)
|
|
3425
|
+
return;
|
|
3325
3426
|
await this.sendFanoutUnicastOrBroadcast(shardTopic, senderKey, payload);
|
|
3326
3427
|
return;
|
|
3327
3428
|
}
|