@fluidframework/container-loader 2.0.2 → 2.1.0-276326
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/.eslintrc.cjs +2 -5
- package/api-extractor/api-extractor.legacy.json +4 -0
- package/api-report/container-loader.beta.api.md +0 -27
- package/api-report/{container-loader.alpha.api.md → container-loader.legacy.alpha.api.md} +0 -27
- package/api-report/container-loader.public.api.md +0 -27
- package/dist/attachment.d.ts +2 -1
- package/dist/attachment.d.ts.map +1 -1
- package/dist/attachment.js.map +1 -1
- package/dist/audience.d.ts.map +1 -1
- package/dist/audience.js +4 -4
- package/dist/audience.js.map +1 -1
- package/dist/catchUpMonitor.d.ts +15 -4
- package/dist/catchUpMonitor.d.ts.map +1 -1
- package/dist/catchUpMonitor.js +12 -3
- package/dist/catchUpMonitor.js.map +1 -1
- package/dist/connectionManager.d.ts +24 -8
- package/dist/connectionManager.d.ts.map +1 -1
- package/dist/connectionManager.js +36 -23
- package/dist/connectionManager.js.map +1 -1
- package/dist/connectionStateHandler.d.ts +30 -20
- package/dist/connectionStateHandler.d.ts.map +1 -1
- package/dist/connectionStateHandler.js +15 -11
- package/dist/connectionStateHandler.js.map +1 -1
- package/dist/container.d.ts +7 -2
- package/dist/container.d.ts.map +1 -1
- package/dist/container.js +45 -28
- package/dist/container.js.map +1 -1
- package/dist/containerContext.d.ts +8 -4
- package/dist/containerContext.d.ts.map +1 -1
- package/dist/containerContext.js +3 -1
- package/dist/containerContext.js.map +1 -1
- package/dist/containerStorageAdapter.d.ts +1 -1
- package/dist/containerStorageAdapter.d.ts.map +1 -1
- package/dist/containerStorageAdapter.js +12 -6
- package/dist/containerStorageAdapter.js.map +1 -1
- package/dist/contracts.d.ts +17 -8
- package/dist/contracts.d.ts.map +1 -1
- package/dist/contracts.js +4 -2
- package/dist/contracts.js.map +1 -1
- package/dist/debugLogger.js +3 -3
- package/dist/debugLogger.js.map +1 -1
- package/dist/deltaManager.d.ts +13 -9
- package/dist/deltaManager.d.ts.map +1 -1
- package/dist/deltaManager.js +32 -23
- package/dist/deltaManager.js.map +1 -1
- package/dist/deltaQueue.d.ts +1 -4
- package/dist/deltaQueue.d.ts.map +1 -1
- package/dist/deltaQueue.js +2 -2
- package/dist/deltaQueue.js.map +1 -1
- package/dist/disposal.d.ts +1 -1
- package/dist/disposal.d.ts.map +1 -1
- package/dist/disposal.js.map +1 -1
- package/dist/error.d.ts.map +1 -1
- package/dist/error.js.map +1 -1
- package/dist/legacy.d.ts +1 -1
- package/dist/loadPaused.d.ts +2 -2
- package/dist/loadPaused.d.ts.map +1 -1
- package/dist/loadPaused.js +7 -3
- package/dist/loadPaused.js.map +1 -1
- package/dist/loader.d.ts +10 -1
- package/dist/loader.d.ts.map +1 -1
- package/dist/loader.js +11 -1
- package/dist/loader.js.map +1 -1
- package/dist/location-redirection-utilities/resolveWithLocationRedirection.d.ts +2 -1
- package/dist/location-redirection-utilities/resolveWithLocationRedirection.d.ts.map +1 -1
- package/dist/location-redirection-utilities/resolveWithLocationRedirection.js +3 -1
- package/dist/location-redirection-utilities/resolveWithLocationRedirection.js.map +1 -1
- package/dist/memoryBlobStorage.d.ts.map +1 -1
- package/dist/memoryBlobStorage.js +4 -2
- package/dist/memoryBlobStorage.js.map +1 -1
- package/dist/noopHeuristic.js +1 -1
- package/dist/noopHeuristic.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.d.ts.map +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/protocol/protocol.d.ts +4 -3
- package/dist/protocol/protocol.d.ts.map +1 -1
- package/dist/protocol/protocol.js +6 -5
- package/dist/protocol/protocol.js.map +1 -1
- package/dist/protocol/quorum.d.ts +11 -8
- package/dist/protocol/quorum.d.ts.map +1 -1
- package/dist/protocol/quorum.js +8 -8
- package/dist/protocol/quorum.js.map +1 -1
- package/dist/protocol.d.ts +2 -0
- package/dist/protocol.d.ts.map +1 -1
- package/dist/protocol.js +7 -2
- package/dist/protocol.js.map +1 -1
- package/dist/protocolTreeDocumentStorageService.d.ts +2 -2
- package/dist/protocolTreeDocumentStorageService.d.ts.map +1 -1
- package/dist/protocolTreeDocumentStorageService.js.map +1 -1
- package/dist/retriableDocumentStorageService.d.ts.map +1 -1
- package/dist/retriableDocumentStorageService.js +4 -1
- package/dist/retriableDocumentStorageService.js.map +1 -1
- package/dist/serializedStateManager.d.ts +29 -12
- package/dist/serializedStateManager.d.ts.map +1 -1
- package/dist/serializedStateManager.js +55 -24
- package/dist/serializedStateManager.js.map +1 -1
- package/dist/utils.d.ts +4 -2
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +15 -6
- package/dist/utils.js.map +1 -1
- package/lib/attachment.d.ts +2 -1
- package/lib/attachment.d.ts.map +1 -1
- package/lib/attachment.js.map +1 -1
- package/lib/audience.d.ts.map +1 -1
- package/lib/audience.js +4 -4
- package/lib/audience.js.map +1 -1
- package/lib/catchUpMonitor.d.ts +15 -4
- package/lib/catchUpMonitor.d.ts.map +1 -1
- package/lib/catchUpMonitor.js +12 -3
- package/lib/catchUpMonitor.js.map +1 -1
- package/lib/connectionManager.d.ts +24 -8
- package/lib/connectionManager.d.ts.map +1 -1
- package/lib/connectionManager.js +36 -23
- package/lib/connectionManager.js.map +1 -1
- package/lib/connectionStateHandler.d.ts +30 -20
- package/lib/connectionStateHandler.d.ts.map +1 -1
- package/lib/connectionStateHandler.js +14 -12
- package/lib/connectionStateHandler.js.map +1 -1
- package/lib/container.d.ts +7 -2
- package/lib/container.d.ts.map +1 -1
- package/lib/container.js +45 -28
- package/lib/container.js.map +1 -1
- package/lib/containerContext.d.ts +8 -4
- package/lib/containerContext.d.ts.map +1 -1
- package/lib/containerContext.js +3 -1
- package/lib/containerContext.js.map +1 -1
- package/lib/containerStorageAdapter.d.ts +1 -1
- package/lib/containerStorageAdapter.d.ts.map +1 -1
- package/lib/containerStorageAdapter.js +12 -6
- package/lib/containerStorageAdapter.js.map +1 -1
- package/lib/contracts.d.ts +17 -8
- package/lib/contracts.d.ts.map +1 -1
- package/lib/contracts.js +4 -2
- package/lib/contracts.js.map +1 -1
- package/lib/debugLogger.js +3 -3
- package/lib/debugLogger.js.map +1 -1
- package/lib/deltaManager.d.ts +13 -9
- package/lib/deltaManager.d.ts.map +1 -1
- package/lib/deltaManager.js +32 -23
- package/lib/deltaManager.js.map +1 -1
- package/lib/deltaQueue.d.ts +1 -4
- package/lib/deltaQueue.d.ts.map +1 -1
- package/lib/deltaQueue.js +2 -2
- package/lib/deltaQueue.js.map +1 -1
- package/lib/disposal.d.ts +1 -1
- package/lib/disposal.d.ts.map +1 -1
- package/lib/disposal.js.map +1 -1
- package/lib/error.d.ts.map +1 -1
- package/lib/error.js.map +1 -1
- package/lib/legacy.d.ts +1 -1
- package/lib/loadPaused.d.ts +2 -2
- package/lib/loadPaused.d.ts.map +1 -1
- package/lib/loadPaused.js +8 -4
- package/lib/loadPaused.js.map +1 -1
- package/lib/loader.d.ts +10 -1
- package/lib/loader.d.ts.map +1 -1
- package/lib/loader.js +11 -1
- package/lib/loader.js.map +1 -1
- package/lib/location-redirection-utilities/resolveWithLocationRedirection.d.ts +2 -1
- package/lib/location-redirection-utilities/resolveWithLocationRedirection.d.ts.map +1 -1
- package/lib/location-redirection-utilities/resolveWithLocationRedirection.js +3 -1
- package/lib/location-redirection-utilities/resolveWithLocationRedirection.js.map +1 -1
- package/lib/memoryBlobStorage.d.ts.map +1 -1
- package/lib/memoryBlobStorage.js +4 -2
- package/lib/memoryBlobStorage.js.map +1 -1
- package/lib/noopHeuristic.js +1 -1
- package/lib/noopHeuristic.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.d.ts.map +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/protocol/protocol.d.ts +4 -3
- package/lib/protocol/protocol.d.ts.map +1 -1
- package/lib/protocol/protocol.js +6 -5
- package/lib/protocol/protocol.js.map +1 -1
- package/lib/protocol/quorum.d.ts +11 -8
- package/lib/protocol/quorum.d.ts.map +1 -1
- package/lib/protocol/quorum.js +8 -8
- package/lib/protocol/quorum.js.map +1 -1
- package/lib/protocol.d.ts +2 -0
- package/lib/protocol.d.ts.map +1 -1
- package/lib/protocol.js +7 -2
- package/lib/protocol.js.map +1 -1
- package/lib/protocolTreeDocumentStorageService.d.ts +2 -2
- package/lib/protocolTreeDocumentStorageService.d.ts.map +1 -1
- package/lib/protocolTreeDocumentStorageService.js.map +1 -1
- package/lib/retriableDocumentStorageService.d.ts.map +1 -1
- package/lib/retriableDocumentStorageService.js +4 -1
- package/lib/retriableDocumentStorageService.js.map +1 -1
- package/lib/serializedStateManager.d.ts +29 -12
- package/lib/serializedStateManager.d.ts.map +1 -1
- package/lib/serializedStateManager.js +56 -25
- package/lib/serializedStateManager.js.map +1 -1
- package/lib/utils.d.ts +4 -2
- package/lib/utils.d.ts.map +1 -1
- package/lib/utils.js +16 -7
- package/lib/utils.js.map +1 -1
- package/package.json +21 -17
- package/src/attachment.ts +2 -1
- package/src/audience.ts +4 -4
- package/src/catchUpMonitor.ts +23 -8
- package/src/connectionManager.ts +85 -60
- package/src/connectionStateHandler.ts +85 -63
- package/src/container.ts +118 -84
- package/src/containerContext.ts +5 -3
- package/src/containerStorageAdapter.ts +20 -13
- package/src/contracts.ts +21 -9
- package/src/debugLogger.ts +4 -4
- package/src/deltaManager.ts +75 -56
- package/src/deltaQueue.ts +16 -10
- package/src/disposal.ts +3 -3
- package/src/error.ts +2 -1
- package/src/loadPaused.ts +16 -8
- package/src/loader.ts +20 -2
- package/src/location-redirection-utilities/resolveWithLocationRedirection.ts +7 -3
- package/src/memoryBlobStorage.ts +5 -3
- package/src/noopHeuristic.ts +1 -1
- package/src/packageVersion.ts +1 -1
- package/src/protocol/protocol.ts +12 -11
- package/src/protocol/quorum.ts +49 -40
- package/src/protocol.ts +12 -4
- package/src/protocolTreeDocumentStorageService.ts +3 -2
- package/src/retriableDocumentStorageService.ts +6 -3
- package/src/serializedStateManager.ts +95 -39
- package/src/utils.ts +26 -10
package/src/protocol/quorum.ts
CHANGED
|
@@ -23,19 +23,21 @@ class PendingProposal implements ISequencedProposal {
|
|
|
23
23
|
constructor(
|
|
24
24
|
public readonly sequenceNumber: number,
|
|
25
25
|
public readonly key: string,
|
|
26
|
-
public readonly value:
|
|
26
|
+
public readonly value: unknown,
|
|
27
27
|
public readonly local: boolean,
|
|
28
28
|
) {}
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
/**
|
|
32
32
|
* Snapshot format for a QuorumClients
|
|
33
|
+
* @legacy
|
|
33
34
|
* @alpha
|
|
34
35
|
*/
|
|
35
36
|
export type QuorumClientsSnapshot = [string, ISequencedClient][];
|
|
36
37
|
|
|
37
38
|
/**
|
|
38
39
|
* Snapshot format for a QuorumProposals
|
|
40
|
+
* @legacy
|
|
39
41
|
* @alpha
|
|
40
42
|
*/
|
|
41
43
|
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions
|
|
@@ -46,6 +48,7 @@ export type QuorumProposalsSnapshot = {
|
|
|
46
48
|
|
|
47
49
|
/**
|
|
48
50
|
* Snapshot format for a Quorum
|
|
51
|
+
* @legacy
|
|
49
52
|
* @alpha
|
|
50
53
|
*/
|
|
51
54
|
export interface IQuorumSnapshot {
|
|
@@ -64,7 +67,7 @@ export class QuorumClients
|
|
|
64
67
|
{
|
|
65
68
|
private readonly members: Map<string, ISequencedClient>;
|
|
66
69
|
private isDisposed: boolean = false;
|
|
67
|
-
public get disposed() {
|
|
70
|
+
public get disposed(): boolean {
|
|
68
71
|
return this.isDisposed;
|
|
69
72
|
}
|
|
70
73
|
|
|
@@ -86,7 +89,7 @@ export class QuorumClients
|
|
|
86
89
|
* @returns a snapshot of the clients in the quorum
|
|
87
90
|
*/
|
|
88
91
|
public snapshot(): QuorumClientsSnapshot {
|
|
89
|
-
this.snapshotCache ??=
|
|
92
|
+
this.snapshotCache ??= [...this.members];
|
|
90
93
|
|
|
91
94
|
return this.snapshotCache;
|
|
92
95
|
}
|
|
@@ -94,7 +97,7 @@ export class QuorumClients
|
|
|
94
97
|
/**
|
|
95
98
|
* Adds a new client to the quorum
|
|
96
99
|
*/
|
|
97
|
-
public addMember(clientId: string, details: ISequencedClient) {
|
|
100
|
+
public addMember(clientId: string, details: ISequencedClient): void {
|
|
98
101
|
assert(!!clientId, 0x9a0 /* clientId has to be non-empty string */);
|
|
99
102
|
assert(!this.members.has(clientId), 0x9a1 /* clientId not found */);
|
|
100
103
|
this.members.set(clientId, details);
|
|
@@ -107,7 +110,7 @@ export class QuorumClients
|
|
|
107
110
|
/**
|
|
108
111
|
* Removes a client from the quorum
|
|
109
112
|
*/
|
|
110
|
-
public removeMember(clientId: string) {
|
|
113
|
+
public removeMember(clientId: string): void {
|
|
111
114
|
assert(!!clientId, 0x9a2 /* clientId has to be non-empty string */);
|
|
112
115
|
assert(this.members.has(clientId), 0x9a3 /* clientId not found */);
|
|
113
116
|
this.members.delete(clientId);
|
|
@@ -148,7 +151,7 @@ export class QuorumProposals
|
|
|
148
151
|
private readonly proposals: Map<number, PendingProposal>;
|
|
149
152
|
private readonly values: Map<string, ICommittedProposal>;
|
|
150
153
|
private isDisposed: boolean = false;
|
|
151
|
-
public get disposed() {
|
|
154
|
+
public get disposed(): boolean {
|
|
152
155
|
return this.isDisposed;
|
|
153
156
|
}
|
|
154
157
|
|
|
@@ -164,7 +167,7 @@ export class QuorumProposals
|
|
|
164
167
|
|
|
165
168
|
constructor(
|
|
166
169
|
snapshot: QuorumProposalsSnapshot,
|
|
167
|
-
private readonly sendProposal: (key: string, value:
|
|
170
|
+
private readonly sendProposal: (key: string, value: unknown) => number,
|
|
168
171
|
) {
|
|
169
172
|
super();
|
|
170
173
|
|
|
@@ -191,14 +194,12 @@ export class QuorumProposals
|
|
|
191
194
|
* @returns arrays of proposals and values
|
|
192
195
|
*/
|
|
193
196
|
public snapshot(): QuorumProposalsSnapshot {
|
|
194
|
-
this.proposalsSnapshotCache ??=
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
);
|
|
201
|
-
this.valuesSnapshotCache ??= Array.from(this.values);
|
|
197
|
+
this.proposalsSnapshotCache ??= [...this.proposals].map(([sequenceNumber, proposal]) => [
|
|
198
|
+
sequenceNumber,
|
|
199
|
+
{ sequenceNumber, key: proposal.key, value: proposal.value },
|
|
200
|
+
[], // rejections, which has been removed
|
|
201
|
+
]);
|
|
202
|
+
this.valuesSnapshotCache ??= [...this.values];
|
|
202
203
|
|
|
203
204
|
return {
|
|
204
205
|
proposals: this.proposalsSnapshotCache,
|
|
@@ -216,7 +217,7 @@ export class QuorumProposals
|
|
|
216
217
|
/**
|
|
217
218
|
* Returns the consensus value for the given key
|
|
218
219
|
*/
|
|
219
|
-
public get(key: string):
|
|
220
|
+
public get(key: string): unknown {
|
|
220
221
|
return this.values.get(key)?.value;
|
|
221
222
|
}
|
|
222
223
|
|
|
@@ -233,7 +234,7 @@ export class QuorumProposals
|
|
|
233
234
|
* - Resolve when the proposal is accepted
|
|
234
235
|
* - Reject if the proposal fails to send or if the QuorumProposals is disposed
|
|
235
236
|
*/
|
|
236
|
-
public async propose(key: string, value:
|
|
237
|
+
public async propose(key: string, value: unknown): Promise<void> {
|
|
237
238
|
const clientSequenceNumber = this.sendProposal(key, value);
|
|
238
239
|
if (clientSequenceNumber < 0) {
|
|
239
240
|
this.emit("error", { eventName: "ProposalInDisconnectedState", key });
|
|
@@ -248,7 +249,10 @@ export class QuorumProposals
|
|
|
248
249
|
// A proposal goes through two phases before this promise resolves:
|
|
249
250
|
// 1. Sequencing - waiting for the proposal to be ack'd by the server.
|
|
250
251
|
// 2. Approval - waiting for the proposal to be approved by connected clients.
|
|
251
|
-
const localProposalSequencedHandler = (
|
|
252
|
+
const localProposalSequencedHandler = (
|
|
253
|
+
sequencedCSN: number,
|
|
254
|
+
sequenceNumber: number,
|
|
255
|
+
): void => {
|
|
252
256
|
if (sequencedCSN === clientSequenceNumber) {
|
|
253
257
|
thisProposalSequenceNumber = sequenceNumber;
|
|
254
258
|
this.stateEvents.off("localProposalSequenced", localProposalSequencedHandler);
|
|
@@ -256,7 +260,7 @@ export class QuorumProposals
|
|
|
256
260
|
this.stateEvents.on("localProposalApproved", localProposalApprovedHandler);
|
|
257
261
|
}
|
|
258
262
|
};
|
|
259
|
-
const localProposalApprovedHandler = (sequenceNumber: number) => {
|
|
263
|
+
const localProposalApprovedHandler = (sequenceNumber: number): void => {
|
|
260
264
|
// Proposals can be uniquely identified by the sequenceNumber they were assigned.
|
|
261
265
|
if (sequenceNumber === thisProposalSequenceNumber) {
|
|
262
266
|
resolve();
|
|
@@ -270,7 +274,7 @@ export class QuorumProposals
|
|
|
270
274
|
// -> The promise can still resolve, once it is approved.
|
|
271
275
|
// 2. We reconnect and see the proposal was not sequenced in the meantime, so it will never sequence.
|
|
272
276
|
// -> The promise rejects.
|
|
273
|
-
const disconnectedHandler = () => {
|
|
277
|
+
const disconnectedHandler = (): void => {
|
|
274
278
|
// If we haven't seen the ack by the time we disconnect, we hope to see it by the time we reconnect.
|
|
275
279
|
if (thisProposalSequenceNumber === undefined) {
|
|
276
280
|
this.stateEvents.once("connected", () => {
|
|
@@ -284,12 +288,12 @@ export class QuorumProposals
|
|
|
284
288
|
};
|
|
285
289
|
// If the QuorumProposals is disposed of, we assume something catastrophic has happened
|
|
286
290
|
// All outstanding proposals are considered rejected.
|
|
287
|
-
const disposedHandler = () => {
|
|
291
|
+
const disposedHandler = (): void => {
|
|
288
292
|
reject(new Error("QuorumProposals was disposed"));
|
|
289
293
|
removeListeners();
|
|
290
294
|
};
|
|
291
295
|
// Convenience function to clean up our listeners.
|
|
292
|
-
const removeListeners = () => {
|
|
296
|
+
const removeListeners = (): void => {
|
|
293
297
|
this.stateEvents.off("localProposalSequenced", localProposalSequencedHandler);
|
|
294
298
|
this.stateEvents.off("localProposalApproved", localProposalApprovedHandler);
|
|
295
299
|
this.stateEvents.off("disconnected", disconnectedHandler);
|
|
@@ -306,11 +310,11 @@ export class QuorumProposals
|
|
|
306
310
|
*/
|
|
307
311
|
public addProposal(
|
|
308
312
|
key: string,
|
|
309
|
-
value:
|
|
313
|
+
value: unknown,
|
|
310
314
|
sequenceNumber: number,
|
|
311
315
|
local: boolean,
|
|
312
316
|
clientSequenceNumber: number,
|
|
313
|
-
) {
|
|
317
|
+
): void {
|
|
314
318
|
assert(!this.proposals.has(sequenceNumber), 0x9a4 /* sequenceNumber not found */);
|
|
315
319
|
|
|
316
320
|
const proposal = new PendingProposal(sequenceNumber, key, value, local);
|
|
@@ -368,13 +372,13 @@ export class QuorumProposals
|
|
|
368
372
|
let proposalKeySeen = false;
|
|
369
373
|
for (const [, p] of this.proposals) {
|
|
370
374
|
if (p.key === committedProposal.key) {
|
|
371
|
-
if (
|
|
372
|
-
// set proposalSettled to true if the proposal key match is unique thus far
|
|
373
|
-
proposalSettled = true;
|
|
374
|
-
} else {
|
|
375
|
+
if (proposalKeySeen) {
|
|
375
376
|
// set proposalSettled to false if matching proposal key is not unique
|
|
376
377
|
proposalSettled = false;
|
|
377
378
|
break;
|
|
379
|
+
} else {
|
|
380
|
+
// set proposalSettled to true if the proposal key match is unique thus far
|
|
381
|
+
proposalSettled = true;
|
|
378
382
|
}
|
|
379
383
|
proposalKeySeen = true;
|
|
380
384
|
}
|
|
@@ -409,7 +413,7 @@ export class QuorumProposals
|
|
|
409
413
|
}
|
|
410
414
|
}
|
|
411
415
|
|
|
412
|
-
public setConnectionState(connected: boolean) {
|
|
416
|
+
public setConnectionState(connected: boolean): void {
|
|
413
417
|
if (connected) {
|
|
414
418
|
this.stateEvents.emit("connected");
|
|
415
419
|
} else {
|
|
@@ -432,7 +436,7 @@ export class Quorum extends TypedEventEmitter<IQuorum["on"]> implements IQuorum
|
|
|
432
436
|
private readonly quorumClients: QuorumClients;
|
|
433
437
|
private readonly quorumProposals: QuorumProposals;
|
|
434
438
|
private readonly isDisposed: boolean = false;
|
|
435
|
-
public get disposed() {
|
|
439
|
+
public get disposed(): boolean {
|
|
436
440
|
return this.isDisposed;
|
|
437
441
|
}
|
|
438
442
|
|
|
@@ -440,7 +444,7 @@ export class Quorum extends TypedEventEmitter<IQuorum["on"]> implements IQuorum
|
|
|
440
444
|
members: QuorumClientsSnapshot,
|
|
441
445
|
proposals: QuorumProposalsSnapshot["proposals"],
|
|
442
446
|
values: QuorumProposalsSnapshot["values"],
|
|
443
|
-
sendProposal: (key: string, value:
|
|
447
|
+
sendProposal: (key: string, value: unknown) => number,
|
|
444
448
|
) {
|
|
445
449
|
super();
|
|
446
450
|
|
|
@@ -458,13 +462,18 @@ export class Quorum extends TypedEventEmitter<IQuorum["on"]> implements IQuorum
|
|
|
458
462
|
});
|
|
459
463
|
this.quorumProposals.on(
|
|
460
464
|
"approveProposal",
|
|
461
|
-
(
|
|
465
|
+
(
|
|
466
|
+
sequenceNumber: number,
|
|
467
|
+
key: string,
|
|
468
|
+
value: unknown,
|
|
469
|
+
approvalSequenceNumber: number,
|
|
470
|
+
) => {
|
|
462
471
|
this.emit("approveProposal", sequenceNumber, key, value, approvalSequenceNumber);
|
|
463
472
|
},
|
|
464
473
|
);
|
|
465
474
|
}
|
|
466
475
|
|
|
467
|
-
public close() {
|
|
476
|
+
public close(): void {
|
|
468
477
|
this.removeAllListeners();
|
|
469
478
|
}
|
|
470
479
|
|
|
@@ -492,7 +501,7 @@ export class Quorum extends TypedEventEmitter<IQuorum["on"]> implements IQuorum
|
|
|
492
501
|
/**
|
|
493
502
|
* Returns the consensus value for the given key
|
|
494
503
|
*/
|
|
495
|
-
public get(key: string):
|
|
504
|
+
public get(key: string): unknown {
|
|
496
505
|
return this.quorumProposals.get(key);
|
|
497
506
|
}
|
|
498
507
|
|
|
@@ -507,14 +516,14 @@ export class Quorum extends TypedEventEmitter<IQuorum["on"]> implements IQuorum
|
|
|
507
516
|
/**
|
|
508
517
|
* Adds a new client to the quorum
|
|
509
518
|
*/
|
|
510
|
-
public addMember(clientId: string, details: ISequencedClient) {
|
|
519
|
+
public addMember(clientId: string, details: ISequencedClient): void {
|
|
511
520
|
this.quorumClients.addMember(clientId, details);
|
|
512
521
|
}
|
|
513
522
|
|
|
514
523
|
/**
|
|
515
524
|
* Removes a client from the quorum
|
|
516
525
|
*/
|
|
517
|
-
public removeMember(clientId: string) {
|
|
526
|
+
public removeMember(clientId: string): void {
|
|
518
527
|
this.quorumClients.removeMember(clientId);
|
|
519
528
|
}
|
|
520
529
|
|
|
@@ -536,7 +545,7 @@ export class Quorum extends TypedEventEmitter<IQuorum["on"]> implements IQuorum
|
|
|
536
545
|
* Proposes a new value. Returns a promise that will resolve when the proposal is either accepted, or reject if
|
|
537
546
|
* the proposal fails to send.
|
|
538
547
|
*/
|
|
539
|
-
public async propose(key: string, value:
|
|
548
|
+
public async propose(key: string, value: unknown): Promise<void> {
|
|
540
549
|
return this.quorumProposals.propose(key, value);
|
|
541
550
|
}
|
|
542
551
|
|
|
@@ -545,11 +554,11 @@ export class Quorum extends TypedEventEmitter<IQuorum["on"]> implements IQuorum
|
|
|
545
554
|
*/
|
|
546
555
|
public addProposal(
|
|
547
556
|
key: string,
|
|
548
|
-
value:
|
|
557
|
+
value: unknown,
|
|
549
558
|
sequenceNumber: number,
|
|
550
559
|
local: boolean,
|
|
551
560
|
clientSequenceNumber: number,
|
|
552
|
-
) {
|
|
561
|
+
): void {
|
|
553
562
|
return this.quorumProposals.addProposal(
|
|
554
563
|
key,
|
|
555
564
|
value,
|
|
@@ -567,7 +576,7 @@ export class Quorum extends TypedEventEmitter<IQuorum["on"]> implements IQuorum
|
|
|
567
576
|
this.quorumProposals.updateMinimumSequenceNumber(message);
|
|
568
577
|
}
|
|
569
578
|
|
|
570
|
-
public setConnectionState(connected: boolean, clientId?: string) {
|
|
579
|
+
public setConnectionState(connected: boolean, clientId?: string): void {
|
|
571
580
|
this.quorumProposals.setConnectionState(connected);
|
|
572
581
|
}
|
|
573
582
|
|
package/src/protocol.ts
CHANGED
|
@@ -25,15 +25,19 @@ export enum SignalType {
|
|
|
25
25
|
|
|
26
26
|
/**
|
|
27
27
|
* Function to be used for creating a protocol handler.
|
|
28
|
+
* @legacy
|
|
28
29
|
* @alpha
|
|
29
30
|
*/
|
|
30
31
|
export type ProtocolHandlerBuilder = (
|
|
31
32
|
attributes: IDocumentAttributes,
|
|
32
33
|
snapshot: IQuorumSnapshot,
|
|
34
|
+
// TODO: use a real type (breaking change)
|
|
35
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
33
36
|
sendProposal: (key: string, value: any) => number,
|
|
34
37
|
) => IProtocolHandler;
|
|
35
38
|
|
|
36
39
|
/**
|
|
40
|
+
* @legacy
|
|
37
41
|
* @alpha
|
|
38
42
|
*/
|
|
39
43
|
export interface IProtocolHandler extends IBaseProtocolHandler {
|
|
@@ -45,6 +49,8 @@ export class ProtocolHandler extends ProtocolOpHandler implements IProtocolHandl
|
|
|
45
49
|
constructor(
|
|
46
50
|
attributes: IDocumentAttributes,
|
|
47
51
|
quorumSnapshot: IQuorumSnapshot,
|
|
52
|
+
// TODO: use a real type (breaking change)
|
|
53
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
48
54
|
sendProposal: (key: string, value: any) => number,
|
|
49
55
|
public readonly audience: IAudienceOwner,
|
|
50
56
|
private readonly shouldClientHaveLeft: (clientId: string) => boolean,
|
|
@@ -78,6 +84,7 @@ export class ProtocolHandler extends ProtocolOpHandler implements IProtocolHandl
|
|
|
78
84
|
): IProcessMessageResult {
|
|
79
85
|
// Check and report if we're getting messages from a clientId that we previously
|
|
80
86
|
// flagged as shouldHaveLeft, or from a client that's not in the quorum but should be
|
|
87
|
+
// eslint-disable-next-line unicorn/no-null
|
|
81
88
|
if (message.clientId != null) {
|
|
82
89
|
const client = this.quorum.getMember(message.clientId);
|
|
83
90
|
|
|
@@ -98,8 +105,8 @@ export class ProtocolHandler extends ProtocolOpHandler implements IProtocolHandl
|
|
|
98
105
|
return super.processMessage(message, local);
|
|
99
106
|
}
|
|
100
107
|
|
|
101
|
-
public processSignal(message: ISignalMessage) {
|
|
102
|
-
const innerContent = message.content as { content:
|
|
108
|
+
public processSignal(message: ISignalMessage): void {
|
|
109
|
+
const innerContent = message.content as { content: unknown; type: string };
|
|
103
110
|
switch (innerContent.type) {
|
|
104
111
|
case SignalType.Clear: {
|
|
105
112
|
const members = this.audience.getMembers();
|
|
@@ -126,8 +133,9 @@ export class ProtocolHandler extends ProtocolOpHandler implements IProtocolHandl
|
|
|
126
133
|
}
|
|
127
134
|
break;
|
|
128
135
|
}
|
|
129
|
-
default:
|
|
136
|
+
default: {
|
|
130
137
|
break;
|
|
138
|
+
}
|
|
131
139
|
}
|
|
132
140
|
}
|
|
133
141
|
}
|
|
@@ -137,7 +145,7 @@ export class ProtocolHandler extends ProtocolOpHandler implements IProtocolHandl
|
|
|
137
145
|
* The protocol handler should strictly handle only ClientJoin, ClientLeave
|
|
138
146
|
* and Clear signal types.
|
|
139
147
|
*/
|
|
140
|
-
export function protocolHandlerShouldProcessSignal(message: ISignalMessage) {
|
|
148
|
+
export function protocolHandlerShouldProcessSignal(message: ISignalMessage): boolean {
|
|
141
149
|
// Signal originates from server
|
|
142
150
|
if (message.clientId === null) {
|
|
143
151
|
const innerContent = message.content as { content: unknown; type: string };
|
|
@@ -8,6 +8,7 @@ import { ISummaryTree } from "@fluidframework/driver-definitions";
|
|
|
8
8
|
import {
|
|
9
9
|
IDocumentStorageService,
|
|
10
10
|
ISummaryContext,
|
|
11
|
+
type IDocumentStorageServicePolicies,
|
|
11
12
|
} from "@fluidframework/driver-definitions/internal";
|
|
12
13
|
|
|
13
14
|
/**
|
|
@@ -34,10 +35,10 @@ export class ProtocolTreeStorageService implements IDocumentStorageService, IDis
|
|
|
34
35
|
this.downloadSummary = internalStorageService.downloadSummary.bind(internalStorageService);
|
|
35
36
|
this.dispose = internalStorageService.dispose.bind(internalStorageService);
|
|
36
37
|
}
|
|
37
|
-
public get policies() {
|
|
38
|
+
public get policies(): IDocumentStorageServicePolicies | undefined {
|
|
38
39
|
return this.internalStorageService.policies;
|
|
39
40
|
}
|
|
40
|
-
public get disposed() {
|
|
41
|
+
public get disposed(): boolean {
|
|
41
42
|
return this.internalStorageService.disposed;
|
|
42
43
|
}
|
|
43
44
|
|
|
@@ -42,16 +42,17 @@ export class RetriableDocumentStorageService implements IDocumentStorageService,
|
|
|
42
42
|
}
|
|
43
43
|
throw new Error("storage service not yet instantiated");
|
|
44
44
|
}
|
|
45
|
-
public get disposed() {
|
|
45
|
+
public get disposed(): boolean {
|
|
46
46
|
return this._disposed;
|
|
47
47
|
}
|
|
48
|
-
public dispose() {
|
|
48
|
+
public dispose(): void {
|
|
49
49
|
this._disposed = true;
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
public async getSnapshotTree(
|
|
53
53
|
version?: IVersion,
|
|
54
54
|
scenarioName?: string,
|
|
55
|
+
// eslint-disable-next-line @rushstack/no-new-null -- API used below returns null
|
|
55
56
|
): Promise<ISnapshotTree | null> {
|
|
56
57
|
return this.runWithRetry(
|
|
57
58
|
async () =>
|
|
@@ -85,6 +86,8 @@ export class RetriableDocumentStorageService implements IDocumentStorageService,
|
|
|
85
86
|
}
|
|
86
87
|
|
|
87
88
|
public async getVersions(
|
|
89
|
+
// API used below returns null
|
|
90
|
+
// eslint-disable-next-line @rushstack/no-new-null
|
|
88
91
|
versionId: string | null,
|
|
89
92
|
count: number,
|
|
90
93
|
scenarioName?: string,
|
|
@@ -146,7 +149,7 @@ export class RetriableDocumentStorageService implements IDocumentStorageService,
|
|
|
146
149
|
);
|
|
147
150
|
}
|
|
148
151
|
|
|
149
|
-
private checkStorageDisposed(callName: string, error: unknown) {
|
|
152
|
+
private checkStorageDisposed(callName: string, error: unknown): void {
|
|
150
153
|
if (this._disposed) {
|
|
151
154
|
this.logger.sendTelemetryEvent(
|
|
152
155
|
{
|