@fluidframework/datastore 2.0.0-internal.3.0.5 → 2.0.0-internal.3.1.1
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/.eslintrc.js +5 -7
- package/.mocharc.js +2 -2
- package/README.md +3 -0
- package/api-extractor.json +2 -2
- package/dist/channelContext.d.ts.map +1 -1
- package/dist/channelContext.js.map +1 -1
- package/dist/channelDeltaConnection.d.ts.map +1 -1
- package/dist/channelDeltaConnection.js.map +1 -1
- package/dist/channelStorageService.d.ts.map +1 -1
- package/dist/channelStorageService.js +1 -3
- package/dist/channelStorageService.js.map +1 -1
- package/dist/dataStoreRuntime.d.ts +11 -24
- package/dist/dataStoreRuntime.d.ts.map +1 -1
- package/dist/dataStoreRuntime.js +68 -86
- package/dist/dataStoreRuntime.js.map +1 -1
- package/dist/fluidHandle.d.ts.map +1 -1
- package/dist/fluidHandle.js.map +1 -1
- package/dist/localChannelContext.d.ts.map +1 -1
- package/dist/localChannelContext.js +9 -5
- package/dist/localChannelContext.js.map +1 -1
- package/dist/localChannelStorageService.d.ts.map +1 -1
- package/dist/localChannelStorageService.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/remoteChannelContext.d.ts.map +1 -1
- package/dist/remoteChannelContext.js +2 -2
- package/dist/remoteChannelContext.js.map +1 -1
- package/lib/channelContext.d.ts.map +1 -1
- package/lib/channelContext.js.map +1 -1
- package/lib/channelDeltaConnection.d.ts.map +1 -1
- package/lib/channelDeltaConnection.js.map +1 -1
- package/lib/channelStorageService.d.ts.map +1 -1
- package/lib/channelStorageService.js +1 -3
- package/lib/channelStorageService.js.map +1 -1
- package/lib/dataStoreRuntime.d.ts +11 -24
- package/lib/dataStoreRuntime.d.ts.map +1 -1
- package/lib/dataStoreRuntime.js +71 -89
- package/lib/dataStoreRuntime.js.map +1 -1
- package/lib/fluidHandle.d.ts.map +1 -1
- package/lib/fluidHandle.js.map +1 -1
- package/lib/localChannelContext.d.ts.map +1 -1
- package/lib/localChannelContext.js +9 -5
- package/lib/localChannelContext.js.map +1 -1
- package/lib/localChannelStorageService.d.ts.map +1 -1
- package/lib/localChannelStorageService.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/remoteChannelContext.d.ts.map +1 -1
- package/lib/remoteChannelContext.js +2 -2
- package/lib/remoteChannelContext.js.map +1 -1
- package/package.json +111 -110
- package/prettier.config.cjs +1 -1
- package/src/channelContext.ts +66 -65
- package/src/channelDeltaConnection.ts +50 -44
- package/src/channelStorageService.ts +58 -54
- package/src/dataStoreRuntime.ts +1122 -1086
- package/src/fluidHandle.ts +87 -91
- package/src/localChannelContext.ts +302 -255
- package/src/localChannelStorageService.ts +47 -45
- package/src/packageVersion.ts +1 -1
- package/src/remoteChannelContext.ts +300 -291
- package/tsconfig.esnext.json +6 -6
- package/tsconfig.json +9 -13
|
@@ -8,308 +8,317 @@ import { assert } from "@fluidframework/common-utils";
|
|
|
8
8
|
import { DataCorruptionError } from "@fluidframework/container-utils";
|
|
9
9
|
import { IFluidHandle } from "@fluidframework/core-interfaces";
|
|
10
10
|
import {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
IChannel,
|
|
12
|
+
IChannelAttributes,
|
|
13
|
+
IFluidDataStoreRuntime,
|
|
14
|
+
IChannelFactory,
|
|
15
15
|
} from "@fluidframework/datastore-definitions";
|
|
16
16
|
import { IDocumentStorageService } from "@fluidframework/driver-definitions";
|
|
17
17
|
import { readAndParse } from "@fluidframework/driver-utils";
|
|
18
|
+
import { ISequencedDocumentMessage, ISnapshotTree } from "@fluidframework/protocol-definitions";
|
|
18
19
|
import {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
ISummarizeInternalResult,
|
|
28
|
-
ISummarizeResult,
|
|
29
|
-
ISummarizerNodeWithGC,
|
|
30
|
-
ITelemetryContext,
|
|
20
|
+
CreateChildSummarizerNodeFn,
|
|
21
|
+
IFluidDataStoreContext,
|
|
22
|
+
IGarbageCollectionData,
|
|
23
|
+
IGarbageCollectionDetailsBase,
|
|
24
|
+
ISummarizeInternalResult,
|
|
25
|
+
ISummarizeResult,
|
|
26
|
+
ISummarizerNodeWithGC,
|
|
27
|
+
ITelemetryContext,
|
|
31
28
|
} from "@fluidframework/runtime-definitions";
|
|
32
29
|
import { ChildLogger, TelemetryDataTag, ThresholdCounter } from "@fluidframework/telemetry-utils";
|
|
33
30
|
import {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
31
|
+
attributesBlobKey,
|
|
32
|
+
createServiceEndpoints,
|
|
33
|
+
IChannelContext,
|
|
34
|
+
summarizeChannelAsync,
|
|
38
35
|
} from "./channelContext";
|
|
39
36
|
import { ChannelDeltaConnection } from "./channelDeltaConnection";
|
|
40
37
|
import { ChannelStorageService } from "./channelStorageService";
|
|
41
38
|
import { ISharedObjectRegistry } from "./dataStoreRuntime";
|
|
42
39
|
|
|
43
40
|
export class RemoteChannelContext implements IChannelContext {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
41
|
+
private isLoaded = false;
|
|
42
|
+
private pending: ISequencedDocumentMessage[] | undefined = [];
|
|
43
|
+
private channelP: Promise<IChannel> | undefined;
|
|
44
|
+
private channel: IChannel | undefined;
|
|
45
|
+
private readonly services: {
|
|
46
|
+
readonly deltaConnection: ChannelDeltaConnection;
|
|
47
|
+
readonly objectStorage: ChannelStorageService;
|
|
48
|
+
};
|
|
49
|
+
private readonly summarizerNode: ISummarizerNodeWithGC;
|
|
50
|
+
private readonly subLogger: ITelemetryLogger;
|
|
51
|
+
private readonly thresholdOpsCounter: ThresholdCounter;
|
|
52
|
+
private static readonly pendingOpsCountThreshold = 1000;
|
|
53
|
+
|
|
54
|
+
constructor(
|
|
55
|
+
private readonly runtime: IFluidDataStoreRuntime,
|
|
56
|
+
private readonly dataStoreContext: IFluidDataStoreContext,
|
|
57
|
+
storageService: IDocumentStorageService,
|
|
58
|
+
submitFn: (content: any, localOpMetadata: unknown) => void,
|
|
59
|
+
dirtyFn: (address: string) => void,
|
|
60
|
+
addedGCOutboundReferenceFn: (srcHandle: IFluidHandle, outboundHandle: IFluidHandle) => void,
|
|
61
|
+
private readonly id: string,
|
|
62
|
+
baseSnapshot: ISnapshotTree,
|
|
63
|
+
private readonly registry: ISharedObjectRegistry,
|
|
64
|
+
extraBlobs: Map<string, ArrayBufferLike> | undefined,
|
|
65
|
+
createSummarizerNode: CreateChildSummarizerNodeFn,
|
|
66
|
+
getBaseGCDetails: () => Promise<IGarbageCollectionDetailsBase>,
|
|
67
|
+
private readonly attachMessageType?: string,
|
|
68
|
+
) {
|
|
69
|
+
assert(!this.id.includes("/"), 0x310 /* Channel context ID cannot contain slashes */);
|
|
70
|
+
|
|
71
|
+
this.subLogger = ChildLogger.create(this.runtime.logger, "RemoteChannelContext");
|
|
72
|
+
|
|
73
|
+
this.services = createServiceEndpoints(
|
|
74
|
+
this.id,
|
|
75
|
+
this.dataStoreContext.connected,
|
|
76
|
+
submitFn,
|
|
77
|
+
() => dirtyFn(this.id),
|
|
78
|
+
addedGCOutboundReferenceFn,
|
|
79
|
+
storageService,
|
|
80
|
+
this.subLogger,
|
|
81
|
+
baseSnapshot,
|
|
82
|
+
extraBlobs,
|
|
83
|
+
);
|
|
84
|
+
|
|
85
|
+
const thisSummarizeInternal = async (
|
|
86
|
+
fullTree: boolean,
|
|
87
|
+
trackState: boolean,
|
|
88
|
+
telemetryContext?: ITelemetryContext,
|
|
89
|
+
) => this.summarizeInternal(fullTree, trackState, telemetryContext);
|
|
90
|
+
|
|
91
|
+
this.summarizerNode = createSummarizerNode(
|
|
92
|
+
thisSummarizeInternal,
|
|
93
|
+
async (fullGC?: boolean) => this.getGCDataInternal(fullGC),
|
|
94
|
+
async () => getBaseGCDetails(),
|
|
95
|
+
);
|
|
96
|
+
|
|
97
|
+
this.thresholdOpsCounter = new ThresholdCounter(
|
|
98
|
+
RemoteChannelContext.pendingOpsCountThreshold,
|
|
99
|
+
this.subLogger,
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// eslint-disable-next-line @typescript-eslint/promise-function-async
|
|
104
|
+
public getChannel(): Promise<IChannel> {
|
|
105
|
+
if (this.channelP === undefined) {
|
|
106
|
+
this.channelP = this.loadChannel();
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
return this.channelP;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
public setConnectionState(connected: boolean, clientId?: string) {
|
|
113
|
+
// Connection events are ignored if the data store is not yet loaded
|
|
114
|
+
if (!this.isLoaded) {
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
this.services.deltaConnection.setConnectionState(connected);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
public applyStashedOp(message: ISequencedDocumentMessage): unknown {
|
|
122
|
+
assert(this.isLoaded, 0x194 /* "Remote channel must be loaded when rebasing op" */);
|
|
123
|
+
return this.services.deltaConnection.applyStashedOp(message);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
public processOp(
|
|
127
|
+
message: ISequencedDocumentMessage,
|
|
128
|
+
local: boolean,
|
|
129
|
+
localOpMetadata: unknown,
|
|
130
|
+
): void {
|
|
131
|
+
this.summarizerNode.invalidate(message.sequenceNumber);
|
|
132
|
+
|
|
133
|
+
if (this.isLoaded) {
|
|
134
|
+
this.services.deltaConnection.process(message, local, localOpMetadata);
|
|
135
|
+
} else {
|
|
136
|
+
assert(!local, 0x195 /* "Remote channel must not be local when processing op" */);
|
|
137
|
+
assert(this.pending !== undefined, 0x23e /* "pending is undefined" */);
|
|
138
|
+
this.pending.push(message);
|
|
139
|
+
this.thresholdOpsCounter.sendIfMultiple("StorePendingOps", this.pending.length);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
public reSubmit(content: any, localOpMetadata: unknown) {
|
|
144
|
+
assert(this.isLoaded, 0x196 /* "Remote channel must be loaded when resubmitting op" */);
|
|
145
|
+
|
|
146
|
+
this.services.deltaConnection.reSubmit(content, localOpMetadata);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
public rollback(content: any, localOpMetadata: unknown) {
|
|
150
|
+
assert(this.isLoaded, 0x2f0 /* "Remote channel must be loaded when rolling back op" */);
|
|
151
|
+
|
|
152
|
+
this.services.deltaConnection.rollback(content, localOpMetadata);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Returns a summary at the current sequence number.
|
|
157
|
+
* @param fullTree - true to bypass optimizations and force a full summary tree
|
|
158
|
+
* @param trackState - This tells whether we should track state from this summary.
|
|
159
|
+
* @param telemetryContext - summary data passed through the layers for telemetry purposes
|
|
160
|
+
*/
|
|
161
|
+
public async summarize(
|
|
162
|
+
fullTree: boolean = false,
|
|
163
|
+
trackState: boolean = true,
|
|
164
|
+
telemetryContext?: ITelemetryContext,
|
|
165
|
+
): Promise<ISummarizeResult> {
|
|
166
|
+
return this.summarizerNode.summarize(fullTree, trackState, telemetryContext);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
private async summarizeInternal(
|
|
170
|
+
fullTree: boolean,
|
|
171
|
+
trackState: boolean,
|
|
172
|
+
telemetryContext?: ITelemetryContext,
|
|
173
|
+
): Promise<ISummarizeInternalResult> {
|
|
174
|
+
const channel = await this.getChannel();
|
|
175
|
+
const summarizeResult = await summarizeChannelAsync(
|
|
176
|
+
channel,
|
|
177
|
+
fullTree,
|
|
178
|
+
trackState,
|
|
179
|
+
telemetryContext,
|
|
180
|
+
);
|
|
181
|
+
return { ...summarizeResult, id: this.id };
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
private async loadChannel(): Promise<IChannel> {
|
|
185
|
+
assert(
|
|
186
|
+
!this.isLoaded,
|
|
187
|
+
0x197 /* "Remote channel must not already be loaded when loading" */,
|
|
188
|
+
);
|
|
189
|
+
|
|
190
|
+
let attributes: IChannelAttributes | undefined;
|
|
191
|
+
if (await this.services.objectStorage.contains(attributesBlobKey)) {
|
|
192
|
+
attributes = await readAndParse<IChannelAttributes | undefined>(
|
|
193
|
+
this.services.objectStorage,
|
|
194
|
+
attributesBlobKey,
|
|
195
|
+
);
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
let factory: IChannelFactory | undefined;
|
|
199
|
+
// this is a backward compatibility case where
|
|
200
|
+
// the attach message doesn't include
|
|
201
|
+
// the attributes. Since old attach messages
|
|
202
|
+
// will not have attributes we need to keep
|
|
203
|
+
// this as long as we support old attach messages
|
|
204
|
+
if (attributes === undefined) {
|
|
205
|
+
if (this.attachMessageType === undefined) {
|
|
206
|
+
// TODO: dataStoreId may require a different tag from PackageData #7488
|
|
207
|
+
throw new DataCorruptionError("channelTypeNotAvailable", {
|
|
208
|
+
channelId: {
|
|
209
|
+
value: this.id,
|
|
210
|
+
tag: TelemetryDataTag.CodeArtifact,
|
|
211
|
+
},
|
|
212
|
+
dataStoreId: {
|
|
213
|
+
value: this.dataStoreContext.id,
|
|
214
|
+
tag: TelemetryDataTag.CodeArtifact,
|
|
215
|
+
},
|
|
216
|
+
dataStorePackagePath: this.dataStoreContext.packagePath.join("/"),
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
factory = this.registry.get(this.attachMessageType);
|
|
220
|
+
if (factory === undefined) {
|
|
221
|
+
// TODO: dataStoreId may require a different tag from PackageData #7488
|
|
222
|
+
throw new DataCorruptionError("channelFactoryNotRegisteredForAttachMessageType", {
|
|
223
|
+
channelId: {
|
|
224
|
+
value: this.id,
|
|
225
|
+
tag: TelemetryDataTag.CodeArtifact,
|
|
226
|
+
},
|
|
227
|
+
dataStoreId: {
|
|
228
|
+
value: this.dataStoreContext.id,
|
|
229
|
+
tag: TelemetryDataTag.CodeArtifact,
|
|
230
|
+
},
|
|
231
|
+
dataStorePackagePath: this.dataStoreContext.packagePath.join("/"),
|
|
232
|
+
channelFactoryType: this.attachMessageType,
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
attributes = factory.attributes;
|
|
236
|
+
} else {
|
|
237
|
+
factory = this.registry.get(attributes.type);
|
|
238
|
+
if (factory === undefined) {
|
|
239
|
+
// TODO: dataStoreId may require a different tag from PackageData #7488
|
|
240
|
+
throw new DataCorruptionError("channelFactoryNotRegisteredForGivenType", {
|
|
241
|
+
channelId: {
|
|
242
|
+
value: this.id,
|
|
243
|
+
tag: TelemetryDataTag.CodeArtifact,
|
|
244
|
+
},
|
|
245
|
+
dataStoreId: {
|
|
246
|
+
value: this.dataStoreContext.id,
|
|
247
|
+
tag: TelemetryDataTag.CodeArtifact,
|
|
248
|
+
},
|
|
249
|
+
dataStorePackagePath: this.dataStoreContext.packagePath.join("/"),
|
|
250
|
+
channelFactoryType: attributes.type,
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
// Compare snapshot version to collaborative object version
|
|
256
|
+
if (
|
|
257
|
+
attributes.snapshotFormatVersion !== undefined &&
|
|
258
|
+
attributes.snapshotFormatVersion !== factory.attributes.snapshotFormatVersion
|
|
259
|
+
) {
|
|
260
|
+
this.subLogger.sendTelemetryEvent({
|
|
261
|
+
eventName: "ChannelAttributesVersionMismatch",
|
|
262
|
+
channelType: { value: attributes.type, tag: TelemetryDataTag.CodeArtifact },
|
|
263
|
+
channelSnapshotVersion: {
|
|
264
|
+
value: `${attributes.snapshotFormatVersion}@${attributes.packageVersion}`,
|
|
265
|
+
tag: TelemetryDataTag.CodeArtifact,
|
|
266
|
+
},
|
|
267
|
+
channelCodeVersion: {
|
|
268
|
+
value: `${factory.attributes.snapshotFormatVersion}@${factory.attributes.packageVersion}`,
|
|
269
|
+
tag: TelemetryDataTag.CodeArtifact,
|
|
270
|
+
},
|
|
271
|
+
});
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
const channel = await factory.load(this.runtime, this.id, this.services, attributes);
|
|
275
|
+
|
|
276
|
+
// Send all pending messages to the channel
|
|
277
|
+
assert(this.pending !== undefined, 0x23f /* "pending undefined" */);
|
|
278
|
+
for (const message of this.pending) {
|
|
279
|
+
this.services.deltaConnection.process(message, false, undefined /* localOpMetadata */);
|
|
280
|
+
}
|
|
281
|
+
this.thresholdOpsCounter.send("ProcessPendingOps", this.pending.length);
|
|
282
|
+
|
|
283
|
+
// Commit changes.
|
|
284
|
+
this.channel = channel;
|
|
285
|
+
this.pending = undefined;
|
|
286
|
+
this.isLoaded = true;
|
|
287
|
+
|
|
288
|
+
// Because have some await between we created the service and here, the connection state might have changed
|
|
289
|
+
// and we don't propagate the connection state when we are not loaded. So we have to set it again here.
|
|
290
|
+
this.services.deltaConnection.setConnectionState(this.dataStoreContext.connected);
|
|
291
|
+
return this.channel;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
/**
|
|
295
|
+
* Returns the data used for garbage collection. This includes a list of GC nodes that represent this context.
|
|
296
|
+
* Each node has a set of outbound routes to other GC nodes in the document.
|
|
297
|
+
* If there is no new data in this context since the last summary, previous GC data is used.
|
|
298
|
+
* If there is new data, the GC data is generated again (by calling getGCDataInternal).
|
|
299
|
+
* @param fullGC - true to bypass optimizations and force full generation of GC data.
|
|
300
|
+
*/
|
|
301
|
+
public async getGCData(fullGC: boolean = false): Promise<IGarbageCollectionData> {
|
|
302
|
+
return this.summarizerNode.getGCData(fullGC);
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
/**
|
|
306
|
+
* Generates the data used for garbage collection. This is called when there is new data since last summary. It
|
|
307
|
+
* loads the context and calls into the channel to get its GC data.
|
|
308
|
+
* @param fullGC - true to bypass optimizations and force full generation of GC data.
|
|
309
|
+
*/
|
|
310
|
+
private async getGCDataInternal(fullGC: boolean = false): Promise<IGarbageCollectionData> {
|
|
311
|
+
const channel = await this.getChannel();
|
|
312
|
+
return channel.getGCData(fullGC);
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
public updateUsedRoutes(usedRoutes: string[]) {
|
|
316
|
+
/**
|
|
317
|
+
* Currently, DDSes are always considered referenced and are not garbage collected. Update the summarizer node's
|
|
318
|
+
* used routes to contain a route to this channel context.
|
|
319
|
+
* Once we have GC at DDS level, this will be updated to use the passed usedRoutes. See -
|
|
320
|
+
* https://github.com/microsoft/FluidFramework/issues/4611
|
|
321
|
+
*/
|
|
322
|
+
this.summarizerNode.updateUsedRoutes([""]);
|
|
323
|
+
}
|
|
315
324
|
}
|
package/tsconfig.esnext.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
2
|
+
"extends": "./tsconfig.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"outDir": "./lib",
|
|
5
|
+
"module": "esnext",
|
|
6
|
+
},
|
|
7
|
+
}
|