@fluidframework/container-loader 2.0.0-internal.5.1.1 → 2.0.0-internal.5.2.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 +16 -0
- package/dist/catchUpMonitor.d.ts +1 -1
- package/dist/catchUpMonitor.d.ts.map +1 -1
- package/dist/catchUpMonitor.js.map +1 -1
- package/dist/connectionManager.d.ts.map +1 -1
- package/dist/connectionManager.js.map +1 -1
- package/dist/connectionStateHandler.d.ts +3 -0
- package/dist/connectionStateHandler.d.ts.map +1 -1
- package/dist/connectionStateHandler.js +10 -8
- package/dist/connectionStateHandler.js.map +1 -1
- package/dist/container.d.ts +20 -27
- package/dist/container.d.ts.map +1 -1
- package/dist/container.js +164 -104
- package/dist/container.js.map +1 -1
- package/dist/containerContext.d.ts +22 -58
- package/dist/containerContext.d.ts.map +1 -1
- package/dist/containerContext.js +27 -200
- 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.map +1 -1
- package/dist/noopHeuristic.d.ts +23 -0
- package/dist/noopHeuristic.d.ts.map +1 -0
- package/dist/{collabWindowTracker.js → noopHeuristic.js} +30 -42
- package/dist/noopHeuristic.js.map +1 -0
- 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 -12
- package/dist/protocol.d.ts.map +1 -1
- package/dist/protocol.js +0 -18
- package/dist/protocol.js.map +1 -1
- package/dist/protocolTreeDocumentStorageService.d.ts +1 -1
- package/dist/protocolTreeDocumentStorageService.d.ts.map +1 -1
- package/dist/protocolTreeDocumentStorageService.js.map +1 -1
- package/dist/retriableDocumentStorageService.d.ts +1 -1
- package/dist/retriableDocumentStorageService.d.ts.map +1 -1
- package/dist/retriableDocumentStorageService.js.map +1 -1
- package/lib/catchUpMonitor.d.ts +1 -1
- package/lib/catchUpMonitor.d.ts.map +1 -1
- package/lib/catchUpMonitor.js.map +1 -1
- package/lib/connectionManager.d.ts.map +1 -1
- package/lib/connectionManager.js.map +1 -1
- package/lib/connectionStateHandler.d.ts +3 -0
- package/lib/connectionStateHandler.d.ts.map +1 -1
- package/lib/connectionStateHandler.js +10 -8
- package/lib/connectionStateHandler.js.map +1 -1
- package/lib/container.d.ts +20 -27
- package/lib/container.d.ts.map +1 -1
- package/lib/container.js +166 -106
- package/lib/container.js.map +1 -1
- package/lib/containerContext.d.ts +22 -58
- package/lib/containerContext.d.ts.map +1 -1
- package/lib/containerContext.js +27 -200
- 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.map +1 -1
- package/lib/noopHeuristic.d.ts +23 -0
- package/lib/noopHeuristic.d.ts.map +1 -0
- package/lib/{collabWindowTracker.js → noopHeuristic.js} +30 -42
- package/lib/noopHeuristic.js.map +1 -0
- 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 -12
- package/lib/protocol.d.ts.map +1 -1
- package/lib/protocol.js +0 -18
- package/lib/protocol.js.map +1 -1
- package/lib/protocolTreeDocumentStorageService.d.ts +1 -1
- package/lib/protocolTreeDocumentStorageService.d.ts.map +1 -1
- package/lib/protocolTreeDocumentStorageService.js.map +1 -1
- package/lib/retriableDocumentStorageService.d.ts +1 -1
- package/lib/retriableDocumentStorageService.d.ts.map +1 -1
- package/lib/retriableDocumentStorageService.js.map +1 -1
- package/package.json +11 -11
- package/src/catchUpMonitor.ts +1 -1
- package/src/connectionManager.ts +2 -1
- package/src/connectionStateHandler.ts +14 -9
- package/src/container.ts +247 -126
- package/src/containerContext.ts +32 -318
- package/src/containerStorageAdapter.ts +1 -1
- package/src/{collabWindowTracker.ts → noopHeuristic.ts} +37 -47
- package/src/packageVersion.ts +1 -1
- package/src/protocol.ts +0 -39
- package/src/protocolTreeDocumentStorageService.ts +1 -1
- package/src/retriableDocumentStorageService.ts +2 -1
- package/dist/collabWindowTracker.d.ts +0 -19
- package/dist/collabWindowTracker.d.ts.map +0 -1
- package/dist/collabWindowTracker.js.map +0 -1
- package/lib/collabWindowTracker.d.ts +0 -19
- package/lib/collabWindowTracker.d.ts.map +0 -1
- package/lib/collabWindowTracker.js.map +0 -1
|
@@ -3,18 +3,22 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
import { ITelemetryLoggerExt } from "@fluidframework/telemetry-utils";
|
|
6
|
-
import { IAudience, IContainerContext, IDeltaManager, ILoader, ICriticalContainerError, AttachState, ILoaderOptions, IFluidCodeDetails,
|
|
7
|
-
import {
|
|
6
|
+
import { IAudience, IContainerContext, IDeltaManager, ILoader, ICriticalContainerError, AttachState, ILoaderOptions, IFluidCodeDetails, IBatchMessage } from "@fluidframework/container-definitions";
|
|
7
|
+
import { FluidObject } from "@fluidframework/core-interfaces";
|
|
8
8
|
import { IDocumentStorageService } from "@fluidframework/driver-definitions";
|
|
9
|
-
import { IClientConfiguration, IClientDetails, IDocumentMessage, IQuorum, IQuorumClients, ISequencedDocumentMessage,
|
|
10
|
-
|
|
9
|
+
import { IClientConfiguration, IClientDetails, IDocumentMessage, IQuorum, IQuorumClients, ISequencedDocumentMessage, ISnapshotTree, IVersion, MessageType, ISummaryContent } from "@fluidframework/protocol-definitions";
|
|
10
|
+
/**
|
|
11
|
+
* {@inheritDoc @fluidframework/container-definitions#IContainerContext}
|
|
12
|
+
*/
|
|
11
13
|
export declare class ContainerContext implements IContainerContext {
|
|
12
|
-
|
|
14
|
+
readonly options: ILoaderOptions;
|
|
13
15
|
readonly scope: FluidObject;
|
|
14
|
-
|
|
15
|
-
private readonly
|
|
16
|
-
private readonly _baseSnapshot;
|
|
16
|
+
readonly baseSnapshot: ISnapshotTree | undefined;
|
|
17
|
+
private readonly _version;
|
|
17
18
|
readonly deltaManager: IDeltaManager<ISequencedDocumentMessage, IDocumentMessage>;
|
|
19
|
+
readonly storage: IDocumentStorageService;
|
|
20
|
+
private readonly _quorum;
|
|
21
|
+
readonly audience: IAudience;
|
|
18
22
|
readonly loader: ILoader;
|
|
19
23
|
readonly submitFn: (type: MessageType, contents: any, batch: boolean, appData: any) => number;
|
|
20
24
|
readonly submitSummaryFn: (summaryOp: ISummaryContent, referenceSequenceNumber?: number) => number;
|
|
@@ -23,51 +27,35 @@ export declare class ContainerContext implements IContainerContext {
|
|
|
23
27
|
readonly submitSignalFn: (contents: any) => void;
|
|
24
28
|
readonly disposeFn: (error?: ICriticalContainerError) => void;
|
|
25
29
|
readonly closeFn: (error?: ICriticalContainerError) => void;
|
|
26
|
-
readonly version: string;
|
|
27
30
|
readonly updateDirtyContainerState: (dirty: boolean) => void;
|
|
31
|
+
readonly getAbsoluteUrl: (relativeUrl: string) => Promise<string | undefined>;
|
|
32
|
+
private readonly _getContainerDiagnosticId;
|
|
33
|
+
private readonly _getClientId;
|
|
34
|
+
private readonly _getServiceConfiguration;
|
|
35
|
+
private readonly _getAttachState;
|
|
36
|
+
private readonly _getConnected;
|
|
37
|
+
readonly clientDetails: IClientDetails;
|
|
28
38
|
readonly existing: boolean;
|
|
29
|
-
readonly pendingLocalState?: unknown;
|
|
30
|
-
static createOrLoad(container: Container, scope: FluidObject, codeLoader: ICodeDetailsLoader, codeDetails: IFluidCodeDetails, baseSnapshot: ISnapshotTree | undefined, deltaManager: IDeltaManager<ISequencedDocumentMessage, IDocumentMessage>, quorum: IQuorum, loader: ILoader, submitFn: (type: MessageType, contents: any, batch: boolean, appData: any) => number, submitSummaryFn: (summaryOp: ISummaryContent, referenceSequenceNumber?: number) => number, submitBatchFn: (batch: IBatchMessage[], referenceSequenceNumber?: number) => number, submitSignalFn: (contents: any) => void, disposeFn: (error?: ICriticalContainerError) => void, closeFn: (error?: ICriticalContainerError) => void, version: string, updateDirtyContainerState: (dirty: boolean) => void, existing: boolean, pendingLocalState?: unknown): Promise<ContainerContext>;
|
|
31
39
|
readonly taggedLogger: ITelemetryLoggerExt;
|
|
40
|
+
readonly pendingLocalState?: unknown;
|
|
32
41
|
readonly supportedFeatures: ReadonlyMap<string, unknown>;
|
|
33
42
|
get clientId(): string | undefined;
|
|
34
43
|
/**
|
|
35
44
|
* DISCLAIMER: this id is only for telemetry purposes. Not suitable for any other usages.
|
|
36
45
|
*/
|
|
37
46
|
get id(): string;
|
|
38
|
-
get clientDetails(): IClientDetails;
|
|
39
|
-
private _connected;
|
|
40
47
|
/**
|
|
41
48
|
* When true, ops are free to flow
|
|
42
49
|
* When false, ops should be kept as pending or rejected
|
|
43
50
|
*/
|
|
44
51
|
get connected(): boolean;
|
|
45
|
-
get canSummarize(): boolean;
|
|
46
52
|
get serviceConfiguration(): IClientConfiguration | undefined;
|
|
47
|
-
get audience(): IAudience;
|
|
48
|
-
get options(): ILoaderOptions;
|
|
49
|
-
get baseSnapshot(): ISnapshotTree | undefined;
|
|
50
|
-
get storage(): IDocumentStorageService;
|
|
51
|
-
private _runtime;
|
|
52
|
-
private get runtime();
|
|
53
53
|
private _disposed;
|
|
54
54
|
get disposed(): boolean;
|
|
55
|
-
get codeDetails(): IFluidCodeDetails;
|
|
56
|
-
private readonly _quorum;
|
|
57
55
|
get quorum(): IQuorumClients;
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* {@inheritDoc @fluidframework/container-definitions#IContainerContext.getEntryPoint}
|
|
61
|
-
*/
|
|
62
|
-
getEntryPoint?(): Promise<FluidObject | undefined>;
|
|
63
|
-
/**
|
|
64
|
-
* Emits events about the container context's lifecycle.
|
|
65
|
-
* Use it to coordinate things inside the ContainerContext class.
|
|
66
|
-
*/
|
|
67
|
-
private readonly lifecycleEvents;
|
|
68
|
-
constructor(container: Container, scope: FluidObject, codeLoader: ICodeDetailsLoader, _codeDetails: IFluidCodeDetails, _baseSnapshot: ISnapshotTree | undefined, deltaManager: IDeltaManager<ISequencedDocumentMessage, IDocumentMessage>, quorum: IQuorum, loader: ILoader, submitFn: (type: MessageType, contents: any, batch: boolean, appData: any) => number, submitSummaryFn: (summaryOp: ISummaryContent, referenceSequenceNumber?: number) => number,
|
|
56
|
+
constructor(options: ILoaderOptions, scope: FluidObject, baseSnapshot: ISnapshotTree | undefined, _version: IVersion | undefined, deltaManager: IDeltaManager<ISequencedDocumentMessage, IDocumentMessage>, storage: IDocumentStorageService, _quorum: IQuorum, audience: IAudience, loader: ILoader, submitFn: (type: MessageType, contents: any, batch: boolean, appData: any) => number, submitSummaryFn: (summaryOp: ISummaryContent, referenceSequenceNumber?: number) => number,
|
|
69
57
|
/** @returns clientSequenceNumber of last message in a batch */
|
|
70
|
-
submitBatchFn: (batch: IBatchMessage[], referenceSequenceNumber?: number) => number, submitSignalFn: (contents: any) => void, disposeFn: (error?: ICriticalContainerError) => void, closeFn: (error?: ICriticalContainerError) => void,
|
|
58
|
+
submitBatchFn: (batch: IBatchMessage[], referenceSequenceNumber?: number) => number, submitSignalFn: (contents: any) => void, disposeFn: (error?: ICriticalContainerError) => void, closeFn: (error?: ICriticalContainerError) => void, updateDirtyContainerState: (dirty: boolean) => void, getAbsoluteUrl: (relativeUrl: string) => Promise<string | undefined>, _getContainerDiagnosticId: () => string | undefined, _getClientId: () => string | undefined, _getServiceConfiguration: () => IClientConfiguration | undefined, _getAttachState: () => AttachState, _getConnected: () => boolean, clientDetails: IClientDetails, existing: boolean, taggedLogger: ITelemetryLoggerExt, pendingLocalState?: unknown);
|
|
71
59
|
/**
|
|
72
60
|
* @deprecated Temporary migratory API, to be removed when customers no longer need it.
|
|
73
61
|
* When removed, `ContainerContext` should only take an {@link @fluidframework/container-definitions#IQuorumClients}
|
|
@@ -78,29 +66,5 @@ export declare class ContainerContext implements IContainerContext {
|
|
|
78
66
|
dispose(error?: Error): void;
|
|
79
67
|
getLoadedFromVersion(): IVersion | undefined;
|
|
80
68
|
get attachState(): AttachState;
|
|
81
|
-
/**
|
|
82
|
-
* Create a summary. Used when attaching or serializing a detached container.
|
|
83
|
-
*
|
|
84
|
-
* @param blobRedirectTable - A table passed during the attach process. While detached, blob upload is supported
|
|
85
|
-
* using IDs generated locally. After attach, these IDs cannot be used, so this table maps the old local IDs to the
|
|
86
|
-
* new storage IDs so requests can be redirected.
|
|
87
|
-
*/
|
|
88
|
-
createSummary(blobRedirectTable?: Map<string, string>): ISummaryTree;
|
|
89
|
-
setConnectionState(connected: boolean, clientId?: string): void;
|
|
90
|
-
process(message: ISequencedDocumentMessage, local: boolean): void;
|
|
91
|
-
processSignal(message: ISignalMessage, local: boolean): void;
|
|
92
|
-
request(path: IRequest): Promise<IResponse>;
|
|
93
|
-
getAbsoluteUrl(relativeUrl: string): Promise<string | undefined>;
|
|
94
|
-
getPendingLocalState(): unknown;
|
|
95
|
-
/**
|
|
96
|
-
* Determines if the current code details of the context
|
|
97
|
-
* satisfy the incoming constraint code details
|
|
98
|
-
*/
|
|
99
|
-
satisfies(constraintCodeDetails: IFluidCodeDetails): Promise<boolean>;
|
|
100
|
-
notifyOpReplay(message: ISequencedDocumentMessage): Promise<void>;
|
|
101
|
-
private getRuntimeFactory;
|
|
102
|
-
private instantiateRuntime;
|
|
103
|
-
private attachListener;
|
|
104
|
-
private loadCodeModule;
|
|
105
69
|
}
|
|
106
70
|
//# sourceMappingURL=containerContext.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"containerContext.d.ts","sourceRoot":"","sources":["../src/containerContext.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,mBAAmB,
|
|
1
|
+
{"version":3,"file":"containerContext.d.ts","sourceRoot":"","sources":["../src/containerContext.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AACtE,OAAO,EACN,SAAS,EACT,iBAAiB,EACjB,aAAa,EACb,OAAO,EACP,uBAAuB,EACvB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AAM;IACX,+DAA+D;IAC/C,aAAa,EAAE,CAC9B,KAAK,EAAE,aAAa,EAAE,EACtB,uBAAuB,CAAC,EAAE,MAAM,KAC5B,MAAM,EACK,cAAc,EAAE,CAAC,QAAQ,EAAE,GAAG,KAAK,IAAI,EACvC,SAAS,EAAE,CAAC,KAAK,CAAC,EAAE,uBAAuB,KAAK,IAAI,EACpD,OAAO,EAAE,CAAC,KAAK,CAAC,EAAE,uBAAuB,KAAK,IAAI,EAClD,yBAAyB,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,EACnD,cAAc,EAAE,CAAC,WAAW,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,EACnE,yBAAyB,EAAE,MAAM,MAAM,GAAG,SAAS,EACnD,YAAY,EAAE,MAAM,MAAM,GAAG,SAAS,EACtC,wBAAwB,EAAE,MAAM,oBAAoB,GAAG,SAAS,EAChE,eAAe,EAAE,MAAM,WAAW,EAClC,aAAa,EAAE,MAAM,OAAO,EAC7B,aAAa,EAAE,cAAc,EAC7B,QAAQ,EAAE,OAAO,EACjB,YAAY,EAAE,mBAAmB,EACjC,iBAAiB,CAAC,SAAS;IAG5C;;;;;OAKG;IACI,uBAAuB,IAAI,iBAAiB,GAAG,SAAS;IAMxD,OAAO,CAAC,KAAK,CAAC,EAAE,KAAK,GAAG,IAAI;IAI5B,oBAAoB,IAAI,QAAQ,GAAG,SAAS;IAInD,IAAW,WAAW,IAAI,WAAW,CAEpC;CACD"}
|
package/lib/containerContext.js
CHANGED
|
@@ -2,21 +2,21 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
import { UsageError } from "@fluidframework/container-utils";
|
|
9
|
-
const PackageNotFactoryError = "Code package does not implement IRuntimeFactory";
|
|
5
|
+
/**
|
|
6
|
+
* {@inheritDoc @fluidframework/container-definitions#IContainerContext}
|
|
7
|
+
*/
|
|
10
8
|
export class ContainerContext {
|
|
11
|
-
constructor(
|
|
9
|
+
constructor(options, scope, baseSnapshot, _version, deltaManager, storage, _quorum, audience, loader, submitFn, submitSummaryFn,
|
|
12
10
|
/** @returns clientSequenceNumber of last message in a batch */
|
|
13
|
-
submitBatchFn, submitSignalFn, disposeFn, closeFn,
|
|
14
|
-
this.
|
|
11
|
+
submitBatchFn, submitSignalFn, disposeFn, closeFn, updateDirtyContainerState, getAbsoluteUrl, _getContainerDiagnosticId, _getClientId, _getServiceConfiguration, _getAttachState, _getConnected, clientDetails, existing, taggedLogger, pendingLocalState) {
|
|
12
|
+
this.options = options;
|
|
15
13
|
this.scope = scope;
|
|
16
|
-
this.
|
|
17
|
-
this.
|
|
18
|
-
this._baseSnapshot = _baseSnapshot;
|
|
14
|
+
this.baseSnapshot = baseSnapshot;
|
|
15
|
+
this._version = _version;
|
|
19
16
|
this.deltaManager = deltaManager;
|
|
17
|
+
this.storage = storage;
|
|
18
|
+
this._quorum = _quorum;
|
|
19
|
+
this.audience = audience;
|
|
20
20
|
this.loader = loader;
|
|
21
21
|
this.submitFn = submitFn;
|
|
22
22
|
this.submitSummaryFn = submitSummaryFn;
|
|
@@ -24,20 +24,17 @@ export class ContainerContext {
|
|
|
24
24
|
this.submitSignalFn = submitSignalFn;
|
|
25
25
|
this.disposeFn = disposeFn;
|
|
26
26
|
this.closeFn = closeFn;
|
|
27
|
-
this.version = version;
|
|
28
27
|
this.updateDirtyContainerState = updateDirtyContainerState;
|
|
28
|
+
this.getAbsoluteUrl = getAbsoluteUrl;
|
|
29
|
+
this._getContainerDiagnosticId = _getContainerDiagnosticId;
|
|
30
|
+
this._getClientId = _getClientId;
|
|
31
|
+
this._getServiceConfiguration = _getServiceConfiguration;
|
|
32
|
+
this._getAttachState = _getAttachState;
|
|
33
|
+
this._getConnected = _getConnected;
|
|
34
|
+
this.clientDetails = clientDetails;
|
|
29
35
|
this.existing = existing;
|
|
36
|
+
this.taggedLogger = taggedLogger;
|
|
30
37
|
this.pendingLocalState = pendingLocalState;
|
|
31
|
-
this._disposed = false;
|
|
32
|
-
/**
|
|
33
|
-
* Emits events about the container context's lifecycle.
|
|
34
|
-
* Use it to coordinate things inside the ContainerContext class.
|
|
35
|
-
*/
|
|
36
|
-
this.lifecycleEvents = new TypedEventEmitter();
|
|
37
|
-
this._connected = this.container.connected;
|
|
38
|
-
this._quorum = quorum;
|
|
39
|
-
this.taggedLogger = container.subLogger;
|
|
40
|
-
this._fluidModuleP = new LazyPromise(async () => this.loadCodeModule(_codeDetails));
|
|
41
38
|
this.supportedFeatures = new Map([
|
|
42
39
|
/**
|
|
43
40
|
* This version of the loader accepts `referenceSequenceNumber`, provided by the container runtime,
|
|
@@ -46,92 +43,34 @@ export class ContainerContext {
|
|
|
46
43
|
*/
|
|
47
44
|
["referenceSequenceNumbers", true],
|
|
48
45
|
]);
|
|
49
|
-
this.
|
|
50
|
-
}
|
|
51
|
-
static async createOrLoad(container, scope, codeLoader, codeDetails, baseSnapshot, deltaManager, quorum, loader, submitFn, submitSummaryFn, submitBatchFn, submitSignalFn, disposeFn, closeFn, version, updateDirtyContainerState, existing, pendingLocalState) {
|
|
52
|
-
const context = new ContainerContext(container, scope, codeLoader, codeDetails, baseSnapshot, deltaManager, quorum, loader, submitFn, submitSummaryFn, submitBatchFn, submitSignalFn, disposeFn, closeFn, version, updateDirtyContainerState, existing, pendingLocalState);
|
|
53
|
-
await context.instantiateRuntime(existing);
|
|
54
|
-
return context;
|
|
46
|
+
this._disposed = false;
|
|
55
47
|
}
|
|
56
48
|
get clientId() {
|
|
57
|
-
return this.
|
|
49
|
+
return this._getClientId();
|
|
58
50
|
}
|
|
59
51
|
/**
|
|
60
52
|
* DISCLAIMER: this id is only for telemetry purposes. Not suitable for any other usages.
|
|
61
53
|
*/
|
|
62
54
|
get id() {
|
|
63
|
-
var _a
|
|
64
|
-
return (
|
|
65
|
-
}
|
|
66
|
-
get clientDetails() {
|
|
67
|
-
return this.container.clientDetails;
|
|
55
|
+
var _a;
|
|
56
|
+
return (_a = this._getContainerDiagnosticId()) !== null && _a !== void 0 ? _a : "";
|
|
68
57
|
}
|
|
69
58
|
/**
|
|
70
59
|
* When true, ops are free to flow
|
|
71
60
|
* When false, ops should be kept as pending or rejected
|
|
72
61
|
*/
|
|
73
62
|
get connected() {
|
|
74
|
-
return this.
|
|
75
|
-
}
|
|
76
|
-
get canSummarize() {
|
|
77
|
-
return "summarize" in this.runtime;
|
|
63
|
+
return this._getConnected();
|
|
78
64
|
}
|
|
79
65
|
get serviceConfiguration() {
|
|
80
|
-
return this.
|
|
81
|
-
}
|
|
82
|
-
get audience() {
|
|
83
|
-
return this.container.audience;
|
|
84
|
-
}
|
|
85
|
-
get options() {
|
|
86
|
-
return this.container.options;
|
|
87
|
-
}
|
|
88
|
-
get baseSnapshot() {
|
|
89
|
-
return this._baseSnapshot;
|
|
90
|
-
}
|
|
91
|
-
get storage() {
|
|
92
|
-
return this.container.storage;
|
|
93
|
-
}
|
|
94
|
-
get runtime() {
|
|
95
|
-
if (this._runtime === undefined) {
|
|
96
|
-
throw new Error("Attempted to access runtime before it was defined");
|
|
97
|
-
}
|
|
98
|
-
return this._runtime;
|
|
66
|
+
return this._getServiceConfiguration();
|
|
99
67
|
}
|
|
100
68
|
get disposed() {
|
|
101
69
|
return this._disposed;
|
|
102
70
|
}
|
|
103
|
-
get codeDetails() {
|
|
104
|
-
return this._codeDetails;
|
|
105
|
-
}
|
|
106
71
|
get quorum() {
|
|
107
72
|
return this._quorum;
|
|
108
73
|
}
|
|
109
|
-
/**
|
|
110
|
-
* {@inheritDoc @fluidframework/container-definitions#IContainerContext.getEntryPoint}
|
|
111
|
-
*/
|
|
112
|
-
async getEntryPoint() {
|
|
113
|
-
var _a, _b;
|
|
114
|
-
if (this._disposed) {
|
|
115
|
-
throw new UsageError("The context is already disposed");
|
|
116
|
-
}
|
|
117
|
-
if (this._runtime !== undefined) {
|
|
118
|
-
return (_b = (_a = this._runtime) === null || _a === void 0 ? void 0 : _a.getEntryPoint) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
119
|
-
}
|
|
120
|
-
return new Promise((resolve, reject) => {
|
|
121
|
-
const runtimeInstantiatedHandler = () => {
|
|
122
|
-
var _a, _b;
|
|
123
|
-
assert(this._runtime !== undefined, 0x5a3 /* runtimeInstantiated fired but runtime is still undefined */);
|
|
124
|
-
resolve((_b = (_a = this._runtime).getEntryPoint) === null || _b === void 0 ? void 0 : _b.call(_a));
|
|
125
|
-
this.lifecycleEvents.off("disposed", disposedHandler);
|
|
126
|
-
};
|
|
127
|
-
const disposedHandler = () => {
|
|
128
|
-
reject(new Error("ContainerContext was disposed"));
|
|
129
|
-
this.lifecycleEvents.off("runtimeInstantiated", runtimeInstantiatedHandler);
|
|
130
|
-
};
|
|
131
|
-
this.lifecycleEvents.once("runtimeInstantiated", runtimeInstantiatedHandler);
|
|
132
|
-
this.lifecycleEvents.once("disposed", disposedHandler);
|
|
133
|
-
});
|
|
134
|
-
}
|
|
135
74
|
/**
|
|
136
75
|
* @deprecated Temporary migratory API, to be removed when customers no longer need it.
|
|
137
76
|
* When removed, `ContainerContext` should only take an {@link @fluidframework/container-definitions#IQuorumClients}
|
|
@@ -143,125 +82,13 @@ export class ContainerContext {
|
|
|
143
82
|
return ((_a = this._quorum.get("code")) !== null && _a !== void 0 ? _a : this._quorum.get("code2"));
|
|
144
83
|
}
|
|
145
84
|
dispose(error) {
|
|
146
|
-
if (this._disposed) {
|
|
147
|
-
return;
|
|
148
|
-
}
|
|
149
85
|
this._disposed = true;
|
|
150
|
-
this.lifecycleEvents.emit("disposed");
|
|
151
|
-
this.runtime.dispose(error);
|
|
152
|
-
this._quorum.dispose();
|
|
153
|
-
this.deltaManager.dispose();
|
|
154
86
|
}
|
|
155
87
|
getLoadedFromVersion() {
|
|
156
|
-
return this.
|
|
88
|
+
return this._version;
|
|
157
89
|
}
|
|
158
90
|
get attachState() {
|
|
159
|
-
return this.
|
|
160
|
-
}
|
|
161
|
-
/**
|
|
162
|
-
* Create a summary. Used when attaching or serializing a detached container.
|
|
163
|
-
*
|
|
164
|
-
* @param blobRedirectTable - A table passed during the attach process. While detached, blob upload is supported
|
|
165
|
-
* using IDs generated locally. After attach, these IDs cannot be used, so this table maps the old local IDs to the
|
|
166
|
-
* new storage IDs so requests can be redirected.
|
|
167
|
-
*/
|
|
168
|
-
createSummary(blobRedirectTable) {
|
|
169
|
-
return this.runtime.createSummary(blobRedirectTable);
|
|
170
|
-
}
|
|
171
|
-
setConnectionState(connected, clientId) {
|
|
172
|
-
const runtime = this.runtime;
|
|
173
|
-
this._connected = connected;
|
|
174
|
-
runtime.setConnectionState(connected, clientId);
|
|
175
|
-
}
|
|
176
|
-
process(message, local) {
|
|
177
|
-
this.runtime.process(message, local);
|
|
178
|
-
}
|
|
179
|
-
processSignal(message, local) {
|
|
180
|
-
this.runtime.processSignal(message, local);
|
|
181
|
-
}
|
|
182
|
-
async request(path) {
|
|
183
|
-
return this.runtime.request(path);
|
|
184
|
-
}
|
|
185
|
-
async getAbsoluteUrl(relativeUrl) {
|
|
186
|
-
return this.container.getAbsoluteUrl(relativeUrl);
|
|
187
|
-
}
|
|
188
|
-
getPendingLocalState() {
|
|
189
|
-
return this.runtime.getPendingLocalState();
|
|
190
|
-
}
|
|
191
|
-
/**
|
|
192
|
-
* Determines if the current code details of the context
|
|
193
|
-
* satisfy the incoming constraint code details
|
|
194
|
-
*/
|
|
195
|
-
async satisfies(constraintCodeDetails) {
|
|
196
|
-
var _a;
|
|
197
|
-
const comparers = [];
|
|
198
|
-
const maybeCompareCodeLoader = this.codeLoader;
|
|
199
|
-
if (maybeCompareCodeLoader.IFluidCodeDetailsComparer !== undefined) {
|
|
200
|
-
comparers.push(maybeCompareCodeLoader.IFluidCodeDetailsComparer);
|
|
201
|
-
}
|
|
202
|
-
const moduleWithDetails = await this._fluidModuleP;
|
|
203
|
-
const maybeCompareExport = (_a = moduleWithDetails.module) === null || _a === void 0 ? void 0 : _a.fluidExport;
|
|
204
|
-
if ((maybeCompareExport === null || maybeCompareExport === void 0 ? void 0 : maybeCompareExport.IFluidCodeDetailsComparer) !== undefined) {
|
|
205
|
-
comparers.push(maybeCompareExport.IFluidCodeDetailsComparer);
|
|
206
|
-
}
|
|
207
|
-
// if there are not comparers it is not possible to know
|
|
208
|
-
// if the current satisfy the incoming, so return false,
|
|
209
|
-
// as assuming they do not satisfy is safer .e.g we will
|
|
210
|
-
// reload, rather than potentially running with
|
|
211
|
-
// incompatible code
|
|
212
|
-
if (comparers.length === 0) {
|
|
213
|
-
return false;
|
|
214
|
-
}
|
|
215
|
-
for (const comparer of comparers) {
|
|
216
|
-
const satisfies = await comparer.satisfies(moduleWithDetails.details, constraintCodeDetails);
|
|
217
|
-
if (satisfies === false) {
|
|
218
|
-
return false;
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
return true;
|
|
222
|
-
}
|
|
223
|
-
async notifyOpReplay(message) {
|
|
224
|
-
var _a, _b;
|
|
225
|
-
return (_b = (_a = this.runtime).notifyOpReplay) === null || _b === void 0 ? void 0 : _b.call(_a, message);
|
|
226
|
-
}
|
|
227
|
-
// #region private
|
|
228
|
-
async getRuntimeFactory() {
|
|
229
|
-
var _a;
|
|
230
|
-
const fluidExport = (_a = (await this._fluidModuleP).module) === null || _a === void 0 ? void 0 : _a.fluidExport;
|
|
231
|
-
const runtimeFactory = fluidExport === null || fluidExport === void 0 ? void 0 : fluidExport.IRuntimeFactory;
|
|
232
|
-
if (runtimeFactory === undefined) {
|
|
233
|
-
throw new Error(PackageNotFactoryError);
|
|
234
|
-
}
|
|
235
|
-
return runtimeFactory;
|
|
236
|
-
}
|
|
237
|
-
async instantiateRuntime(existing) {
|
|
238
|
-
const runtimeFactory = await this.getRuntimeFactory();
|
|
239
|
-
this._runtime = await PerformanceEvent.timedExecAsync(this.taggedLogger, { eventName: "InstantiateRuntime" }, async () => runtimeFactory.instantiateRuntime(this, existing));
|
|
240
|
-
this.lifecycleEvents.emit("runtimeInstantiated");
|
|
241
|
-
}
|
|
242
|
-
attachListener() {
|
|
243
|
-
this.container.once("attaching", () => {
|
|
244
|
-
this.runtime.setAttachState(AttachState.Attaching);
|
|
245
|
-
});
|
|
246
|
-
this.container.once("attached", () => {
|
|
247
|
-
this.runtime.setAttachState(AttachState.Attached);
|
|
248
|
-
});
|
|
249
|
-
}
|
|
250
|
-
async loadCodeModule(codeDetails) {
|
|
251
|
-
const loadCodeResult = await PerformanceEvent.timedExecAsync(this.taggedLogger, { eventName: "CodeLoad" }, async () => this.codeLoader.load(codeDetails));
|
|
252
|
-
if ("module" in loadCodeResult) {
|
|
253
|
-
const { module, details } = loadCodeResult;
|
|
254
|
-
return {
|
|
255
|
-
module,
|
|
256
|
-
details: details !== null && details !== void 0 ? details : codeDetails,
|
|
257
|
-
};
|
|
258
|
-
}
|
|
259
|
-
else {
|
|
260
|
-
// If "module" is not in the result, we are using a legacy ICodeLoader. Fix the result up with details.
|
|
261
|
-
// Once usage drops to 0 we can remove this compat path.
|
|
262
|
-
this.taggedLogger.sendTelemetryEvent({ eventName: "LegacyCodeLoader" });
|
|
263
|
-
return loadCodeResult;
|
|
264
|
-
}
|
|
91
|
+
return this._getAttachState();
|
|
265
92
|
}
|
|
266
93
|
}
|
|
267
94
|
//# sourceMappingURL=containerContext.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"containerContext.js","sourceRoot":"","sources":["../src/containerContext.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAuB,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACxF,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACtF,OAAO,EAON,WAAW,GAUX,MAAM,uCAAuC,CAAC;AAiB/C,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAG7D,MAAM,sBAAsB,GAAG,iDAA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corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryLoggerExt, PerformanceEvent } from \"@fluidframework/telemetry-utils\";\nimport { assert, LazyPromise, TypedEventEmitter } from \"@fluidframework/common-utils\";\nimport {\n\tIAudience,\n\tIContainerContext,\n\tIDeltaManager,\n\tILoader,\n\tIRuntime,\n\tICriticalContainerError,\n\tAttachState,\n\tILoaderOptions,\n\tIRuntimeFactory,\n\tIProvideRuntimeFactory,\n\tIFluidCodeDetails,\n\tIFluidCodeDetailsComparer,\n\tIProvideFluidCodeDetailsComparer,\n\tICodeDetailsLoader,\n\tIFluidModuleWithDetails,\n\tIBatchMessage,\n} from \"@fluidframework/container-definitions\";\nimport { IRequest, IResponse, FluidObject } from \"@fluidframework/core-interfaces\";\nimport { IDocumentStorageService } from \"@fluidframework/driver-definitions\";\nimport {\n\tIClientConfiguration,\n\tIClientDetails,\n\tIDocumentMessage,\n\tIQuorum,\n\tIQuorumClients,\n\tISequencedDocumentMessage,\n\tISignalMessage,\n\tISnapshotTree,\n\tISummaryTree,\n\tIVersion,\n\tMessageType,\n\tISummaryContent,\n} from \"@fluidframework/protocol-definitions\";\nimport { UsageError } from \"@fluidframework/container-utils\";\nimport { Container } from \"./container\";\n\nconst PackageNotFactoryError = \"Code package does not implement IRuntimeFactory\";\n\n/**\n * Events that {@link ContainerContext} can emit through its lifecycle.\n *\n * \"runtimeInstantiated\" - When an {@link @fluidframework/container-definitions#IRuntime} has been instantiated (by\n * calling instantiateRuntime() on the runtime factory), and this._runtime is set.\n *\n * \"disposed\" - When its dispose() method is called. The {@link ContainerContext} is no longer usable at that point.\n */\ntype ContextLifecycleEvents = \"runtimeInstantiated\" | \"disposed\";\n\nexport class ContainerContext implements IContainerContext {\n\tpublic static async createOrLoad(\n\t\tcontainer: Container,\n\t\tscope: FluidObject,\n\t\tcodeLoader: ICodeDetailsLoader,\n\t\tcodeDetails: IFluidCodeDetails,\n\t\tbaseSnapshot: ISnapshotTree | undefined,\n\t\tdeltaManager: IDeltaManager<ISequencedDocumentMessage, IDocumentMessage>,\n\t\tquorum: IQuorum,\n\t\tloader: ILoader,\n\t\tsubmitFn: (type: MessageType, contents: any, batch: boolean, appData: any) => number,\n\t\tsubmitSummaryFn: (summaryOp: ISummaryContent, referenceSequenceNumber?: number) => number,\n\t\tsubmitBatchFn: (batch: IBatchMessage[], referenceSequenceNumber?: number) => number,\n\t\tsubmitSignalFn: (contents: any) => void,\n\t\tdisposeFn: (error?: ICriticalContainerError) => void,\n\t\tcloseFn: (error?: ICriticalContainerError) => void,\n\t\tversion: string,\n\t\tupdateDirtyContainerState: (dirty: boolean) => void,\n\t\texisting: boolean,\n\t\tpendingLocalState?: unknown,\n\t): Promise<ContainerContext> {\n\t\tconst context = new ContainerContext(\n\t\t\tcontainer,\n\t\t\tscope,\n\t\t\tcodeLoader,\n\t\t\tcodeDetails,\n\t\t\tbaseSnapshot,\n\t\t\tdeltaManager,\n\t\t\tquorum,\n\t\t\tloader,\n\t\t\tsubmitFn,\n\t\t\tsubmitSummaryFn,\n\t\t\tsubmitBatchFn,\n\t\t\tsubmitSignalFn,\n\t\t\tdisposeFn,\n\t\t\tcloseFn,\n\t\t\tversion,\n\t\t\tupdateDirtyContainerState,\n\t\t\texisting,\n\t\t\tpendingLocalState,\n\t\t);\n\t\tawait context.instantiateRuntime(existing);\n\t\treturn context;\n\t}\n\n\tpublic readonly taggedLogger: ITelemetryLoggerExt;\n\tpublic readonly supportedFeatures: ReadonlyMap<string, unknown>;\n\n\tpublic get clientId(): string | undefined {\n\t\treturn this.container.clientId;\n\t}\n\n\t/**\n\t * DISCLAIMER: this id is only for telemetry purposes. Not suitable for any other usages.\n\t */\n\tpublic get id(): string {\n\t\treturn this.container.resolvedUrl?.id ?? \"\";\n\t}\n\n\tpublic get clientDetails(): IClientDetails {\n\t\treturn this.container.clientDetails;\n\t}\n\n\tprivate _connected: boolean;\n\t/**\n\t * When true, ops are free to flow\n\t * When false, ops should be kept as pending or rejected\n\t */\n\tpublic get connected(): boolean {\n\t\treturn this._connected;\n\t}\n\n\tpublic get canSummarize(): boolean {\n\t\treturn \"summarize\" in this.runtime;\n\t}\n\n\tpublic get serviceConfiguration(): IClientConfiguration | undefined {\n\t\treturn this.container.serviceConfiguration;\n\t}\n\n\tpublic get audience(): IAudience {\n\t\treturn this.container.audience;\n\t}\n\n\tpublic get options(): ILoaderOptions {\n\t\treturn this.container.options;\n\t}\n\n\tpublic get baseSnapshot() {\n\t\treturn this._baseSnapshot;\n\t}\n\n\tpublic get storage(): IDocumentStorageService {\n\t\treturn this.container.storage;\n\t}\n\n\tprivate _runtime: IRuntime | undefined;\n\tprivate get runtime() {\n\t\tif (this._runtime === undefined) {\n\t\t\tthrow new Error(\"Attempted to access runtime before it was defined\");\n\t\t}\n\t\treturn this._runtime;\n\t}\n\n\tprivate _disposed = false;\n\n\tpublic get disposed() {\n\t\treturn this._disposed;\n\t}\n\n\tpublic get codeDetails() {\n\t\treturn this._codeDetails;\n\t}\n\n\tprivate readonly _quorum: IQuorum;\n\tpublic get quorum(): IQuorumClients {\n\t\treturn this._quorum;\n\t}\n\n\tprivate readonly _fluidModuleP: Promise<IFluidModuleWithDetails>;\n\n\t/**\n\t * {@inheritDoc @fluidframework/container-definitions#IContainerContext.getEntryPoint}\n\t */\n\tpublic async getEntryPoint?(): Promise<FluidObject | undefined> {\n\t\tif (this._disposed) {\n\t\t\tthrow new UsageError(\"The context is already disposed\");\n\t\t}\n\t\tif (this._runtime !== undefined) {\n\t\t\treturn this._runtime?.getEntryPoint?.();\n\t\t}\n\t\treturn new Promise<FluidObject | undefined>((resolve, reject) => {\n\t\t\tconst runtimeInstantiatedHandler = () => {\n\t\t\t\tassert(\n\t\t\t\t\tthis._runtime !== undefined,\n\t\t\t\t\t0x5a3 /* runtimeInstantiated fired but runtime is still undefined */,\n\t\t\t\t);\n\t\t\t\tresolve(this._runtime.getEntryPoint?.());\n\t\t\t\tthis.lifecycleEvents.off(\"disposed\", disposedHandler);\n\t\t\t};\n\t\t\tconst disposedHandler = () => {\n\t\t\t\treject(new Error(\"ContainerContext was disposed\"));\n\t\t\t\tthis.lifecycleEvents.off(\"runtimeInstantiated\", runtimeInstantiatedHandler);\n\t\t\t};\n\t\t\tthis.lifecycleEvents.once(\"runtimeInstantiated\", runtimeInstantiatedHandler);\n\t\t\tthis.lifecycleEvents.once(\"disposed\", disposedHandler);\n\t\t});\n\t}\n\n\t/**\n\t * Emits events about the container context's lifecycle.\n\t * Use it to coordinate things inside the ContainerContext class.\n\t */\n\tprivate readonly lifecycleEvents = new TypedEventEmitter<ContextLifecycleEvents>();\n\n\tconstructor(\n\t\tprivate readonly container: Container,\n\t\tpublic readonly scope: FluidObject,\n\t\tprivate readonly codeLoader: ICodeDetailsLoader,\n\t\tprivate readonly _codeDetails: IFluidCodeDetails,\n\t\tprivate readonly _baseSnapshot: ISnapshotTree | undefined,\n\t\tpublic readonly deltaManager: IDeltaManager<ISequencedDocumentMessage, IDocumentMessage>,\n\t\tquorum: IQuorum,\n\t\tpublic readonly loader: ILoader,\n\t\tpublic readonly submitFn: (\n\t\t\ttype: MessageType,\n\t\t\tcontents: any,\n\t\t\tbatch: boolean,\n\t\t\tappData: any,\n\t\t) => number,\n\t\tpublic readonly submitSummaryFn: (\n\t\t\tsummaryOp: ISummaryContent,\n\t\t\treferenceSequenceNumber?: number,\n\t\t) => number,\n\t\t/** @returns clientSequenceNumber of last message in a batch */\n\t\tpublic readonly submitBatchFn: (\n\t\t\tbatch: IBatchMessage[],\n\t\t\treferenceSequenceNumber?: number,\n\t\t) => number,\n\t\tpublic readonly submitSignalFn: (contents: any) => void,\n\t\tpublic readonly disposeFn: (error?: ICriticalContainerError) => void,\n\t\tpublic readonly closeFn: (error?: ICriticalContainerError) => void,\n\t\tpublic readonly version: string,\n\t\tpublic readonly updateDirtyContainerState: (dirty: boolean) => void,\n\t\tpublic readonly existing: boolean,\n\t\tpublic readonly pendingLocalState?: unknown,\n\t) {\n\t\tthis._connected = this.container.connected;\n\t\tthis._quorum = quorum;\n\t\tthis.taggedLogger = container.subLogger;\n\t\tthis._fluidModuleP = new LazyPromise<IFluidModuleWithDetails>(async () =>\n\t\t\tthis.loadCodeModule(_codeDetails),\n\t\t);\n\n\t\tthis.supportedFeatures = new Map([\n\t\t\t/**\n\t\t\t * This version of the loader accepts `referenceSequenceNumber`, provided by the container runtime,\n\t\t\t * as a parameter to the `submitBatchFn` and `submitSummaryFn` functions.\n\t\t\t * This is then used to set the reference sequence numbers of the submitted ops in the DeltaManager.\n\t\t\t */\n\t\t\t[\"referenceSequenceNumbers\", true],\n\t\t]);\n\t\tthis.attachListener();\n\t}\n\n\t/**\n\t * @deprecated Temporary migratory API, to be removed when customers no longer need it.\n\t * When removed, `ContainerContext` should only take an {@link @fluidframework/container-definitions#IQuorumClients}\n\t * rather than an {@link @fluidframework/protocol-definitions#IQuorum}.\n\t * See {@link @fluidframework/container-definitions#IContainerContext} for more details.\n\t */\n\tpublic getSpecifiedCodeDetails(): IFluidCodeDetails | undefined {\n\t\treturn (this._quorum.get(\"code\") ?? this._quorum.get(\"code2\")) as\n\t\t\t| IFluidCodeDetails\n\t\t\t| undefined;\n\t}\n\n\tpublic dispose(error?: Error): void {\n\t\tif (this._disposed) {\n\t\t\treturn;\n\t\t}\n\t\tthis._disposed = true;\n\n\t\tthis.lifecycleEvents.emit(\"disposed\");\n\t\tthis.runtime.dispose(error);\n\t\tthis._quorum.dispose();\n\t\tthis.deltaManager.dispose();\n\t}\n\n\tpublic getLoadedFromVersion(): IVersion | undefined {\n\t\treturn this.container.loadedFromVersion;\n\t}\n\n\tpublic get attachState(): AttachState {\n\t\treturn this.container.attachState;\n\t}\n\n\t/**\n\t * Create a summary. Used when attaching or serializing a detached container.\n\t *\n\t * @param blobRedirectTable - A table passed during the attach process. While detached, blob upload is supported\n\t * using IDs generated locally. After attach, these IDs cannot be used, so this table maps the old local IDs to the\n\t * new storage IDs so requests can be redirected.\n\t */\n\tpublic createSummary(blobRedirectTable?: Map<string, string>): ISummaryTree {\n\t\treturn this.runtime.createSummary(blobRedirectTable);\n\t}\n\n\tpublic setConnectionState(connected: boolean, clientId?: string) {\n\t\tconst runtime = this.runtime;\n\t\tthis._connected = connected;\n\t\truntime.setConnectionState(connected, clientId);\n\t}\n\n\tpublic process(message: ISequencedDocumentMessage, local: boolean) {\n\t\tthis.runtime.process(message, local);\n\t}\n\n\tpublic processSignal(message: ISignalMessage, local: boolean) {\n\t\tthis.runtime.processSignal(message, local);\n\t}\n\n\tpublic async request(path: IRequest): Promise<IResponse> {\n\t\treturn this.runtime.request(path);\n\t}\n\n\tpublic async getAbsoluteUrl(relativeUrl: string): Promise<string | undefined> {\n\t\treturn this.container.getAbsoluteUrl(relativeUrl);\n\t}\n\n\tpublic getPendingLocalState(): unknown {\n\t\treturn this.runtime.getPendingLocalState();\n\t}\n\n\t/**\n\t * Determines if the current code details of the context\n\t * satisfy the incoming constraint code details\n\t */\n\tpublic async satisfies(constraintCodeDetails: IFluidCodeDetails) {\n\t\tconst comparers: IFluidCodeDetailsComparer[] = [];\n\n\t\tconst maybeCompareCodeLoader = this.codeLoader;\n\t\tif (maybeCompareCodeLoader.IFluidCodeDetailsComparer !== undefined) {\n\t\t\tcomparers.push(maybeCompareCodeLoader.IFluidCodeDetailsComparer);\n\t\t}\n\n\t\tconst moduleWithDetails = await this._fluidModuleP;\n\t\tconst maybeCompareExport: Partial<IProvideFluidCodeDetailsComparer> | undefined =\n\t\t\tmoduleWithDetails.module?.fluidExport;\n\t\tif (maybeCompareExport?.IFluidCodeDetailsComparer !== undefined) {\n\t\t\tcomparers.push(maybeCompareExport.IFluidCodeDetailsComparer);\n\t\t}\n\n\t\t// if there are not comparers it is not possible to know\n\t\t// if the current satisfy the incoming, so return false,\n\t\t// as assuming they do not satisfy is safer .e.g we will\n\t\t// reload, rather than potentially running with\n\t\t// incompatible code\n\t\tif (comparers.length === 0) {\n\t\t\treturn false;\n\t\t}\n\n\t\tfor (const comparer of comparers) {\n\t\t\tconst satisfies = await comparer.satisfies(\n\t\t\t\tmoduleWithDetails.details,\n\t\t\t\tconstraintCodeDetails,\n\t\t\t);\n\t\t\tif (satisfies === false) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t\treturn true;\n\t}\n\n\tpublic async notifyOpReplay(message: ISequencedDocumentMessage): Promise<void> {\n\t\treturn this.runtime.notifyOpReplay?.(message);\n\t}\n\n\t// #region private\n\n\tprivate async getRuntimeFactory(): Promise<IRuntimeFactory> {\n\t\tconst fluidExport: FluidObject<IProvideRuntimeFactory> | undefined = (\n\t\t\tawait this._fluidModuleP\n\t\t).module?.fluidExport;\n\t\tconst runtimeFactory = fluidExport?.IRuntimeFactory;\n\t\tif (runtimeFactory === undefined) {\n\t\t\tthrow new Error(PackageNotFactoryError);\n\t\t}\n\n\t\treturn runtimeFactory;\n\t}\n\n\tprivate async instantiateRuntime(existing: boolean) {\n\t\tconst runtimeFactory = await this.getRuntimeFactory();\n\t\tthis._runtime = await PerformanceEvent.timedExecAsync(\n\t\t\tthis.taggedLogger,\n\t\t\t{ eventName: \"InstantiateRuntime\" },\n\t\t\tasync () => runtimeFactory.instantiateRuntime(this, existing),\n\t\t);\n\t\tthis.lifecycleEvents.emit(\"runtimeInstantiated\");\n\t}\n\n\tprivate attachListener() {\n\t\tthis.container.once(\"attaching\", () => {\n\t\t\tthis.runtime.setAttachState(AttachState.Attaching);\n\t\t});\n\t\tthis.container.once(\"attached\", () => {\n\t\t\tthis.runtime.setAttachState(AttachState.Attached);\n\t\t});\n\t}\n\n\tprivate async loadCodeModule(codeDetails: IFluidCodeDetails): Promise<IFluidModuleWithDetails> {\n\t\tconst loadCodeResult = await PerformanceEvent.timedExecAsync(\n\t\t\tthis.taggedLogger,\n\t\t\t{ eventName: \"CodeLoad\" },\n\t\t\tasync () => this.codeLoader.load(codeDetails),\n\t\t);\n\n\t\tif (\"module\" in loadCodeResult) {\n\t\t\tconst { module, details } = loadCodeResult;\n\t\t\treturn {\n\t\t\t\tmodule,\n\t\t\t\tdetails: details ?? codeDetails,\n\t\t\t};\n\t\t} else {\n\t\t\t// If \"module\" is not in the result, we are using a legacy ICodeLoader. Fix the result up with details.\n\t\t\t// Once usage drops to 0 we can remove this compat path.\n\t\t\tthis.taggedLogger.sendTelemetryEvent({ eventName: \"LegacyCodeLoader\" });\n\t\t\treturn loadCodeResult;\n\t\t}\n\t}\n\t// #endregion\n}\n"]}
|
|
1
|
+
{"version":3,"file":"containerContext.js","sourceRoot":"","sources":["../src/containerContext.ts"],"names":[],"mappings":"AAAA;;;GAGG;AA6BH;;GAEG;AACH,MAAM,OAAO,gBAAgB;IA2C5B,YACiB,OAAuB,EACvB,KAAkB,EAClB,YAAuC,EACtC,QAA8B,EAC/B,YAAwE,EACxE,OAAgC,EAC/B,OAAgB,EACjB,QAAmB,EACnB,MAAe,EACf,QAKL,EACK,eAGL;IACX,+DAA+D;IAC/C,aAGL,EACK,cAAuC,EACvC,SAAoD,EACpD,OAAkD,EAClD,yBAAmD,EACnD,cAAoE,EACnE,yBAAmD,EACnD,YAAsC,EACtC,wBAAgE,EAChE,eAAkC,EAClC,aAA4B,EAC7B,aAA6B,EAC7B,QAAiB,EACjB,YAAiC,EACjC,iBAA2B;QArC3B,YAAO,GAAP,OAAO,CAAgB;QACvB,UAAK,GAAL,KAAK,CAAa;QAClB,iBAAY,GAAZ,YAAY,CAA2B;QACtC,aAAQ,GAAR,QAAQ,CAAsB;QAC/B,iBAAY,GAAZ,YAAY,CAA4D;QACxE,YAAO,GAAP,OAAO,CAAyB;QAC/B,YAAO,GAAP,OAAO,CAAS;QACjB,aAAQ,GAAR,QAAQ,CAAW;QACnB,WAAM,GAAN,MAAM,CAAS;QACf,aAAQ,GAAR,QAAQ,CAKb;QACK,oBAAe,GAAf,eAAe,CAGpB;QAEK,kBAAa,GAAb,aAAa,CAGlB;QACK,mBAAc,GAAd,cAAc,CAAyB;QACvC,cAAS,GAAT,SAAS,CAA2C;QACpD,YAAO,GAAP,OAA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a;QAC3B,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;IACvB,CAAC;IAEM,oBAAoB;QAC1B,OAAO,IAAI,CAAC,QAAQ,CAAC;IACtB,CAAC;IAED,IAAW,WAAW;QACrB,OAAO,IAAI,CAAC,eAAe,EAAE,CAAC;IAC/B,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryLoggerExt } from \"@fluidframework/telemetry-utils\";\nimport {\n\tIAudience,\n\tIContainerContext,\n\tIDeltaManager,\n\tILoader,\n\tICriticalContainerError,\n\tAttachState,\n\tILoaderOptions,\n\tIFluidCodeDetails,\n\tIBatchMessage,\n} from \"@fluidframework/container-definitions\";\nimport { FluidObject } from \"@fluidframework/core-interfaces\";\nimport { IDocumentStorageService } from \"@fluidframework/driver-definitions\";\nimport {\n\tIClientConfiguration,\n\tIClientDetails,\n\tIDocumentMessage,\n\tIQuorum,\n\tIQuorumClients,\n\tISequencedDocumentMessage,\n\tISnapshotTree,\n\tIVersion,\n\tMessageType,\n\tISummaryContent,\n} from \"@fluidframework/protocol-definitions\";\n\n/**\n * {@inheritDoc @fluidframework/container-definitions#IContainerContext}\n */\nexport class ContainerContext implements IContainerContext {\n\tpublic readonly supportedFeatures: ReadonlyMap<string, unknown> = new Map([\n\t\t/**\n\t\t * This version of the loader accepts `referenceSequenceNumber`, provided by the container runtime,\n\t\t * as a parameter to the `submitBatchFn` and `submitSummaryFn` functions.\n\t\t * This is then used to set the reference sequence numbers of the submitted ops in the DeltaManager.\n\t\t */\n\t\t[\"referenceSequenceNumbers\", true],\n\t]);\n\n\tpublic get clientId(): string | undefined {\n\t\treturn this._getClientId();\n\t}\n\n\t/**\n\t * DISCLAIMER: this id is only for telemetry purposes. Not suitable for any other usages.\n\t */\n\tpublic get id(): string {\n\t\treturn this._getContainerDiagnosticId() ?? \"\";\n\t}\n\n\t/**\n\t * When true, ops are free to flow\n\t * When false, ops should be kept as pending or rejected\n\t */\n\tpublic get connected(): boolean {\n\t\treturn this._getConnected();\n\t}\n\n\tpublic get serviceConfiguration(): IClientConfiguration | undefined {\n\t\treturn this._getServiceConfiguration();\n\t}\n\n\tprivate _disposed = false;\n\n\tpublic get disposed() {\n\t\treturn this._disposed;\n\t}\n\n\tpublic get quorum(): IQuorumClients {\n\t\treturn this._quorum;\n\t}\n\n\tconstructor(\n\t\tpublic readonly options: ILoaderOptions,\n\t\tpublic readonly scope: FluidObject,\n\t\tpublic readonly baseSnapshot: ISnapshotTree | undefined,\n\t\tprivate readonly _version: IVersion | undefined,\n\t\tpublic readonly deltaManager: IDeltaManager<ISequencedDocumentMessage, IDocumentMessage>,\n\t\tpublic readonly storage: IDocumentStorageService,\n\t\tprivate readonly _quorum: IQuorum,\n\t\tpublic readonly audience: IAudience,\n\t\tpublic readonly loader: ILoader,\n\t\tpublic readonly submitFn: (\n\t\t\ttype: MessageType,\n\t\t\tcontents: any,\n\t\t\tbatch: boolean,\n\t\t\tappData: any,\n\t\t) => number,\n\t\tpublic readonly submitSummaryFn: (\n\t\t\tsummaryOp: ISummaryContent,\n\t\t\treferenceSequenceNumber?: number,\n\t\t) => number,\n\t\t/** @returns clientSequenceNumber of last message in a batch */\n\t\tpublic readonly submitBatchFn: (\n\t\t\tbatch: IBatchMessage[],\n\t\t\treferenceSequenceNumber?: number,\n\t\t) => number,\n\t\tpublic readonly submitSignalFn: (contents: any) => void,\n\t\tpublic readonly disposeFn: (error?: ICriticalContainerError) => void,\n\t\tpublic readonly closeFn: (error?: ICriticalContainerError) => void,\n\t\tpublic readonly updateDirtyContainerState: (dirty: boolean) => void,\n\t\tpublic readonly getAbsoluteUrl: (relativeUrl: string) => Promise<string | undefined>,\n\t\tprivate readonly _getContainerDiagnosticId: () => string | undefined,\n\t\tprivate readonly _getClientId: () => string | undefined,\n\t\tprivate readonly _getServiceConfiguration: () => IClientConfiguration | undefined,\n\t\tprivate readonly _getAttachState: () => AttachState,\n\t\tprivate readonly _getConnected: () => boolean,\n\t\tpublic readonly clientDetails: IClientDetails,\n\t\tpublic readonly existing: boolean,\n\t\tpublic readonly taggedLogger: ITelemetryLoggerExt,\n\t\tpublic readonly pendingLocalState?: unknown,\n\t) {}\n\n\t/**\n\t * @deprecated Temporary migratory API, to be removed when customers no longer need it.\n\t * When removed, `ContainerContext` should only take an {@link @fluidframework/container-definitions#IQuorumClients}\n\t * rather than an {@link @fluidframework/protocol-definitions#IQuorum}.\n\t * See {@link @fluidframework/container-definitions#IContainerContext} for more details.\n\t */\n\tpublic getSpecifiedCodeDetails(): IFluidCodeDetails | undefined {\n\t\treturn (this._quorum.get(\"code\") ?? this._quorum.get(\"code2\")) as\n\t\t\t| IFluidCodeDetails\n\t\t\t| undefined;\n\t}\n\n\tpublic dispose(error?: Error): void {\n\t\tthis._disposed = true;\n\t}\n\n\tpublic getLoadedFromVersion(): IVersion | undefined {\n\t\treturn this._version;\n\t}\n\n\tpublic get attachState(): AttachState {\n\t\treturn this._getAttachState();\n\t}\n}\n"]}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
import { IDisposable } from "@fluidframework/
|
|
5
|
+
import { IDisposable } from "@fluidframework/core-interfaces";
|
|
6
6
|
import { ITelemetryLoggerExt } from "@fluidframework/telemetry-utils";
|
|
7
7
|
import { ISnapshotTreeWithBlobContents } from "@fluidframework/container-definitions";
|
|
8
8
|
import { FetchSource, IDocumentService, IDocumentStorageService, IDocumentStorageServicePolicies, ISummaryContext } from "@fluidframework/driver-definitions";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"containerStorageAdapter.d.ts","sourceRoot":"","sources":["../src/containerStorageAdapter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"containerStorageAdap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K,SAAS,EAAE,KAAK,CAAC,6CAA6C,CAAC,CAAC;QAChF,oDAAoD;QACpD,KAAK,CAAC,EAAE,CAAC,GAAG,cAAc,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;KACzC;AACF,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IDisposable } from \"@fluidframework/common-definitions\";\nimport { ITelemetryLoggerExt } from \"@fluidframework/telemetry-utils\";\nimport { assert, bufferToString, stringToBuffer } from \"@fluidframework/common-utils\";\nimport { ISnapshotTreeWithBlobContents } from \"@fluidframework/container-definitions\";\nimport {\n\tFetchSource,\n\tIDocumentService,\n\tIDocumentStorageService,\n\tIDocumentStorageServicePolicies,\n\tISummaryContext,\n} from \"@fluidframework/driver-definitions\";\nimport { UsageError } from \"@fluidframework/driver-utils\";\nimport {\n\tICreateBlobResponse,\n\tISnapshotTree,\n\tISummaryHandle,\n\tISummaryTree,\n\tIVersion,\n} from \"@fluidframework/protocol-definitions\";\nimport { IDetachedBlobStorage } from \"./loader\";\nimport { ProtocolTreeStorageService } from \"./protocolTreeDocumentStorageService\";\nimport { RetriableDocumentStorageService } from \"./retriableDocumentStorageService\";\n\n/**\n * Stringified blobs from a summary/snapshot tree.\n * @internal\n */\nexport interface ISerializableBlobContents {\n\t[id: string]: string;\n}\n\n/**\n * This class wraps the actual storage and make sure no wrong apis are called according to\n * container attach state.\n */\nexport class ContainerStorageAdapter implements IDocumentStorageService, IDisposable {\n\tprivate _storageService: IDocumentStorageService & Partial<IDisposable>;\n\n\tprivate _summarizeProtocolTree: boolean | undefined;\n\t/**\n\t * Whether the adapter will enforce sending combined summary trees.\n\t */\n\tpublic get summarizeProtocolTree() {\n\t\treturn this._summarizeProtocolTree === true;\n\t}\n\n\t/**\n\t * An adapter that ensures we're using detachedBlobStorage up until we connect to a real service, and then\n\t * after connecting to a real service augments it with retry and combined summary tree enforcement.\n\t * @param detachedBlobStorage - The detached blob storage to use up until we connect to a real service\n\t * @param logger - Telemetry logger\n\t * @param addProtocolSummaryIfMissing - a callback to permit the container to inspect the summary we're about to\n\t * upload, and fix it up with a protocol tree if needed\n\t * @param forceEnableSummarizeProtocolTree - Enforce uploading a protocol summary regardless of the service's policy\n\t */\n\tpublic constructor(\n\t\tdetachedBlobStorage: IDetachedBlobStorage | undefined,\n\t\tprivate readonly logger: ITelemetryLoggerExt,\n\t\t/**\n\t\t * ArrayBufferLikes or utf8 encoded strings, containing blobs from a snapshot\n\t\t */\n\t\tprivate readonly blobContents: { [id: string]: ArrayBufferLike | string } = {},\n\t\tprivate readonly addProtocolSummaryIfMissing: (summaryTree: ISummaryTree) => ISummaryTree,\n\t\tforceEnableSummarizeProtocolTree: boolean | undefined,\n\t) {\n\t\tthis._storageService = new BlobOnlyStorage(detachedBlobStorage, logger);\n\t\tthis._summarizeProtocolTree = forceEnableSummarizeProtocolTree;\n\t}\n\n\tdisposed: boolean = false;\n\tdispose(error?: Error): void {\n\t\tthis._storageService?.dispose?.(error);\n\t\tthis.disposed = true;\n\t}\n\n\tpublic async connectToService(service: IDocumentService): Promise<void> {\n\t\tif (!(this._storageService instanceof BlobOnlyStorage)) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst storageService = await service.connectToStorage();\n\t\tconst retriableStorage = (this._storageService = new RetriableDocumentStorageService(\n\t\t\tstorageService,\n\t\t\tthis.logger,\n\t\t));\n\n\t\tthis._summarizeProtocolTree =\n\t\t\tthis._summarizeProtocolTree ?? service.policies?.summarizeProtocolTree;\n\t\tif (this.summarizeProtocolTree) {\n\t\t\tthis.logger.sendTelemetryEvent({ eventName: \"summarizeProtocolTreeEnabled\" });\n\t\t\tthis._storageService = new ProtocolTreeStorageService(\n\t\t\t\tretriableStorage,\n\t\t\t\tthis.addProtocolSummaryIfMissing,\n\t\t\t);\n\t\t}\n\n\t\t// ensure we did not lose that policy in the process of wrapping\n\t\tassert(\n\t\t\tstorageService.policies?.minBlobSize === this._storageService.policies?.minBlobSize,\n\t\t\t0x0e0 /* \"lost minBlobSize policy\" */,\n\t\t);\n\t}\n\n\tpublic loadSnapshotForRehydratingContainer(snapshotTree: ISnapshotTreeWithBlobContents) {\n\t\tthis.getBlobContents(snapshotTree);\n\t}\n\n\tprivate getBlobContents(snapshotTree: ISnapshotTreeWithBlobContents) {\n\t\tfor (const [id, value] of Object.entries(snapshotTree.blobsContents)) {\n\t\t\tthis.blobContents[id] = value;\n\t\t}\n\t\tfor (const [_, tree] of Object.entries(snapshotTree.trees)) {\n\t\t\tthis.getBlobContents(tree);\n\t\t}\n\t}\n\n\tpublic get policies(): IDocumentStorageServicePolicies | undefined {\n\t\t// back-compat 0.40 containerRuntime requests policies even in detached container if storage is present\n\t\t// and storage is always present in >=0.41.\n\t\ttry {\n\t\t\treturn this._storageService.policies;\n\t\t} catch (e) {}\n\t\treturn undefined;\n\t}\n\n\tpublic get repositoryUrl(): string {\n\t\treturn this._storageService.repositoryUrl;\n\t}\n\n\tpublic async getSnapshotTree(\n\t\tversion?: IVersion,\n\t\tscenarioName?: string,\n\t): Promise<ISnapshotTree | null> {\n\t\treturn this._storageService.getSnapshotTree(version, scenarioName);\n\t}\n\n\tpublic async readBlob(id: string): Promise<ArrayBufferLike> {\n\t\tconst maybeBlob = this.blobContents[id];\n\t\tif (maybeBlob !== undefined) {\n\t\t\tif (typeof maybeBlob === \"string\") {\n\t\t\t\tconst blob = stringToBuffer(maybeBlob, \"utf8\");\n\t\t\t\treturn blob;\n\t\t\t}\n\t\t\treturn maybeBlob;\n\t\t}\n\t\treturn this._storageService.readBlob(id);\n\t}\n\n\tpublic async getVersions(\n\t\tversionId: string | null,\n\t\tcount: number,\n\t\tscenarioName?: string,\n\t\tfetchSource?: FetchSource,\n\t): Promise<IVersion[]> {\n\t\treturn this._storageService.getVersions(versionId, count, scenarioName, fetchSource);\n\t}\n\n\tpublic async uploadSummaryWithContext(\n\t\tsummary: ISummaryTree,\n\t\tcontext: ISummaryContext,\n\t): Promise<string> {\n\t\treturn this._storageService.uploadSummaryWithContext(summary, context);\n\t}\n\n\tpublic async downloadSummary(handle: ISummaryHandle): Promise<ISummaryTree> {\n\t\treturn this._storageService.downloadSummary(handle);\n\t}\n\n\tpublic async createBlob(file: ArrayBufferLike): Promise<ICreateBlobResponse> {\n\t\treturn this._storageService.createBlob(file);\n\t}\n}\n\n/**\n * Storage which only supports createBlob() and readBlob(). This is used with IDetachedBlobStorage to support\n * blobs in detached containers.\n */\nclass BlobOnlyStorage implements IDocumentStorageService {\n\tconstructor(\n\t\tprivate readonly detachedStorage: IDetachedBlobStorage | undefined,\n\t\tprivate readonly logger: ITelemetryLoggerExt,\n\t) {}\n\n\tpublic async createBlob(content: ArrayBufferLike): Promise<ICreateBlobResponse> {\n\t\treturn this.verifyStorage().createBlob(content);\n\t}\n\n\tpublic async readBlob(blobId: string): Promise<ArrayBufferLike> {\n\t\treturn this.verifyStorage().readBlob(blobId);\n\t}\n\n\tprivate verifyStorage(): IDetachedBlobStorage {\n\t\tif (this.detachedStorage === undefined) {\n\t\t\tthrow new UsageError(\"Real storage calls not allowed in Unattached container\");\n\t\t}\n\t\treturn this.detachedStorage;\n\t}\n\n\tpublic get policies(): IDocumentStorageServicePolicies | undefined {\n\t\treturn this.notCalled();\n\t}\n\n\tpublic get repositoryUrl(): string {\n\t\treturn this.notCalled();\n\t}\n\n\t/* eslint-disable @typescript-eslint/unbound-method */\n\tpublic getSnapshotTree: () => Promise<ISnapshotTree | null> = this.notCalled;\n\tpublic getVersions: () => Promise<IVersion[]> = this.notCalled;\n\tpublic write: () => Promise<IVersion> = this.notCalled;\n\tpublic uploadSummaryWithContext: () => Promise<string> = this.notCalled;\n\tpublic downloadSummary: () => Promise<ISummaryTree> = this.notCalled;\n\t/* eslint-enable @typescript-eslint/unbound-method */\n\n\tprivate notCalled(): never {\n\t\tthis.verifyStorage();\n\t\ttry {\n\t\t\t// some browsers may not populate stack unless exception is thrown\n\t\t\tthrow new Error(\"BlobOnlyStorage not implemented method used\");\n\t\t} catch (err) {\n\t\t\tthis.logger.sendTelemetryEvent({ eventName: \"BlobOnlyStorageWrongCall\" }, err);\n\t\t\tthrow err;\n\t\t}\n\t}\n}\n\n/**\n * Get blob contents of a snapshot tree from storage (or, ideally, cache)\n */\nexport async function getBlobContentsFromTree(\n\tsnapshot: ISnapshotTree,\n\tstorage: IDocumentStorageService,\n): Promise<ISerializableBlobContents> {\n\tconst blobs = {};\n\tawait getBlobContentsFromTreeCore(snapshot, blobs, storage);\n\treturn blobs;\n}\n\nasync function getBlobContentsFromTreeCore(\n\ttree: ISnapshotTree,\n\tblobs: ISerializableBlobContents,\n\tstorage: IDocumentStorageService,\n) {\n\tconst treePs: Promise<any>[] = [];\n\tfor (const subTree of Object.values(tree.trees)) {\n\t\ttreePs.push(getBlobContentsFromTreeCore(subTree, blobs, storage));\n\t}\n\tfor (const id of Object.values(tree.blobs)) {\n\t\tconst blob = await storage.readBlob(id);\n\t\t// ArrayBufferLike will not survive JSON.stringify()\n\t\tblobs[id] = bufferToString(blob, \"utf8\");\n\t}\n\treturn Promise.all(treePs);\n}\n\n/**\n * Extract blob contents from a snapshot tree with blob contents\n */\nexport function getBlobContentsFromTreeWithBlobContents(\n\tsnapshot: ISnapshotTreeWithBlobContents,\n): ISerializableBlobContents {\n\tconst blobs = {};\n\tgetBlobContentsFromTreeWithBlobContentsCore(snapshot, blobs);\n\treturn blobs;\n}\n\nfunction getBlobContentsFromTreeWithBlobContentsCore(\n\ttree: ISnapshotTreeWithBlobContents,\n\tblobs: ISerializableBlobContents,\n) {\n\tfor (const subTree of Object.values(tree.trees)) {\n\t\tgetBlobContentsFromTreeWithBlobContentsCore(subTree, blobs);\n\t}\n\tfor (const id of Object.values(tree.blobs)) {\n\t\tconst blob = tree.blobsContents[id];\n\t\tassert(blob !== undefined, 0x2ec /* \"Blob must be present in blobsContents\" */);\n\t\t// ArrayBufferLike will not survive JSON.stringify()\n\t\tblobs[id] = bufferToString(blob, \"utf8\");\n\t}\n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K,MAAM,EAAE,IAAI,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE;QAC3C,MAAM,IAAI,GAAG,IAAI,CAAC,aAAa,CAAC,EAAE,CAAC,CAAC;QACpC,MAAM,CAAC,IAAI,KAAK,SAAS,EAAE,KAAK,CAAC,6CAA6C,CAAC,CAAC;QAChF,oDAAoD;QACpD,KAAK,CAAC,EAAE,CAAC,GAAG,cAAc,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;KACzC;AACF,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IDisposable } from \"@fluidframework/core-interfaces\";\nimport { ITelemetryLoggerExt } from \"@fluidframework/telemetry-utils\";\nimport { assert, bufferToString, stringToBuffer } from \"@fluidframework/common-utils\";\nimport { ISnapshotTreeWithBlobContents } from \"@fluidframework/container-definitions\";\nimport {\n\tFetchSource,\n\tIDocumentService,\n\tIDocumentStorageService,\n\tIDocumentStorageServicePolicies,\n\tISummaryContext,\n} from \"@fluidframework/driver-definitions\";\nimport { UsageError } from \"@fluidframework/driver-utils\";\nimport {\n\tICreateBlobResponse,\n\tISnapshotTree,\n\tISummaryHandle,\n\tISummaryTree,\n\tIVersion,\n} from \"@fluidframework/protocol-definitions\";\nimport { IDetachedBlobStorage } from \"./loader\";\nimport { ProtocolTreeStorageService } from \"./protocolTreeDocumentStorageService\";\nimport { RetriableDocumentStorageService } from \"./retriableDocumentStorageService\";\n\n/**\n * Stringified blobs from a summary/snapshot tree.\n * @internal\n */\nexport interface ISerializableBlobContents {\n\t[id: string]: string;\n}\n\n/**\n * This class wraps the actual storage and make sure no wrong apis are called according to\n * container attach state.\n */\nexport class ContainerStorageAdapter implements IDocumentStorageService, IDisposable {\n\tprivate _storageService: IDocumentStorageService & Partial<IDisposable>;\n\n\tprivate _summarizeProtocolTree: boolean | undefined;\n\t/**\n\t * Whether the adapter will enforce sending combined summary trees.\n\t */\n\tpublic get summarizeProtocolTree() {\n\t\treturn this._summarizeProtocolTree === true;\n\t}\n\n\t/**\n\t * An adapter that ensures we're using detachedBlobStorage up until we connect to a real service, and then\n\t * after connecting to a real service augments it with retry and combined summary tree enforcement.\n\t * @param detachedBlobStorage - The detached blob storage to use up until we connect to a real service\n\t * @param logger - Telemetry logger\n\t * @param addProtocolSummaryIfMissing - a callback to permit the container to inspect the summary we're about to\n\t * upload, and fix it up with a protocol tree if needed\n\t * @param forceEnableSummarizeProtocolTree - Enforce uploading a protocol summary regardless of the service's policy\n\t */\n\tpublic constructor(\n\t\tdetachedBlobStorage: IDetachedBlobStorage | undefined,\n\t\tprivate readonly logger: ITelemetryLoggerExt,\n\t\t/**\n\t\t * ArrayBufferLikes or utf8 encoded strings, containing blobs from a snapshot\n\t\t */\n\t\tprivate readonly blobContents: { [id: string]: ArrayBufferLike | string } = {},\n\t\tprivate readonly addProtocolSummaryIfMissing: (summaryTree: ISummaryTree) => ISummaryTree,\n\t\tforceEnableSummarizeProtocolTree: boolean | undefined,\n\t) {\n\t\tthis._storageService = new BlobOnlyStorage(detachedBlobStorage, logger);\n\t\tthis._summarizeProtocolTree = forceEnableSummarizeProtocolTree;\n\t}\n\n\tdisposed: boolean = false;\n\tdispose(error?: Error): void {\n\t\tthis._storageService?.dispose?.(error);\n\t\tthis.disposed = true;\n\t}\n\n\tpublic async connectToService(service: IDocumentService): Promise<void> {\n\t\tif (!(this._storageService instanceof BlobOnlyStorage)) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst storageService = await service.connectToStorage();\n\t\tconst retriableStorage = (this._storageService = new RetriableDocumentStorageService(\n\t\t\tstorageService,\n\t\t\tthis.logger,\n\t\t));\n\n\t\tthis._summarizeProtocolTree =\n\t\t\tthis._summarizeProtocolTree ?? service.policies?.summarizeProtocolTree;\n\t\tif (this.summarizeProtocolTree) {\n\t\t\tthis.logger.sendTelemetryEvent({ eventName: \"summarizeProtocolTreeEnabled\" });\n\t\t\tthis._storageService = new ProtocolTreeStorageService(\n\t\t\t\tretriableStorage,\n\t\t\t\tthis.addProtocolSummaryIfMissing,\n\t\t\t);\n\t\t}\n\n\t\t// ensure we did not lose that policy in the process of wrapping\n\t\tassert(\n\t\t\tstorageService.policies?.minBlobSize === this._storageService.policies?.minBlobSize,\n\t\t\t0x0e0 /* \"lost minBlobSize policy\" */,\n\t\t);\n\t}\n\n\tpublic loadSnapshotForRehydratingContainer(snapshotTree: ISnapshotTreeWithBlobContents) {\n\t\tthis.getBlobContents(snapshotTree);\n\t}\n\n\tprivate getBlobContents(snapshotTree: ISnapshotTreeWithBlobContents) {\n\t\tfor (const [id, value] of Object.entries(snapshotTree.blobsContents)) {\n\t\t\tthis.blobContents[id] = value;\n\t\t}\n\t\tfor (const [_, tree] of Object.entries(snapshotTree.trees)) {\n\t\t\tthis.getBlobContents(tree);\n\t\t}\n\t}\n\n\tpublic get policies(): IDocumentStorageServicePolicies | undefined {\n\t\t// back-compat 0.40 containerRuntime requests policies even in detached container if storage is present\n\t\t// and storage is always present in >=0.41.\n\t\ttry {\n\t\t\treturn this._storageService.policies;\n\t\t} catch (e) {}\n\t\treturn undefined;\n\t}\n\n\tpublic get repositoryUrl(): string {\n\t\treturn this._storageService.repositoryUrl;\n\t}\n\n\tpublic async getSnapshotTree(\n\t\tversion?: IVersion,\n\t\tscenarioName?: string,\n\t): Promise<ISnapshotTree | null> {\n\t\treturn this._storageService.getSnapshotTree(version, scenarioName);\n\t}\n\n\tpublic async readBlob(id: string): Promise<ArrayBufferLike> {\n\t\tconst maybeBlob = this.blobContents[id];\n\t\tif (maybeBlob !== undefined) {\n\t\t\tif (typeof maybeBlob === \"string\") {\n\t\t\t\tconst blob = stringToBuffer(maybeBlob, \"utf8\");\n\t\t\t\treturn blob;\n\t\t\t}\n\t\t\treturn maybeBlob;\n\t\t}\n\t\treturn this._storageService.readBlob(id);\n\t}\n\n\tpublic async getVersions(\n\t\tversionId: string | null,\n\t\tcount: number,\n\t\tscenarioName?: string,\n\t\tfetchSource?: FetchSource,\n\t): Promise<IVersion[]> {\n\t\treturn this._storageService.getVersions(versionId, count, scenarioName, fetchSource);\n\t}\n\n\tpublic async uploadSummaryWithContext(\n\t\tsummary: ISummaryTree,\n\t\tcontext: ISummaryContext,\n\t): Promise<string> {\n\t\treturn this._storageService.uploadSummaryWithContext(summary, context);\n\t}\n\n\tpublic async downloadSummary(handle: ISummaryHandle): Promise<ISummaryTree> {\n\t\treturn this._storageService.downloadSummary(handle);\n\t}\n\n\tpublic async createBlob(file: ArrayBufferLike): Promise<ICreateBlobResponse> {\n\t\treturn this._storageService.createBlob(file);\n\t}\n}\n\n/**\n * Storage which only supports createBlob() and readBlob(). This is used with IDetachedBlobStorage to support\n * blobs in detached containers.\n */\nclass BlobOnlyStorage implements IDocumentStorageService {\n\tconstructor(\n\t\tprivate readonly detachedStorage: IDetachedBlobStorage | undefined,\n\t\tprivate readonly logger: ITelemetryLoggerExt,\n\t) {}\n\n\tpublic async createBlob(content: ArrayBufferLike): Promise<ICreateBlobResponse> {\n\t\treturn this.verifyStorage().createBlob(content);\n\t}\n\n\tpublic async readBlob(blobId: string): Promise<ArrayBufferLike> {\n\t\treturn this.verifyStorage().readBlob(blobId);\n\t}\n\n\tprivate verifyStorage(): IDetachedBlobStorage {\n\t\tif (this.detachedStorage === undefined) {\n\t\t\tthrow new UsageError(\"Real storage calls not allowed in Unattached container\");\n\t\t}\n\t\treturn this.detachedStorage;\n\t}\n\n\tpublic get policies(): IDocumentStorageServicePolicies | undefined {\n\t\treturn this.notCalled();\n\t}\n\n\tpublic get repositoryUrl(): string {\n\t\treturn this.notCalled();\n\t}\n\n\t/* eslint-disable @typescript-eslint/unbound-method */\n\tpublic getSnapshotTree: () => Promise<ISnapshotTree | null> = this.notCalled;\n\tpublic getVersions: () => Promise<IVersion[]> = this.notCalled;\n\tpublic write: () => Promise<IVersion> = this.notCalled;\n\tpublic uploadSummaryWithContext: () => Promise<string> = this.notCalled;\n\tpublic downloadSummary: () => Promise<ISummaryTree> = this.notCalled;\n\t/* eslint-enable @typescript-eslint/unbound-method */\n\n\tprivate notCalled(): never {\n\t\tthis.verifyStorage();\n\t\ttry {\n\t\t\t// some browsers may not populate stack unless exception is thrown\n\t\t\tthrow new Error(\"BlobOnlyStorage not implemented method used\");\n\t\t} catch (err) {\n\t\t\tthis.logger.sendTelemetryEvent({ eventName: \"BlobOnlyStorageWrongCall\" }, err);\n\t\t\tthrow err;\n\t\t}\n\t}\n}\n\n/**\n * Get blob contents of a snapshot tree from storage (or, ideally, cache)\n */\nexport async function getBlobContentsFromTree(\n\tsnapshot: ISnapshotTree,\n\tstorage: IDocumentStorageService,\n): Promise<ISerializableBlobContents> {\n\tconst blobs = {};\n\tawait getBlobContentsFromTreeCore(snapshot, blobs, storage);\n\treturn blobs;\n}\n\nasync function getBlobContentsFromTreeCore(\n\ttree: ISnapshotTree,\n\tblobs: ISerializableBlobContents,\n\tstorage: IDocumentStorageService,\n) {\n\tconst treePs: Promise<any>[] = [];\n\tfor (const subTree of Object.values(tree.trees)) {\n\t\ttreePs.push(getBlobContentsFromTreeCore(subTree, blobs, storage));\n\t}\n\tfor (const id of Object.values(tree.blobs)) {\n\t\tconst blob = await storage.readBlob(id);\n\t\t// ArrayBufferLike will not survive JSON.stringify()\n\t\tblobs[id] = bufferToString(blob, \"utf8\");\n\t}\n\treturn Promise.all(treePs);\n}\n\n/**\n * Extract blob contents from a snapshot tree with blob contents\n */\nexport function getBlobContentsFromTreeWithBlobContents(\n\tsnapshot: ISnapshotTreeWithBlobContents,\n): ISerializableBlobContents {\n\tconst blobs = {};\n\tgetBlobContentsFromTreeWithBlobContentsCore(snapshot, blobs);\n\treturn blobs;\n}\n\nfunction getBlobContentsFromTreeWithBlobContentsCore(\n\ttree: ISnapshotTreeWithBlobContents,\n\tblobs: ISerializableBlobContents,\n) {\n\tfor (const subTree of Object.values(tree.trees)) {\n\t\tgetBlobContentsFromTreeWithBlobContentsCore(subTree, blobs);\n\t}\n\tfor (const id of Object.values(tree.blobs)) {\n\t\tconst blob = tree.blobsContents[id];\n\t\tassert(blob !== undefined, 0x2ec /* \"Blob must be present in blobsContents\" */);\n\t\t// ArrayBufferLike will not survive JSON.stringify()\n\t\tblobs[id] = bufferToString(blob, \"utf8\");\n\t}\n}\n"]}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
import { TypedEventEmitter } from "@fluidframework/common-utils";
|
|
6
|
+
import { ISequencedDocumentMessage } from "@fluidframework/protocol-definitions";
|
|
7
|
+
import { IEvent } from "@fluidframework/common-definitions";
|
|
8
|
+
export interface INoopSenderEvents extends IEvent {
|
|
9
|
+
(event: "wantsNoop", listener: () => void): any;
|
|
10
|
+
}
|
|
11
|
+
export declare class NoopHeuristic extends TypedEventEmitter<INoopSenderEvents> {
|
|
12
|
+
private readonly NoopCountFrequency;
|
|
13
|
+
private opsProcessedSinceOpSent;
|
|
14
|
+
private readonly timer;
|
|
15
|
+
constructor(NoopTimeFrequency?: number, NoopCountFrequency?: number);
|
|
16
|
+
/**
|
|
17
|
+
* Schedules as ack to the server to update the reference sequence number
|
|
18
|
+
*/
|
|
19
|
+
notifyMessageProcessed(message: ISequencedDocumentMessage): void;
|
|
20
|
+
notifyDisconnect(): void;
|
|
21
|
+
notifyMessageSent(): void;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=noopHeuristic.d.ts.map
|