@peerbit/shared-log 13.2.33 → 13.2.35
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 +7 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +284 -91
- package/dist/src/index.js.map +1 -1
- package/dist/src/peer-session.d.ts +2 -1
- package/dist/src/peer-session.d.ts.map +1 -1
- package/dist/src/peer-session.js +8 -2
- package/dist/src/peer-session.js.map +1 -1
- package/dist/src/replication-announcement.d.ts +1 -0
- package/dist/src/replication-announcement.d.ts.map +1 -1
- package/dist/src/replication-announcement.js +16 -2
- package/dist/src/replication-announcement.js.map +1 -1
- package/dist/src/replication-info-v2-receive.d.ts +84 -4
- package/dist/src/replication-info-v2-receive.d.ts.map +1 -1
- package/dist/src/replication-info-v2-receive.js +441 -7
- package/dist/src/replication-info-v2-receive.js.map +1 -1
- package/dist/src/replication-info-v2-send.d.ts +20 -0
- package/dist/src/replication-info-v2-send.d.ts.map +1 -1
- package/dist/src/replication-info-v2-send.js +177 -55
- package/dist/src/replication-info-v2-send.js.map +1 -1
- package/dist/src/sync/factory.js +1 -1
- package/dist/src/sync/factory.js.map +1 -1
- package/package.json +11 -11
- package/src/index.ts +350 -123
- package/src/peer-session.ts +8 -0
- package/src/replication-announcement.ts +17 -2
- package/src/replication-info-v2-receive.ts +634 -11
- package/src/replication-info-v2-send.ts +227 -65
- package/src/sync/factory.ts +1 -1
package/src/peer-session.ts
CHANGED
|
@@ -31,6 +31,11 @@ export type PeerReceiveAdmissionOptions = {
|
|
|
31
31
|
export class PeerSession {
|
|
32
32
|
readonly peerHash: string;
|
|
33
33
|
readonly kind: PeerSessionKind;
|
|
34
|
+
// True when rotate() superseded an earlier subscription generation. This is
|
|
35
|
+
// deliberately independent of the predecessor's phase/kind: a newer
|
|
36
|
+
// transport can announce a subscription without first delivering an
|
|
37
|
+
// unsubscribe, and must not inherit the old transport's signed capability.
|
|
38
|
+
readonly hasPredecessor: boolean;
|
|
34
39
|
// The lifecycle controller live at rotation. All current seams pair the
|
|
35
40
|
// epoch check with a lifecycle check against a controller captured in the
|
|
36
41
|
// same synchronous window as the epoch advance; capturing it here
|
|
@@ -59,10 +64,12 @@ export class PeerSession {
|
|
|
59
64
|
peerHash: string,
|
|
60
65
|
kind: PeerSessionKind,
|
|
61
66
|
replicationLifecycleController: AbortController | undefined,
|
|
67
|
+
hasPredecessor: boolean,
|
|
62
68
|
) {
|
|
63
69
|
this.peerHash = peerHash;
|
|
64
70
|
this.kind = kind;
|
|
65
71
|
this.replicationLifecycleController = replicationLifecycleController;
|
|
72
|
+
this.hasPredecessor = hasPredecessor;
|
|
66
73
|
this.phase = kind;
|
|
67
74
|
}
|
|
68
75
|
|
|
@@ -278,6 +285,7 @@ export class PeerSessionRegistry {
|
|
|
278
285
|
peerHash,
|
|
279
286
|
kind,
|
|
280
287
|
this.deps.getReplicationLifecycleController(),
|
|
288
|
+
previous !== undefined,
|
|
281
289
|
);
|
|
282
290
|
this.sessions.set(peerHash, next);
|
|
283
291
|
return next;
|
|
@@ -204,9 +204,10 @@ export type ReplicationAnnouncementDeps<R extends "u32" | "u64"> = {
|
|
|
204
204
|
// Owner-routed so coordinator spies keep observing re-entrant queueing.
|
|
205
205
|
queueCurrentReplicationStateAnnouncementRepair: () => void;
|
|
206
206
|
queueCurrentReplicationStateAnnouncementRetry: (error: unknown) => boolean;
|
|
207
|
-
//
|
|
208
|
-
// retains its exact rejection/retry semantics
|
|
207
|
+
// V2 is always current. Legacy publication is enabled only for an explicit
|
|
208
|
+
// compatibility open and retains its exact rejection/retry semantics there.
|
|
209
209
|
enqueueReplicationInfoV2: (message: LegacyReplicationInfoMessage) => void;
|
|
210
|
+
isLegacyReplicationInfoEnabled: () => boolean;
|
|
210
211
|
};
|
|
211
212
|
|
|
212
213
|
type LegacyReplicationInfoMessage =
|
|
@@ -270,6 +271,7 @@ export class ReplicationAnnouncementCoordinator<R extends "u32" | "u64"> {
|
|
|
270
271
|
|
|
271
272
|
queueCurrentReplicationStateAnnouncementRetry(error: unknown): boolean {
|
|
272
273
|
if (
|
|
274
|
+
!this.deps.isLegacyReplicationInfoEnabled() ||
|
|
273
275
|
this.deps.isClosed() ||
|
|
274
276
|
this.deps.getCloseSignal().aborted ||
|
|
275
277
|
this._replicationAnnouncementRetryController.signal.aborted ||
|
|
@@ -362,6 +364,7 @@ export class ReplicationAnnouncementCoordinator<R extends "u32" | "u64"> {
|
|
|
362
364
|
|
|
363
365
|
queueCurrentReplicationStateAnnouncementRepair(): void {
|
|
364
366
|
if (
|
|
367
|
+
!this.deps.isLegacyReplicationInfoEnabled() ||
|
|
365
368
|
this.deps.isClosed() ||
|
|
366
369
|
this.deps.getCloseSignal().aborted ||
|
|
367
370
|
this._replicationAnnouncementRepairController.signal.aborted ||
|
|
@@ -437,6 +440,11 @@ export class ReplicationAnnouncementCoordinator<R extends "u32" | "u64"> {
|
|
|
437
440
|
async repairCurrentReplicationStateAnnouncement(
|
|
438
441
|
context?: ReplicationAnnouncementRepairWorkerContext,
|
|
439
442
|
): Promise<void> {
|
|
443
|
+
if (!this.deps.isLegacyReplicationInfoEnabled()) {
|
|
444
|
+
this._announcementRepairBinding.pending = false;
|
|
445
|
+
this._announcementRepairBinding.targets.clear();
|
|
446
|
+
return;
|
|
447
|
+
}
|
|
440
448
|
if (!this._announcementRepairBinding.pending) {
|
|
441
449
|
return;
|
|
442
450
|
}
|
|
@@ -645,6 +653,9 @@ export class ReplicationAnnouncementCoordinator<R extends "u32" | "u64"> {
|
|
|
645
653
|
this.rotateAnnouncementSession();
|
|
646
654
|
this.advanceCurrentReplicationStateAnnouncementRepairGeneration();
|
|
647
655
|
this.deps.enqueueReplicationInfoV2(message);
|
|
656
|
+
if (!this.deps.isLegacyReplicationInfoEnabled()) {
|
|
657
|
+
return;
|
|
658
|
+
}
|
|
648
659
|
try {
|
|
649
660
|
await this.deps.getRpc().send(message, {
|
|
650
661
|
priority: CONVERGENCE_MESSAGE_PRIORITY,
|
|
@@ -677,6 +688,10 @@ export class ReplicationAnnouncementCoordinator<R extends "u32" | "u64"> {
|
|
|
677
688
|
}
|
|
678
689
|
|
|
679
690
|
async retryCurrentReplicationStateAnnouncement(): Promise<void> {
|
|
691
|
+
if (!this.deps.isLegacyReplicationInfoEnabled()) {
|
|
692
|
+
this._replicationAnnouncementRetryPending = false;
|
|
693
|
+
return;
|
|
694
|
+
}
|
|
680
695
|
const session = this._announcementSession;
|
|
681
696
|
const controller = this._replicationAnnouncementRetryController;
|
|
682
697
|
try {
|