@fluidframework/datastore 2.0.0-internal.4.2.1 → 2.0.0-internal.4.3.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/dist/channelContext.d.ts +12 -5
- package/dist/channelContext.d.ts.map +1 -1
- package/dist/channelContext.js +74 -5
- package/dist/channelContext.js.map +1 -1
- package/dist/channelDeltaConnection.d.ts +4 -5
- package/dist/channelDeltaConnection.d.ts.map +1 -1
- package/dist/channelDeltaConnection.js +3 -4
- package/dist/channelDeltaConnection.js.map +1 -1
- package/dist/dataStoreRuntime.d.ts.map +1 -1
- package/dist/dataStoreRuntime.js +1 -2
- package/dist/dataStoreRuntime.js.map +1 -1
- package/dist/localChannelContext.d.ts +7 -16
- package/dist/localChannelContext.d.ts.map +1 -1
- package/dist/localChannelContext.js +52 -65
- package/dist/localChannelContext.js.map +1 -1
- package/dist/remoteChannelContext.d.ts +3 -8
- package/dist/remoteChannelContext.d.ts.map +1 -1
- package/dist/remoteChannelContext.js +22 -89
- package/dist/remoteChannelContext.js.map +1 -1
- package/lib/channelContext.d.ts +12 -5
- package/lib/channelContext.d.ts.map +1 -1
- package/lib/channelContext.js +70 -3
- package/lib/channelContext.js.map +1 -1
- package/lib/channelDeltaConnection.d.ts +4 -5
- package/lib/channelDeltaConnection.d.ts.map +1 -1
- package/lib/channelDeltaConnection.js +3 -4
- package/lib/channelDeltaConnection.js.map +1 -1
- package/lib/dataStoreRuntime.d.ts.map +1 -1
- package/lib/dataStoreRuntime.js +1 -2
- package/lib/dataStoreRuntime.js.map +1 -1
- package/lib/localChannelContext.d.ts +7 -16
- package/lib/localChannelContext.d.ts.map +1 -1
- package/lib/localChannelContext.js +54 -67
- package/lib/localChannelContext.js.map +1 -1
- package/lib/remoteChannelContext.d.ts +3 -8
- package/lib/remoteChannelContext.d.ts.map +1 -1
- package/lib/remoteChannelContext.js +25 -92
- package/lib/remoteChannelContext.js.map +1 -1
- package/package.json +14 -15
- package/src/channelContext.ts +105 -6
- package/src/channelDeltaConnection.ts +4 -5
- package/src/dataStoreRuntime.ts +4 -8
- package/src/localChannelContext.ts +105 -140
- package/src/remoteChannelContext.ts +58 -125
- package/dist/packageVersion.d.ts +0 -9
- package/dist/packageVersion.d.ts.map +0 -1
- package/dist/packageVersion.js +0 -12
- package/dist/packageVersion.js.map +0 -1
- package/lib/packageVersion.d.ts +0 -9
- package/lib/packageVersion.d.ts.map +0 -1
- package/lib/packageVersion.js +0 -9
- package/lib/packageVersion.js.map +0 -1
- package/src/packageVersion.ts +0 -9
|
@@ -4,34 +4,36 @@
|
|
|
4
4
|
*/
|
|
5
5
|
// eslint-disable-next-line import/no-internal-modules
|
|
6
6
|
import cloneDeep from "lodash/cloneDeep";
|
|
7
|
-
import { readAndParse } from "@fluidframework/driver-utils";
|
|
8
7
|
import { DataProcessingError } from "@fluidframework/container-utils";
|
|
9
|
-
import { assert, Lazy } from "@fluidframework/common-utils";
|
|
10
|
-
import {
|
|
8
|
+
import { assert, Lazy, LazyPromise } from "@fluidframework/common-utils";
|
|
9
|
+
import { createChannelServiceEndpoints, loadChannel, loadChannelFactoryAndAttributes, summarizeChannel, summarizeChannelAsync, } from "./channelContext";
|
|
11
10
|
/**
|
|
12
11
|
* Channel context for a locally created channel
|
|
13
12
|
*/
|
|
14
13
|
export class LocalChannelContextBase {
|
|
15
|
-
constructor(id,
|
|
14
|
+
constructor(id, runtime, services, channelP, _channel) {
|
|
16
15
|
this.id = id;
|
|
17
|
-
this.registry = registry;
|
|
18
16
|
this.runtime = runtime;
|
|
19
|
-
this.
|
|
17
|
+
this.services = services;
|
|
18
|
+
this.channelP = channelP;
|
|
19
|
+
this._channel = _channel;
|
|
20
20
|
this.globallyVisible = false;
|
|
21
21
|
this.pending = [];
|
|
22
22
|
assert(!this.id.includes("/"), 0x30f /* Channel context ID cannot contain slashes */);
|
|
23
23
|
}
|
|
24
24
|
async getChannel() {
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
if (this._channel === undefined) {
|
|
26
|
+
return this.channelP.then((c) => (this._channel = c));
|
|
27
|
+
}
|
|
28
|
+
return this.channelP;
|
|
27
29
|
}
|
|
28
30
|
get isLoaded() {
|
|
29
|
-
return this.
|
|
31
|
+
return this._channel !== undefined;
|
|
30
32
|
}
|
|
31
33
|
setConnectionState(connected, clientId) {
|
|
32
34
|
// Connection events are ignored if the data store is not yet globallyVisible or loaded
|
|
33
35
|
if (this.globallyVisible && this.isLoaded) {
|
|
34
|
-
this.
|
|
36
|
+
this.services.value.deltaConnection.setConnectionState(connected);
|
|
35
37
|
}
|
|
36
38
|
}
|
|
37
39
|
processOp(message, local, localOpMetadata) {
|
|
@@ -40,7 +42,7 @@ export class LocalChannelContextBase {
|
|
|
40
42
|
// delay loading. So after the container is attached and some other client joins which start generating
|
|
41
43
|
// ops for this channel. So not loaded local channel can still receive ops and we store them to process later.
|
|
42
44
|
if (this.isLoaded) {
|
|
43
|
-
this.
|
|
45
|
+
this.services.value.deltaConnection.process(message, local, localOpMetadata);
|
|
44
46
|
}
|
|
45
47
|
else {
|
|
46
48
|
assert(local === false, 0x189 /* "Should always be remote because a local dds shouldn't generate ops before loading" */);
|
|
@@ -50,12 +52,12 @@ export class LocalChannelContextBase {
|
|
|
50
52
|
reSubmit(content, localOpMetadata) {
|
|
51
53
|
assert(this.isLoaded, 0x18a /* "Channel should be loaded to resubmit ops" */);
|
|
52
54
|
assert(this.globallyVisible, 0x2d4 /* "Local channel must be globally visible when resubmitting op" */);
|
|
53
|
-
this.
|
|
55
|
+
this.services.value.deltaConnection.reSubmit(content, localOpMetadata);
|
|
54
56
|
}
|
|
55
57
|
rollback(content, localOpMetadata) {
|
|
56
58
|
assert(this.isLoaded, 0x2ee /* "Channel should be loaded to rollback ops" */);
|
|
57
59
|
assert(this.globallyVisible, 0x2ef /* "Local channel must be globally visible when rolling back op" */);
|
|
58
|
-
this.
|
|
60
|
+
this.services.value.deltaConnection.rollback(content, localOpMetadata);
|
|
59
61
|
}
|
|
60
62
|
applyStashedOp() {
|
|
61
63
|
throw new Error("no stashed ops on local channel");
|
|
@@ -67,20 +69,20 @@ export class LocalChannelContextBase {
|
|
|
67
69
|
* @param telemetryContext - summary data passed through the layers for telemetry purposes
|
|
68
70
|
*/
|
|
69
71
|
async summarize(fullTree = false, trackState = false, telemetryContext) {
|
|
70
|
-
|
|
71
|
-
return summarizeChannelAsync(
|
|
72
|
+
const channel = await this.getChannel();
|
|
73
|
+
return summarizeChannelAsync(channel, fullTree, trackState, telemetryContext);
|
|
72
74
|
}
|
|
73
75
|
getAttachSummary(telemetryContext) {
|
|
74
|
-
assert(this.
|
|
75
|
-
return summarizeChannel(this.
|
|
76
|
+
assert(this._channel !== undefined, 0x18d /* "Channel should be loaded to take snapshot" */);
|
|
77
|
+
return summarizeChannel(this._channel, true /* fullTree */, false /* trackState */, telemetryContext);
|
|
76
78
|
}
|
|
77
79
|
makeVisible() {
|
|
78
80
|
if (this.globallyVisible) {
|
|
79
81
|
throw new Error("Channel is already globally visible");
|
|
80
82
|
}
|
|
81
83
|
if (this.isLoaded) {
|
|
82
|
-
assert(!!this.
|
|
83
|
-
this.
|
|
84
|
+
assert(!!this._channel, 0x192 /* "Channel should be there if loaded!!" */);
|
|
85
|
+
this._channel.connect(this.services.value);
|
|
84
86
|
}
|
|
85
87
|
this.globallyVisible = true;
|
|
86
88
|
}
|
|
@@ -91,8 +93,8 @@ export class LocalChannelContextBase {
|
|
|
91
93
|
* @param fullGC - true to bypass optimizations and force full generation of GC data.
|
|
92
94
|
*/
|
|
93
95
|
async getGCData(fullGC = false) {
|
|
94
|
-
|
|
95
|
-
return
|
|
96
|
+
const channel = await this.getChannel();
|
|
97
|
+
return channel.getGCData(fullGC);
|
|
96
98
|
}
|
|
97
99
|
updateUsedRoutes(usedRoutes) {
|
|
98
100
|
/**
|
|
@@ -104,50 +106,35 @@ export class LocalChannelContextBase {
|
|
|
104
106
|
}
|
|
105
107
|
export class RehydratedLocalChannelContext extends LocalChannelContextBase {
|
|
106
108
|
constructor(id, registry, runtime, dataStoreContext, storageService, logger, submitFn, dirtyFn, addedGCOutboundReferenceFn, snapshotTree) {
|
|
107
|
-
super(id,
|
|
109
|
+
super(id, runtime, new Lazy(() => {
|
|
110
|
+
const blobMap = new Map();
|
|
111
|
+
const clonedSnapshotTree = cloneDeep(this.snapshotTree);
|
|
112
|
+
// 0.47 back-compat Need to sanitize if snapshotTree.blobs still contains blob contents too.
|
|
113
|
+
// This is for older snapshot which is generated by loader <=0.47 version which still contains
|
|
114
|
+
// the contents within blobs. After a couple of revisions we can remove it.
|
|
115
|
+
if (this.isSnapshotInOldFormatAndCollectBlobs(clonedSnapshotTree, blobMap)) {
|
|
116
|
+
this.sanitizeSnapshot(clonedSnapshotTree);
|
|
117
|
+
}
|
|
118
|
+
return createChannelServiceEndpoints(dataStoreContext.connected, submitFn, this.dirtyFn, addedGCOutboundReferenceFn, storageService, logger, clonedSnapshotTree, blobMap);
|
|
119
|
+
}), new LazyPromise(async () => {
|
|
120
|
+
try {
|
|
121
|
+
const { attributes, factory } = await loadChannelFactoryAndAttributes(dataStoreContext, this.services.value, this.id, registry);
|
|
122
|
+
const channel = await loadChannel(runtime, attributes, factory, this.services.value, logger, this.id);
|
|
123
|
+
// Send all pending messages to the channel
|
|
124
|
+
for (const message of this.pending) {
|
|
125
|
+
this.services.value.deltaConnection.process(message, false, undefined /* localOpMetadata */);
|
|
126
|
+
}
|
|
127
|
+
return channel;
|
|
128
|
+
}
|
|
129
|
+
catch (err) {
|
|
130
|
+
throw DataProcessingError.wrapIfUnrecognized(err, "rehydratedLocalChannelContextFailedToLoadChannel", undefined);
|
|
131
|
+
}
|
|
132
|
+
}));
|
|
108
133
|
this.snapshotTree = snapshotTree;
|
|
109
|
-
const blobMap = new Map();
|
|
110
|
-
const clonedSnapshotTree = cloneDeep(this.snapshotTree);
|
|
111
|
-
// 0.47 back-compat Need to sanitize if snapshotTree.blobs still contains blob contents too.
|
|
112
|
-
// This is for older snapshot which is generated by loader <=0.47 version which still contains
|
|
113
|
-
// the contents within blobs. After a couple of revisions we can remove it.
|
|
114
|
-
if (this.isSnapshotInOldFormatAndCollectBlobs(clonedSnapshotTree, blobMap)) {
|
|
115
|
-
this.sanitizeSnapshot(clonedSnapshotTree);
|
|
116
|
-
}
|
|
117
|
-
this.services = new Lazy(() => {
|
|
118
|
-
return createServiceEndpoints(this.id, dataStoreContext.connected, submitFn, this.dirtyFn, addedGCOutboundReferenceFn, storageService, logger, clonedSnapshotTree, blobMap);
|
|
119
|
-
});
|
|
120
134
|
this.dirtyFn = () => {
|
|
121
135
|
dirtyFn(id);
|
|
122
136
|
};
|
|
123
137
|
}
|
|
124
|
-
async getChannel() {
|
|
125
|
-
if (this.channel === undefined) {
|
|
126
|
-
this.channel = await this.loadChannel().catch((err) => {
|
|
127
|
-
throw DataProcessingError.wrapIfUnrecognized(err, "rehydratedLocalChannelContextFailedToLoadChannel", undefined);
|
|
128
|
-
});
|
|
129
|
-
}
|
|
130
|
-
return this.channel;
|
|
131
|
-
}
|
|
132
|
-
async loadChannel() {
|
|
133
|
-
assert(!this.isLoaded, 0x18e /* "Channel must not already be loaded when loading" */);
|
|
134
|
-
assert(await this.services.value.objectStorage.contains(".attributes"), 0x190 /* ".attributes blob should be present" */);
|
|
135
|
-
const attributes = await readAndParse(this.services.value.objectStorage, ".attributes");
|
|
136
|
-
assert(this.factory === undefined, 0x208 /* "Factory should be undefined before loading" */);
|
|
137
|
-
this.factory = this.registry.get(attributes.type);
|
|
138
|
-
if (this.factory === undefined) {
|
|
139
|
-
throw new Error(`Channel Factory ${attributes.type} not registered`);
|
|
140
|
-
}
|
|
141
|
-
// Services will be assigned during this load.
|
|
142
|
-
const channel = await this.factory.load(this.runtime, this.id, this.services.value, attributes);
|
|
143
|
-
// Commit changes.
|
|
144
|
-
this.channel = channel;
|
|
145
|
-
// Send all pending messages to the channel
|
|
146
|
-
for (const message of this.pending) {
|
|
147
|
-
this.services.value.deltaConnection.process(message, false, undefined /* localOpMetadata */);
|
|
148
|
-
}
|
|
149
|
-
return this.channel;
|
|
150
|
-
}
|
|
151
138
|
isSnapshotInOldFormatAndCollectBlobs(snapshotTree, blobMap) {
|
|
152
139
|
let sanitize = false;
|
|
153
140
|
const blobsContents = snapshotTree
|
|
@@ -179,16 +166,16 @@ export class RehydratedLocalChannelContext extends LocalChannelContextBase {
|
|
|
179
166
|
}
|
|
180
167
|
export class LocalChannelContext extends LocalChannelContextBase {
|
|
181
168
|
constructor(id, registry, type, runtime, dataStoreContext, storageService, logger, submitFn, dirtyFn, addedGCOutboundReferenceFn) {
|
|
182
|
-
super(id, registry, runtime, () => this.services);
|
|
183
169
|
assert(type !== undefined, 0x209 /* "Factory Type should be defined" */);
|
|
184
|
-
|
|
185
|
-
if (
|
|
170
|
+
const factory = registry.get(type);
|
|
171
|
+
if (factory === undefined) {
|
|
186
172
|
throw new Error(`Channel Factory ${type} not registered`);
|
|
187
173
|
}
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
return
|
|
191
|
-
});
|
|
174
|
+
const channel = factory.create(runtime, id);
|
|
175
|
+
super(id, runtime, new Lazy(() => {
|
|
176
|
+
return createChannelServiceEndpoints(dataStoreContext.connected, submitFn, this.dirtyFn, addedGCOutboundReferenceFn, storageService, logger);
|
|
177
|
+
}), Promise.resolve(channel), channel);
|
|
178
|
+
this.channel = channel;
|
|
192
179
|
this.dirtyFn = () => {
|
|
193
180
|
dirtyFn(id);
|
|
194
181
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"localChannelContext.js","sourceRoot":"","sources":["../src/localChannelContext.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,sDAAsD;AACtD,OAAO,SAAS,MAAM,kBAAkB,CAAC;AAgBzC,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAC5D,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AACtE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,M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ClD,MAAM,CAAC,IAAI,KAAK,SAAS,EAAE,KAAK,CAAC,sCAAsC,CAAC,CAAC;QACzE,IAAI,CAAC,OAAO,GAAG,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QAClC,IAAI,IAAI,CAAC,OAAO,KAAK,SAAS,EAAE;YAC/B,MAAM,IAAI,KAAK,CAAC,mBAAmB,IAAI,iBAAiB,CAAC,CAAC;SAC1D;QACD,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;QAChD,IAAI,CAAC,QAAQ,GAAG,IAAI,IAAI,CAAC,GAAG,EAAE;YAC7B,OAAO,sBAAsB,CAC5B,IAAI,CAAC,EAAE,EACP,gBAAgB,CAAC,SAAS,EAC1B,QAAQ,EACR,IAAI,CAAC,OAAO,EACZ,0BAA0B,EAC1B,cAAc,EACd,MAAM,CACN,CAAC;QACH,CAAC,CAAC,CAAC;QACH,IAAI,CAAC,OAAO,GAAG,GAAG,EAAE;YACnB,OAAO,CAAC,EAAE,CAAC,CAAC;QACb,CAAC,CAAC;IACH,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n// eslint-disable-next-line import/no-internal-modules\nimport cloneDeep from \"lodash/cloneDeep\";\nimport { ITelemetryLogger } from \"@fluidframework/common-definitions\";\nimport { IDocumentStorageService } from \"@fluidframework/driver-definitions\";\nimport { ISequencedDocumentMessage, ISnapshotTree } from \"@fluidframework/protocol-definitions\";\nimport {\n\tIChannel,\n\tIFluidDataStoreRuntime,\n\tIChannelFactory,\n\tIChannelAttributes,\n} from \"@fluidframework/datastore-definitions\";\nimport {\n\tIFluidDataStoreContext,\n\tIGarbageCollectionData,\n\tISummarizeResult,\n\tITelemetryContext,\n} from \"@fluidframework/runtime-definitions\";\nimport { readAndParse } from \"@fluidframework/driver-utils\";\nimport { DataProcessingError } from \"@fluidframework/container-utils\";\nimport { assert, Lazy } from \"@fluidframework/common-utils\";\nimport { IFluidHandle } from \"@fluidframework/core-interfaces\";\nimport {\n\tcreateServiceEndpoints,\n\tIChannelContext,\n\tsummarizeChannel,\n\tsummarizeChannelAsync,\n} from \"./channelContext\";\nimport { ChannelDeltaConnection } from \"./channelDeltaConnection\";\nimport { ISharedObjectRegistry } from \"./dataStoreRuntime\";\nimport { ChannelStorageService } from \"./channelStorageService\";\n\n/**\n * Channel context for a locally created channel\n */\nexport abstract class LocalChannelContextBase implements IChannelContext {\n\tpublic channel: IChannel | undefined;\n\tprivate globallyVisible = false;\n\tprotected readonly pending: ISequencedDocumentMessage[] = [];\n\tprotected factory: IChannelFactory | undefined;\n\tconstructor(\n\t\tprotected readonly id: string,\n\t\tprotected readonly registry: ISharedObjectRegistry,\n\t\tprotected readonly runtime: IFluidDataStoreRuntime,\n\t\tprivate readonly servicesGetter: () => Lazy<{\n\t\t\treadonly deltaConnection: ChannelDeltaConnection;\n\t\t\treadonly objectStorage: ChannelStorageService;\n\t\t}>,\n\t) {\n\t\tassert(!this.id.includes(\"/\"), 0x30f /* Channel context ID cannot contain slashes */);\n\t}\n\n\tpublic async getChannel(): Promise<IChannel> {\n\t\tassert(this.channel !== undefined, 0x207 /* \"Channel should be defined\" */);\n\t\treturn this.channel;\n\t}\n\n\tpublic get isLoaded(): boolean {\n\t\treturn this.channel !== undefined;\n\t}\n\n\tpublic setConnectionState(connected: boolean, clientId?: string) {\n\t\t// Connection events are ignored if the data store is not yet globallyVisible or loaded\n\t\tif (this.globallyVisible && this.isLoaded) {\n\t\t\tthis.servicesGetter().value.deltaConnection.setConnectionState(connected);\n\t\t}\n\t}\n\n\tpublic processOp(\n\t\tmessage: ISequencedDocumentMessage,\n\t\tlocal: boolean,\n\t\tlocalOpMetadata: unknown,\n\t): void {\n\t\tassert(\n\t\t\tthis.globallyVisible,\n\t\t\t0x2d3 /* \"Local channel must be globally visible when processing op\" */,\n\t\t);\n\n\t\t// A local channel may not be loaded in case where we rehydrate the container from a snapshot because of\n\t\t// delay loading. So after the container is attached and some other client joins which start generating\n\t\t// ops for this channel. So not loaded local channel can still receive ops and we store them to process later.\n\t\tif (this.isLoaded) {\n\t\t\tthis.servicesGetter().value.deltaConnection.process(message, local, localOpMetadata);\n\t\t} else {\n\t\t\tassert(\n\t\t\t\tlocal === false,\n\t\t\t\t0x189 /* \"Should always be remote because a local dds shouldn't generate ops before loading\" */,\n\t\t\t);\n\t\t\tthis.pending.push(message);\n\t\t}\n\t}\n\n\tpublic reSubmit(content: any, localOpMetadata: unknown) {\n\t\tassert(this.isLoaded, 0x18a /* \"Channel should be loaded to resubmit ops\" */);\n\t\tassert(\n\t\t\tthis.globallyVisible,\n\t\t\t0x2d4 /* \"Local channel must be globally visible when resubmitting op\" */,\n\t\t);\n\t\tthis.servicesGetter().value.deltaConnection.reSubmit(content, localOpMetadata);\n\t}\n\tpublic rollback(content: any, localOpMetadata: unknown) {\n\t\tassert(this.isLoaded, 0x2ee /* \"Channel should be loaded to rollback ops\" */);\n\t\tassert(\n\t\t\tthis.globallyVisible,\n\t\t\t0x2ef /* \"Local channel must be globally visible when rolling back op\" */,\n\t\t);\n\t\tthis.servicesGetter().value.deltaConnection.rollback(content, localOpMetadata);\n\t}\n\n\tpublic applyStashedOp() {\n\t\tthrow new Error(\"no stashed ops on local channel\");\n\t}\n\n\t/**\n\t * Returns a summary at the current sequence number.\n\t * @param fullTree - true to bypass optimizations and force a full summary tree\n\t * @param trackState - This tells whether we should track state from this summary.\n\t * @param telemetryContext - summary data passed through the layers for telemetry purposes\n\t */\n\tpublic async summarize(\n\t\tfullTree: boolean = false,\n\t\ttrackState: boolean = false,\n\t\ttelemetryContext?: ITelemetryContext,\n\t): Promise<ISummarizeResult> {\n\t\tassert(\n\t\t\tthis.isLoaded && this.channel !== undefined,\n\t\t\t0x18c /* \"Channel should be loaded to summarize\" */,\n\t\t);\n\t\treturn summarizeChannelAsync(this.channel, fullTree, trackState, telemetryContext);\n\t}\n\n\tpublic getAttachSummary(telemetryContext?: ITelemetryContext): ISummarizeResult {\n\t\tassert(\n\t\t\tthis.isLoaded && this.channel !== undefined,\n\t\t\t0x18d /* \"Channel should be loaded to take snapshot\" */,\n\t\t);\n\t\treturn summarizeChannel(\n\t\t\tthis.channel,\n\t\t\ttrue /* fullTree */,\n\t\t\tfalse /* trackState */,\n\t\t\ttelemetryContext,\n\t\t);\n\t}\n\n\tpublic makeVisible(): void {\n\t\tif (this.globallyVisible) {\n\t\t\tthrow new Error(\"Channel is already globally visible\");\n\t\t}\n\n\t\tif (this.isLoaded) {\n\t\t\tassert(!!this.channel, 0x192 /* \"Channel should be there if loaded!!\" */);\n\t\t\tthis.channel.connect(this.servicesGetter().value);\n\t\t}\n\t\tthis.globallyVisible = true;\n\t}\n\n\t/**\n\t * Returns the data used for garbage collection. This includes a list of GC nodes that represent this context.\n\t * Each node has a set of outbound routes to other GC nodes in the document. This should be called only after\n\t * the context has loaded.\n\t * @param fullGC - true to bypass optimizations and force full generation of GC data.\n\t */\n\tpublic async getGCData(fullGC: boolean = false): Promise<IGarbageCollectionData> {\n\t\tassert(\n\t\t\tthis.isLoaded && this.channel !== undefined,\n\t\t\t0x193 /* \"Channel should be loaded to run GC\" */,\n\t\t);\n\t\treturn this.channel.getGCData(fullGC);\n\t}\n\n\tpublic updateUsedRoutes(usedRoutes: string[]) {\n\t\t/**\n\t\t * Currently, DDSes are always considered referenced and are not garbage collected.\n\t\t * Once we have GC at DDS level, this channel context's used routes will be updated as per the passed\n\t\t * value. See - https://github.com/microsoft/FluidFramework/issues/4611\n\t\t */\n\t}\n}\n\nexport class RehydratedLocalChannelContext extends LocalChannelContextBase {\n\tprivate readonly services: Lazy<{\n\t\treadonly deltaConnection: ChannelDeltaConnection;\n\t\treadonly objectStorage: ChannelStorageService;\n\t}>;\n\n\tprivate readonly dirtyFn: () => void;\n\n\tconstructor(\n\t\tid: string,\n\t\tregistry: ISharedObjectRegistry,\n\t\truntime: IFluidDataStoreRuntime,\n\t\tdataStoreContext: IFluidDataStoreContext,\n\t\tstorageService: IDocumentStorageService,\n\t\tlogger: ITelemetryLogger,\n\t\tsubmitFn: (content: any, localOpMetadata: unknown) => void,\n\t\tdirtyFn: (address: string) => void,\n\t\taddedGCOutboundReferenceFn: (srcHandle: IFluidHandle, outboundHandle: IFluidHandle) => void,\n\t\tprivate readonly snapshotTree: ISnapshotTree,\n\t) {\n\t\tsuper(id, registry, runtime, () => this.services);\n\t\tconst blobMap: Map<string, ArrayBufferLike> = new Map<string, ArrayBufferLike>();\n\t\tconst clonedSnapshotTree = cloneDeep(this.snapshotTree);\n\t\t// 0.47 back-compat Need to sanitize if snapshotTree.blobs still contains blob contents too.\n\t\t// This is for older snapshot which is generated by loader <=0.47 version which still contains\n\t\t// the contents within blobs. After a couple of revisions we can remove it.\n\t\tif (this.isSnapshotInOldFormatAndCollectBlobs(clonedSnapshotTree, blobMap)) {\n\t\t\tthis.sanitizeSnapshot(clonedSnapshotTree);\n\t\t}\n\n\t\tthis.services = new Lazy(() => {\n\t\t\treturn createServiceEndpoints(\n\t\t\t\tthis.id,\n\t\t\t\tdataStoreContext.connected,\n\t\t\t\tsubmitFn,\n\t\t\t\tthis.dirtyFn,\n\t\t\t\taddedGCOutboundReferenceFn,\n\t\t\t\tstorageService,\n\t\t\t\tlogger,\n\t\t\t\tclonedSnapshotTree,\n\t\t\t\tblobMap,\n\t\t\t);\n\t\t});\n\t\tthis.dirtyFn = () => {\n\t\t\tdirtyFn(id);\n\t\t};\n\t}\n\n\tpublic async getChannel(): Promise<IChannel> {\n\t\tif (this.channel === undefined) {\n\t\t\tthis.channel = await this.loadChannel().catch((err) => {\n\t\t\t\tthrow DataProcessingError.wrapIfUnrecognized(\n\t\t\t\t\terr,\n\t\t\t\t\t\"rehydratedLocalChannelContextFailedToLoadChannel\",\n\t\t\t\t\tundefined,\n\t\t\t\t);\n\t\t\t});\n\t\t}\n\t\treturn this.channel;\n\t}\n\n\tprivate async loadChannel(): Promise<IChannel> {\n\t\tassert(!this.isLoaded, 0x18e /* \"Channel must not already be loaded when loading\" */);\n\t\tassert(\n\t\t\tawait this.services.value.objectStorage.contains(\".attributes\"),\n\t\t\t0x190 /* \".attributes blob should be present\" */,\n\t\t);\n\t\tconst attributes = await readAndParse<IChannelAttributes>(\n\t\t\tthis.services.value.objectStorage,\n\t\t\t\".attributes\",\n\t\t);\n\n\t\tassert(\n\t\t\tthis.factory === undefined,\n\t\t\t0x208 /* \"Factory should be undefined before loading\" */,\n\t\t);\n\t\tthis.factory = this.registry.get(attributes.type);\n\t\tif (this.factory === undefined) {\n\t\t\tthrow new Error(`Channel Factory ${attributes.type} not registered`);\n\t\t}\n\t\t// Services will be assigned during this load.\n\t\tconst channel = await this.factory.load(\n\t\t\tthis.runtime,\n\t\t\tthis.id,\n\t\t\tthis.services.value,\n\t\t\tattributes,\n\t\t);\n\n\t\t// Commit changes.\n\t\tthis.channel = channel;\n\n\t\t// Send all pending messages to the channel\n\t\tfor (const message of this.pending) {\n\t\t\tthis.services.value.deltaConnection.process(\n\t\t\t\tmessage,\n\t\t\t\tfalse,\n\t\t\t\tundefined /* localOpMetadata */,\n\t\t\t);\n\t\t}\n\t\treturn this.channel;\n\t}\n\n\tprivate isSnapshotInOldFormatAndCollectBlobs(\n\t\tsnapshotTree: ISnapshotTree,\n\t\tblobMap: Map<string, ArrayBufferLike>,\n\t): boolean {\n\t\tlet sanitize = false;\n\t\tconst blobsContents: { [path: string]: ArrayBufferLike } = (snapshotTree as any)\n\t\t\t.blobsContents;\n\t\tObject.entries(blobsContents).forEach(([key, value]) => {\n\t\t\tblobMap.set(key, value);\n\t\t\tif (snapshotTree.blobs[key] !== undefined) {\n\t\t\t\tsanitize = true;\n\t\t\t}\n\t\t});\n\t\tfor (const value of Object.values(snapshotTree.trees)) {\n\t\t\tsanitize = sanitize || this.isSnapshotInOldFormatAndCollectBlobs(value, blobMap);\n\t\t}\n\t\treturn sanitize;\n\t}\n\n\tprivate sanitizeSnapshot(snapshotTree: ISnapshotTree) {\n\t\tconst blobMapInitial = new Map(Object.entries(snapshotTree.blobs));\n\t\tfor (const [blobName, blobId] of blobMapInitial.entries()) {\n\t\t\tconst blobValue = blobMapInitial.get(blobId);\n\t\t\tif (blobValue === undefined) {\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n\t\t\t\tdelete snapshotTree.blobs[blobName];\n\t\t\t}\n\t\t}\n\t\tfor (const value of Object.values(snapshotTree.trees)) {\n\t\t\tthis.sanitizeSnapshot(value);\n\t\t}\n\t}\n}\n\nexport class LocalChannelContext extends LocalChannelContextBase {\n\tprivate readonly services: Lazy<{\n\t\treadonly deltaConnection: ChannelDeltaConnection;\n\t\treadonly objectStorage: ChannelStorageService;\n\t}>;\n\tprivate readonly dirtyFn: () => void;\n\tconstructor(\n\t\tid: string,\n\t\tregistry: ISharedObjectRegistry,\n\t\ttype: string,\n\t\truntime: IFluidDataStoreRuntime,\n\t\tdataStoreContext: IFluidDataStoreContext,\n\t\tstorageService: IDocumentStorageService,\n\t\tlogger: ITelemetryLogger,\n\t\tsubmitFn: (content: any, localOpMetadata: unknown) => void,\n\t\tdirtyFn: (address: string) => void,\n\t\taddedGCOutboundReferenceFn: (srcHandle: IFluidHandle, outboundHandle: IFluidHandle) => void,\n\t) {\n\t\tsuper(id, registry, runtime, () => this.services);\n\t\tassert(type !== undefined, 0x209 /* \"Factory Type should be defined\" */);\n\t\tthis.factory = registry.get(type);\n\t\tif (this.factory === undefined) {\n\t\t\tthrow new Error(`Channel Factory ${type} not registered`);\n\t\t}\n\t\tthis.channel = this.factory.create(runtime, id);\n\t\tthis.services = new Lazy(() => {\n\t\t\treturn createServiceEndpoints(\n\t\t\t\tthis.id,\n\t\t\t\tdataStoreContext.connected,\n\t\t\t\tsubmitFn,\n\t\t\t\tthis.dirtyFn,\n\t\t\t\taddedGCOutboundReferenceFn,\n\t\t\t\tstorageService,\n\t\t\t\tlogger,\n\t\t\t);\n\t\t});\n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O,CAAC;QAEvB,IAAI,CAAC,OAAO,GAAG,GAAG,EAAE;YACnB,OAAO,CAAC,EAAE,CAAC,CAAC;QACb,CAAC,CAAC;IACH,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n// eslint-disable-next-line import/no-internal-modules\nimport cloneDeep from \"lodash/cloneDeep\";\nimport { ITelemetryLogger } from \"@fluidframework/common-definitions\";\nimport { IDocumentStorageService } from \"@fluidframework/driver-definitions\";\nimport { ISequencedDocumentMessage, ISnapshotTree } from \"@fluidframework/protocol-definitions\";\nimport { IChannel, IFluidDataStoreRuntime } from \"@fluidframework/datastore-definitions\";\nimport {\n\tIFluidDataStoreContext,\n\tIGarbageCollectionData,\n\tISummarizeResult,\n\tITelemetryContext,\n} from \"@fluidframework/runtime-definitions\";\nimport { DataProcessingError } from \"@fluidframework/container-utils\";\nimport { assert, Lazy, LazyPromise } from \"@fluidframework/common-utils\";\nimport { IFluidHandle } from \"@fluidframework/core-interfaces\";\nimport {\n\tChannelServiceEndpoints,\n\tcreateChannelServiceEndpoints,\n\tIChannelContext,\n\tloadChannel,\n\tloadChannelFactoryAndAttributes,\n\tsummarizeChannel,\n\tsummarizeChannelAsync,\n} from \"./channelContext\";\nimport { ISharedObjectRegistry } from \"./dataStoreRuntime\";\n\n/**\n * Channel context for a locally created channel\n */\nexport abstract class LocalChannelContextBase implements IChannelContext {\n\tprivate globallyVisible = false;\n\tprotected readonly pending: ISequencedDocumentMessage[] = [];\n\tconstructor(\n\t\tprotected readonly id: string,\n\t\tprotected readonly runtime: IFluidDataStoreRuntime,\n\t\tprotected readonly services: Lazy<ChannelServiceEndpoints>,\n\t\tprivate readonly channelP: Promise<IChannel>,\n\t\tprivate _channel?: IChannel,\n\t) {\n\t\tassert(!this.id.includes(\"/\"), 0x30f /* Channel context ID cannot contain slashes */);\n\t}\n\n\tpublic async getChannel(): Promise<IChannel> {\n\t\tif (this._channel === undefined) {\n\t\t\treturn this.channelP.then((c) => (this._channel = c));\n\t\t}\n\t\treturn this.channelP;\n\t}\n\n\tpublic get isLoaded(): boolean {\n\t\treturn this._channel !== undefined;\n\t}\n\n\tpublic setConnectionState(connected: boolean, clientId?: string) {\n\t\t// Connection events are ignored if the data store is not yet globallyVisible or loaded\n\t\tif (this.globallyVisible && this.isLoaded) {\n\t\t\tthis.services.value.deltaConnection.setConnectionState(connected);\n\t\t}\n\t}\n\n\tpublic processOp(\n\t\tmessage: ISequencedDocumentMessage,\n\t\tlocal: boolean,\n\t\tlocalOpMetadata: unknown,\n\t): void {\n\t\tassert(\n\t\t\tthis.globallyVisible,\n\t\t\t0x2d3 /* \"Local channel must be globally visible when processing op\" */,\n\t\t);\n\n\t\t// A local channel may not be loaded in case where we rehydrate the container from a snapshot because of\n\t\t// delay loading. So after the container is attached and some other client joins which start generating\n\t\t// ops for this channel. So not loaded local channel can still receive ops and we store them to process later.\n\t\tif (this.isLoaded) {\n\t\t\tthis.services.value.deltaConnection.process(message, local, localOpMetadata);\n\t\t} else {\n\t\t\tassert(\n\t\t\t\tlocal === false,\n\t\t\t\t0x189 /* \"Should always be remote because a local dds shouldn't generate ops before loading\" */,\n\t\t\t);\n\t\t\tthis.pending.push(message);\n\t\t}\n\t}\n\n\tpublic reSubmit(content: any, localOpMetadata: unknown) {\n\t\tassert(this.isLoaded, 0x18a /* \"Channel should be loaded to resubmit ops\" */);\n\t\tassert(\n\t\t\tthis.globallyVisible,\n\t\t\t0x2d4 /* \"Local channel must be globally visible when resubmitting op\" */,\n\t\t);\n\t\tthis.services.value.deltaConnection.reSubmit(content, localOpMetadata);\n\t}\n\tpublic rollback(content: any, localOpMetadata: unknown) {\n\t\tassert(this.isLoaded, 0x2ee /* \"Channel should be loaded to rollback ops\" */);\n\t\tassert(\n\t\t\tthis.globallyVisible,\n\t\t\t0x2ef /* \"Local channel must be globally visible when rolling back op\" */,\n\t\t);\n\t\tthis.services.value.deltaConnection.rollback(content, localOpMetadata);\n\t}\n\n\tpublic applyStashedOp() {\n\t\tthrow new Error(\"no stashed ops on local channel\");\n\t}\n\n\t/**\n\t * Returns a summary at the current sequence number.\n\t * @param fullTree - true to bypass optimizations and force a full summary tree\n\t * @param trackState - This tells whether we should track state from this summary.\n\t * @param telemetryContext - summary data passed through the layers for telemetry purposes\n\t */\n\tpublic async summarize(\n\t\tfullTree: boolean = false,\n\t\ttrackState: boolean = false,\n\t\ttelemetryContext?: ITelemetryContext,\n\t): Promise<ISummarizeResult> {\n\t\tconst channel = await this.getChannel();\n\t\treturn summarizeChannelAsync(channel, fullTree, trackState, telemetryContext);\n\t}\n\n\tpublic getAttachSummary(telemetryContext?: ITelemetryContext): ISummarizeResult {\n\t\tassert(\n\t\t\tthis._channel !== undefined,\n\t\t\t0x18d /* \"Channel should be loaded to take snapshot\" */,\n\t\t);\n\t\treturn summarizeChannel(\n\t\t\tthis._channel,\n\t\t\ttrue /* fullTree */,\n\t\t\tfalse /* trackState */,\n\t\t\ttelemetryContext,\n\t\t);\n\t}\n\n\tpublic makeVisible(): void {\n\t\tif (this.globallyVisible) {\n\t\t\tthrow new Error(\"Channel is already globally visible\");\n\t\t}\n\n\t\tif (this.isLoaded) {\n\t\t\tassert(!!this._channel, 0x192 /* \"Channel should be there if loaded!!\" */);\n\t\t\tthis._channel.connect(this.services.value);\n\t\t}\n\t\tthis.globallyVisible = true;\n\t}\n\n\t/**\n\t * Returns the data used for garbage collection. This includes a list of GC nodes that represent this context.\n\t * Each node has a set of outbound routes to other GC nodes in the document. This should be called only after\n\t * the context has loaded.\n\t * @param fullGC - true to bypass optimizations and force full generation of GC data.\n\t */\n\tpublic async getGCData(fullGC: boolean = false): Promise<IGarbageCollectionData> {\n\t\tconst channel = await this.getChannel();\n\t\treturn channel.getGCData(fullGC);\n\t}\n\n\tpublic updateUsedRoutes(usedRoutes: string[]) {\n\t\t/**\n\t\t * Currently, DDSes are always considered referenced and are not garbage collected.\n\t\t * Once we have GC at DDS level, this channel context's used routes will be updated as per the passed\n\t\t * value. See - https://github.com/microsoft/FluidFramework/issues/4611\n\t\t */\n\t}\n}\n\nexport class RehydratedLocalChannelContext extends LocalChannelContextBase {\n\tprivate readonly dirtyFn: () => void;\n\tconstructor(\n\t\tid: string,\n\t\tregistry: ISharedObjectRegistry,\n\t\truntime: IFluidDataStoreRuntime,\n\t\tdataStoreContext: IFluidDataStoreContext,\n\t\tstorageService: IDocumentStorageService,\n\t\tlogger: ITelemetryLogger,\n\t\tsubmitFn: (content: any, localOpMetadata: unknown) => void,\n\t\tdirtyFn: (address: string) => void,\n\t\taddedGCOutboundReferenceFn: (srcHandle: IFluidHandle, outboundHandle: IFluidHandle) => void,\n\t\tprivate readonly snapshotTree: ISnapshotTree,\n\t) {\n\t\tsuper(\n\t\t\tid,\n\t\t\truntime,\n\t\t\tnew Lazy(() => {\n\t\t\t\tconst blobMap: Map<string, ArrayBufferLike> = new Map<string, ArrayBufferLike>();\n\t\t\t\tconst clonedSnapshotTree = cloneDeep(this.snapshotTree);\n\t\t\t\t// 0.47 back-compat Need to sanitize if snapshotTree.blobs still contains blob contents too.\n\t\t\t\t// This is for older snapshot which is generated by loader <=0.47 version which still contains\n\t\t\t\t// the contents within blobs. After a couple of revisions we can remove it.\n\t\t\t\tif (this.isSnapshotInOldFormatAndCollectBlobs(clonedSnapshotTree, blobMap)) {\n\t\t\t\t\tthis.sanitizeSnapshot(clonedSnapshotTree);\n\t\t\t\t}\n\t\t\t\treturn createChannelServiceEndpoints(\n\t\t\t\t\tdataStoreContext.connected,\n\t\t\t\t\tsubmitFn,\n\t\t\t\t\tthis.dirtyFn,\n\t\t\t\t\taddedGCOutboundReferenceFn,\n\t\t\t\t\tstorageService,\n\t\t\t\t\tlogger,\n\t\t\t\t\tclonedSnapshotTree,\n\t\t\t\t\tblobMap,\n\t\t\t\t);\n\t\t\t}),\n\t\t\tnew LazyPromise<IChannel>(async () => {\n\t\t\t\ttry {\n\t\t\t\t\tconst { attributes, factory } = await loadChannelFactoryAndAttributes(\n\t\t\t\t\t\tdataStoreContext,\n\t\t\t\t\t\tthis.services.value,\n\t\t\t\t\t\tthis.id,\n\t\t\t\t\t\tregistry,\n\t\t\t\t\t);\n\t\t\t\t\tconst channel = await loadChannel(\n\t\t\t\t\t\truntime,\n\t\t\t\t\t\tattributes,\n\t\t\t\t\t\tfactory,\n\t\t\t\t\t\tthis.services.value,\n\t\t\t\t\t\tlogger,\n\t\t\t\t\t\tthis.id,\n\t\t\t\t\t);\n\t\t\t\t\t// Send all pending messages to the channel\n\t\t\t\t\tfor (const message of this.pending) {\n\t\t\t\t\t\tthis.services.value.deltaConnection.process(\n\t\t\t\t\t\t\tmessage,\n\t\t\t\t\t\t\tfalse,\n\t\t\t\t\t\t\tundefined /* localOpMetadata */,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\treturn channel;\n\t\t\t\t} catch (err) {\n\t\t\t\t\tthrow DataProcessingError.wrapIfUnrecognized(\n\t\t\t\t\t\terr,\n\t\t\t\t\t\t\"rehydratedLocalChannelContextFailedToLoadChannel\",\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}),\n\t\t);\n\n\t\tthis.dirtyFn = () => {\n\t\t\tdirtyFn(id);\n\t\t};\n\t}\n\n\tprivate isSnapshotInOldFormatAndCollectBlobs(\n\t\tsnapshotTree: ISnapshotTree,\n\t\tblobMap: Map<string, ArrayBufferLike>,\n\t): boolean {\n\t\tlet sanitize = false;\n\t\tconst blobsContents: { [path: string]: ArrayBufferLike } = (snapshotTree as any)\n\t\t\t.blobsContents;\n\t\tObject.entries(blobsContents).forEach(([key, value]) => {\n\t\t\tblobMap.set(key, value);\n\t\t\tif (snapshotTree.blobs[key] !== undefined) {\n\t\t\t\tsanitize = true;\n\t\t\t}\n\t\t});\n\t\tfor (const value of Object.values(snapshotTree.trees)) {\n\t\t\tsanitize = sanitize || this.isSnapshotInOldFormatAndCollectBlobs(value, blobMap);\n\t\t}\n\t\treturn sanitize;\n\t}\n\n\tprivate sanitizeSnapshot(snapshotTree: ISnapshotTree) {\n\t\tconst blobMapInitial = new Map(Object.entries(snapshotTree.blobs));\n\t\tfor (const [blobName, blobId] of blobMapInitial.entries()) {\n\t\t\tconst blobValue = blobMapInitial.get(blobId);\n\t\t\tif (blobValue === undefined) {\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n\t\t\t\tdelete snapshotTree.blobs[blobName];\n\t\t\t}\n\t\t}\n\t\tfor (const value of Object.values(snapshotTree.trees)) {\n\t\t\tthis.sanitizeSnapshot(value);\n\t\t}\n\t}\n}\n\nexport class LocalChannelContext extends LocalChannelContextBase {\n\tprivate readonly dirtyFn: () => void;\n\tpublic readonly channel: IChannel;\n\tconstructor(\n\t\tid: string,\n\t\tregistry: ISharedObjectRegistry,\n\t\ttype: string,\n\t\truntime: IFluidDataStoreRuntime,\n\t\tdataStoreContext: IFluidDataStoreContext,\n\t\tstorageService: IDocumentStorageService,\n\t\tlogger: ITelemetryLogger,\n\t\tsubmitFn: (content: any, localOpMetadata: unknown) => void,\n\t\tdirtyFn: (address: string) => void,\n\t\taddedGCOutboundReferenceFn: (srcHandle: IFluidHandle, outboundHandle: IFluidHandle) => void,\n\t) {\n\t\tassert(type !== undefined, 0x209 /* \"Factory Type should be defined\" */);\n\t\tconst factory = registry.get(type);\n\t\tif (factory === undefined) {\n\t\t\tthrow new Error(`Channel Factory ${type} not registered`);\n\t\t}\n\t\tconst channel = factory.create(runtime, id);\n\t\tsuper(\n\t\t\tid,\n\t\t\truntime,\n\t\t\tnew Lazy(() => {\n\t\t\t\treturn createChannelServiceEndpoints(\n\t\t\t\t\tdataStoreContext.connected,\n\t\t\t\t\tsubmitFn,\n\t\t\t\t\tthis.dirtyFn,\n\t\t\t\t\taddedGCOutboundReferenceFn,\n\t\t\t\t\tstorageService,\n\t\t\t\t\tlogger,\n\t\t\t\t);\n\t\t\t}),\n\t\t\tPromise.resolve(channel),\n\t\t\tchannel,\n\t\t);\n\t\tthis.channel = channel;\n\n\t\tthis.dirtyFn = () => {\n\t\t\tdirtyFn(id);\n\t\t};\n\t}\n}\n"]}
|
|
@@ -10,24 +10,20 @@ import { CreateChildSummarizerNodeFn, IFluidDataStoreContext, IGarbageCollection
|
|
|
10
10
|
import { IChannelContext } from "./channelContext";
|
|
11
11
|
import { ISharedObjectRegistry } from "./dataStoreRuntime";
|
|
12
12
|
export declare class RemoteChannelContext implements IChannelContext {
|
|
13
|
-
private readonly runtime;
|
|
14
|
-
private readonly dataStoreContext;
|
|
15
13
|
private readonly id;
|
|
16
|
-
private readonly registry;
|
|
17
|
-
private readonly attachMessageType?;
|
|
18
14
|
private isLoaded;
|
|
19
15
|
private pending;
|
|
20
|
-
private channelP;
|
|
16
|
+
private readonly channelP;
|
|
21
17
|
private channel;
|
|
22
18
|
private readonly services;
|
|
23
19
|
private readonly summarizerNode;
|
|
24
20
|
private readonly subLogger;
|
|
25
21
|
private readonly thresholdOpsCounter;
|
|
26
22
|
private static readonly pendingOpsCountThreshold;
|
|
27
|
-
constructor(runtime: IFluidDataStoreRuntime, dataStoreContext: IFluidDataStoreContext, storageService: IDocumentStorageService, submitFn: (content: any, localOpMetadata: unknown) => void, dirtyFn: (address: string) => void, addedGCOutboundReferenceFn: (srcHandle: IFluidHandle, outboundHandle: IFluidHandle) => void, id: string, baseSnapshot: ISnapshotTree, registry: ISharedObjectRegistry, extraBlobs: Map<string, ArrayBufferLike> | undefined, createSummarizerNode: CreateChildSummarizerNodeFn, attachMessageType?: string
|
|
23
|
+
constructor(runtime: IFluidDataStoreRuntime, dataStoreContext: IFluidDataStoreContext, storageService: IDocumentStorageService, submitFn: (content: any, localOpMetadata: unknown) => void, dirtyFn: (address: string) => void, addedGCOutboundReferenceFn: (srcHandle: IFluidHandle, outboundHandle: IFluidHandle) => void, id: string, baseSnapshot: ISnapshotTree, registry: ISharedObjectRegistry, extraBlobs: Map<string, ArrayBufferLike> | undefined, createSummarizerNode: CreateChildSummarizerNodeFn, attachMessageType?: string);
|
|
28
24
|
getChannel(): Promise<IChannel>;
|
|
29
25
|
setConnectionState(connected: boolean, clientId?: string): void;
|
|
30
|
-
applyStashedOp(
|
|
26
|
+
applyStashedOp(content: any): unknown;
|
|
31
27
|
processOp(message: ISequencedDocumentMessage, local: boolean, localOpMetadata: unknown): void;
|
|
32
28
|
reSubmit(content: any, localOpMetadata: unknown): void;
|
|
33
29
|
rollback(content: any, localOpMetadata: unknown): void;
|
|
@@ -39,7 +35,6 @@ export declare class RemoteChannelContext implements IChannelContext {
|
|
|
39
35
|
*/
|
|
40
36
|
summarize(fullTree?: boolean, trackState?: boolean, telemetryContext?: ITelemetryContext): Promise<ISummarizeResult>;
|
|
41
37
|
private summarizeInternal;
|
|
42
|
-
private loadChannel;
|
|
43
38
|
/**
|
|
44
39
|
* Returns the data used for garbage collection. This includes a list of GC nodes that represent this context.
|
|
45
40
|
* Each node has a set of outbound routes to other GC nodes in the document.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"remoteChannelContext.d.ts","sourceRoot":"","sources":["../src/remoteChannelContext.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"remoteChannelContext.d.ts","sourceRoot":"","sources":["../src/remoteChannelContext.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,sBAAsB,EAAE,MAAM,uCAAuC,CAAC;AACzF,OAAO,EAAE,uBAAuB,EAAE,MAAM,oCAAoC,CAAC;AAC7E,OAAO,EAAE,yBAAyB,EAAE,aAAa,EAAE,MAAM,sCAAsC,CAAC;AAChG,OAAO,EACN,2BAA2B,EAC3B,sBAAsB,EACtB,sBAAsB,EAGtB,gBAAgB,EAEhB,iBAAiB,EACjB,MAAM,qCAAqC,CAAC;AAE7C,OAAO,EAGN,eAAe,EAIf,MAAM,kBAAkB,CAAC;AA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AAK,EAAE,OAAO,EACd,eAAe,EAAE,OAAO,GACtB,IAAI;IAaA,QAAQ,CAAC,OAAO,EAAE,GAAG,EAAE,eAAe,EAAE,OAAO;IAM/C,QAAQ,CAAC,OAAO,EAAE,GAAG,EAAE,eAAe,EAAE,OAAO;IAMtD;;;;;OAKG;IACU,SAAS,CACrB,QAAQ,GAAE,OAAe,EACzB,UAAU,GAAE,OAAc,EAC1B,gBAAgB,CAAC,EAAE,iBAAiB,GAClC,OAAO,CAAC,gBAAgB,CAAC;YAId,iBAAiB;IAiB/B;;;;;;OAMG;IACU,SAAS,CAAC,MAAM,GAAE,OAAe,GAAG,OAAO,CAAC,sBAAsB,CAAC;IAIhF;;;;OAIG;YACW,iBAAiB;IAKxB,gBAAgB,CAAC,UAAU,EAAE,MAAM,EAAE;CAS5C"}
|
|
@@ -2,32 +2,41 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
import { assert } from "@fluidframework/common-utils";
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import { ChildLogger, TelemetryDataTag, ThresholdCounter } from "@fluidframework/telemetry-utils";
|
|
9
|
-
import { attributesBlobKey, createServiceEndpoints, summarizeChannelAsync, } from "./channelContext";
|
|
5
|
+
import { LazyPromise, assert } from "@fluidframework/common-utils";
|
|
6
|
+
import { ChildLogger, ThresholdCounter } from "@fluidframework/telemetry-utils";
|
|
7
|
+
import { createChannelServiceEndpoints, loadChannel, loadChannelFactoryAndAttributes, summarizeChannelAsync, } from "./channelContext";
|
|
10
8
|
export class RemoteChannelContext {
|
|
11
9
|
constructor(runtime, dataStoreContext, storageService, submitFn, dirtyFn, addedGCOutboundReferenceFn, id, baseSnapshot, registry, extraBlobs, createSummarizerNode, attachMessageType) {
|
|
12
|
-
this.runtime = runtime;
|
|
13
|
-
this.dataStoreContext = dataStoreContext;
|
|
14
10
|
this.id = id;
|
|
15
|
-
this.registry = registry;
|
|
16
|
-
this.attachMessageType = attachMessageType;
|
|
17
11
|
this.isLoaded = false;
|
|
18
12
|
this.pending = [];
|
|
19
13
|
assert(!this.id.includes("/"), 0x310 /* Channel context ID cannot contain slashes */);
|
|
20
|
-
this.subLogger = ChildLogger.create(
|
|
21
|
-
this.services =
|
|
14
|
+
this.subLogger = ChildLogger.create(runtime.logger, "RemoteChannelContext");
|
|
15
|
+
this.services = createChannelServiceEndpoints(dataStoreContext.connected, submitFn, () => dirtyFn(this.id), addedGCOutboundReferenceFn, storageService, this.subLogger, baseSnapshot, extraBlobs);
|
|
16
|
+
this.channelP = new LazyPromise(async () => {
|
|
17
|
+
const { attributes, factory } = await loadChannelFactoryAndAttributes(dataStoreContext, this.services, this.id, registry, attachMessageType);
|
|
18
|
+
const channel = await loadChannel(runtime, attributes, factory, this.services, this.subLogger, this.id);
|
|
19
|
+
// Send all pending messages to the channel
|
|
20
|
+
assert(this.pending !== undefined, 0x23f /* "pending undefined" */);
|
|
21
|
+
for (const message of this.pending) {
|
|
22
|
+
this.services.deltaConnection.process(message, false, undefined /* localOpMetadata */);
|
|
23
|
+
}
|
|
24
|
+
this.thresholdOpsCounter.send("ProcessPendingOps", this.pending.length);
|
|
25
|
+
// Commit changes.
|
|
26
|
+
this.channel = channel;
|
|
27
|
+
this.pending = undefined;
|
|
28
|
+
this.isLoaded = true;
|
|
29
|
+
// Because have some await between we created the service and here, the connection state might have changed
|
|
30
|
+
// and we don't propagate the connection state when we are not loaded. So we have to set it again here.
|
|
31
|
+
this.services.deltaConnection.setConnectionState(dataStoreContext.connected);
|
|
32
|
+
return this.channel;
|
|
33
|
+
});
|
|
22
34
|
const thisSummarizeInternal = async (fullTree, trackState, telemetryContext, incrementalSummaryContext) => this.summarizeInternal(fullTree, trackState, telemetryContext, incrementalSummaryContext);
|
|
23
35
|
this.summarizerNode = createSummarizerNode(thisSummarizeInternal, async (fullGC) => this.getGCDataInternal(fullGC));
|
|
24
36
|
this.thresholdOpsCounter = new ThresholdCounter(RemoteChannelContext.pendingOpsCountThreshold, this.subLogger);
|
|
25
37
|
}
|
|
26
38
|
// eslint-disable-next-line @typescript-eslint/promise-function-async
|
|
27
39
|
getChannel() {
|
|
28
|
-
if (this.channelP === undefined) {
|
|
29
|
-
this.channelP = this.loadChannel();
|
|
30
|
-
}
|
|
31
40
|
return this.channelP;
|
|
32
41
|
}
|
|
33
42
|
setConnectionState(connected, clientId) {
|
|
@@ -37,9 +46,9 @@ export class RemoteChannelContext {
|
|
|
37
46
|
}
|
|
38
47
|
this.services.deltaConnection.setConnectionState(connected);
|
|
39
48
|
}
|
|
40
|
-
applyStashedOp(
|
|
49
|
+
applyStashedOp(content) {
|
|
41
50
|
assert(this.isLoaded, 0x194 /* "Remote channel must be loaded when rebasing op" */);
|
|
42
|
-
return this.services.deltaConnection.applyStashedOp(
|
|
51
|
+
return this.services.deltaConnection.applyStashedOp(content);
|
|
43
52
|
}
|
|
44
53
|
processOp(message, local, localOpMetadata) {
|
|
45
54
|
this.summarizerNode.invalidate(message.sequenceNumber);
|
|
@@ -75,82 +84,6 @@ export class RemoteChannelContext {
|
|
|
75
84
|
const summarizeResult = await summarizeChannelAsync(channel, fullTree, trackState, telemetryContext, incrementalSummaryContext);
|
|
76
85
|
return Object.assign(Object.assign({}, summarizeResult), { id: this.id });
|
|
77
86
|
}
|
|
78
|
-
async loadChannel() {
|
|
79
|
-
assert(!this.isLoaded, 0x197 /* "Remote channel must not already be loaded when loading" */);
|
|
80
|
-
let attributes;
|
|
81
|
-
if (await this.services.objectStorage.contains(attributesBlobKey)) {
|
|
82
|
-
attributes = await readAndParse(this.services.objectStorage, attributesBlobKey);
|
|
83
|
-
}
|
|
84
|
-
// This is a backward compatibility case where the attach message doesn't include attributes. They must
|
|
85
|
-
// include attach message type.
|
|
86
|
-
// Since old attach messages will not have attributes, we need to keep this as long as we support old attach
|
|
87
|
-
// messages.
|
|
88
|
-
const channelFactoryType = attributes ? attributes.type : this.attachMessageType;
|
|
89
|
-
if (channelFactoryType === undefined) {
|
|
90
|
-
throw new DataCorruptionError("channelTypeNotAvailable", {
|
|
91
|
-
channelId: {
|
|
92
|
-
value: this.id,
|
|
93
|
-
tag: TelemetryDataTag.CodeArtifact,
|
|
94
|
-
},
|
|
95
|
-
dataStoreId: {
|
|
96
|
-
value: this.dataStoreContext.id,
|
|
97
|
-
tag: TelemetryDataTag.CodeArtifact,
|
|
98
|
-
},
|
|
99
|
-
dataStorePackagePath: this.dataStoreContext.packagePath.join("/"),
|
|
100
|
-
channelFactoryType: this.attachMessageType,
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
const factory = this.registry.get(channelFactoryType);
|
|
104
|
-
if (factory === undefined) {
|
|
105
|
-
// TODO: dataStoreId may require a different tag from PackageData #7488
|
|
106
|
-
throw new DataCorruptionError("channelFactoryNotRegisteredForGivenType", {
|
|
107
|
-
channelId: {
|
|
108
|
-
value: this.id,
|
|
109
|
-
tag: TelemetryDataTag.CodeArtifact,
|
|
110
|
-
},
|
|
111
|
-
dataStoreId: {
|
|
112
|
-
value: this.dataStoreContext.id,
|
|
113
|
-
tag: TelemetryDataTag.CodeArtifact,
|
|
114
|
-
},
|
|
115
|
-
dataStorePackagePath: this.dataStoreContext.packagePath.join("/"),
|
|
116
|
-
channelFactoryType,
|
|
117
|
-
});
|
|
118
|
-
}
|
|
119
|
-
// This is a backward compatibility case where the attach message doesn't include attributes. Get the attributes
|
|
120
|
-
// from the factory.
|
|
121
|
-
attributes = attributes !== null && attributes !== void 0 ? attributes : factory.attributes;
|
|
122
|
-
// Compare snapshot version to collaborative object version
|
|
123
|
-
if (attributes.snapshotFormatVersion !== undefined &&
|
|
124
|
-
attributes.snapshotFormatVersion !== factory.attributes.snapshotFormatVersion) {
|
|
125
|
-
this.subLogger.sendTelemetryEvent({
|
|
126
|
-
eventName: "ChannelAttributesVersionMismatch",
|
|
127
|
-
channelType: { value: attributes.type, tag: TelemetryDataTag.CodeArtifact },
|
|
128
|
-
channelSnapshotVersion: {
|
|
129
|
-
value: `${attributes.snapshotFormatVersion}@${attributes.packageVersion}`,
|
|
130
|
-
tag: TelemetryDataTag.CodeArtifact,
|
|
131
|
-
},
|
|
132
|
-
channelCodeVersion: {
|
|
133
|
-
value: `${factory.attributes.snapshotFormatVersion}@${factory.attributes.packageVersion}`,
|
|
134
|
-
tag: TelemetryDataTag.CodeArtifact,
|
|
135
|
-
},
|
|
136
|
-
});
|
|
137
|
-
}
|
|
138
|
-
const channel = await factory.load(this.runtime, this.id, this.services, attributes);
|
|
139
|
-
// Send all pending messages to the channel
|
|
140
|
-
assert(this.pending !== undefined, 0x23f /* "pending undefined" */);
|
|
141
|
-
for (const message of this.pending) {
|
|
142
|
-
this.services.deltaConnection.process(message, false, undefined /* localOpMetadata */);
|
|
143
|
-
}
|
|
144
|
-
this.thresholdOpsCounter.send("ProcessPendingOps", this.pending.length);
|
|
145
|
-
// Commit changes.
|
|
146
|
-
this.channel = channel;
|
|
147
|
-
this.pending = undefined;
|
|
148
|
-
this.isLoaded = true;
|
|
149
|
-
// Because have some await between we created the service and here, the connection state might have changed
|
|
150
|
-
// and we don't propagate the connection state when we are not loaded. So we have to set it again here.
|
|
151
|
-
this.services.deltaConnection.setConnectionState(this.dataStoreContext.connected);
|
|
152
|
-
return this.channel;
|
|
153
|
-
}
|
|
154
87
|
/**
|
|
155
88
|
* Returns the data used for garbage collection. This includes a list of GC nodes that represent this context.
|
|
156
89
|
* Each node has a set of outbound routes to other GC nodes in the document.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"remoteChannelContext.js","sourceRoot":"","sources":["../src/remoteChannelContext.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AACtD,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAQtE,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAY5D,OAAO,EAAE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AI,IAAI,CAAC,OAAO,EAAE;YACnC,IAAI,CAAC,QAAQ,CAAC,eAAe,CAAC,OAAO,CAAC,OAAO,EAAE,KAAK,EAAE,SAAS,CAAC,qBAAqB,CAAC,CAAC;SACvF;QACD,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,mBAAmB,EAAE,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QAExE,kBAAkB;QAClB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,OAAO,GAAG,SAAS,CAAC;QACzB,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;QAErB,2GAA2G;QAC3G,wGAAwG;QACxG,IAAI,CAAC,QAAQ,CAAC,eAAe,CAAC,kBAAkB,CAAC,IAAI,CAAC,gBAAgB,CAAC,SAAS,CAAC,CAAC;QAClF,OAAO,IAAI,CAAC,OAAO,CAAC;IACrB,CAAC;IAED;;;;;;OAMG;IACI,KAAK,CAAC,SAAS,CAAC,SAAkB,KAAK;QAC7C,OAAO,IAAI,CAAC,cAAc,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IAC9C,CAAC;IAED;;;;OAIG;IACK,KAAK,CAAC,iBAAiB,CAAC,SAAkB,KAAK;QACtD,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,UAAU,EAAE,CAAC;QACxC,OAAO,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IAClC,CAAC;IAEM,gBAAgB,CAAC,UAAoB;QAC3C;;;;;WAKG;QACH,IAAI,CAAC,cAAc,CAAC,gBAAgB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAC5C,CAAC;;AArQuB,6CAAwB,GAAG,IAAI,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryLogger } from \"@fluidframework/common-definitions\";\nimport { assert } from \"@fluidframework/common-utils\";\nimport { DataCorruptionError } from \"@fluidframework/container-utils\";\nimport { IFluidHandle } from \"@fluidframework/core-interfaces\";\nimport {\n\tIChannel,\n\tIChannelAttributes,\n\tIFluidDataStoreRuntime,\n} from \"@fluidframework/datastore-definitions\";\nimport { IDocumentStorageService } from \"@fluidframework/driver-definitions\";\nimport { readAndParse } from \"@fluidframework/driver-utils\";\nimport { ISequencedDocumentMessage, ISnapshotTree } from \"@fluidframework/protocol-definitions\";\nimport {\n\tCreateChildSummarizerNodeFn,\n\tIFluidDataStoreContext,\n\tIGarbageCollectionData,\n\tIExperimentalIncrementalSummaryContext,\n\tISummarizeInternalResult,\n\tISummarizeResult,\n\tISummarizerNodeWithGC,\n\tITelemetryContext,\n} from \"@fluidframework/runtime-definitions\";\nimport { ChildLogger, TelemetryDataTag, ThresholdCounter } from \"@fluidframework/telemetry-utils\";\nimport {\n\tattributesBlobKey,\n\tcreateServiceEndpoints,\n\tIChannelContext,\n\tsummarizeChannelAsync,\n} from \"./channelContext\";\nimport { ChannelDeltaConnection } from \"./channelDeltaConnection\";\nimport { ChannelStorageService } from \"./channelStorageService\";\nimport { ISharedObjectRegistry } from \"./dataStoreRuntime\";\n\nexport class RemoteChannelContext implements IChannelContext {\n\tprivate isLoaded = false;\n\tprivate pending: ISequencedDocumentMessage[] | undefined = [];\n\tprivate channelP: Promise<IChannel> | undefined;\n\tprivate channel: IChannel | undefined;\n\tprivate readonly services: {\n\t\treadonly deltaConnection: ChannelDeltaConnection;\n\t\treadonly objectStorage: ChannelStorageService;\n\t};\n\tprivate readonly summarizerNode: ISummarizerNodeWithGC;\n\tprivate readonly subLogger: ITelemetryLogger;\n\tprivate readonly thresholdOpsCounter: ThresholdCounter;\n\tprivate static readonly pendingOpsCountThreshold = 1000;\n\n\tconstructor(\n\t\tprivate readonly runtime: IFluidDataStoreRuntime,\n\t\tprivate readonly dataStoreContext: IFluidDataStoreContext,\n\t\tstorageService: IDocumentStorageService,\n\t\tsubmitFn: (content: any, localOpMetadata: unknown) => void,\n\t\tdirtyFn: (address: string) => void,\n\t\taddedGCOutboundReferenceFn: (srcHandle: IFluidHandle, outboundHandle: IFluidHandle) => void,\n\t\tprivate readonly id: string,\n\t\tbaseSnapshot: ISnapshotTree,\n\t\tprivate readonly registry: ISharedObjectRegistry,\n\t\textraBlobs: Map<string, ArrayBufferLike> | undefined,\n\t\tcreateSummarizerNode: CreateChildSummarizerNodeFn,\n\t\tprivate readonly attachMessageType?: string,\n\t) {\n\t\tassert(!this.id.includes(\"/\"), 0x310 /* Channel context ID cannot contain slashes */);\n\n\t\tthis.subLogger = ChildLogger.create(this.runtime.logger, \"RemoteChannelContext\");\n\n\t\tthis.services = createServiceEndpoints(\n\t\t\tthis.id,\n\t\t\tthis.dataStoreContext.connected,\n\t\t\tsubmitFn,\n\t\t\t() => dirtyFn(this.id),\n\t\t\taddedGCOutboundReferenceFn,\n\t\t\tstorageService,\n\t\t\tthis.subLogger,\n\t\t\tbaseSnapshot,\n\t\t\textraBlobs,\n\t\t);\n\n\t\tconst thisSummarizeInternal = async (\n\t\t\tfullTree: boolean,\n\t\t\ttrackState: boolean,\n\t\t\ttelemetryContext?: ITelemetryContext,\n\t\t\tincrementalSummaryContext?: IExperimentalIncrementalSummaryContext,\n\t\t) =>\n\t\t\tthis.summarizeInternal(\n\t\t\t\tfullTree,\n\t\t\t\ttrackState,\n\t\t\t\ttelemetryContext,\n\t\t\t\tincrementalSummaryContext,\n\t\t\t);\n\n\t\tthis.summarizerNode = createSummarizerNode(\n\t\t\tthisSummarizeInternal,\n\t\t\tasync (fullGC?: boolean) => this.getGCDataInternal(fullGC),\n\t\t);\n\n\t\tthis.thresholdOpsCounter = new ThresholdCounter(\n\t\t\tRemoteChannelContext.pendingOpsCountThreshold,\n\t\t\tthis.subLogger,\n\t\t);\n\t}\n\n\t// eslint-disable-next-line @typescript-eslint/promise-function-async\n\tpublic getChannel(): Promise<IChannel> {\n\t\tif (this.channelP === undefined) {\n\t\t\tthis.channelP = this.loadChannel();\n\t\t}\n\n\t\treturn this.channelP;\n\t}\n\n\tpublic setConnectionState(connected: boolean, clientId?: string) {\n\t\t// Connection events are ignored if the data store is not yet loaded\n\t\tif (!this.isLoaded) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.services.deltaConnection.setConnectionState(connected);\n\t}\n\n\tpublic applyStashedOp(message: ISequencedDocumentMessage): unknown {\n\t\tassert(this.isLoaded, 0x194 /* \"Remote channel must be loaded when rebasing op\" */);\n\t\treturn this.services.deltaConnection.applyStashedOp(message);\n\t}\n\n\tpublic processOp(\n\t\tmessage: ISequencedDocumentMessage,\n\t\tlocal: boolean,\n\t\tlocalOpMetadata: unknown,\n\t): void {\n\t\tthis.summarizerNode.invalidate(message.sequenceNumber);\n\n\t\tif (this.isLoaded) {\n\t\t\tthis.services.deltaConnection.process(message, local, localOpMetadata);\n\t\t} else {\n\t\t\tassert(!local, 0x195 /* \"Remote channel must not be local when processing op\" */);\n\t\t\tassert(this.pending !== undefined, 0x23e /* \"pending is undefined\" */);\n\t\t\tthis.pending.push(message);\n\t\t\tthis.thresholdOpsCounter.sendIfMultiple(\"StorePendingOps\", this.pending.length);\n\t\t}\n\t}\n\n\tpublic reSubmit(content: any, localOpMetadata: unknown) {\n\t\tassert(this.isLoaded, 0x196 /* \"Remote channel must be loaded when resubmitting op\" */);\n\n\t\tthis.services.deltaConnection.reSubmit(content, localOpMetadata);\n\t}\n\n\tpublic rollback(content: any, localOpMetadata: unknown) {\n\t\tassert(this.isLoaded, 0x2f0 /* \"Remote channel must be loaded when rolling back op\" */);\n\n\t\tthis.services.deltaConnection.rollback(content, localOpMetadata);\n\t}\n\n\t/**\n\t * Returns a summary at the current sequence number.\n\t * @param fullTree - true to bypass optimizations and force a full summary tree\n\t * @param trackState - This tells whether we should track state from this summary.\n\t * @param telemetryContext - summary data passed through the layers for telemetry purposes\n\t */\n\tpublic async summarize(\n\t\tfullTree: boolean = false,\n\t\ttrackState: boolean = true,\n\t\ttelemetryContext?: ITelemetryContext,\n\t): Promise<ISummarizeResult> {\n\t\treturn this.summarizerNode.summarize(fullTree, trackState, telemetryContext);\n\t}\n\n\tprivate async summarizeInternal(\n\t\tfullTree: boolean,\n\t\ttrackState: boolean,\n\t\ttelemetryContext?: ITelemetryContext,\n\t\tincrementalSummaryContext?: IExperimentalIncrementalSummaryContext,\n\t): Promise<ISummarizeInternalResult> {\n\t\tconst channel = await this.getChannel();\n\t\tconst summarizeResult = await summarizeChannelAsync(\n\t\t\tchannel,\n\t\t\tfullTree,\n\t\t\ttrackState,\n\t\t\ttelemetryContext,\n\t\t\tincrementalSummaryContext,\n\t\t);\n\t\treturn { ...summarizeResult, id: this.id };\n\t}\n\n\tprivate async loadChannel(): Promise<IChannel> {\n\t\tassert(\n\t\t\t!this.isLoaded,\n\t\t\t0x197 /* \"Remote channel must not already be loaded when loading\" */,\n\t\t);\n\n\t\tlet attributes: IChannelAttributes | undefined;\n\t\tif (await this.services.objectStorage.contains(attributesBlobKey)) {\n\t\t\tattributes = await readAndParse<IChannelAttributes | undefined>(\n\t\t\t\tthis.services.objectStorage,\n\t\t\t\tattributesBlobKey,\n\t\t\t);\n\t\t}\n\n\t\t// This is a backward compatibility case where the attach message doesn't include attributes. They must\n\t\t// include attach message type.\n\t\t// Since old attach messages will not have attributes, we need to keep this as long as we support old attach\n\t\t// messages.\n\t\tconst channelFactoryType = attributes ? attributes.type : this.attachMessageType;\n\t\tif (channelFactoryType === undefined) {\n\t\t\tthrow new DataCorruptionError(\"channelTypeNotAvailable\", {\n\t\t\t\tchannelId: {\n\t\t\t\t\tvalue: this.id,\n\t\t\t\t\ttag: TelemetryDataTag.CodeArtifact,\n\t\t\t\t},\n\t\t\t\tdataStoreId: {\n\t\t\t\t\tvalue: this.dataStoreContext.id,\n\t\t\t\t\ttag: TelemetryDataTag.CodeArtifact,\n\t\t\t\t},\n\t\t\t\tdataStorePackagePath: this.dataStoreContext.packagePath.join(\"/\"),\n\t\t\t\tchannelFactoryType: this.attachMessageType,\n\t\t\t});\n\t\t}\n\t\tconst factory = this.registry.get(channelFactoryType);\n\t\tif (factory === undefined) {\n\t\t\t// TODO: dataStoreId may require a different tag from PackageData #7488\n\t\t\tthrow new DataCorruptionError(\"channelFactoryNotRegisteredForGivenType\", {\n\t\t\t\tchannelId: {\n\t\t\t\t\tvalue: this.id,\n\t\t\t\t\ttag: TelemetryDataTag.CodeArtifact,\n\t\t\t\t},\n\t\t\t\tdataStoreId: {\n\t\t\t\t\tvalue: this.dataStoreContext.id,\n\t\t\t\t\ttag: TelemetryDataTag.CodeArtifact,\n\t\t\t\t},\n\t\t\t\tdataStorePackagePath: this.dataStoreContext.packagePath.join(\"/\"),\n\t\t\t\tchannelFactoryType,\n\t\t\t});\n\t\t}\n\n\t\t// This is a backward compatibility case where the attach message doesn't include attributes. Get the attributes\n\t\t// from the factory.\n\t\tattributes = attributes ?? factory.attributes;\n\n\t\t// Compare snapshot version to collaborative object version\n\t\tif (\n\t\t\tattributes.snapshotFormatVersion !== undefined &&\n\t\t\tattributes.snapshotFormatVersion !== factory.attributes.snapshotFormatVersion\n\t\t) {\n\t\t\tthis.subLogger.sendTelemetryEvent({\n\t\t\t\teventName: \"ChannelAttributesVersionMismatch\",\n\t\t\t\tchannelType: { value: attributes.type, tag: TelemetryDataTag.CodeArtifact },\n\t\t\t\tchannelSnapshotVersion: {\n\t\t\t\t\tvalue: `${attributes.snapshotFormatVersion}@${attributes.packageVersion}`,\n\t\t\t\t\ttag: TelemetryDataTag.CodeArtifact,\n\t\t\t\t},\n\t\t\t\tchannelCodeVersion: {\n\t\t\t\t\tvalue: `${factory.attributes.snapshotFormatVersion}@${factory.attributes.packageVersion}`,\n\t\t\t\t\ttag: TelemetryDataTag.CodeArtifact,\n\t\t\t\t},\n\t\t\t});\n\t\t}\n\n\t\tconst channel = await factory.load(this.runtime, this.id, this.services, attributes);\n\n\t\t// Send all pending messages to the channel\n\t\tassert(this.pending !== undefined, 0x23f /* \"pending undefined\" */);\n\t\tfor (const message of this.pending) {\n\t\t\tthis.services.deltaConnection.process(message, false, undefined /* localOpMetadata */);\n\t\t}\n\t\tthis.thresholdOpsCounter.send(\"ProcessPendingOps\", this.pending.length);\n\n\t\t// Commit changes.\n\t\tthis.channel = channel;\n\t\tthis.pending = undefined;\n\t\tthis.isLoaded = true;\n\n\t\t// Because have some await between we created the service and here, the connection state might have changed\n\t\t// and we don't propagate the connection state when we are not loaded. So we have to set it again here.\n\t\tthis.services.deltaConnection.setConnectionState(this.dataStoreContext.connected);\n\t\treturn this.channel;\n\t}\n\n\t/**\n\t * Returns the data used for garbage collection. This includes a list of GC nodes that represent this context.\n\t * Each node has a set of outbound routes to other GC nodes in the document.\n\t * If there is no new data in this context since the last summary, previous GC data is used.\n\t * If there is new data, the GC data is generated again (by calling getGCDataInternal).\n\t * @param fullGC - true to bypass optimizations and force full generation of GC data.\n\t */\n\tpublic async getGCData(fullGC: boolean = false): Promise<IGarbageCollectionData> {\n\t\treturn this.summarizerNode.getGCData(fullGC);\n\t}\n\n\t/**\n\t * Generates the data used for garbage collection. This is called when there is new data since last summary. It\n\t * loads the context and calls into the channel to get its GC data.\n\t * @param fullGC - true to bypass optimizations and force full generation of GC data.\n\t */\n\tprivate async getGCDataInternal(fullGC: boolean = false): Promise<IGarbageCollectionData> {\n\t\tconst channel = await this.getChannel();\n\t\treturn channel.getGCData(fullGC);\n\t}\n\n\tpublic updateUsedRoutes(usedRoutes: string[]) {\n\t\t/**\n\t\t * Currently, DDSes are always considered referenced and are not garbage collected. Update the summarizer node's\n\t\t * used routes to contain a route to this channel context.\n\t\t * Once we have GC at DDS level, this will be updated to use the passed usedRoutes. See -\n\t\t * https://github.com/microsoft/FluidFramework/issues/4611\n\t\t */\n\t\tthis.summarizerNode.updateUsedRoutes([\"\"]);\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"remoteChannelContext.js","sourceRoot":"","sources":["../src/remoteChannelContext.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,8BA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,CAAC;;AA3MuB,6CAAwB,GAAG,IAAI,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryLogger } from \"@fluidframework/common-definitions\";\nimport { LazyPromise, assert } from \"@fluidframework/common-utils\";\nimport { IFluidHandle } from \"@fluidframework/core-interfaces\";\nimport { IChannel, IFluidDataStoreRuntime } from \"@fluidframework/datastore-definitions\";\nimport { IDocumentStorageService } from \"@fluidframework/driver-definitions\";\nimport { ISequencedDocumentMessage, ISnapshotTree } from \"@fluidframework/protocol-definitions\";\nimport {\n\tCreateChildSummarizerNodeFn,\n\tIFluidDataStoreContext,\n\tIGarbageCollectionData,\n\tIExperimentalIncrementalSummaryContext,\n\tISummarizeInternalResult,\n\tISummarizeResult,\n\tISummarizerNodeWithGC,\n\tITelemetryContext,\n} from \"@fluidframework/runtime-definitions\";\nimport { ChildLogger, ThresholdCounter } from \"@fluidframework/telemetry-utils\";\nimport {\n\tChannelServiceEndpoints,\n\tcreateChannelServiceEndpoints,\n\tIChannelContext,\n\tloadChannel,\n\tloadChannelFactoryAndAttributes,\n\tsummarizeChannelAsync,\n} from \"./channelContext\";\nimport { ISharedObjectRegistry } from \"./dataStoreRuntime\";\n\nexport class RemoteChannelContext implements IChannelContext {\n\tprivate isLoaded = false;\n\tprivate pending: ISequencedDocumentMessage[] | undefined = [];\n\tprivate readonly channelP: Promise<IChannel>;\n\tprivate channel: IChannel | undefined;\n\tprivate readonly services: ChannelServiceEndpoints;\n\tprivate readonly summarizerNode: ISummarizerNodeWithGC;\n\tprivate readonly subLogger: ITelemetryLogger;\n\tprivate readonly thresholdOpsCounter: ThresholdCounter;\n\tprivate static readonly pendingOpsCountThreshold = 1000;\n\n\tconstructor(\n\t\truntime: IFluidDataStoreRuntime,\n\t\tdataStoreContext: IFluidDataStoreContext,\n\t\tstorageService: IDocumentStorageService,\n\t\tsubmitFn: (content: any, localOpMetadata: unknown) => void,\n\t\tdirtyFn: (address: string) => void,\n\t\taddedGCOutboundReferenceFn: (srcHandle: IFluidHandle, outboundHandle: IFluidHandle) => void,\n\t\tprivate readonly id: string,\n\t\tbaseSnapshot: ISnapshotTree,\n\t\tregistry: ISharedObjectRegistry,\n\t\textraBlobs: Map<string, ArrayBufferLike> | undefined,\n\t\tcreateSummarizerNode: CreateChildSummarizerNodeFn,\n\t\tattachMessageType?: string,\n\t) {\n\t\tassert(!this.id.includes(\"/\"), 0x310 /* Channel context ID cannot contain slashes */);\n\n\t\tthis.subLogger = ChildLogger.create(runtime.logger, \"RemoteChannelContext\");\n\n\t\tthis.services = createChannelServiceEndpoints(\n\t\t\tdataStoreContext.connected,\n\t\t\tsubmitFn,\n\t\t\t() => dirtyFn(this.id),\n\t\t\taddedGCOutboundReferenceFn,\n\t\t\tstorageService,\n\t\t\tthis.subLogger,\n\t\t\tbaseSnapshot,\n\t\t\textraBlobs,\n\t\t);\n\n\t\tthis.channelP = new LazyPromise<IChannel>(async () => {\n\t\t\tconst { attributes, factory } = await loadChannelFactoryAndAttributes(\n\t\t\t\tdataStoreContext,\n\t\t\t\tthis.services,\n\t\t\t\tthis.id,\n\t\t\t\tregistry,\n\t\t\t\tattachMessageType,\n\t\t\t);\n\n\t\t\tconst channel = await loadChannel(\n\t\t\t\truntime,\n\t\t\t\tattributes,\n\t\t\t\tfactory,\n\t\t\t\tthis.services,\n\t\t\t\tthis.subLogger,\n\t\t\t\tthis.id,\n\t\t\t);\n\n\t\t\t// Send all pending messages to the channel\n\t\t\tassert(this.pending !== undefined, 0x23f /* \"pending undefined\" */);\n\t\t\tfor (const message of this.pending) {\n\t\t\t\tthis.services.deltaConnection.process(\n\t\t\t\t\tmessage,\n\t\t\t\t\tfalse,\n\t\t\t\t\tundefined /* localOpMetadata */,\n\t\t\t\t);\n\t\t\t}\n\t\t\tthis.thresholdOpsCounter.send(\"ProcessPendingOps\", this.pending.length);\n\n\t\t\t// Commit changes.\n\t\t\tthis.channel = channel;\n\t\t\tthis.pending = undefined;\n\t\t\tthis.isLoaded = true;\n\n\t\t\t// Because have some await between we created the service and here, the connection state might have changed\n\t\t\t// and we don't propagate the connection state when we are not loaded. So we have to set it again here.\n\t\t\tthis.services.deltaConnection.setConnectionState(dataStoreContext.connected);\n\t\t\treturn this.channel;\n\t\t});\n\n\t\tconst thisSummarizeInternal = async (\n\t\t\tfullTree: boolean,\n\t\t\ttrackState: boolean,\n\t\t\ttelemetryContext?: ITelemetryContext,\n\t\t\tincrementalSummaryContext?: IExperimentalIncrementalSummaryContext,\n\t\t) =>\n\t\t\tthis.summarizeInternal(\n\t\t\t\tfullTree,\n\t\t\t\ttrackState,\n\t\t\t\ttelemetryContext,\n\t\t\t\tincrementalSummaryContext,\n\t\t\t);\n\n\t\tthis.summarizerNode = createSummarizerNode(\n\t\t\tthisSummarizeInternal,\n\t\t\tasync (fullGC?: boolean) => this.getGCDataInternal(fullGC),\n\t\t);\n\n\t\tthis.thresholdOpsCounter = new ThresholdCounter(\n\t\t\tRemoteChannelContext.pendingOpsCountThreshold,\n\t\t\tthis.subLogger,\n\t\t);\n\t}\n\n\t// eslint-disable-next-line @typescript-eslint/promise-function-async\n\tpublic getChannel(): Promise<IChannel> {\n\t\treturn this.channelP;\n\t}\n\n\tpublic setConnectionState(connected: boolean, clientId?: string) {\n\t\t// Connection events are ignored if the data store is not yet loaded\n\t\tif (!this.isLoaded) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.services.deltaConnection.setConnectionState(connected);\n\t}\n\n\tpublic applyStashedOp(content: any): unknown {\n\t\tassert(this.isLoaded, 0x194 /* \"Remote channel must be loaded when rebasing op\" */);\n\t\treturn this.services.deltaConnection.applyStashedOp(content);\n\t}\n\n\tpublic processOp(\n\t\tmessage: ISequencedDocumentMessage,\n\t\tlocal: boolean,\n\t\tlocalOpMetadata: unknown,\n\t): void {\n\t\tthis.summarizerNode.invalidate(message.sequenceNumber);\n\n\t\tif (this.isLoaded) {\n\t\t\tthis.services.deltaConnection.process(message, local, localOpMetadata);\n\t\t} else {\n\t\t\tassert(!local, 0x195 /* \"Remote channel must not be local when processing op\" */);\n\t\t\tassert(this.pending !== undefined, 0x23e /* \"pending is undefined\" */);\n\t\t\tthis.pending.push(message);\n\t\t\tthis.thresholdOpsCounter.sendIfMultiple(\"StorePendingOps\", this.pending.length);\n\t\t}\n\t}\n\n\tpublic reSubmit(content: any, localOpMetadata: unknown) {\n\t\tassert(this.isLoaded, 0x196 /* \"Remote channel must be loaded when resubmitting op\" */);\n\n\t\tthis.services.deltaConnection.reSubmit(content, localOpMetadata);\n\t}\n\n\tpublic rollback(content: any, localOpMetadata: unknown) {\n\t\tassert(this.isLoaded, 0x2f0 /* \"Remote channel must be loaded when rolling back op\" */);\n\n\t\tthis.services.deltaConnection.rollback(content, localOpMetadata);\n\t}\n\n\t/**\n\t * Returns a summary at the current sequence number.\n\t * @param fullTree - true to bypass optimizations and force a full summary tree\n\t * @param trackState - This tells whether we should track state from this summary.\n\t * @param telemetryContext - summary data passed through the layers for telemetry purposes\n\t */\n\tpublic async summarize(\n\t\tfullTree: boolean = false,\n\t\ttrackState: boolean = true,\n\t\ttelemetryContext?: ITelemetryContext,\n\t): Promise<ISummarizeResult> {\n\t\treturn this.summarizerNode.summarize(fullTree, trackState, telemetryContext);\n\t}\n\n\tprivate async summarizeInternal(\n\t\tfullTree: boolean,\n\t\ttrackState: boolean,\n\t\ttelemetryContext?: ITelemetryContext,\n\t\tincrementalSummaryContext?: IExperimentalIncrementalSummaryContext,\n\t): Promise<ISummarizeInternalResult> {\n\t\tconst channel = await this.getChannel();\n\t\tconst summarizeResult = await summarizeChannelAsync(\n\t\t\tchannel,\n\t\t\tfullTree,\n\t\t\ttrackState,\n\t\t\ttelemetryContext,\n\t\t\tincrementalSummaryContext,\n\t\t);\n\t\treturn { ...summarizeResult, id: this.id };\n\t}\n\n\t/**\n\t * Returns the data used for garbage collection. This includes a list of GC nodes that represent this context.\n\t * Each node has a set of outbound routes to other GC nodes in the document.\n\t * If there is no new data in this context since the last summary, previous GC data is used.\n\t * If there is new data, the GC data is generated again (by calling getGCDataInternal).\n\t * @param fullGC - true to bypass optimizations and force full generation of GC data.\n\t */\n\tpublic async getGCData(fullGC: boolean = false): Promise<IGarbageCollectionData> {\n\t\treturn this.summarizerNode.getGCData(fullGC);\n\t}\n\n\t/**\n\t * Generates the data used for garbage collection. This is called when there is new data since last summary. It\n\t * loads the context and calls into the channel to get its GC data.\n\t * @param fullGC - true to bypass optimizations and force full generation of GC data.\n\t */\n\tprivate async getGCDataInternal(fullGC: boolean = false): Promise<IGarbageCollectionData> {\n\t\tconst channel = await this.getChannel();\n\t\treturn channel.getGCData(fullGC);\n\t}\n\n\tpublic updateUsedRoutes(usedRoutes: string[]) {\n\t\t/**\n\t\t * Currently, DDSes are always considered referenced and are not garbage collected. Update the summarizer node's\n\t\t * used routes to contain a route to this channel context.\n\t\t * Once we have GC at DDS level, this will be updated to use the passed usedRoutes. See -\n\t\t * https://github.com/microsoft/FluidFramework/issues/4611\n\t\t */\n\t\tthis.summarizerNode.updateUsedRoutes([\"\"]);\n\t}\n}\n"]}
|