@fluidframework/datastore 2.41.0-338401 → 2.42.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/.eslintrc.cjs +1 -4
- package/CHANGELOG.md +8 -0
- package/dist/channelContext.d.ts +7 -5
- package/dist/channelContext.d.ts.map +1 -1
- package/dist/channelContext.js +3 -1
- package/dist/channelContext.js.map +1 -1
- package/dist/channelDeltaConnection.d.ts +5 -5
- package/dist/channelDeltaConnection.d.ts.map +1 -1
- package/dist/channelDeltaConnection.js +7 -6
- package/dist/channelDeltaConnection.js.map +1 -1
- package/dist/channelStorageService.js +2 -2
- package/dist/channelStorageService.js.map +1 -1
- package/dist/dataStoreRuntime.d.ts +20 -0
- package/dist/dataStoreRuntime.d.ts.map +1 -1
- package/dist/dataStoreRuntime.js +125 -48
- package/dist/dataStoreRuntime.js.map +1 -1
- package/dist/fluidHandle.d.ts.map +1 -1
- package/dist/fluidHandle.js +6 -2
- package/dist/fluidHandle.js.map +1 -1
- package/dist/localChannelContext.d.ts +8 -6
- package/dist/localChannelContext.d.ts.map +1 -1
- package/dist/localChannelContext.js +8 -6
- package/dist/localChannelContext.js.map +1 -1
- package/dist/localChannelStorageService.d.ts.map +1 -1
- package/dist/localChannelStorageService.js +6 -4
- package/dist/localChannelStorageService.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.d.ts.map +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/remoteChannelContext.d.ts +7 -5
- package/dist/remoteChannelContext.d.ts.map +1 -1
- package/dist/remoteChannelContext.js +5 -4
- package/dist/remoteChannelContext.js.map +1 -1
- package/lib/channelContext.d.ts +7 -5
- package/lib/channelContext.d.ts.map +1 -1
- package/lib/channelContext.js +3 -1
- package/lib/channelContext.js.map +1 -1
- package/lib/channelDeltaConnection.d.ts +5 -5
- package/lib/channelDeltaConnection.d.ts.map +1 -1
- package/lib/channelDeltaConnection.js +7 -6
- package/lib/channelDeltaConnection.js.map +1 -1
- package/lib/channelStorageService.js +2 -2
- package/lib/channelStorageService.js.map +1 -1
- package/lib/dataStoreRuntime.d.ts +20 -0
- package/lib/dataStoreRuntime.d.ts.map +1 -1
- package/lib/dataStoreRuntime.js +125 -48
- package/lib/dataStoreRuntime.js.map +1 -1
- package/lib/fluidHandle.d.ts.map +1 -1
- package/lib/fluidHandle.js +6 -2
- package/lib/fluidHandle.js.map +1 -1
- package/lib/localChannelContext.d.ts +8 -6
- package/lib/localChannelContext.d.ts.map +1 -1
- package/lib/localChannelContext.js +8 -6
- package/lib/localChannelContext.js.map +1 -1
- package/lib/localChannelStorageService.d.ts.map +1 -1
- package/lib/localChannelStorageService.js +6 -4
- package/lib/localChannelStorageService.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.d.ts.map +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/remoteChannelContext.d.ts +7 -5
- package/lib/remoteChannelContext.d.ts.map +1 -1
- package/lib/remoteChannelContext.js +5 -4
- package/lib/remoteChannelContext.js.map +1 -1
- package/package.json +16 -16
- package/src/channelContext.ts +7 -5
- package/src/channelDeltaConnection.ts +19 -19
- package/src/channelStorageService.ts +3 -3
- package/src/dataStoreRuntime.ts +174 -75
- package/src/fluidHandle.ts +7 -3
- package/src/localChannelContext.ts +18 -16
- package/src/localChannelStorageService.ts +6 -4
- package/src/packageVersion.ts +1 -1
- package/src/remoteChannelContext.ts +19 -19
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"channelStorageService.js","sourceRoot":"","sources":["../src/channelStorageService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAM7D,OAAO,EAAE,mCAAmC,EAAE,MAAM,wCAAwC,CAAC;AAG7F,MAAM,OAAO,qBAAqB;IACzB,MAAM,CAAC,WAAW,CACzB,I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CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,IAAI,EAAE,CAAC,CAAC;IACvC,CAAC;IAEO,KAAK,CAAC,YAAY,CAAC,IAAY;QACtC,OAAO,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;IACjC,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport { IChannelStorageService } from \"@fluidframework/datastore-definitions/internal\";\nimport {\n\tIDocumentStorageService,\n\tISnapshotTree,\n} from \"@fluidframework/driver-definitions/internal\";\nimport { getNormalizedObjectStoragePathParts } from \"@fluidframework/runtime-utils/internal\";\nimport { ITelemetryLoggerExt } from \"@fluidframework/telemetry-utils/internal\";\n\nexport class ChannelStorageService implements IChannelStorageService {\n\tprivate static flattenTree(\n\t\tbase: string,\n\t\ttree: ISnapshotTree,\n\t\tresults: { [path: string]: string },\n\t): void {\n\t\tfor (const [path, subtree] of Object.entries(tree.trees)) {\n\t\t\tChannelStorageService.flattenTree(`${base}${path}/`, subtree, results);\n\t\t}\n\n\t\tfor (const [blobName, blobId] of Object.entries(tree.blobs)) {\n\t\t\tresults[`${base}${blobName}`] = blobId;\n\t\t}\n\t}\n\n\tprivate readonly flattenedTree: { [path: string]: string };\n\n\tconstructor(\n\t\tprivate readonly tree: ISnapshotTree | undefined,\n\t\tprivate readonly storage: Pick<IDocumentStorageService, \"readBlob\">,\n\t\tprivate readonly logger: ITelemetryLoggerExt,\n\t\tprivate readonly extraBlobs?: Map<string, ArrayBufferLike>,\n\t) {\n\t\tthis.flattenedTree = {};\n\t\t// Create a map from paths to blobs\n\t\tif (tree !== undefined) {\n\t\t\tChannelStorageService.flattenTree(\"\", tree, this.flattenedTree);\n\t\t}\n\t}\n\n\tpublic async contains(path: string): Promise<boolean> {\n\t\treturn this.flattenedTree[path] !== undefined;\n\t}\n\n\tpublic async readBlob(path: string): Promise<ArrayBufferLike> {\n\t\tconst id = await this.getIdForPath(path);\n\t\tassert(id !== undefined, 0x9d7 /* id is undefined in ChannelStorageService.readBlob() */);\n\t\tconst blob = this.extraBlobs === undefined ? undefined : this.extraBlobs.get(id);\n\n\t\tif (blob !== undefined) {\n\t\t\treturn blob;\n\t\t}\n\t\tconst blobP = this.storage.readBlob(id);\n\t\tblobP.catch((error) =>\n\t\t\tthis.logger.sendErrorEvent({ eventName: \"ChannelStorageBlobError\" }, error),\n\t\t);\n\n\t\treturn blobP;\n\t}\n\n\tpublic async list(path: string): Promise<string[]> {\n\t\tlet tree = this.tree;\n\t\tconst pathParts = getNormalizedObjectStoragePathParts(path);\n\t\twhile (tree !== undefined && pathParts.length > 0) {\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\tconst part = pathParts.shift()!;\n\t\t\ttree = tree.trees[part];\n\t\t}\n\t\tif (tree === undefined || pathParts.length > 0) {\n\t\t\tthrow new Error(\"path does not exist\");\n\t\t}\n\n\t\treturn Object.keys(tree?.blobs ?? {});\n\t}\n\n\tprivate async getIdForPath(path: string): Promise<string | undefined> {\n\t\treturn this.flattenedTree[path];\n\t}\n}\n"]}
|
|
@@ -109,6 +109,14 @@ export declare class FluidDataStoreRuntime extends TypedEventEmitter<IFluidDataS
|
|
|
109
109
|
* and the primary way of interacting with some Fluid objects, and should be used if possible.
|
|
110
110
|
*/
|
|
111
111
|
constructor(dataStoreContext: IFluidDataStoreContext, sharedObjectRegistry: ISharedObjectRegistry, existing: boolean, provideEntryPoint: (runtime: IFluidDataStoreRuntime) => Promise<FluidObject>, policies?: Partial<IFluidDataStorePolicies>);
|
|
112
|
+
/**
|
|
113
|
+
* Implementation of IFluidDataStoreRuntimeExperimental.inStagingMode
|
|
114
|
+
*/
|
|
115
|
+
private get inStagingMode();
|
|
116
|
+
/**
|
|
117
|
+
* Implementation of IFluidDataStoreRuntimeExperimental.isDirty
|
|
118
|
+
*/
|
|
119
|
+
private get isDirty();
|
|
112
120
|
get deltaManager(): IDeltaManagerErased;
|
|
113
121
|
dispose(): void;
|
|
114
122
|
resolveHandle(request: IRequest): Promise<IResponse>;
|
|
@@ -256,6 +264,11 @@ export declare class FluidDataStoreRuntime extends TypedEventEmitter<IFluidDataS
|
|
|
256
264
|
*/
|
|
257
265
|
private makeChannelLocallyVisible;
|
|
258
266
|
private submitChannelOp;
|
|
267
|
+
/**
|
|
268
|
+
* Count of pending ops that have been submitted but not yet ack'd.
|
|
269
|
+
* Used to compute {@link FluidDataStoreRuntime.isDirty}
|
|
270
|
+
*/
|
|
271
|
+
private readonly pendingOpCount;
|
|
259
272
|
private submit;
|
|
260
273
|
/**
|
|
261
274
|
* For messages of type MessageType.Operation, finds the right channel and asks it to resubmit the message.
|
|
@@ -272,6 +285,13 @@ export declare class FluidDataStoreRuntime extends TypedEventEmitter<IFluidDataS
|
|
|
272
285
|
*/
|
|
273
286
|
rollback?(type: DataStoreMessageType, content: any, localOpMetadata: unknown): void;
|
|
274
287
|
applyStashedOp(content: any): Promise<unknown>;
|
|
288
|
+
/**
|
|
289
|
+
* Indicates the given channel is dirty from Summarizer's point of view,
|
|
290
|
+
* i.e. it has local changes that need to be included in the summary.
|
|
291
|
+
*
|
|
292
|
+
* @remarks - If a channel's changes are rolled back or rebased away, we won't
|
|
293
|
+
* clear the dirty flag set here.
|
|
294
|
+
*/
|
|
275
295
|
private setChannelDirty;
|
|
276
296
|
private attachListener;
|
|
277
297
|
private verifyNotClosed;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dataStoreRuntime.d.ts","sourceRoot":"","sources":["../src/dataStoreRuntime.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,iBAAiB,EAA4B,MAAM,8BAA8B,CAAC;AAC3F,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,uCAAuC,CAAC;AAC/E,OAAO,EAAE,aAAa,EAAE,MAAM,gDAAgD,CAAC;AAC/E,OAAO,EACN,WAAW,EAC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,IAAI,EAAE,oBAAoB,EAG1B,OAAO,EAAE,GAAG,EACZ,eAAe,EAAE,OAAO,GACtB,IAAI;IAwBM,cAAc,CAAC,OAAO,EAAE,GAAG,GAAG,OAAO,CAAC,OAAO,CAAC;IA4C3D;;;;;;OAMG;IACH,OAAO,CAAC,eAAe;IAKvB,OAAO,CAAC,cAAc;IAkBtB,OAAO,CAAC,eAAe;IAMvB;;;;OAIG;IACH,OAAO,CAAC,+BAA+B;IAyBhC,cAAc,CAAC,WAAW,EAAE,WAAW,CAAC,SAAS,GAAG,WAAW,CAAC,QAAQ,GAAG,IAAI;CA+CtF;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,mBAAmB,mBACf,CAAC,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,qBAAqB,KAAK,QAAQ,SAAS,CAAC,SACnF,4BAA4B,KAChC,4BAS+B,CAAC;AAEnC;;;;;;;GAOG;AACH,eAAO,MAAM,mBAAmB,YACtB,CACR,OAAO,EAAE,qBAAqB,KAC1B,QAAQ;IAAE,IAAI,EAAE,MAAM,EAAE,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GAAG,SAAS,CAAC,SACvD,4BAA4B,KAChC,4BAyC+B,CAAC"}
|
package/lib/dataStoreRuntime.js
CHANGED
|
@@ -36,6 +36,21 @@ export var DataStoreMessageType;
|
|
|
36
36
|
const defaultPolicies = {
|
|
37
37
|
readonlyInStagingMode: true,
|
|
38
38
|
};
|
|
39
|
+
/**
|
|
40
|
+
* Set up the boxed pendingOpCount value.
|
|
41
|
+
*/
|
|
42
|
+
function initializePendingOpCount() {
|
|
43
|
+
let value = 0;
|
|
44
|
+
return {
|
|
45
|
+
get value() {
|
|
46
|
+
return value;
|
|
47
|
+
},
|
|
48
|
+
set value(newValue) {
|
|
49
|
+
assert(newValue >= 0, 0xbbd /* pendingOpCount must be non-negative */);
|
|
50
|
+
value = newValue;
|
|
51
|
+
},
|
|
52
|
+
};
|
|
53
|
+
}
|
|
39
54
|
/**
|
|
40
55
|
* Base data store class
|
|
41
56
|
* @legacy
|
|
@@ -66,6 +81,8 @@ export class FluidDataStoreRuntime extends TypedEventEmitter {
|
|
|
66
81
|
get idCompressor() {
|
|
67
82
|
return this.dataStoreContext.idCompressor;
|
|
68
83
|
}
|
|
84
|
+
// TODO: the methods below should have more specific return typing, per the interfaces they are implementing.
|
|
85
|
+
// Doing so would be a breaking change.
|
|
69
86
|
get IFluidHandleContext() {
|
|
70
87
|
return this;
|
|
71
88
|
}
|
|
@@ -120,6 +137,11 @@ export class FluidDataStoreRuntime extends TypedEventEmitter {
|
|
|
120
137
|
* is currently marked as legacy alpha. So, using unknown here.
|
|
121
138
|
*/
|
|
122
139
|
this.ILayerCompatDetails = dataStoreCompatDetailsForRuntime;
|
|
140
|
+
/**
|
|
141
|
+
* Count of pending ops that have been submitted but not yet ack'd.
|
|
142
|
+
* Used to compute {@link FluidDataStoreRuntime.isDirty}
|
|
143
|
+
*/
|
|
144
|
+
this.pendingOpCount = initializePendingOpCount();
|
|
123
145
|
assert(!dataStoreContext.id.includes("/"), 0x30e /* Id cannot contain slashes. DataStoreContext should have validated this. */);
|
|
124
146
|
this.policies = { ...defaultPolicies, ...policies };
|
|
125
147
|
// Validate that the Runtime is compatible with this DataStore.
|
|
@@ -150,10 +172,10 @@ export class FluidDataStoreRuntime extends TypedEventEmitter {
|
|
|
150
172
|
const tree = dataStoreContext.baseSnapshot;
|
|
151
173
|
// Must always receive the data store type inside of the attributes
|
|
152
174
|
if (tree?.trees !== undefined) {
|
|
153
|
-
Object.entries(tree.trees)
|
|
175
|
+
for (const [path, subtree] of Object.entries(tree.trees)) {
|
|
154
176
|
// Issue #4414
|
|
155
177
|
if (path === "_search") {
|
|
156
|
-
|
|
178
|
+
continue;
|
|
157
179
|
}
|
|
158
180
|
let channelContext;
|
|
159
181
|
// If already exists on storage, then create a remote channel. However, if it is case of rehydrating a
|
|
@@ -165,11 +187,11 @@ export class FluidDataStoreRuntime extends TypedEventEmitter {
|
|
|
165
187
|
// data store, if the data store is loaded after the container is attached, then we missed making
|
|
166
188
|
// the channel visible. So do it now. Otherwise, add it to local channel context queue, so
|
|
167
189
|
// that it can be make it visible later with the data store.
|
|
168
|
-
if (dataStoreContext.attachState
|
|
169
|
-
|
|
190
|
+
if (dataStoreContext.attachState === AttachState.Detached) {
|
|
191
|
+
this.localChannelContextQueue.set(path, channelContext);
|
|
170
192
|
}
|
|
171
193
|
else {
|
|
172
|
-
|
|
194
|
+
channelContext.makeVisible();
|
|
173
195
|
}
|
|
174
196
|
}
|
|
175
197
|
else {
|
|
@@ -178,7 +200,7 @@ export class FluidDataStoreRuntime extends TypedEventEmitter {
|
|
|
178
200
|
}));
|
|
179
201
|
}
|
|
180
202
|
this.contexts.set(path, channelContext);
|
|
181
|
-
}
|
|
203
|
+
}
|
|
182
204
|
}
|
|
183
205
|
this.entryPoint = new FluidObjectHandle(new LazyPromise(async () => provideEntryPoint(this)), "", this.objectsRoutingContext);
|
|
184
206
|
this.attachListener();
|
|
@@ -209,17 +231,27 @@ export class FluidDataStoreRuntime extends TypedEventEmitter {
|
|
|
209
231
|
// By default, a data store can log maximum 10 local changes telemetry in summarizer.
|
|
210
232
|
this.localChangesTelemetryCount =
|
|
211
233
|
this.mc.config.getNumber("Fluid.Telemetry.LocalChangesTelemetryCount") ?? 10;
|
|
234
|
+
// Reference these properties to avoid unused private member errors.
|
|
235
|
+
// They're accessed via IFluidDataStoreRuntimeExperimental interface.
|
|
236
|
+
// eslint-disable-next-line no-void
|
|
237
|
+
void [this.inStagingMode, this.isDirty];
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* Implementation of IFluidDataStoreRuntimeExperimental.inStagingMode
|
|
241
|
+
*/
|
|
242
|
+
// eslint-disable-next-line import/no-deprecated
|
|
243
|
+
get inStagingMode() {
|
|
244
|
+
return (
|
|
212
245
|
// eslint-disable-next-line import/no-deprecated
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
}
|
|
246
|
+
this.dataStoreContext.containerRuntime
|
|
247
|
+
?.inStagingMode);
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* Implementation of IFluidDataStoreRuntimeExperimental.isDirty
|
|
251
|
+
*/
|
|
252
|
+
// eslint-disable-next-line import/no-deprecated
|
|
253
|
+
get isDirty() {
|
|
254
|
+
return this.pendingOpCount.value > 0;
|
|
223
255
|
}
|
|
224
256
|
get deltaManager() {
|
|
225
257
|
return toDeltaManagerErased(this.deltaManagerInternal);
|
|
@@ -320,11 +352,7 @@ export class FluidDataStoreRuntime extends TypedEventEmitter {
|
|
|
320
352
|
}
|
|
321
353
|
createChannel(idArg, type) {
|
|
322
354
|
let id;
|
|
323
|
-
if (idArg
|
|
324
|
-
id = idArg;
|
|
325
|
-
this.validateChannelId(id);
|
|
326
|
-
}
|
|
327
|
-
else {
|
|
355
|
+
if (idArg === undefined) {
|
|
328
356
|
/**
|
|
329
357
|
* Return uuid if short-ids are explicitly disabled via feature flags.
|
|
330
358
|
*/
|
|
@@ -338,19 +366,23 @@ export class FluidDataStoreRuntime extends TypedEventEmitter {
|
|
|
338
366
|
// - uuids
|
|
339
367
|
// In first two cases we will encode result as strings in more compact form, with leading underscore,
|
|
340
368
|
// to ensure no overlap with user-provided DDS names (see validateChannelId())
|
|
341
|
-
if (this.visibilityState
|
|
342
|
-
// container is detached, only one client observes content, no way to hit collisions with other clients.
|
|
343
|
-
id = encodeCompactIdToString(2 * this.contexts.size, "_");
|
|
344
|
-
}
|
|
345
|
-
else {
|
|
369
|
+
if (this.visibilityState === VisibilityState.GloballyVisible) {
|
|
346
370
|
// Due to back-compat, we could not depend yet on generateDocumentUniqueId() being there.
|
|
347
371
|
// We can remove the need to leverage uuid() as fall-back in couple releases.
|
|
348
372
|
const res = this.dataStoreContext.containerRuntime.generateDocumentUniqueId?.() ?? uuid();
|
|
349
373
|
id = typeof res === "number" ? encodeCompactIdToString(2 * res + 1, "_") : res;
|
|
350
374
|
}
|
|
375
|
+
else {
|
|
376
|
+
// container is detached, only one client observes content, no way to hit collisions with other clients.
|
|
377
|
+
id = encodeCompactIdToString(2 * this.contexts.size, "_");
|
|
378
|
+
}
|
|
351
379
|
}
|
|
352
380
|
assert(!id.includes("/"), 0x8fc /* slash */);
|
|
353
381
|
}
|
|
382
|
+
else {
|
|
383
|
+
id = idArg;
|
|
384
|
+
this.validateChannelId(id);
|
|
385
|
+
}
|
|
354
386
|
this.verifyNotClosed();
|
|
355
387
|
assert(!this.contexts.has(id), 0x179 /* "createChannel() with existing ID" */);
|
|
356
388
|
assert(type !== undefined, 0x209 /* "Factory Type should be defined" */);
|
|
@@ -414,9 +446,9 @@ export class FluidDataStoreRuntime extends TypedEventEmitter {
|
|
|
414
446
|
return;
|
|
415
447
|
}
|
|
416
448
|
this.visibilityState = VisibilityState.LocallyVisible;
|
|
417
|
-
this.pendingHandlesToMakeVisible
|
|
449
|
+
for (const handle of this.pendingHandlesToMakeVisible) {
|
|
418
450
|
handle.attachGraph();
|
|
419
|
-
}
|
|
451
|
+
}
|
|
420
452
|
this.pendingHandlesToMakeVisible.clear();
|
|
421
453
|
this.dataStoreContext.makeLocallyVisible();
|
|
422
454
|
}
|
|
@@ -482,7 +514,7 @@ export class FluidDataStoreRuntime extends TypedEventEmitter {
|
|
|
482
514
|
*/
|
|
483
515
|
let currentAddress;
|
|
484
516
|
let currentMessagesContent = [];
|
|
485
|
-
const { messagesContent, local } = messageCollection;
|
|
517
|
+
const { messagesContent, local, envelope } = messageCollection;
|
|
486
518
|
const sendBunchedMessages = () => {
|
|
487
519
|
// Current address will be undefined for the first message in the list.
|
|
488
520
|
if (currentAddress === undefined) {
|
|
@@ -492,7 +524,7 @@ export class FluidDataStoreRuntime extends TypedEventEmitter {
|
|
|
492
524
|
const channelContext = this.contexts.get(currentAddress);
|
|
493
525
|
assert(!!channelContext, 0xa6b /* Channel context not found */);
|
|
494
526
|
channelContext.processMessages({
|
|
495
|
-
envelope
|
|
527
|
+
envelope,
|
|
496
528
|
messagesContent: currentMessagesContent,
|
|
497
529
|
local,
|
|
498
530
|
});
|
|
@@ -547,15 +579,20 @@ export class FluidDataStoreRuntime extends TypedEventEmitter {
|
|
|
547
579
|
*/
|
|
548
580
|
processMessages(messageCollection) {
|
|
549
581
|
this.verifyNotClosed();
|
|
550
|
-
const { envelope, messagesContent } = messageCollection;
|
|
582
|
+
const { envelope, local, messagesContent } = messageCollection;
|
|
583
|
+
if (local) {
|
|
584
|
+
this.pendingOpCount.value -= messagesContent.length;
|
|
585
|
+
}
|
|
551
586
|
try {
|
|
552
587
|
switch (envelope.type) {
|
|
553
|
-
case DataStoreMessageType.ChannelOp:
|
|
588
|
+
case DataStoreMessageType.ChannelOp: {
|
|
554
589
|
this.processChannelMessages(messageCollection);
|
|
555
590
|
break;
|
|
556
|
-
|
|
591
|
+
}
|
|
592
|
+
case DataStoreMessageType.Attach: {
|
|
557
593
|
this.processAttachMessages(messageCollection);
|
|
558
594
|
break;
|
|
595
|
+
}
|
|
559
596
|
default:
|
|
560
597
|
}
|
|
561
598
|
}
|
|
@@ -757,7 +794,10 @@ export class FluidDataStoreRuntime extends TypedEventEmitter {
|
|
|
757
794
|
}
|
|
758
795
|
}
|
|
759
796
|
}
|
|
760
|
-
submitMessage(type,
|
|
797
|
+
submitMessage(type,
|
|
798
|
+
// TODO: use something other than `any` here (breaking change)
|
|
799
|
+
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any
|
|
800
|
+
content, localOpMetadata) {
|
|
761
801
|
this.submit(type, content, localOpMetadata);
|
|
762
802
|
}
|
|
763
803
|
/**
|
|
@@ -768,7 +808,7 @@ export class FluidDataStoreRuntime extends TypedEventEmitter {
|
|
|
768
808
|
*/
|
|
769
809
|
submitSignal(type, content, targetClientId) {
|
|
770
810
|
this.verifyNotClosed();
|
|
771
|
-
|
|
811
|
+
this.dataStoreContext.submitSignal(type, content, targetClientId);
|
|
772
812
|
}
|
|
773
813
|
/**
|
|
774
814
|
* Will return when the data store is attached.
|
|
@@ -812,6 +852,7 @@ export class FluidDataStoreRuntime extends TypedEventEmitter {
|
|
|
812
852
|
submit(type, content, localOpMetadata = undefined) {
|
|
813
853
|
this.verifyNotClosed();
|
|
814
854
|
this.dataStoreContext.submitMessage(type, content, localOpMetadata);
|
|
855
|
+
++this.pendingOpCount.value;
|
|
815
856
|
}
|
|
816
857
|
/**
|
|
817
858
|
* For messages of type MessageType.Operation, finds the right channel and asks it to resubmit the message.
|
|
@@ -820,8 +861,14 @@ export class FluidDataStoreRuntime extends TypedEventEmitter {
|
|
|
820
861
|
* @param content - The content of the original message.
|
|
821
862
|
* @param localOpMetadata - The local metadata associated with the original message.
|
|
822
863
|
*/
|
|
823
|
-
reSubmit(type,
|
|
864
|
+
reSubmit(type,
|
|
865
|
+
// TODO: use something other than `any` here (breaking change)
|
|
866
|
+
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any
|
|
867
|
+
content, localOpMetadata, squash) {
|
|
824
868
|
this.verifyNotClosed();
|
|
869
|
+
// The op being resubmitted was not / will not be submitted, so decrement the count.
|
|
870
|
+
// The calls below may result in one or more ops submitted again, which will increment the count (or not if nothing needs to be submitted anymore).
|
|
871
|
+
--this.pendingOpCount.value;
|
|
825
872
|
switch (type) {
|
|
826
873
|
case DataStoreMessageType.ChannelOp: {
|
|
827
874
|
// For Operations, find the right channel and trigger resubmission on it.
|
|
@@ -831,12 +878,14 @@ export class FluidDataStoreRuntime extends TypedEventEmitter {
|
|
|
831
878
|
channelContext.reSubmit(envelope.contents, localOpMetadata, squash);
|
|
832
879
|
break;
|
|
833
880
|
}
|
|
834
|
-
case DataStoreMessageType.Attach:
|
|
881
|
+
case DataStoreMessageType.Attach: {
|
|
835
882
|
// For Attach messages, just submit them again.
|
|
836
883
|
this.submit(type, content, localOpMetadata);
|
|
837
884
|
break;
|
|
838
|
-
|
|
885
|
+
}
|
|
886
|
+
default: {
|
|
839
887
|
unreachableCase(type);
|
|
888
|
+
}
|
|
840
889
|
}
|
|
841
890
|
}
|
|
842
891
|
/**
|
|
@@ -844,8 +893,13 @@ export class FluidDataStoreRuntime extends TypedEventEmitter {
|
|
|
844
893
|
* @param content - The content of the original message.
|
|
845
894
|
* @param localOpMetadata - The local metadata associated with the original message.
|
|
846
895
|
*/
|
|
847
|
-
rollback(type,
|
|
896
|
+
rollback(type,
|
|
897
|
+
// TODO: use something other than `any` here (breaking change)
|
|
898
|
+
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any
|
|
899
|
+
content, localOpMetadata) {
|
|
848
900
|
this.verifyNotClosed();
|
|
901
|
+
// The op being rolled back was not/will not be submitted, so decrement the count.
|
|
902
|
+
--this.pendingOpCount.value;
|
|
849
903
|
switch (type) {
|
|
850
904
|
case DataStoreMessageType.ChannelOp: {
|
|
851
905
|
// For Operations, find the right channel and trigger resubmission on it.
|
|
@@ -855,14 +909,22 @@ export class FluidDataStoreRuntime extends TypedEventEmitter {
|
|
|
855
909
|
channelContext.rollback(envelope.contents, localOpMetadata);
|
|
856
910
|
break;
|
|
857
911
|
}
|
|
858
|
-
default:
|
|
912
|
+
default: {
|
|
859
913
|
throw new LoggingError(`Can't rollback ${type} message`);
|
|
914
|
+
}
|
|
860
915
|
}
|
|
861
916
|
}
|
|
917
|
+
// TODO: use something other than `any` here
|
|
918
|
+
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any
|
|
862
919
|
async applyStashedOp(content) {
|
|
920
|
+
// The op being applied may have been submitted in a previous session, so we increment the count here.
|
|
921
|
+
// Either the ack will arrive and be processed, or that previous session's connection will end, at which point the op will be resubmitted.
|
|
922
|
+
++this.pendingOpCount.value;
|
|
923
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
863
924
|
const type = content?.type;
|
|
864
925
|
switch (type) {
|
|
865
926
|
case DataStoreMessageType.Attach: {
|
|
927
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
866
928
|
const attachMessage = content.content;
|
|
867
929
|
const flatBlobs = new Map();
|
|
868
930
|
const snapshotTree = buildSnapshotTree(attachMessage.snapshot.entries, flatBlobs);
|
|
@@ -879,16 +941,25 @@ export class FluidDataStoreRuntime extends TypedEventEmitter {
|
|
|
879
941
|
return;
|
|
880
942
|
}
|
|
881
943
|
case DataStoreMessageType.ChannelOp: {
|
|
944
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
882
945
|
const envelope = content.content;
|
|
883
946
|
const channelContext = this.contexts.get(envelope.address);
|
|
884
947
|
assert(!!channelContext, 0x184 /* "There should be a channel context for the op" */);
|
|
885
948
|
await channelContext.getChannel();
|
|
886
949
|
return channelContext.applyStashedOp(envelope.contents);
|
|
887
950
|
}
|
|
888
|
-
default:
|
|
951
|
+
default: {
|
|
889
952
|
unreachableCase(type);
|
|
953
|
+
}
|
|
890
954
|
}
|
|
891
955
|
}
|
|
956
|
+
/**
|
|
957
|
+
* Indicates the given channel is dirty from Summarizer's point of view,
|
|
958
|
+
* i.e. it has local changes that need to be included in the summary.
|
|
959
|
+
*
|
|
960
|
+
* @remarks - If a channel's changes are rolled back or rebased away, we won't
|
|
961
|
+
* clear the dirty flag set here.
|
|
962
|
+
*/
|
|
892
963
|
setChannelDirty(address) {
|
|
893
964
|
this.verifyNotClosed();
|
|
894
965
|
this.dataStoreContext.setChannelDirty(address);
|
|
@@ -897,11 +968,13 @@ export class FluidDataStoreRuntime extends TypedEventEmitter {
|
|
|
897
968
|
this.setMaxListeners(Number.MAX_SAFE_INTEGER);
|
|
898
969
|
// back-compat, to be removed in the future.
|
|
899
970
|
// Added in "2.0.0-rc.2.0.0" timeframe.
|
|
971
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call, @typescript-eslint/no-explicit-any
|
|
900
972
|
this.dataStoreContext.once?.("attaching", () => {
|
|
901
973
|
this.setAttachState(AttachState.Attaching);
|
|
902
974
|
});
|
|
903
975
|
// back-compat, to be removed in the future.
|
|
904
976
|
// Added in "2.0.0-rc.2.0.0" timeframe.
|
|
977
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call, @typescript-eslint/no-explicit-any
|
|
905
978
|
this.dataStoreContext.once?.("attached", () => {
|
|
906
979
|
this.setAttachState(AttachState.Attached);
|
|
907
980
|
});
|
|
@@ -937,7 +1010,7 @@ export class FluidDataStoreRuntime extends TypedEventEmitter {
|
|
|
937
1010
|
}
|
|
938
1011
|
setAttachState(attachState) {
|
|
939
1012
|
switch (attachState) {
|
|
940
|
-
case AttachState.Attaching:
|
|
1013
|
+
case AttachState.Attaching: {
|
|
941
1014
|
/**
|
|
942
1015
|
* back-compat 0.59.1000 - Ideally, attachGraph() should have already been called making the data store
|
|
943
1016
|
* locally visible. However, before visibility state was added, this may not have been the case and data
|
|
@@ -952,21 +1025,24 @@ export class FluidDataStoreRuntime extends TypedEventEmitter {
|
|
|
952
1025
|
assert(this.visibilityState === VisibilityState.LocallyVisible, 0x2d1 /* "Data store should be locally visible before it can become globally visible." */);
|
|
953
1026
|
// Mark the data store globally visible and make its child channels visible as well.
|
|
954
1027
|
this.visibilityState = VisibilityState.GloballyVisible;
|
|
955
|
-
this.localChannelContextQueue
|
|
1028
|
+
for (const [, channel] of this.localChannelContextQueue) {
|
|
956
1029
|
channel.makeVisible();
|
|
957
|
-
}
|
|
1030
|
+
}
|
|
958
1031
|
this.localChannelContextQueue.clear();
|
|
959
1032
|
// This promise resolution will be moved to attached event once we fix the scheduler.
|
|
960
1033
|
this.deferredAttached.resolve();
|
|
961
1034
|
this.emit("attaching");
|
|
962
1035
|
break;
|
|
963
|
-
|
|
1036
|
+
}
|
|
1037
|
+
case AttachState.Attached: {
|
|
964
1038
|
assert(this.visibilityState === VisibilityState.GloballyVisible, 0x2d2 /* "Data store should be globally visible when its attached." */);
|
|
965
1039
|
this._attachState = AttachState.Attached;
|
|
966
1040
|
this.emit("attached");
|
|
967
1041
|
break;
|
|
968
|
-
|
|
1042
|
+
}
|
|
1043
|
+
default: {
|
|
969
1044
|
unreachableCase(attachState, "unreached");
|
|
1045
|
+
}
|
|
970
1046
|
}
|
|
971
1047
|
}
|
|
972
1048
|
}
|
|
@@ -1017,6 +1093,7 @@ export const mixinSummaryHandler = (handler, Base = FluidDataStoreRuntime) => cl
|
|
|
1017
1093
|
summary.summary.tree[firstName] = blob;
|
|
1018
1094
|
}
|
|
1019
1095
|
async summarize(...args) {
|
|
1096
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
1020
1097
|
const summary = await super.summarize(...args);
|
|
1021
1098
|
try {
|
|
1022
1099
|
const content = await handler(this);
|
|
@@ -1024,9 +1101,9 @@ export const mixinSummaryHandler = (handler, Base = FluidDataStoreRuntime) => cl
|
|
|
1024
1101
|
this.addBlob(summary, content.path, content.content);
|
|
1025
1102
|
}
|
|
1026
1103
|
}
|
|
1027
|
-
catch (
|
|
1104
|
+
catch (error) {
|
|
1028
1105
|
// Any error coming from app-provided handler should be marked as DataProcessingError
|
|
1029
|
-
throw DataProcessingError.wrapIfUnrecognized(
|
|
1106
|
+
throw DataProcessingError.wrapIfUnrecognized(error, "mixinSummaryHandler");
|
|
1030
1107
|
}
|
|
1031
1108
|
return summary;
|
|
1032
1109
|
}
|