@fluidframework/container-loader 1.2.7 → 2.0.0-dev.1.3.0.96595
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/.mocharc.js +12 -0
- package/dist/audience.d.ts +2 -6
- package/dist/audience.d.ts.map +1 -1
- package/dist/audience.js +6 -11
- package/dist/audience.js.map +1 -1
- package/dist/catchUpMonitor.d.ts +29 -0
- package/dist/catchUpMonitor.d.ts.map +1 -0
- package/dist/catchUpMonitor.js +43 -0
- package/dist/catchUpMonitor.js.map +1 -0
- package/dist/collabWindowTracker.d.ts +1 -1
- package/dist/collabWindowTracker.d.ts.map +1 -1
- package/dist/collabWindowTracker.js +12 -4
- package/dist/collabWindowTracker.js.map +1 -1
- package/dist/connectionManager.d.ts +5 -5
- package/dist/connectionManager.d.ts.map +1 -1
- package/dist/connectionManager.js +43 -22
- package/dist/connectionManager.js.map +1 -1
- package/dist/connectionState.d.ts +0 -5
- package/dist/connectionState.d.ts.map +1 -1
- package/dist/connectionState.js +0 -5
- package/dist/connectionState.js.map +1 -1
- package/dist/connectionStateHandler.d.ts +84 -22
- package/dist/connectionStateHandler.d.ts.map +1 -1
- package/dist/connectionStateHandler.js +172 -59
- package/dist/connectionStateHandler.js.map +1 -1
- package/dist/container.d.ts +29 -17
- package/dist/container.d.ts.map +1 -1
- package/dist/container.js +181 -171
- package/dist/container.js.map +1 -1
- package/dist/containerContext.d.ts +18 -7
- package/dist/containerContext.d.ts.map +1 -1
- package/dist/containerContext.js +18 -8
- package/dist/containerContext.js.map +1 -1
- package/dist/containerStorageAdapter.d.ts +11 -25
- package/dist/containerStorageAdapter.d.ts.map +1 -1
- package/dist/containerStorageAdapter.js +51 -17
- package/dist/containerStorageAdapter.js.map +1 -1
- package/dist/contracts.d.ts +5 -5
- package/dist/contracts.js.map +1 -1
- package/dist/deltaManager.d.ts +4 -1
- package/dist/deltaManager.d.ts.map +1 -1
- package/dist/deltaManager.js +39 -12
- package/dist/deltaManager.js.map +1 -1
- package/dist/deltaManagerProxy.d.ts +4 -1
- package/dist/deltaManagerProxy.d.ts.map +1 -1
- package/dist/deltaQueue.d.ts +9 -2
- package/dist/deltaQueue.d.ts.map +1 -1
- package/dist/deltaQueue.js +31 -26
- package/dist/deltaQueue.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/loader.d.ts +8 -1
- package/dist/loader.d.ts.map +1 -1
- package/dist/loader.js +4 -3
- package/dist/loader.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.d.ts +27 -0
- package/dist/protocol.d.ts.map +1 -0
- package/dist/protocol.js +79 -0
- package/dist/protocol.js.map +1 -0
- package/dist/protocolTreeDocumentStorageService.d.ts +1 -1
- package/dist/protocolTreeDocumentStorageService.d.ts.map +1 -1
- package/dist/retriableDocumentStorageService.d.ts +2 -2
- package/dist/retriableDocumentStorageService.d.ts.map +1 -1
- package/dist/retriableDocumentStorageService.js +2 -2
- package/dist/retriableDocumentStorageService.js.map +1 -1
- package/lib/audience.d.ts +2 -6
- package/lib/audience.d.ts.map +1 -1
- package/lib/audience.js +6 -11
- package/lib/audience.js.map +1 -1
- package/lib/catchUpMonitor.d.ts +29 -0
- package/lib/catchUpMonitor.d.ts.map +1 -0
- package/lib/catchUpMonitor.js +39 -0
- package/lib/catchUpMonitor.js.map +1 -0
- package/lib/collabWindowTracker.d.ts +1 -1
- package/lib/collabWindowTracker.d.ts.map +1 -1
- package/lib/collabWindowTracker.js +13 -5
- package/lib/collabWindowTracker.js.map +1 -1
- package/lib/connectionManager.d.ts +5 -5
- package/lib/connectionManager.d.ts.map +1 -1
- package/lib/connectionManager.js +44 -25
- package/lib/connectionManager.js.map +1 -1
- package/lib/connectionState.d.ts +0 -5
- package/lib/connectionState.d.ts.map +1 -1
- package/lib/connectionState.js +0 -5
- package/lib/connectionState.js.map +1 -1
- package/lib/connectionStateHandler.d.ts +84 -22
- package/lib/connectionStateHandler.d.ts.map +1 -1
- package/lib/connectionStateHandler.js +171 -59
- package/lib/connectionStateHandler.js.map +1 -1
- package/lib/container.d.ts +29 -17
- package/lib/container.d.ts.map +1 -1
- package/lib/container.js +184 -174
- package/lib/container.js.map +1 -1
- package/lib/containerContext.d.ts +18 -7
- package/lib/containerContext.d.ts.map +1 -1
- package/lib/containerContext.js +19 -9
- package/lib/containerContext.js.map +1 -1
- package/lib/containerStorageAdapter.d.ts +11 -25
- package/lib/containerStorageAdapter.d.ts.map +1 -1
- package/lib/containerStorageAdapter.js +51 -16
- package/lib/containerStorageAdapter.js.map +1 -1
- package/lib/contracts.d.ts +5 -5
- package/lib/contracts.js.map +1 -1
- package/lib/deltaManager.d.ts +4 -1
- package/lib/deltaManager.d.ts.map +1 -1
- package/lib/deltaManager.js +41 -14
- package/lib/deltaManager.js.map +1 -1
- package/lib/deltaManagerProxy.d.ts +4 -1
- package/lib/deltaManagerProxy.d.ts.map +1 -1
- package/lib/deltaQueue.d.ts +9 -2
- package/lib/deltaQueue.d.ts.map +1 -1
- package/lib/deltaQueue.js +32 -27
- package/lib/deltaQueue.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/loader.d.ts +8 -1
- package/lib/loader.d.ts.map +1 -1
- package/lib/loader.js +4 -3
- package/lib/loader.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.d.ts +27 -0
- package/lib/protocol.d.ts.map +1 -0
- package/lib/protocol.js +75 -0
- package/lib/protocol.js.map +1 -0
- package/lib/protocolTreeDocumentStorageService.d.ts +1 -1
- package/lib/protocolTreeDocumentStorageService.d.ts.map +1 -1
- package/lib/retriableDocumentStorageService.d.ts +2 -2
- package/lib/retriableDocumentStorageService.d.ts.map +1 -1
- package/lib/retriableDocumentStorageService.js +2 -2
- package/lib/retriableDocumentStorageService.js.map +1 -1
- package/package.json +27 -19
- package/src/audience.ts +8 -14
- package/src/catchUpMonitor.ts +59 -0
- package/src/collabWindowTracker.ts +15 -6
- package/src/connectionManager.ts +56 -33
- package/src/connectionState.ts +0 -6
- package/src/connectionStateHandler.ts +235 -70
- package/src/container.ts +241 -218
- package/src/containerContext.ts +22 -8
- package/src/containerStorageAdapter.ts +71 -16
- package/src/contracts.ts +7 -7
- package/src/deltaManager.ts +48 -15
- package/src/deltaQueue.ts +34 -28
- package/src/index.ts +4 -0
- package/src/loader.ts +14 -3
- package/src/packageVersion.ts +1 -1
- package/src/protocol.ts +120 -0
- package/src/retriableDocumentStorageService.ts +8 -2
package/src/loader.ts
CHANGED
|
@@ -48,6 +48,7 @@ import {
|
|
|
48
48
|
import { Container, IPendingContainerState } from "./container";
|
|
49
49
|
import { IParsedUrl, parseUrl } from "./utils";
|
|
50
50
|
import { pkgVersion } from "./packageVersion";
|
|
51
|
+
import { ProtocolHandlerBuilder } from "./protocol";
|
|
51
52
|
|
|
52
53
|
function canUseCache(request: IRequest): boolean {
|
|
53
54
|
if (request.headers === undefined) {
|
|
@@ -132,7 +133,7 @@ export interface ILoaderOptions extends ILoaderOptions1 {
|
|
|
132
133
|
|
|
133
134
|
/**
|
|
134
135
|
* @deprecated IFluidModuleWithDetails interface is moved to
|
|
135
|
-
* {@link @fluidframework/container-
|
|
136
|
+
* {@link @fluidframework/container-definitions#IFluidModuleWithDetails}
|
|
136
137
|
* to have all the code loading modules in one package. #8193
|
|
137
138
|
* Encapsulates a module entry point with corresponding code details.
|
|
138
139
|
*/
|
|
@@ -211,7 +212,13 @@ export interface ILoaderProps {
|
|
|
211
212
|
/**
|
|
212
213
|
* The configuration provider which may be used to control features.
|
|
213
214
|
*/
|
|
214
|
-
|
|
215
|
+
readonly configProvider?: IConfigProviderBase;
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* Optional property for allowing the container to use a custom
|
|
219
|
+
* protocol implementation for handling the quorum and/or the audience.
|
|
220
|
+
*/
|
|
221
|
+
readonly protocolHandlerBuilder?: ProtocolHandlerBuilder;
|
|
215
222
|
}
|
|
216
223
|
|
|
217
224
|
/**
|
|
@@ -278,6 +285,7 @@ export class Loader implements IHostLoader {
|
|
|
278
285
|
private readonly containers = new Map<string, Promise<Container>>();
|
|
279
286
|
public readonly services: ILoaderServices;
|
|
280
287
|
private readonly mc: MonitoringContext;
|
|
288
|
+
private readonly protocolHandlerBuilder: ProtocolHandlerBuilder | undefined;
|
|
281
289
|
|
|
282
290
|
constructor(loaderProps: ILoaderProps) {
|
|
283
291
|
const scope: FluidObject<ILoader> = { ...loaderProps.scope };
|
|
@@ -306,6 +314,7 @@ export class Loader implements IHostLoader {
|
|
|
306
314
|
};
|
|
307
315
|
this.mc = loggerToMonitoringContext(
|
|
308
316
|
ChildLogger.create(this.services.subLogger, "Loader"));
|
|
317
|
+
this.protocolHandlerBuilder = loaderProps.protocolHandlerBuilder;
|
|
309
318
|
}
|
|
310
319
|
|
|
311
320
|
public get IFluidRouter(): IFluidRouter { return this; }
|
|
@@ -314,6 +323,7 @@ export class Loader implements IHostLoader {
|
|
|
314
323
|
const container = await Container.createDetached(
|
|
315
324
|
this,
|
|
316
325
|
codeDetails,
|
|
326
|
+
this.protocolHandlerBuilder,
|
|
317
327
|
);
|
|
318
328
|
|
|
319
329
|
if (this.cachingEnabled) {
|
|
@@ -330,7 +340,7 @@ export class Loader implements IHostLoader {
|
|
|
330
340
|
}
|
|
331
341
|
|
|
332
342
|
public async rehydrateDetachedContainerFromSnapshot(snapshot: string): Promise<IContainer> {
|
|
333
|
-
return Container.rehydrateDetachedFromSnapshot(this, snapshot);
|
|
343
|
+
return Container.rehydrateDetachedFromSnapshot(this, snapshot, this.protocolHandlerBuilder);
|
|
334
344
|
}
|
|
335
345
|
|
|
336
346
|
public async resolve(request: IRequest, pendingLocalState?: string): Promise<IContainer> {
|
|
@@ -482,6 +492,7 @@ export class Loader implements IHostLoader {
|
|
|
482
492
|
loadMode: request.headers?.[LoaderHeader.loadMode],
|
|
483
493
|
},
|
|
484
494
|
pendingLocalState,
|
|
495
|
+
this.protocolHandlerBuilder,
|
|
485
496
|
);
|
|
486
497
|
}
|
|
487
498
|
}
|
package/src/packageVersion.ts
CHANGED
package/src/protocol.ts
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { IAudienceOwner } from "@fluidframework/container-definitions";
|
|
7
|
+
import {
|
|
8
|
+
ILocalSequencedClient,
|
|
9
|
+
IProtocolHandler as IBaseProtocolHandler,
|
|
10
|
+
IQuorumSnapshot,
|
|
11
|
+
ProtocolOpHandler,
|
|
12
|
+
} from "@fluidframework/protocol-base";
|
|
13
|
+
import {
|
|
14
|
+
IDocumentAttributes,
|
|
15
|
+
IProcessMessageResult,
|
|
16
|
+
ISequencedDocumentMessage,
|
|
17
|
+
ISignalClient,
|
|
18
|
+
ISignalMessage,
|
|
19
|
+
MessageType,
|
|
20
|
+
} from "@fluidframework/protocol-definitions";
|
|
21
|
+
import { canBeCoalescedByService } from "@fluidframework/driver-utils";
|
|
22
|
+
|
|
23
|
+
// ADO: #1986: Start using enum from protocol-base.
|
|
24
|
+
export enum SignalType {
|
|
25
|
+
ClientJoin = "join", // same value as MessageType.ClientJoin,
|
|
26
|
+
ClientLeave = "leave", // same value as MessageType.ClientLeave,
|
|
27
|
+
Clear = "clear", // used only by client for synthetic signals
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Function to be used for creating a protocol handler.
|
|
32
|
+
*/
|
|
33
|
+
export type ProtocolHandlerBuilder = (
|
|
34
|
+
attributes: IDocumentAttributes,
|
|
35
|
+
snapshot: IQuorumSnapshot,
|
|
36
|
+
sendProposal: (key: string, value: any) => number,
|
|
37
|
+
) => IProtocolHandler;
|
|
38
|
+
|
|
39
|
+
export interface IProtocolHandler extends IBaseProtocolHandler {
|
|
40
|
+
readonly audience: IAudienceOwner;
|
|
41
|
+
processSignal(message: ISignalMessage);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export class ProtocolHandler extends ProtocolOpHandler implements IProtocolHandler {
|
|
45
|
+
constructor(
|
|
46
|
+
attributes: IDocumentAttributes,
|
|
47
|
+
quorumSnapshot: IQuorumSnapshot,
|
|
48
|
+
sendProposal: (key: string, value: any) => number,
|
|
49
|
+
readonly audience: IAudienceOwner,
|
|
50
|
+
) {
|
|
51
|
+
super(
|
|
52
|
+
attributes.minimumSequenceNumber,
|
|
53
|
+
attributes.sequenceNumber,
|
|
54
|
+
attributes.term,
|
|
55
|
+
quorumSnapshot.members,
|
|
56
|
+
quorumSnapshot.proposals,
|
|
57
|
+
quorumSnapshot.values,
|
|
58
|
+
sendProposal,
|
|
59
|
+
);
|
|
60
|
+
|
|
61
|
+
// Join / leave signals are ignored for "write" clients in favor of join / leave ops
|
|
62
|
+
this.quorum.on("addMember", (clientId, details) => audience.addMember(clientId, details.client));
|
|
63
|
+
this.quorum.on("removeMember", (clientId) => audience.removeMember(clientId));
|
|
64
|
+
for (const [clientId, details] of this.quorum.getMembers()) {
|
|
65
|
+
this.audience.addMember(clientId, details.client);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
public processMessage(message: ISequencedDocumentMessage, local: boolean): IProcessMessageResult {
|
|
70
|
+
const client: ILocalSequencedClient | undefined = this.quorum.getMember(message.clientId);
|
|
71
|
+
|
|
72
|
+
// Check and report if we're getting messages from a clientId that we previously
|
|
73
|
+
// flagged as shouldHaveLeft, or from a client that's not in the quorum but should be
|
|
74
|
+
if (message.clientId != null) {
|
|
75
|
+
if (client === undefined && message.type !== MessageType.ClientJoin) {
|
|
76
|
+
// pre-0.58 error message: messageClientIdMissingFromQuorum
|
|
77
|
+
throw new Error("Remote message's clientId is missing from the quorum");
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
if (client?.shouldHaveLeft === true && !canBeCoalescedByService(message)) {
|
|
81
|
+
// pre-0.58 error message: messageClientIdShouldHaveLeft
|
|
82
|
+
throw new Error("Remote message's clientId already should have left");
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
return super.processMessage(message, local);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
public processSignal(message: ISignalMessage) {
|
|
90
|
+
const innerContent = message.content as { content: any; type: string; };
|
|
91
|
+
switch (innerContent.type) {
|
|
92
|
+
case SignalType.Clear: {
|
|
93
|
+
const members = this.audience.getMembers();
|
|
94
|
+
for (const [clientId, client] of members) {
|
|
95
|
+
if (client.mode === "read") {
|
|
96
|
+
this.audience.removeMember(clientId);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
break;
|
|
100
|
+
}
|
|
101
|
+
case SignalType.ClientJoin: {
|
|
102
|
+
const newClient = innerContent.content as ISignalClient;
|
|
103
|
+
// Ignore write clients - quorum will control such clients.
|
|
104
|
+
if (newClient.client.mode === "read") {
|
|
105
|
+
this.audience.addMember(newClient.clientId, newClient.client);
|
|
106
|
+
}
|
|
107
|
+
break;
|
|
108
|
+
}
|
|
109
|
+
case SignalType.ClientLeave: {
|
|
110
|
+
const leftClientId = innerContent.content as string;
|
|
111
|
+
// Ignore write clients - quorum will control such clients.
|
|
112
|
+
if (this.audience.getMember(leftClientId)?.mode === "read") {
|
|
113
|
+
this.audience.removeMember(leftClientId);
|
|
114
|
+
}
|
|
115
|
+
break;
|
|
116
|
+
}
|
|
117
|
+
default: break;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
import { assert } from "@fluidframework/common-utils";
|
|
7
7
|
import { GenericError } from "@fluidframework/container-utils";
|
|
8
8
|
import {
|
|
9
|
+
FetchSource,
|
|
9
10
|
IDocumentStorageService,
|
|
10
11
|
IDocumentStorageServicePolicies,
|
|
11
12
|
ISummaryContext,
|
|
@@ -54,9 +55,14 @@ export class RetriableDocumentStorageService implements IDocumentStorageService,
|
|
|
54
55
|
);
|
|
55
56
|
}
|
|
56
57
|
|
|
57
|
-
public async getVersions(
|
|
58
|
+
public async getVersions(
|
|
59
|
+
versionId: string | null,
|
|
60
|
+
count: number,
|
|
61
|
+
scenarioName?: string,
|
|
62
|
+
fetchSource?: FetchSource,
|
|
63
|
+
): Promise<IVersion[]> {
|
|
58
64
|
return this.runWithRetry(
|
|
59
|
-
async () => this.internalStorageService.getVersions(versionId, count, scenarioName),
|
|
65
|
+
async () => this.internalStorageService.getVersions(versionId, count, scenarioName, fetchSource),
|
|
60
66
|
"storage_getVersions",
|
|
61
67
|
);
|
|
62
68
|
}
|