@fluidframework/container-loader 2.0.0-internal.6.3.3 → 2.0.0-internal.7.0.0
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/CHANGELOG.md +112 -0
- package/dist/catchUpMonitor.d.ts +2 -2
- package/dist/catchUpMonitor.d.ts.map +1 -1
- package/dist/connectionManager.d.ts +1 -15
- package/dist/connectionManager.d.ts.map +1 -1
- package/dist/connectionManager.js +90 -82
- package/dist/connectionManager.js.map +1 -1
- package/dist/connectionState.js +1 -1
- package/dist/connectionState.js.map +1 -1
- package/dist/connectionStateHandler.js +9 -9
- package/dist/connectionStateHandler.js.map +1 -1
- package/dist/container.d.ts +21 -2
- package/dist/container.d.ts.map +1 -1
- package/dist/container.js +222 -208
- package/dist/container.js.map +1 -1
- package/dist/containerContext.js +16 -16
- package/dist/containerContext.js.map +1 -1
- package/dist/containerStorageAdapter.d.ts.map +1 -1
- package/dist/containerStorageAdapter.js +6 -8
- package/dist/containerStorageAdapter.js.map +1 -1
- package/dist/contracts.d.ts +2 -1
- package/dist/contracts.d.ts.map +1 -1
- package/dist/contracts.js +1 -1
- package/dist/contracts.js.map +1 -1
- package/dist/debugLogger.d.ts.map +1 -1
- package/dist/debugLogger.js +5 -4
- package/dist/debugLogger.js.map +1 -1
- package/dist/deltaManager.d.ts.map +1 -1
- package/dist/deltaManager.js +87 -90
- package/dist/deltaManager.js.map +1 -1
- package/dist/deltaQueue.js +14 -14
- package/dist/deltaQueue.js.map +1 -1
- package/dist/loader.d.ts +3 -6
- package/dist/loader.d.ts.map +1 -1
- package/dist/loader.js +19 -84
- package/dist/loader.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.d.ts +1 -2
- package/dist/protocol.d.ts.map +1 -1
- package/dist/protocol.js +3 -5
- package/dist/protocol.js.map +1 -1
- package/dist/tsdoc-metadata.json +1 -1
- package/lib/catchUpMonitor.d.ts +2 -2
- package/lib/catchUpMonitor.d.ts.map +1 -1
- package/lib/connectionManager.d.ts +1 -15
- package/lib/connectionManager.d.ts.map +1 -1
- package/lib/connectionManager.js +93 -83
- package/lib/connectionManager.js.map +1 -1
- package/lib/connectionStateHandler.js +9 -9
- package/lib/connectionStateHandler.js.map +1 -1
- package/lib/container.d.ts +21 -2
- package/lib/container.d.ts.map +1 -1
- package/lib/container.js +223 -209
- package/lib/container.js.map +1 -1
- package/lib/containerContext.js +16 -16
- package/lib/containerContext.js.map +1 -1
- package/lib/containerStorageAdapter.d.ts.map +1 -1
- package/lib/containerStorageAdapter.js +6 -8
- package/lib/containerStorageAdapter.js.map +1 -1
- package/lib/contracts.d.ts +2 -1
- package/lib/contracts.d.ts.map +1 -1
- package/lib/contracts.js.map +1 -1
- package/lib/debugLogger.d.ts.map +1 -1
- package/lib/debugLogger.js +5 -4
- package/lib/debugLogger.js.map +1 -1
- package/lib/deltaManager.d.ts.map +1 -1
- package/lib/deltaManager.js +87 -90
- package/lib/deltaManager.js.map +1 -1
- package/lib/deltaQueue.js +14 -14
- package/lib/deltaQueue.js.map +1 -1
- package/lib/loader.d.ts +3 -6
- package/lib/loader.d.ts.map +1 -1
- package/lib/loader.js +19 -84
- package/lib/loader.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.d.ts +1 -2
- package/lib/protocol.d.ts.map +1 -1
- package/lib/protocol.js +1 -3
- package/lib/protocol.js.map +1 -1
- package/package.json +25 -19
- package/src/connectionManager.ts +38 -20
- package/src/container.ts +30 -16
- package/src/containerStorageAdapter.ts +0 -6
- package/src/contracts.ts +5 -1
- package/src/debugLogger.ts +1 -0
- package/src/deltaManager.ts +7 -9
- package/src/loader.ts +24 -92
- package/src/packageVersion.ts +1 -1
- package/src/protocol.ts +2 -6
package/lib/container.js
CHANGED
|
@@ -25,7 +25,7 @@ import { initQuorumValuesFromCodeDetails } from "./quorum";
|
|
|
25
25
|
import { NoopHeuristic } from "./noopHeuristic";
|
|
26
26
|
import { ConnectionManager } from "./connectionManager";
|
|
27
27
|
import { ConnectionState } from "./connectionState";
|
|
28
|
-
import {
|
|
28
|
+
import { ProtocolHandler, protocolHandlerShouldProcessSignal, } from "./protocol";
|
|
29
29
|
const detachedContainerRefSeqNumber = 0;
|
|
30
30
|
const dirtyContainerEvent = "dirty";
|
|
31
31
|
const savedContainerEvent = "saved";
|
|
@@ -121,6 +121,219 @@ export async function ReportIfTooLong(logger, eventName, action) {
|
|
|
121
121
|
}
|
|
122
122
|
const summarizerClientType = "summarizer";
|
|
123
123
|
export class Container extends EventEmitterWithErrorHandling {
|
|
124
|
+
/**
|
|
125
|
+
* Load an existing container.
|
|
126
|
+
* @internal
|
|
127
|
+
*/
|
|
128
|
+
static async load(loadProps, createProps) {
|
|
129
|
+
const { version, pendingLocalState, loadMode, resolvedUrl, loadToSequenceNumber } = loadProps;
|
|
130
|
+
const container = new Container(createProps, loadProps);
|
|
131
|
+
const disableRecordHeapSize = container.mc.config.getBoolean("Fluid.Loader.DisableRecordHeapSize");
|
|
132
|
+
return PerformanceEvent.timedExecAsync(container.mc.logger, { eventName: "Load" }, async (event) => new Promise((resolve, reject) => {
|
|
133
|
+
const defaultMode = { opsBeforeReturn: "cached" };
|
|
134
|
+
// if we have pendingLocalState, anything we cached is not useful and we shouldn't wait for connection
|
|
135
|
+
// to return container, so ignore this value and use undefined for opsBeforeReturn
|
|
136
|
+
const mode = pendingLocalState
|
|
137
|
+
? { ...(loadMode ?? defaultMode), opsBeforeReturn: undefined }
|
|
138
|
+
: loadMode ?? defaultMode;
|
|
139
|
+
const onClosed = (err) => {
|
|
140
|
+
// pre-0.58 error message: containerClosedWithoutErrorDuringLoad
|
|
141
|
+
reject(err ?? new GenericError("Container closed without error during load"));
|
|
142
|
+
};
|
|
143
|
+
container.on("closed", onClosed);
|
|
144
|
+
container
|
|
145
|
+
.load(version, mode, resolvedUrl, pendingLocalState, loadToSequenceNumber)
|
|
146
|
+
.finally(() => {
|
|
147
|
+
container.removeListener("closed", onClosed);
|
|
148
|
+
})
|
|
149
|
+
.then((props) => {
|
|
150
|
+
event.end({ ...props, ...loadMode });
|
|
151
|
+
resolve(container);
|
|
152
|
+
}, (error) => {
|
|
153
|
+
const err = normalizeError(error);
|
|
154
|
+
// Depending where error happens, we can be attempting to connect to web socket
|
|
155
|
+
// and continuously retrying (consider offline mode)
|
|
156
|
+
// Host has no container to close, so it's prudent to do it here
|
|
157
|
+
// Note: We could only dispose the container instead of just close but that would
|
|
158
|
+
// the telemetry where users sometimes search for ContainerClose event to look
|
|
159
|
+
// for load failures. So not removing this at this time.
|
|
160
|
+
container.close(err);
|
|
161
|
+
container.dispose(err);
|
|
162
|
+
onClosed(err);
|
|
163
|
+
});
|
|
164
|
+
}), { start: true, end: true, cancel: "generic" }, disableRecordHeapSize !== true /* recordHeapSize */);
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Create a new container in a detached state.
|
|
168
|
+
*/
|
|
169
|
+
static async createDetached(createProps, codeDetails) {
|
|
170
|
+
const container = new Container(createProps);
|
|
171
|
+
return PerformanceEvent.timedExecAsync(container.mc.logger, { eventName: "CreateDetached" }, async (_event) => {
|
|
172
|
+
await container.createDetached(codeDetails);
|
|
173
|
+
return container;
|
|
174
|
+
}, { start: true, end: true, cancel: "generic" });
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Create a new container in a detached state that is initialized with a
|
|
178
|
+
* snapshot from a previous detached container.
|
|
179
|
+
*/
|
|
180
|
+
static async rehydrateDetachedFromSnapshot(createProps, snapshot) {
|
|
181
|
+
const container = new Container(createProps);
|
|
182
|
+
return PerformanceEvent.timedExecAsync(container.mc.logger, { eventName: "RehydrateDetachedFromSnapshot" }, async (_event) => {
|
|
183
|
+
const deserializedSummary = JSON.parse(snapshot);
|
|
184
|
+
await container.rehydrateDetachedFromSnapshot(deserializedSummary);
|
|
185
|
+
return container;
|
|
186
|
+
}, { start: true, end: true, cancel: "generic" });
|
|
187
|
+
}
|
|
188
|
+
setLoaded() {
|
|
189
|
+
// It's conceivable the container could be closed when this is called
|
|
190
|
+
// Only transition states if currently loading
|
|
191
|
+
if (this._lifecycleState === "loading") {
|
|
192
|
+
// Propagate current connection state through the system.
|
|
193
|
+
this.propagateConnectionState(true /* initial transition */);
|
|
194
|
+
this._lifecycleState = "loaded";
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
get closed() {
|
|
198
|
+
return (this._lifecycleState === "closing" || this._lifecycleState === "closed" || this.disposed);
|
|
199
|
+
}
|
|
200
|
+
get disposed() {
|
|
201
|
+
return this._lifecycleState === "disposing" || this._lifecycleState === "disposed";
|
|
202
|
+
}
|
|
203
|
+
get runtime() {
|
|
204
|
+
if (this._runtime === undefined) {
|
|
205
|
+
throw new Error("Attempted to access runtime before it was defined");
|
|
206
|
+
}
|
|
207
|
+
return this._runtime;
|
|
208
|
+
}
|
|
209
|
+
get protocolHandler() {
|
|
210
|
+
if (this._protocolHandler === undefined) {
|
|
211
|
+
throw new Error("Attempted to access protocolHandler before it was defined");
|
|
212
|
+
}
|
|
213
|
+
return this._protocolHandler;
|
|
214
|
+
}
|
|
215
|
+
get connectionMode() {
|
|
216
|
+
return this._deltaManager.connectionManager.connectionMode;
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* @deprecated Will be removed in future major release. Migrate all usage of IFluidRouter to the "entryPoint" pattern. Refer to Removing-IFluidRouter.md
|
|
220
|
+
*/
|
|
221
|
+
// eslint-disable-next-line import/no-deprecated
|
|
222
|
+
get IFluidRouter() {
|
|
223
|
+
return this;
|
|
224
|
+
}
|
|
225
|
+
get resolvedUrl() {
|
|
226
|
+
/**
|
|
227
|
+
* All attached containers will have a document service,
|
|
228
|
+
* this is required, as attached containers are attached to
|
|
229
|
+
* a service. Detached containers will neither have a document
|
|
230
|
+
* service or a resolved url as they only exist locally.
|
|
231
|
+
* in order to create a document service a resolved url must
|
|
232
|
+
* first be obtained, this is how the container is identified.
|
|
233
|
+
* Because of this, the document service's resolved url
|
|
234
|
+
* is always the same as the containers, as we had to
|
|
235
|
+
* obtain the resolved url, and then create the service from it.
|
|
236
|
+
*/
|
|
237
|
+
return this.service?.resolvedUrl;
|
|
238
|
+
}
|
|
239
|
+
get readOnlyInfo() {
|
|
240
|
+
return this._deltaManager.readOnlyInfo;
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* Sends signal to runtime (and data stores) to be read-only.
|
|
244
|
+
* Hosts may have read only views, indicating to data stores that no edits are allowed.
|
|
245
|
+
* This is independent from this._readonlyPermissions (permissions) and this.connectionMode
|
|
246
|
+
* (server can return "write" mode even when asked for "read")
|
|
247
|
+
* Leveraging same "readonly" event as runtime & data stores should behave the same in such case
|
|
248
|
+
* as in read-only permissions.
|
|
249
|
+
* But this.active can be used by some DDSes to figure out if ops can be sent
|
|
250
|
+
* (for example, read-only view still participates in code proposals / upgrades decisions)
|
|
251
|
+
*
|
|
252
|
+
* Forcing Readonly does not prevent DDS from generating ops. It is up to user code to honour
|
|
253
|
+
* the readonly flag. If ops are generated, they will accumulate locally and not be sent. If
|
|
254
|
+
* there are pending in the outbound queue, it will stop sending until force readonly is
|
|
255
|
+
* cleared.
|
|
256
|
+
*
|
|
257
|
+
* @param readonly - set or clear force readonly.
|
|
258
|
+
*/
|
|
259
|
+
forceReadonly(readonly) {
|
|
260
|
+
this._deltaManager.connectionManager.forceReadonly(readonly);
|
|
261
|
+
}
|
|
262
|
+
get deltaManager() {
|
|
263
|
+
return this._deltaManager;
|
|
264
|
+
}
|
|
265
|
+
get connectionState() {
|
|
266
|
+
return this.connectionStateHandler.connectionState;
|
|
267
|
+
}
|
|
268
|
+
get connected() {
|
|
269
|
+
return this.connectionStateHandler.connectionState === ConnectionState.Connected;
|
|
270
|
+
}
|
|
271
|
+
/**
|
|
272
|
+
* The server provided id of the client.
|
|
273
|
+
* Set once this.connected is true, otherwise undefined
|
|
274
|
+
*/
|
|
275
|
+
get clientId() {
|
|
276
|
+
return this._clientId;
|
|
277
|
+
}
|
|
278
|
+
get offlineLoadEnabled() {
|
|
279
|
+
const enabled = this.mc.config.getBoolean("Fluid.Container.enableOfflineLoad") ??
|
|
280
|
+
this.options?.enableOfflineLoad === true;
|
|
281
|
+
// summarizer will not have any pending state we want to save
|
|
282
|
+
return enabled && this.deltaManager.clientDetails.capabilities.interactive;
|
|
283
|
+
}
|
|
284
|
+
/**
|
|
285
|
+
* Get the code details that are currently specified for the container.
|
|
286
|
+
* @returns The current code details if any are specified, undefined if none are specified.
|
|
287
|
+
*/
|
|
288
|
+
getSpecifiedCodeDetails() {
|
|
289
|
+
return this.getCodeDetailsFromQuorum();
|
|
290
|
+
}
|
|
291
|
+
/**
|
|
292
|
+
* Get the code details that were used to load the container.
|
|
293
|
+
* @returns The code details that were used to load the container if it is loaded, undefined if it is not yet
|
|
294
|
+
* loaded.
|
|
295
|
+
*/
|
|
296
|
+
getLoadedCodeDetails() {
|
|
297
|
+
return this._loadedCodeDetails;
|
|
298
|
+
}
|
|
299
|
+
/**
|
|
300
|
+
* Retrieves the audience associated with the document
|
|
301
|
+
*/
|
|
302
|
+
get audience() {
|
|
303
|
+
return this.protocolHandler.audience;
|
|
304
|
+
}
|
|
305
|
+
/**
|
|
306
|
+
* Returns true if container is dirty.
|
|
307
|
+
* Which means data loss if container is closed at that same moment
|
|
308
|
+
* Most likely that happens when there is no network connection to Relay Service
|
|
309
|
+
*/
|
|
310
|
+
get isDirty() {
|
|
311
|
+
return this._dirtyContainer;
|
|
312
|
+
}
|
|
313
|
+
/**
|
|
314
|
+
* {@inheritDoc @fluidframework/container-definitions#IContainer.entryPoint}
|
|
315
|
+
*/
|
|
316
|
+
async getEntryPoint() {
|
|
317
|
+
if (this._disposed) {
|
|
318
|
+
throw new UsageError("The context is already disposed");
|
|
319
|
+
}
|
|
320
|
+
if (this._runtime !== undefined) {
|
|
321
|
+
return this._runtime.getEntryPoint?.();
|
|
322
|
+
}
|
|
323
|
+
return new Promise((resolve, reject) => {
|
|
324
|
+
const runtimeInstantiatedHandler = () => {
|
|
325
|
+
assert(this._runtime !== undefined, 0x5a3 /* runtimeInstantiated fired but runtime is still undefined */);
|
|
326
|
+
resolve(this._runtime.getEntryPoint?.());
|
|
327
|
+
this._lifecycleEvents.off("disposed", disposedHandler);
|
|
328
|
+
};
|
|
329
|
+
const disposedHandler = () => {
|
|
330
|
+
reject(new Error("ContainerContext was disposed"));
|
|
331
|
+
this._lifecycleEvents.off("runtimeInstantiated", runtimeInstantiatedHandler);
|
|
332
|
+
};
|
|
333
|
+
this._lifecycleEvents.once("runtimeInstantiated", runtimeInstantiatedHandler);
|
|
334
|
+
this._lifecycleEvents.once("disposed", disposedHandler);
|
|
335
|
+
});
|
|
336
|
+
}
|
|
124
337
|
/**
|
|
125
338
|
* @internal
|
|
126
339
|
*/
|
|
@@ -323,201 +536,6 @@ export class Container extends EventEmitterWithErrorHandling {
|
|
|
323
536
|
document.addEventListener("visibilitychange", this.visibilityEventHandler);
|
|
324
537
|
}
|
|
325
538
|
}
|
|
326
|
-
/**
|
|
327
|
-
* Load an existing container.
|
|
328
|
-
* @internal
|
|
329
|
-
*/
|
|
330
|
-
static async load(loadProps, createProps) {
|
|
331
|
-
const { version, pendingLocalState, loadMode, resolvedUrl, loadToSequenceNumber } = loadProps;
|
|
332
|
-
const container = new Container(createProps, loadProps);
|
|
333
|
-
const disableRecordHeapSize = container.mc.config.getBoolean("Fluid.Loader.DisableRecordHeapSize");
|
|
334
|
-
return PerformanceEvent.timedExecAsync(container.mc.logger, { eventName: "Load" }, async (event) => new Promise((resolve, reject) => {
|
|
335
|
-
const defaultMode = { opsBeforeReturn: "cached" };
|
|
336
|
-
// if we have pendingLocalState, anything we cached is not useful and we shouldn't wait for connection
|
|
337
|
-
// to return container, so ignore this value and use undefined for opsBeforeReturn
|
|
338
|
-
const mode = pendingLocalState
|
|
339
|
-
? { ...(loadMode ?? defaultMode), opsBeforeReturn: undefined }
|
|
340
|
-
: loadMode ?? defaultMode;
|
|
341
|
-
const onClosed = (err) => {
|
|
342
|
-
// pre-0.58 error message: containerClosedWithoutErrorDuringLoad
|
|
343
|
-
reject(err ?? new GenericError("Container closed without error during load"));
|
|
344
|
-
};
|
|
345
|
-
container.on("closed", onClosed);
|
|
346
|
-
container
|
|
347
|
-
.load(version, mode, resolvedUrl, pendingLocalState, loadToSequenceNumber)
|
|
348
|
-
.finally(() => {
|
|
349
|
-
container.removeListener("closed", onClosed);
|
|
350
|
-
})
|
|
351
|
-
.then((props) => {
|
|
352
|
-
event.end({ ...props, ...loadMode });
|
|
353
|
-
resolve(container);
|
|
354
|
-
}, (error) => {
|
|
355
|
-
const err = normalizeError(error);
|
|
356
|
-
// Depending where error happens, we can be attempting to connect to web socket
|
|
357
|
-
// and continuously retrying (consider offline mode)
|
|
358
|
-
// Host has no container to close, so it's prudent to do it here
|
|
359
|
-
// Note: We could only dispose the container instead of just close but that would
|
|
360
|
-
// the telemetry where users sometimes search for ContainerClose event to look
|
|
361
|
-
// for load failures. So not removing this at this time.
|
|
362
|
-
container.close(err);
|
|
363
|
-
container.dispose(err);
|
|
364
|
-
onClosed(err);
|
|
365
|
-
});
|
|
366
|
-
}), { start: true, end: true, cancel: "generic" }, disableRecordHeapSize !== true /* recordHeapSize */);
|
|
367
|
-
}
|
|
368
|
-
/**
|
|
369
|
-
* Create a new container in a detached state.
|
|
370
|
-
*/
|
|
371
|
-
static async createDetached(createProps, codeDetails) {
|
|
372
|
-
const container = new Container(createProps);
|
|
373
|
-
return PerformanceEvent.timedExecAsync(container.mc.logger, { eventName: "CreateDetached" }, async (_event) => {
|
|
374
|
-
await container.createDetached(codeDetails);
|
|
375
|
-
return container;
|
|
376
|
-
}, { start: true, end: true, cancel: "generic" });
|
|
377
|
-
}
|
|
378
|
-
/**
|
|
379
|
-
* Create a new container in a detached state that is initialized with a
|
|
380
|
-
* snapshot from a previous detached container.
|
|
381
|
-
*/
|
|
382
|
-
static async rehydrateDetachedFromSnapshot(createProps, snapshot) {
|
|
383
|
-
const container = new Container(createProps);
|
|
384
|
-
return PerformanceEvent.timedExecAsync(container.mc.logger, { eventName: "RehydrateDetachedFromSnapshot" }, async (_event) => {
|
|
385
|
-
const deserializedSummary = JSON.parse(snapshot);
|
|
386
|
-
await container.rehydrateDetachedFromSnapshot(deserializedSummary);
|
|
387
|
-
return container;
|
|
388
|
-
}, { start: true, end: true, cancel: "generic" });
|
|
389
|
-
}
|
|
390
|
-
setLoaded() {
|
|
391
|
-
// It's conceivable the container could be closed when this is called
|
|
392
|
-
// Only transition states if currently loading
|
|
393
|
-
if (this._lifecycleState === "loading") {
|
|
394
|
-
// Propagate current connection state through the system.
|
|
395
|
-
this.propagateConnectionState(true /* initial transition */);
|
|
396
|
-
this._lifecycleState = "loaded";
|
|
397
|
-
}
|
|
398
|
-
}
|
|
399
|
-
get closed() {
|
|
400
|
-
return (this._lifecycleState === "closing" || this._lifecycleState === "closed" || this.disposed);
|
|
401
|
-
}
|
|
402
|
-
get disposed() {
|
|
403
|
-
return this._lifecycleState === "disposing" || this._lifecycleState === "disposed";
|
|
404
|
-
}
|
|
405
|
-
get runtime() {
|
|
406
|
-
if (this._runtime === undefined) {
|
|
407
|
-
throw new Error("Attempted to access runtime before it was defined");
|
|
408
|
-
}
|
|
409
|
-
return this._runtime;
|
|
410
|
-
}
|
|
411
|
-
get protocolHandler() {
|
|
412
|
-
if (this._protocolHandler === undefined) {
|
|
413
|
-
throw new Error("Attempted to access protocolHandler before it was defined");
|
|
414
|
-
}
|
|
415
|
-
return this._protocolHandler;
|
|
416
|
-
}
|
|
417
|
-
get connectionMode() {
|
|
418
|
-
return this._deltaManager.connectionManager.connectionMode;
|
|
419
|
-
}
|
|
420
|
-
get IFluidRouter() {
|
|
421
|
-
return this;
|
|
422
|
-
}
|
|
423
|
-
get resolvedUrl() {
|
|
424
|
-
/**
|
|
425
|
-
* All attached containers will have a document service,
|
|
426
|
-
* this is required, as attached containers are attached to
|
|
427
|
-
* a service. Detached containers will neither have a document
|
|
428
|
-
* service or a resolved url as they only exist locally.
|
|
429
|
-
* in order to create a document service a resolved url must
|
|
430
|
-
* first be obtained, this is how the container is identified.
|
|
431
|
-
* Because of this, the document service's resolved url
|
|
432
|
-
* is always the same as the containers, as we had to
|
|
433
|
-
* obtain the resolved url, and then create the service from it.
|
|
434
|
-
*/
|
|
435
|
-
return this.service?.resolvedUrl;
|
|
436
|
-
}
|
|
437
|
-
get readOnlyInfo() {
|
|
438
|
-
return this._deltaManager.readOnlyInfo;
|
|
439
|
-
}
|
|
440
|
-
/**
|
|
441
|
-
* Tracks host requiring read-only mode.
|
|
442
|
-
*/
|
|
443
|
-
forceReadonly(readonly) {
|
|
444
|
-
this._deltaManager.connectionManager.forceReadonly(readonly);
|
|
445
|
-
}
|
|
446
|
-
get deltaManager() {
|
|
447
|
-
return this._deltaManager;
|
|
448
|
-
}
|
|
449
|
-
get connectionState() {
|
|
450
|
-
return this.connectionStateHandler.connectionState;
|
|
451
|
-
}
|
|
452
|
-
get connected() {
|
|
453
|
-
return this.connectionStateHandler.connectionState === ConnectionState.Connected;
|
|
454
|
-
}
|
|
455
|
-
/**
|
|
456
|
-
* The server provided id of the client.
|
|
457
|
-
* Set once this.connected is true, otherwise undefined
|
|
458
|
-
*/
|
|
459
|
-
get clientId() {
|
|
460
|
-
return this._clientId;
|
|
461
|
-
}
|
|
462
|
-
get offlineLoadEnabled() {
|
|
463
|
-
const enabled = this.mc.config.getBoolean("Fluid.Container.enableOfflineLoad") ??
|
|
464
|
-
this.options?.enableOfflineLoad === true;
|
|
465
|
-
// summarizer will not have any pending state we want to save
|
|
466
|
-
return enabled && this.deltaManager.clientDetails.capabilities.interactive;
|
|
467
|
-
}
|
|
468
|
-
/**
|
|
469
|
-
* Get the code details that are currently specified for the container.
|
|
470
|
-
* @returns The current code details if any are specified, undefined if none are specified.
|
|
471
|
-
*/
|
|
472
|
-
getSpecifiedCodeDetails() {
|
|
473
|
-
return this.getCodeDetailsFromQuorum();
|
|
474
|
-
}
|
|
475
|
-
/**
|
|
476
|
-
* Get the code details that were used to load the container.
|
|
477
|
-
* @returns The code details that were used to load the container if it is loaded, undefined if it is not yet
|
|
478
|
-
* loaded.
|
|
479
|
-
*/
|
|
480
|
-
getLoadedCodeDetails() {
|
|
481
|
-
return this._loadedCodeDetails;
|
|
482
|
-
}
|
|
483
|
-
/**
|
|
484
|
-
* Retrieves the audience associated with the document
|
|
485
|
-
*/
|
|
486
|
-
get audience() {
|
|
487
|
-
return this.protocolHandler.audience;
|
|
488
|
-
}
|
|
489
|
-
/**
|
|
490
|
-
* Returns true if container is dirty.
|
|
491
|
-
* Which means data loss if container is closed at that same moment
|
|
492
|
-
* Most likely that happens when there is no network connection to Relay Service
|
|
493
|
-
*/
|
|
494
|
-
get isDirty() {
|
|
495
|
-
return this._dirtyContainer;
|
|
496
|
-
}
|
|
497
|
-
/**
|
|
498
|
-
* {@inheritDoc @fluidframework/container-definitions#IContainer.entryPoint}
|
|
499
|
-
*/
|
|
500
|
-
async getEntryPoint() {
|
|
501
|
-
if (this._disposed) {
|
|
502
|
-
throw new UsageError("The context is already disposed");
|
|
503
|
-
}
|
|
504
|
-
if (this._runtime !== undefined) {
|
|
505
|
-
return this._runtime.getEntryPoint?.();
|
|
506
|
-
}
|
|
507
|
-
return new Promise((resolve, reject) => {
|
|
508
|
-
const runtimeInstantiatedHandler = () => {
|
|
509
|
-
assert(this._runtime !== undefined, 0x5a3 /* runtimeInstantiated fired but runtime is still undefined */);
|
|
510
|
-
resolve(this._runtime.getEntryPoint?.());
|
|
511
|
-
this._lifecycleEvents.off("disposed", disposedHandler);
|
|
512
|
-
};
|
|
513
|
-
const disposedHandler = () => {
|
|
514
|
-
reject(new Error("ContainerContext was disposed"));
|
|
515
|
-
this._lifecycleEvents.off("runtimeInstantiated", runtimeInstantiatedHandler);
|
|
516
|
-
};
|
|
517
|
-
this._lifecycleEvents.once("runtimeInstantiated", runtimeInstantiatedHandler);
|
|
518
|
-
this._lifecycleEvents.once("disposed", disposedHandler);
|
|
519
|
-
});
|
|
520
|
-
}
|
|
521
539
|
/**
|
|
522
540
|
* Retrieves the quorum associated with the document
|
|
523
541
|
*/
|
|
@@ -652,7 +670,6 @@ export class Container extends EventEmitterWithErrorHandling {
|
|
|
652
670
|
snapshotBlobs: this.baseSnapshotBlobs,
|
|
653
671
|
savedOps: this.savedOps,
|
|
654
672
|
url: this.resolvedUrl.url,
|
|
655
|
-
term: OnlyValidTermValue,
|
|
656
673
|
// no need to save this if there is no pending runtime state
|
|
657
674
|
clientId: pendingRuntimeState !== undefined ? this.clientId : undefined,
|
|
658
675
|
};
|
|
@@ -774,6 +791,9 @@ export class Container extends EventEmitterWithErrorHandling {
|
|
|
774
791
|
}
|
|
775
792
|
}, { start: true, end: true, cancel: "generic" });
|
|
776
793
|
}
|
|
794
|
+
/**
|
|
795
|
+
* @deprecated Will be removed in future major release. Migrate all usage of IFluidRouter to the "entryPoint" pattern. Refer to Removing-IFluidRouter.md
|
|
796
|
+
*/
|
|
777
797
|
async request(path) {
|
|
778
798
|
return PerformanceEvent.timedExecAsync(this.mc.logger, { eventName: "Request" }, async () => this.runtime.request(path), { end: true, cancel: "error" });
|
|
779
799
|
}
|
|
@@ -924,18 +944,14 @@ export class Container extends EventEmitterWithErrorHandling {
|
|
|
924
944
|
async load(specifiedVersion, loadMode, resolvedUrl, pendingLocalState, loadToSequenceNumber) {
|
|
925
945
|
const timings = { phase1: performance.now() };
|
|
926
946
|
this.service = await this.serviceFactory.createDocumentService(resolvedUrl, this.subLogger, this.client.details.type === summarizerClientType);
|
|
927
|
-
//
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
// That all said, "read" does not work with memorylicious workflows (that opens two simultaneous
|
|
933
|
-
// connections to same file) in two ways:
|
|
934
|
-
// A) creation flow breaks (as one of the clients "sees" file as existing, and hits #2 above)
|
|
935
|
-
// B) Once file is created, transition from view-only connection to write does not work - some bugs to be fixed.
|
|
947
|
+
// Except in cases where it has stashed ops or requested by feature gate, the container will connect in "read" mode
|
|
948
|
+
const mode = this.mc.config.getBoolean("Fluid.Container.ForceWriteConnection") === true ||
|
|
949
|
+
(pendingLocalState?.savedOps.length ?? 0) > 0
|
|
950
|
+
? "write"
|
|
951
|
+
: "read";
|
|
936
952
|
const connectionArgs = {
|
|
937
953
|
reason: { text: "DocumentOpen" },
|
|
938
|
-
mode
|
|
954
|
+
mode,
|
|
939
955
|
fetchOpsFromStorage: false,
|
|
940
956
|
};
|
|
941
957
|
// Start websocket connection as soon as possible. Note that there is no op handler attached yet, but the
|
|
@@ -1100,7 +1116,6 @@ export class Container extends EventEmitterWithErrorHandling {
|
|
|
1100
1116
|
async createDetached(codeDetails) {
|
|
1101
1117
|
const attributes = {
|
|
1102
1118
|
sequenceNumber: detachedContainerRefSeqNumber,
|
|
1103
|
-
term: OnlyValidTermValue,
|
|
1104
1119
|
minimumSequenceNumber: 0,
|
|
1105
1120
|
};
|
|
1106
1121
|
await this.attachDeltaManagerOpHandler(attributes);
|
|
@@ -1140,7 +1155,6 @@ export class Container extends EventEmitterWithErrorHandling {
|
|
|
1140
1155
|
return {
|
|
1141
1156
|
minimumSequenceNumber: 0,
|
|
1142
1157
|
sequenceNumber: 0,
|
|
1143
|
-
term: OnlyValidTermValue,
|
|
1144
1158
|
};
|
|
1145
1159
|
}
|
|
1146
1160
|
// Backward compatibility: old docs would have ".attributes" instead of "attributes"
|