@fluidframework/container-loader 2.0.0-dev-rc.5.0.0.267932 → 2.0.0-dev-rc.5.0.0.270401
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/api-report/{container-loader.api.md → container-loader.alpha.api.md} +58 -15
- package/api-report/container-loader.beta.api.md +44 -0
- package/api-report/container-loader.public.api.md +44 -0
- package/dist/audience.js +2 -1
- package/dist/audience.js.map +1 -1
- package/dist/catchUpMonitor.js +11 -8
- package/dist/catchUpMonitor.js.map +1 -1
- package/dist/connectionManager.d.ts +2 -2
- package/dist/connectionManager.d.ts.map +1 -1
- package/dist/connectionManager.js +91 -63
- package/dist/connectionManager.js.map +1 -1
- package/dist/connectionStateHandler.js +35 -11
- package/dist/connectionStateHandler.js.map +1 -1
- package/dist/container.d.ts +2 -2
- package/dist/container.d.ts.map +1 -1
- package/dist/container.js +156 -123
- package/dist/container.js.map +1 -1
- package/dist/containerContext.d.ts +2 -2
- package/dist/containerContext.d.ts.map +1 -1
- package/dist/containerContext.js +34 -8
- package/dist/containerContext.js.map +1 -1
- package/dist/containerStorageAdapter.js +17 -9
- package/dist/containerStorageAdapter.js.map +1 -1
- package/dist/contracts.d.ts +2 -2
- package/dist/contracts.d.ts.map +1 -1
- package/dist/contracts.js.map +1 -1
- package/dist/debugLogger.js +2 -0
- package/dist/debugLogger.js.map +1 -1
- package/dist/deltaManager.d.ts +2 -2
- package/dist/deltaManager.d.ts.map +1 -1
- package/dist/deltaManager.js +48 -35
- package/dist/deltaManager.js.map +1 -1
- package/dist/deltaQueue.js +14 -7
- package/dist/deltaQueue.js.map +1 -1
- package/dist/error.js +5 -4
- package/dist/error.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/legacy.d.ts +5 -0
- package/dist/loader.js +5 -1
- package/dist/loader.js.map +1 -1
- package/dist/noopHeuristic.d.ts +1 -1
- package/dist/noopHeuristic.d.ts.map +1 -1
- package/dist/noopHeuristic.js +3 -1
- package/dist/noopHeuristic.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/protocol/index.d.ts +7 -0
- package/dist/protocol/index.d.ts.map +1 -0
- package/dist/protocol/index.js +12 -0
- package/dist/protocol/index.js.map +1 -0
- package/dist/protocol/protocol.d.ts +52 -0
- package/dist/protocol/protocol.d.ts.map +1 -0
- package/dist/protocol/protocol.js +115 -0
- package/dist/protocol/protocol.js.map +1 -0
- package/dist/protocol/quorum.d.ts +185 -0
- package/dist/protocol/quorum.d.ts.map +1 -0
- package/dist/protocol/quorum.js +440 -0
- package/dist/protocol/quorum.js.map +1 -0
- package/dist/protocol.d.ts +2 -3
- package/dist/protocol.d.ts.map +1 -1
- package/dist/protocol.js +4 -2
- package/dist/protocol.js.map +1 -1
- package/dist/protocolTreeDocumentStorageService.d.ts +7 -7
- package/dist/protocolTreeDocumentStorageService.d.ts.map +1 -1
- package/dist/protocolTreeDocumentStorageService.js +16 -7
- package/dist/protocolTreeDocumentStorageService.js.map +1 -1
- package/dist/retriableDocumentStorageService.js +4 -1
- package/dist/retriableDocumentStorageService.js.map +1 -1
- package/dist/serializedStateManager.d.ts +1 -2
- package/dist/serializedStateManager.d.ts.map +1 -1
- package/dist/serializedStateManager.js +10 -2
- package/dist/serializedStateManager.js.map +1 -1
- package/lib/audience.js +2 -1
- package/lib/audience.js.map +1 -1
- package/lib/catchUpMonitor.js +11 -8
- package/lib/catchUpMonitor.js.map +1 -1
- package/lib/connectionManager.d.ts +2 -2
- package/lib/connectionManager.d.ts.map +1 -1
- package/lib/connectionManager.js +91 -63
- package/lib/connectionManager.js.map +1 -1
- package/lib/connectionStateHandler.js +35 -11
- package/lib/connectionStateHandler.js.map +1 -1
- package/lib/container.d.ts +2 -2
- package/lib/container.d.ts.map +1 -1
- package/lib/container.js +156 -123
- package/lib/container.js.map +1 -1
- package/lib/containerContext.d.ts +2 -2
- package/lib/containerContext.d.ts.map +1 -1
- package/lib/containerContext.js +34 -8
- package/lib/containerContext.js.map +1 -1
- package/lib/containerStorageAdapter.js +17 -9
- package/lib/containerStorageAdapter.js.map +1 -1
- package/lib/contracts.d.ts +2 -2
- package/lib/contracts.d.ts.map +1 -1
- package/lib/contracts.js.map +1 -1
- package/lib/debugLogger.js +2 -0
- package/lib/debugLogger.js.map +1 -1
- package/lib/deltaManager.d.ts +2 -2
- package/lib/deltaManager.d.ts.map +1 -1
- package/lib/deltaManager.js +48 -35
- package/lib/deltaManager.js.map +1 -1
- package/lib/deltaQueue.js +14 -7
- package/lib/deltaQueue.js.map +1 -1
- package/lib/error.js +5 -4
- package/lib/error.js.map +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js.map +1 -1
- package/lib/legacy.d.ts +5 -0
- package/lib/loader.js +5 -1
- package/lib/loader.js.map +1 -1
- package/lib/noopHeuristic.d.ts +1 -1
- package/lib/noopHeuristic.d.ts.map +1 -1
- package/lib/noopHeuristic.js +3 -1
- package/lib/noopHeuristic.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/protocol/index.d.ts +7 -0
- package/lib/protocol/index.d.ts.map +1 -0
- package/lib/protocol/index.js +7 -0
- package/lib/protocol/index.js.map +1 -0
- package/lib/protocol/protocol.d.ts +52 -0
- package/lib/protocol/protocol.d.ts.map +1 -0
- package/lib/protocol/protocol.js +111 -0
- package/lib/protocol/protocol.js.map +1 -0
- package/lib/protocol/quorum.d.ts +185 -0
- package/lib/protocol/quorum.d.ts.map +1 -0
- package/lib/protocol/quorum.js +431 -0
- package/lib/protocol/quorum.js.map +1 -0
- package/lib/protocol.d.ts +2 -3
- package/lib/protocol.d.ts.map +1 -1
- package/lib/protocol.js +3 -1
- package/lib/protocol.js.map +1 -1
- package/lib/protocolTreeDocumentStorageService.d.ts +7 -7
- package/lib/protocolTreeDocumentStorageService.d.ts.map +1 -1
- package/lib/protocolTreeDocumentStorageService.js +16 -7
- package/lib/protocolTreeDocumentStorageService.js.map +1 -1
- package/lib/retriableDocumentStorageService.js +4 -1
- package/lib/retriableDocumentStorageService.js.map +1 -1
- package/lib/serializedStateManager.d.ts +1 -2
- package/lib/serializedStateManager.d.ts.map +1 -1
- package/lib/serializedStateManager.js +10 -2
- package/lib/serializedStateManager.js.map +1 -1
- package/package.json +15 -13
- package/src/catchUpMonitor.ts +1 -1
- package/src/connectionManager.ts +3 -7
- package/src/container.ts +4 -4
- package/src/containerContext.ts +2 -5
- package/src/contracts.ts +3 -6
- package/src/deltaManager.ts +3 -5
- package/src/index.ts +7 -0
- package/src/noopHeuristic.ts +1 -1
- package/src/packageVersion.ts +1 -1
- package/src/protocol/README.md +10 -0
- package/src/protocol/index.ts +16 -0
- package/src/protocol/protocol.ts +185 -0
- package/src/protocol/quorum.ts +584 -0
- package/src/protocol.ts +4 -6
- package/src/protocolTreeDocumentStorageService.ts +16 -8
- package/src/serializedStateManager.ts +1 -1
- package/tsconfig.json +2 -0
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { ISequencedClient } from "@fluidframework/driver-definitions";
|
|
7
|
+
import { ISequencedDocumentMessage } from "@fluidframework/driver-definitions/internal";
|
|
8
|
+
import {
|
|
9
|
+
IDocumentAttributes,
|
|
10
|
+
IClientJoin,
|
|
11
|
+
ICommittedProposal,
|
|
12
|
+
IProcessMessageResult,
|
|
13
|
+
IProposal,
|
|
14
|
+
IQuorum,
|
|
15
|
+
ISequencedDocumentSystemMessage,
|
|
16
|
+
ISequencedProposal,
|
|
17
|
+
MessageType,
|
|
18
|
+
} from "@fluidframework/driver-definitions/internal";
|
|
19
|
+
|
|
20
|
+
import { IQuorumSnapshot, Quorum } from "./quorum.js";
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* @alpha
|
|
24
|
+
*/
|
|
25
|
+
export interface IScribeProtocolState {
|
|
26
|
+
sequenceNumber: number;
|
|
27
|
+
minimumSequenceNumber: number;
|
|
28
|
+
members: [string, ISequencedClient][];
|
|
29
|
+
proposals: [number, ISequencedProposal, string[]][];
|
|
30
|
+
values: [string, ICommittedProposal][];
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* @alpha
|
|
35
|
+
*/
|
|
36
|
+
export interface IProtocolHandler {
|
|
37
|
+
readonly quorum: IQuorum;
|
|
38
|
+
readonly attributes: IDocumentAttributes;
|
|
39
|
+
|
|
40
|
+
setConnectionState(connected: boolean, clientId: string | undefined);
|
|
41
|
+
snapshot(): IQuorumSnapshot;
|
|
42
|
+
|
|
43
|
+
close(): void;
|
|
44
|
+
processMessage(message: ISequencedDocumentMessage, local: boolean): IProcessMessageResult;
|
|
45
|
+
getProtocolState(): IScribeProtocolState;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Handles protocol specific ops.
|
|
50
|
+
* @internal
|
|
51
|
+
*/
|
|
52
|
+
export class ProtocolOpHandler implements IProtocolHandler {
|
|
53
|
+
private readonly _quorum: Quorum;
|
|
54
|
+
public get quorum(): Quorum {
|
|
55
|
+
return this._quorum;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
constructor(
|
|
59
|
+
public minimumSequenceNumber: number,
|
|
60
|
+
public sequenceNumber: number,
|
|
61
|
+
members: [string, ISequencedClient][],
|
|
62
|
+
proposals: [number, ISequencedProposal, string[]][],
|
|
63
|
+
values: [string, ICommittedProposal][],
|
|
64
|
+
sendProposal: (key: string, value: any) => number,
|
|
65
|
+
) {
|
|
66
|
+
this._quorum = new Quorum(members, proposals, values, sendProposal);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
public get attributes(): IDocumentAttributes {
|
|
70
|
+
return {
|
|
71
|
+
minimumSequenceNumber: this.minimumSequenceNumber,
|
|
72
|
+
sequenceNumber: this.sequenceNumber,
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
setConnectionState(connected: boolean, clientId: string | undefined) {
|
|
77
|
+
this._quorum.setConnectionState(connected, clientId);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
snapshot(): IQuorumSnapshot {
|
|
81
|
+
return this._quorum.snapshot();
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
public close() {
|
|
85
|
+
this._quorum.close();
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
public processMessage(
|
|
89
|
+
message: ISequencedDocumentMessage,
|
|
90
|
+
local: boolean,
|
|
91
|
+
): IProcessMessageResult {
|
|
92
|
+
// verify it's moving sequentially
|
|
93
|
+
if (message.sequenceNumber !== this.sequenceNumber + 1) {
|
|
94
|
+
throw new Error(
|
|
95
|
+
`Protocol state is not moving sequentially. ` +
|
|
96
|
+
`Current is ${this.sequenceNumber}. Next is ${message.sequenceNumber}`,
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// Update tracked sequence numbers
|
|
101
|
+
this.sequenceNumber = message.sequenceNumber;
|
|
102
|
+
this.minimumSequenceNumber = message.minimumSequenceNumber;
|
|
103
|
+
|
|
104
|
+
let immediateNoOp = false;
|
|
105
|
+
|
|
106
|
+
/* eslint-disable no-case-declarations */
|
|
107
|
+
|
|
108
|
+
switch (message.type) {
|
|
109
|
+
case MessageType.ClientJoin:
|
|
110
|
+
const systemJoinMessage = message as ISequencedDocumentSystemMessage;
|
|
111
|
+
const join = JSON.parse(systemJoinMessage.data) as IClientJoin;
|
|
112
|
+
const member: ISequencedClient = {
|
|
113
|
+
client: join.detail,
|
|
114
|
+
sequenceNumber: systemJoinMessage.sequenceNumber,
|
|
115
|
+
};
|
|
116
|
+
this._quorum.addMember(join.clientId, member);
|
|
117
|
+
break;
|
|
118
|
+
|
|
119
|
+
case MessageType.ClientLeave:
|
|
120
|
+
const systemLeaveMessage = message as ISequencedDocumentSystemMessage;
|
|
121
|
+
const clientId = JSON.parse(systemLeaveMessage.data) as string;
|
|
122
|
+
this._quorum.removeMember(clientId);
|
|
123
|
+
break;
|
|
124
|
+
|
|
125
|
+
case MessageType.Propose:
|
|
126
|
+
// back-compat: ADO #1385: This should become unconditional eventually.
|
|
127
|
+
// Can be done only after Container.processRemoteMessage() stops parsing content!
|
|
128
|
+
if (typeof message.contents === "string") {
|
|
129
|
+
message.contents = JSON.parse(message.contents);
|
|
130
|
+
}
|
|
131
|
+
const proposal = message.contents as IProposal;
|
|
132
|
+
this._quorum.addProposal(
|
|
133
|
+
proposal.key,
|
|
134
|
+
proposal.value,
|
|
135
|
+
message.sequenceNumber,
|
|
136
|
+
local,
|
|
137
|
+
message.clientSequenceNumber,
|
|
138
|
+
);
|
|
139
|
+
|
|
140
|
+
// On a quorum proposal, immediately send a response to expedite the approval.
|
|
141
|
+
immediateNoOp = true;
|
|
142
|
+
break;
|
|
143
|
+
|
|
144
|
+
default:
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/* eslint-enable no-case-declarations */
|
|
148
|
+
|
|
149
|
+
// Notify the quorum of the MSN from the message. We rely on it to handle duplicate values but may
|
|
150
|
+
// want to move that logic to this class.
|
|
151
|
+
this._quorum.updateMinimumSequenceNumber(message);
|
|
152
|
+
|
|
153
|
+
return { immediateNoOp };
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* Gets the scribe protocol state
|
|
158
|
+
* @param scrubUserData - whether to remove all user data from the quorum members. CAUTION: this will corrupt the quorum if used in a summary.
|
|
159
|
+
*/
|
|
160
|
+
public getProtocolState(scrubUserData = false): IScribeProtocolState {
|
|
161
|
+
// return a new object every time
|
|
162
|
+
// this ensures future state changes will not affect outside callers
|
|
163
|
+
const snapshot = this._quorum.snapshot();
|
|
164
|
+
|
|
165
|
+
if (scrubUserData) {
|
|
166
|
+
// In place, remove any identifying client information
|
|
167
|
+
snapshot.members = snapshot.members.map(([id, sequencedClient]) => [
|
|
168
|
+
id,
|
|
169
|
+
{
|
|
170
|
+
...sequencedClient,
|
|
171
|
+
client: {
|
|
172
|
+
...sequencedClient.client,
|
|
173
|
+
user: { id: "" },
|
|
174
|
+
},
|
|
175
|
+
},
|
|
176
|
+
]);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
return {
|
|
180
|
+
sequenceNumber: this.sequenceNumber,
|
|
181
|
+
minimumSequenceNumber: this.minimumSequenceNumber,
|
|
182
|
+
...snapshot,
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
}
|