@fluidframework/datastore 2.0.0-dev.5.3.2.178189 → 2.0.0-dev.6.4.0.191457
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +89 -0
- package/README.md +4 -3
- package/dist/channelContext.d.ts.map +1 -1
- package/dist/channelContext.js +15 -33
- package/dist/channelContext.js.map +1 -1
- package/dist/channelDeltaConnection.js +5 -5
- package/dist/channelDeltaConnection.js.map +1 -1
- package/dist/channelStorageService.js +1 -2
- package/dist/channelStorageService.js.map +1 -1
- package/dist/dataStoreRuntime.d.ts +9 -3
- package/dist/dataStoreRuntime.d.ts.map +1 -1
- package/dist/dataStoreRuntime.js +91 -93
- package/dist/dataStoreRuntime.js.map +1 -1
- package/dist/localChannelContext.d.ts +1 -1
- package/dist/localChannelContext.d.ts.map +1 -1
- package/dist/localChannelContext.js +12 -13
- package/dist/localChannelContext.js.map +1 -1
- package/dist/localChannelStorageService.js +2 -2
- package/dist/localChannelStorageService.js.map +1 -1
- package/dist/remoteChannelContext.d.ts.map +1 -1
- package/dist/remoteChannelContext.js +12 -10
- package/dist/remoteChannelContext.js.map +1 -1
- package/lib/channelContext.d.ts.map +1 -1
- package/lib/channelContext.js +16 -34
- package/lib/channelContext.js.map +1 -1
- package/lib/channelDeltaConnection.js +2 -2
- package/lib/channelDeltaConnection.js.map +1 -1
- package/lib/channelStorageService.js +1 -2
- package/lib/channelStorageService.js.map +1 -1
- package/lib/dataStoreRuntime.d.ts +9 -3
- package/lib/dataStoreRuntime.d.ts.map +1 -1
- package/lib/dataStoreRuntime.js +74 -76
- package/lib/dataStoreRuntime.js.map +1 -1
- package/lib/localChannelContext.d.ts +1 -1
- package/lib/localChannelContext.d.ts.map +1 -1
- package/lib/localChannelContext.js +2 -3
- package/lib/localChannelContext.js.map +1 -1
- package/lib/localChannelStorageService.js +1 -1
- package/lib/localChannelStorageService.js.map +1 -1
- package/lib/remoteChannelContext.d.ts.map +1 -1
- package/lib/remoteChannelContext.js +7 -5
- package/lib/remoteChannelContext.js.map +1 -1
- package/package.json +28 -31
- package/src/channelContext.ts +28 -36
- package/src/channelDeltaConnection.ts +2 -2
- package/src/dataStoreRuntime.ts +105 -94
- package/src/localChannelContext.ts +2 -4
- package/src/localChannelStorageService.ts +1 -1
- package/src/remoteChannelContext.ts +6 -4
package/dist/dataStoreRuntime.js
CHANGED
|
@@ -5,11 +5,10 @@
|
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
7
|
exports.mixinSummaryHandler = exports.mixinRequestHandler = exports.FluidDataStoreRuntime = exports.DataStoreMessageType = void 0;
|
|
8
|
+
const client_utils_1 = require("@fluid-internal/client-utils");
|
|
8
9
|
const telemetry_utils_1 = require("@fluidframework/telemetry-utils");
|
|
9
10
|
const core_utils_1 = require("@fluidframework/core-utils");
|
|
10
11
|
const container_definitions_1 = require("@fluidframework/container-definitions");
|
|
11
|
-
const container_utils_1 = require("@fluidframework/container-utils");
|
|
12
|
-
const common_utils_1 = require("@fluidframework/common-utils");
|
|
13
12
|
const driver_utils_1 = require("@fluidframework/driver-utils");
|
|
14
13
|
const protocol_definitions_1 = require("@fluidframework/protocol-definitions");
|
|
15
14
|
const runtime_definitions_1 = require("@fluidframework/runtime-definitions");
|
|
@@ -28,7 +27,7 @@ var DataStoreMessageType;
|
|
|
28
27
|
/**
|
|
29
28
|
* Base data store class
|
|
30
29
|
*/
|
|
31
|
-
class FluidDataStoreRuntime extends
|
|
30
|
+
class FluidDataStoreRuntime extends client_utils_1.TypedEventEmitter {
|
|
32
31
|
/**
|
|
33
32
|
* Create an instance of a DataStore runtime.
|
|
34
33
|
*
|
|
@@ -41,24 +40,26 @@ class FluidDataStoreRuntime extends common_utils_1.TypedEventEmitter {
|
|
|
41
40
|
* and the primary way of interacting with some Fluid objects, and should be used if possible.
|
|
42
41
|
*/
|
|
43
42
|
constructor(dataStoreContext, sharedObjectRegistry, existing, initializeEntryPoint) {
|
|
44
|
-
var _a;
|
|
45
43
|
super();
|
|
46
44
|
this.dataStoreContext = dataStoreContext;
|
|
47
45
|
this.sharedObjectRegistry = sharedObjectRegistry;
|
|
48
46
|
this._disposed = false;
|
|
49
47
|
this.contexts = new Map();
|
|
50
|
-
this.
|
|
51
|
-
this.
|
|
52
|
-
this.deferredAttached = new common_utils_1.Deferred();
|
|
48
|
+
this.pendingAttach = new Set();
|
|
49
|
+
this.deferredAttached = new core_utils_1.Deferred();
|
|
53
50
|
this.localChannelContextQueue = new Map();
|
|
54
51
|
this.notBoundedChannelContextSet = new Set();
|
|
55
52
|
// A list of handles that are bound when the data store is not visible. We have to make them visible when the data
|
|
56
53
|
// store becomes visible.
|
|
57
54
|
this.pendingHandlesToMakeVisible = new Set();
|
|
58
|
-
(0,
|
|
59
|
-
this.mc = (0, telemetry_utils_1.
|
|
60
|
-
|
|
61
|
-
|
|
55
|
+
(0, core_utils_1.assert)(!dataStoreContext.id.includes("/"), 0x30e /* Id cannot contain slashes. DataStoreContext should have validated this. */);
|
|
56
|
+
this.mc = (0, telemetry_utils_1.createChildMonitoringContext)({
|
|
57
|
+
logger: dataStoreContext.logger,
|
|
58
|
+
namespace: "FluidDataStoreRuntime",
|
|
59
|
+
properties: {
|
|
60
|
+
all: { dataStoreId: (0, uuid_1.v4)() },
|
|
61
|
+
},
|
|
62
|
+
});
|
|
62
63
|
this.id = dataStoreContext.id;
|
|
63
64
|
this.options = dataStoreContext.options;
|
|
64
65
|
this.deltaManager = dataStoreContext.deltaManager;
|
|
@@ -66,7 +67,7 @@ class FluidDataStoreRuntime extends common_utils_1.TypedEventEmitter {
|
|
|
66
67
|
this.audience = dataStoreContext.getAudience();
|
|
67
68
|
const tree = dataStoreContext.baseSnapshot;
|
|
68
69
|
// Must always receive the data store type inside of the attributes
|
|
69
|
-
if (
|
|
70
|
+
if (tree?.trees !== undefined) {
|
|
70
71
|
Object.keys(tree.trees).forEach((path) => {
|
|
71
72
|
// Issue #4414
|
|
72
73
|
if (path === "_search") {
|
|
@@ -94,10 +95,7 @@ class FluidDataStoreRuntime extends common_utils_1.TypedEventEmitter {
|
|
|
94
95
|
type: runtime_definitions_1.CreateSummarizerNodeSource.FromSummary,
|
|
95
96
|
}));
|
|
96
97
|
}
|
|
97
|
-
const deferred = new common_utils_1.Deferred();
|
|
98
|
-
deferred.resolve(channelContext);
|
|
99
98
|
this.contexts.set(path, channelContext);
|
|
100
|
-
this.contextsDeferred.set(path, deferred);
|
|
101
99
|
});
|
|
102
100
|
}
|
|
103
101
|
if (initializeEntryPoint) {
|
|
@@ -131,7 +129,7 @@ class FluidDataStoreRuntime extends common_utils_1.TypedEventEmitter {
|
|
|
131
129
|
}
|
|
132
130
|
// By default, a data store can log maximum 10 local changes telemetry in summarizer.
|
|
133
131
|
this.localChangesTelemetryCount =
|
|
134
|
-
|
|
132
|
+
this.mc.config.getNumber("Fluid.Telemetry.LocalChangesTelemetryCount") ?? 10;
|
|
135
133
|
}
|
|
136
134
|
/**
|
|
137
135
|
* @deprecated - Instantiate the class using its constructor instead.
|
|
@@ -144,6 +142,9 @@ class FluidDataStoreRuntime extends common_utils_1.TypedEventEmitter {
|
|
|
144
142
|
static load(context, sharedObjectRegistry, existing) {
|
|
145
143
|
return new FluidDataStoreRuntime(context, sharedObjectRegistry, existing, async (dataStoreRuntime) => (0, runtime_utils_1.requestFluidObject)(dataStoreRuntime, "/"));
|
|
146
144
|
}
|
|
145
|
+
/**
|
|
146
|
+
* @deprecated - Will be removed in future major release. Migrate all usage of IFluidRouter to the "entryPoint" pattern. Refer to Removing-IFluidRouter.md
|
|
147
|
+
*/
|
|
147
148
|
get IFluidRouter() {
|
|
148
149
|
return this;
|
|
149
150
|
}
|
|
@@ -214,6 +215,9 @@ class FluidDataStoreRuntime extends common_utils_1.TypedEventEmitter {
|
|
|
214
215
|
async resolveHandle(request) {
|
|
215
216
|
return this.request(request);
|
|
216
217
|
}
|
|
218
|
+
/**
|
|
219
|
+
* @deprecated - Will be removed in future major release. Migrate all usage of IFluidRouter to the "entryPoint" pattern. Refer to Removing-IFluidRouter.md
|
|
220
|
+
*/
|
|
217
221
|
async request(request) {
|
|
218
222
|
try {
|
|
219
223
|
const parser = runtime_utils_1.RequestParser.create(request);
|
|
@@ -222,11 +226,10 @@ class FluidDataStoreRuntime extends common_utils_1.TypedEventEmitter {
|
|
|
222
226
|
return this.request(parser.createSubRequest(1));
|
|
223
227
|
}
|
|
224
228
|
// Check for a data type reference first
|
|
225
|
-
|
|
229
|
+
const context = this.contexts.get(id);
|
|
230
|
+
if (context !== undefined && parser.isLeaf(1)) {
|
|
226
231
|
try {
|
|
227
|
-
|
|
228
|
-
const value = await this.contextsDeferred.get(id).promise;
|
|
229
|
-
const channel = await value.getChannel();
|
|
232
|
+
const channel = await context.getChannel();
|
|
230
233
|
return { mimeType: "fluid/object", status: 200, value: channel };
|
|
231
234
|
}
|
|
232
235
|
catch (error) {
|
|
@@ -243,35 +246,21 @@ class FluidDataStoreRuntime extends common_utils_1.TypedEventEmitter {
|
|
|
243
246
|
}
|
|
244
247
|
async getChannel(id) {
|
|
245
248
|
this.verifyNotClosed();
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
if (!this.contextsDeferred.has(id)) {
|
|
250
|
-
this.contextsDeferred.set(id, new common_utils_1.Deferred());
|
|
249
|
+
const context = this.contexts.get(id);
|
|
250
|
+
if (context === undefined) {
|
|
251
|
+
throw new telemetry_utils_1.LoggingError("Channel does not exist");
|
|
251
252
|
}
|
|
252
|
-
|
|
253
|
-
const context = await this.contextsDeferred.get(id).promise;
|
|
254
|
-
const channel = await context.getChannel();
|
|
255
|
-
return channel;
|
|
253
|
+
return context.getChannel();
|
|
256
254
|
}
|
|
257
255
|
createChannel(id = (0, uuid_1.v4)(), type) {
|
|
258
256
|
if (id.includes("/")) {
|
|
259
|
-
throw new
|
|
257
|
+
throw new telemetry_utils_1.UsageError(`Id cannot contain slashes: ${id}`);
|
|
260
258
|
}
|
|
261
259
|
this.verifyNotClosed();
|
|
262
|
-
(0,
|
|
260
|
+
(0, core_utils_1.assert)(!this.contexts.has(id), 0x179 /* "createChannel() with existing ID" */);
|
|
263
261
|
this.notBoundedChannelContextSet.add(id);
|
|
264
262
|
const context = new localChannelContext_1.LocalChannelContext(id, this.sharedObjectRegistry, type, this, this.dataStoreContext, this.dataStoreContext.storage, this.logger, (content, localOpMetadata) => this.submitChannelOp(id, content, localOpMetadata), (address) => this.setChannelDirty(address), (srcHandle, outboundHandle) => this.addedGCOutboundReference(srcHandle, outboundHandle));
|
|
265
263
|
this.contexts.set(id, context);
|
|
266
|
-
if (this.contextsDeferred.has(id)) {
|
|
267
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
268
|
-
this.contextsDeferred.get(id).resolve(context);
|
|
269
|
-
}
|
|
270
|
-
else {
|
|
271
|
-
const deferred = new common_utils_1.Deferred();
|
|
272
|
-
deferred.resolve(context);
|
|
273
|
-
this.contextsDeferred.set(id, deferred);
|
|
274
|
-
}
|
|
275
264
|
// Channels (DDS) should not be created in summarizer client.
|
|
276
265
|
this.identifyLocalChangeInSummarizer("DDSCreatedInSummarizer", id, type);
|
|
277
266
|
return context.channel;
|
|
@@ -282,7 +271,7 @@ class FluidDataStoreRuntime extends common_utils_1.TypedEventEmitter {
|
|
|
282
271
|
* @param channel - channel to be registered.
|
|
283
272
|
*/
|
|
284
273
|
bindChannel(channel) {
|
|
285
|
-
(0,
|
|
274
|
+
(0, core_utils_1.assert)(this.notBoundedChannelContextSet.has(channel.id), 0x17b /* "Channel to be bound should be in not bounded set" */);
|
|
286
275
|
this.notBoundedChannelContextSet.delete(channel.id);
|
|
287
276
|
// If our data store is attached, then attach the channel.
|
|
288
277
|
if (this.isAttached) {
|
|
@@ -361,9 +350,14 @@ class FluidDataStoreRuntime extends common_utils_1.TypedEventEmitter {
|
|
|
361
350
|
getAudience() {
|
|
362
351
|
return this.audience;
|
|
363
352
|
}
|
|
364
|
-
async uploadBlob(blob) {
|
|
353
|
+
async uploadBlob(blob, signal) {
|
|
365
354
|
this.verifyNotClosed();
|
|
366
|
-
return this.dataStoreContext.uploadBlob(blob);
|
|
355
|
+
return this.dataStoreContext.uploadBlob(blob, signal);
|
|
356
|
+
}
|
|
357
|
+
createRemoteChannelContext(attachMessage, summarizerNodeParams) {
|
|
358
|
+
const flatBlobs = new Map();
|
|
359
|
+
const snapshotTree = (0, driver_utils_1.buildSnapshotTree)(attachMessage.snapshot.entries, flatBlobs);
|
|
360
|
+
return new remoteChannelContext_1.RemoteChannelContext(this, this.dataStoreContext, this.dataStoreContext.storage, (content, localContentMetadata) => this.submitChannelOp(attachMessage.id, content, localContentMetadata), (address) => this.setChannelDirty(address), (srcHandle, outboundHandle) => this.addedGCOutboundReference(srcHandle, outboundHandle), attachMessage.id, snapshotTree, this.sharedObjectRegistry, flatBlobs, this.dataStoreContext.getCreateChildSummarizerNodeFn(attachMessage.id, summarizerNodeParams), attachMessage.type);
|
|
367
361
|
}
|
|
368
362
|
process(message, local, localOpMetadata) {
|
|
369
363
|
this.verifyNotClosed();
|
|
@@ -376,28 +370,17 @@ class FluidDataStoreRuntime extends common_utils_1.TypedEventEmitter {
|
|
|
376
370
|
// If a non-local operation then go and create the object
|
|
377
371
|
// Otherwise mark it as officially attached.
|
|
378
372
|
if (local) {
|
|
379
|
-
(0,
|
|
380
|
-
this.pendingAttach.delete(id);
|
|
373
|
+
(0, core_utils_1.assert)(this.pendingAttach.delete(id), 0x17c /* "Unexpected attach (local) channel OP" */);
|
|
381
374
|
}
|
|
382
375
|
else {
|
|
383
|
-
(0,
|
|
384
|
-
const
|
|
385
|
-
const snapshotTree = (0, driver_utils_1.buildSnapshotTree)(attachMessage.snapshot.entries, flatBlobs);
|
|
386
|
-
const remoteChannelContext = new remoteChannelContext_1.RemoteChannelContext(this, this.dataStoreContext, this.dataStoreContext.storage, (content, localContentMetadata) => this.submitChannelOp(id, content, localContentMetadata), (address) => this.setChannelDirty(address), (srcHandle, outboundHandle) => this.addedGCOutboundReference(srcHandle, outboundHandle), id, snapshotTree, this.sharedObjectRegistry, flatBlobs, this.dataStoreContext.getCreateChildSummarizerNodeFn(id, {
|
|
376
|
+
(0, core_utils_1.assert)(!this.contexts.has(id), 0x17d /* "Unexpected attach channel OP" */);
|
|
377
|
+
const summarizerNodeParams = {
|
|
387
378
|
type: runtime_definitions_1.CreateSummarizerNodeSource.FromAttach,
|
|
388
379
|
sequenceNumber: message.sequenceNumber,
|
|
389
380
|
snapshot: attachMessage.snapshot,
|
|
390
|
-
}
|
|
381
|
+
};
|
|
382
|
+
const remoteChannelContext = this.createRemoteChannelContext(attachMessage, summarizerNodeParams);
|
|
391
383
|
this.contexts.set(id, remoteChannelContext);
|
|
392
|
-
if (this.contextsDeferred.has(id)) {
|
|
393
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
394
|
-
this.contextsDeferred.get(id).resolve(remoteChannelContext);
|
|
395
|
-
}
|
|
396
|
-
else {
|
|
397
|
-
const deferred = new common_utils_1.Deferred();
|
|
398
|
-
deferred.resolve(remoteChannelContext);
|
|
399
|
-
this.contextsDeferred.set(id, deferred);
|
|
400
|
-
}
|
|
401
384
|
}
|
|
402
385
|
break;
|
|
403
386
|
}
|
|
@@ -409,7 +392,7 @@ class FluidDataStoreRuntime extends common_utils_1.TypedEventEmitter {
|
|
|
409
392
|
this.emit("op", message);
|
|
410
393
|
}
|
|
411
394
|
catch (error) {
|
|
412
|
-
throw
|
|
395
|
+
throw telemetry_utils_1.DataProcessingError.wrapIfUnrecognized(error, "fluidDataStoreRuntimeFailedToProcessMessage", message);
|
|
413
396
|
}
|
|
414
397
|
}
|
|
415
398
|
processSignal(message, local) {
|
|
@@ -491,16 +474,15 @@ class FluidDataStoreRuntime extends common_utils_1.TypedEventEmitter {
|
|
|
491
474
|
* @param usedRoutes - The routes that are used in all contexts in this channel.
|
|
492
475
|
*/
|
|
493
476
|
updateUsedRoutes(usedRoutes) {
|
|
494
|
-
var _a;
|
|
495
477
|
// Get a map of channel ids to routes used in it.
|
|
496
478
|
const usedContextRoutes = (0, runtime_utils_1.unpackChildNodesUsedRoutes)(usedRoutes);
|
|
497
479
|
// Verify that the used routes are correct.
|
|
498
480
|
for (const [id] of usedContextRoutes) {
|
|
499
|
-
(0,
|
|
481
|
+
(0, core_utils_1.assert)(this.contexts.has(id), 0x17e /* "Used route does not belong to any known context" */);
|
|
500
482
|
}
|
|
501
483
|
// Update the used routes in each context. Used routes is empty for unused context.
|
|
502
484
|
for (const [contextId, context] of this.contexts) {
|
|
503
|
-
context.updateUsedRoutes(
|
|
485
|
+
context.updateUsedRoutes(usedContextRoutes.get(contextId) ?? []);
|
|
504
486
|
}
|
|
505
487
|
}
|
|
506
488
|
/**
|
|
@@ -510,8 +492,7 @@ class FluidDataStoreRuntime extends common_utils_1.TypedEventEmitter {
|
|
|
510
492
|
* @param outboundHandle - The handle of the outbound node that is referenced.
|
|
511
493
|
*/
|
|
512
494
|
addedGCOutboundReference(srcHandle, outboundHandle) {
|
|
513
|
-
|
|
514
|
-
(_b = (_a = this.dataStoreContext).addedGCOutboundReference) === null || _b === void 0 ? void 0 : _b.call(_a, srcHandle, outboundHandle);
|
|
495
|
+
this.dataStoreContext.addedGCOutboundReference?.(srcHandle, outboundHandle);
|
|
515
496
|
}
|
|
516
497
|
/**
|
|
517
498
|
* Returns a summary at the current sequence number.
|
|
@@ -526,7 +507,7 @@ class FluidDataStoreRuntime extends common_utils_1.TypedEventEmitter {
|
|
|
526
507
|
.filter(([contextId, _]) => {
|
|
527
508
|
const isAttached = this.isChannelAttached(contextId);
|
|
528
509
|
// We are not expecting local dds! Summary may not capture local state.
|
|
529
|
-
(0,
|
|
510
|
+
(0, core_utils_1.assert)(isAttached, 0x17f /* "Not expecting detached channels during summarize" */);
|
|
530
511
|
// If the object is registered - and we have received the sequenced op creating the object
|
|
531
512
|
// (i.e. it has a base mapping) - then we go ahead and summarize
|
|
532
513
|
return isAttached;
|
|
@@ -566,13 +547,13 @@ class FluidDataStoreRuntime extends common_utils_1.TypedEventEmitter {
|
|
|
566
547
|
let summaryTree;
|
|
567
548
|
if (context.isLoaded) {
|
|
568
549
|
const contextSummary = context.getAttachSummary(telemetryContext);
|
|
569
|
-
(0,
|
|
550
|
+
(0, core_utils_1.assert)(contextSummary.summary.type === protocol_definitions_1.SummaryType.Tree, 0x180 /* "getAttachSummary should always return a tree" */);
|
|
570
551
|
summaryTree = { stats: contextSummary.stats, summary: contextSummary.summary };
|
|
571
552
|
}
|
|
572
553
|
else {
|
|
573
554
|
// If this channel is not yet loaded, then there should be no changes in the snapshot from which
|
|
574
555
|
// it was created as it is detached container. So just use the previous snapshot.
|
|
575
|
-
(0,
|
|
556
|
+
(0, core_utils_1.assert)(!!this.dataStoreContext.baseSnapshot, 0x181 /* "BaseSnapshot should be there as detached container loaded from snapshot" */);
|
|
576
557
|
summaryTree = (0, runtime_utils_1.convertSnapshotTreeToSummaryTree)(this.dataStoreContext.baseSnapshot.trees[contextId]);
|
|
577
558
|
}
|
|
578
559
|
summaryBuilder.addWithStats(contextId, summaryTree);
|
|
@@ -603,8 +584,8 @@ class FluidDataStoreRuntime extends common_utils_1.TypedEventEmitter {
|
|
|
603
584
|
return;
|
|
604
585
|
}
|
|
605
586
|
channel.handle.attachGraph();
|
|
606
|
-
(0,
|
|
607
|
-
(0,
|
|
587
|
+
(0, core_utils_1.assert)(this.isAttached, 0x182 /* "Data store should be attached to attach the channel." */);
|
|
588
|
+
(0, core_utils_1.assert)(this.visibilityState === runtime_definitions_1.VisibilityState.GloballyVisible, 0x2d0 /* "Data store should be globally visible to attach channels." */);
|
|
608
589
|
const summarizeResult = (0, channelContext_1.summarizeChannel)(channel, true /* fullTree */, false /* trackState */);
|
|
609
590
|
// Attach message needs the summary in ITree format. Convert the ISummaryTree into an ITree.
|
|
610
591
|
const snapshot = (0, runtime_utils_1.convertSummaryTreeToITree)(summarizeResult.summary);
|
|
@@ -613,7 +594,7 @@ class FluidDataStoreRuntime extends common_utils_1.TypedEventEmitter {
|
|
|
613
594
|
snapshot,
|
|
614
595
|
type: channel.attributes.type,
|
|
615
596
|
};
|
|
616
|
-
this.pendingAttach.
|
|
597
|
+
this.pendingAttach.add(channel.id);
|
|
617
598
|
this.submit(DataStoreMessageType.Attach, message);
|
|
618
599
|
const context = this.contexts.get(channel.id);
|
|
619
600
|
context.makeVisible();
|
|
@@ -640,7 +621,7 @@ class FluidDataStoreRuntime extends common_utils_1.TypedEventEmitter {
|
|
|
640
621
|
// For Operations, find the right channel and trigger resubmission on it.
|
|
641
622
|
const envelope = content;
|
|
642
623
|
const channelContext = this.contexts.get(envelope.address);
|
|
643
|
-
(0,
|
|
624
|
+
(0, core_utils_1.assert)(!!channelContext, 0x183 /* "There should be a channel context for the op" */);
|
|
644
625
|
channelContext.reSubmit(envelope.contents, localOpMetadata);
|
|
645
626
|
break;
|
|
646
627
|
}
|
|
@@ -649,7 +630,7 @@ class FluidDataStoreRuntime extends common_utils_1.TypedEventEmitter {
|
|
|
649
630
|
this.submit(type, content, localOpMetadata);
|
|
650
631
|
break;
|
|
651
632
|
default:
|
|
652
|
-
(0,
|
|
633
|
+
(0, core_utils_1.unreachableCase)(type);
|
|
653
634
|
}
|
|
654
635
|
}
|
|
655
636
|
/**
|
|
@@ -664,7 +645,7 @@ class FluidDataStoreRuntime extends common_utils_1.TypedEventEmitter {
|
|
|
664
645
|
// For Operations, find the right channel and trigger resubmission on it.
|
|
665
646
|
const envelope = content;
|
|
666
647
|
const channelContext = this.contexts.get(envelope.address);
|
|
667
|
-
(0,
|
|
648
|
+
(0, core_utils_1.assert)(!!channelContext, 0x2ed /* "There should be a channel context for the op" */);
|
|
668
649
|
channelContext.rollback(envelope.contents, localOpMetadata);
|
|
669
650
|
break;
|
|
670
651
|
}
|
|
@@ -673,11 +654,29 @@ class FluidDataStoreRuntime extends common_utils_1.TypedEventEmitter {
|
|
|
673
654
|
}
|
|
674
655
|
}
|
|
675
656
|
async applyStashedOp(content) {
|
|
676
|
-
const
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
657
|
+
const type = content?.type;
|
|
658
|
+
switch (type) {
|
|
659
|
+
case DataStoreMessageType.Attach: {
|
|
660
|
+
const attachMessage = content.content;
|
|
661
|
+
// local means this node will throw if summarized; this is fine because only interactive clients will have stashed ops
|
|
662
|
+
const summarizerNodeParams = {
|
|
663
|
+
type: runtime_definitions_1.CreateSummarizerNodeSource.Local,
|
|
664
|
+
};
|
|
665
|
+
const context = this.createRemoteChannelContext(attachMessage, summarizerNodeParams);
|
|
666
|
+
this.pendingAttach.add(attachMessage.id);
|
|
667
|
+
this.contexts.set(attachMessage.id, context);
|
|
668
|
+
return;
|
|
669
|
+
}
|
|
670
|
+
case DataStoreMessageType.ChannelOp: {
|
|
671
|
+
const envelope = content.content;
|
|
672
|
+
const channelContext = this.contexts.get(envelope.address);
|
|
673
|
+
(0, core_utils_1.assert)(!!channelContext, 0x184 /* "There should be a channel context for the op" */);
|
|
674
|
+
await channelContext.getChannel();
|
|
675
|
+
return channelContext.applyStashedOp(envelope.contents);
|
|
676
|
+
}
|
|
677
|
+
default:
|
|
678
|
+
(0, core_utils_1.unreachableCase)(type);
|
|
679
|
+
}
|
|
681
680
|
}
|
|
682
681
|
setChannelDirty(address) {
|
|
683
682
|
this.verifyNotClosed();
|
|
@@ -686,9 +685,12 @@ class FluidDataStoreRuntime extends common_utils_1.TypedEventEmitter {
|
|
|
686
685
|
processChannelOp(message, local, localOpMetadata) {
|
|
687
686
|
this.verifyNotClosed();
|
|
688
687
|
const envelope = message.contents;
|
|
689
|
-
const transformed =
|
|
688
|
+
const transformed = {
|
|
689
|
+
...message,
|
|
690
|
+
contents: envelope.contents,
|
|
691
|
+
};
|
|
690
692
|
const channelContext = this.contexts.get(envelope.address);
|
|
691
|
-
(0,
|
|
693
|
+
(0, core_utils_1.assert)(!!channelContext, 0x185 /* "Channel not found" */);
|
|
692
694
|
channelContext.processOp(transformed, local, localOpMetadata);
|
|
693
695
|
return channelContext;
|
|
694
696
|
}
|
|
@@ -706,7 +708,7 @@ class FluidDataStoreRuntime extends common_utils_1.TypedEventEmitter {
|
|
|
706
708
|
*/
|
|
707
709
|
this.attachGraph();
|
|
708
710
|
this._attachState = container_definitions_1.AttachState.Attaching;
|
|
709
|
-
(0,
|
|
711
|
+
(0, core_utils_1.assert)(this.visibilityState === runtime_definitions_1.VisibilityState.LocallyVisible, 0x2d1 /* "Data store should be locally visible before it can become globally visible." */);
|
|
710
712
|
// Mark the data store globally visible and make its child channels visible as well.
|
|
711
713
|
this.visibilityState = runtime_definitions_1.VisibilityState.GloballyVisible;
|
|
712
714
|
this.localChannelContextQueue.forEach((channel) => {
|
|
@@ -718,7 +720,7 @@ class FluidDataStoreRuntime extends common_utils_1.TypedEventEmitter {
|
|
|
718
720
|
this.emit("attaching");
|
|
719
721
|
});
|
|
720
722
|
this.dataStoreContext.once("attached", () => {
|
|
721
|
-
(0,
|
|
723
|
+
(0, core_utils_1.assert)(this.visibilityState === runtime_definitions_1.VisibilityState.GloballyVisible, 0x2d2 /* "Data store should be globally visible when its attached." */);
|
|
722
724
|
this._attachState = container_definitions_1.AttachState.Attached;
|
|
723
725
|
this.emit("attached");
|
|
724
726
|
});
|
|
@@ -742,16 +744,12 @@ class FluidDataStoreRuntime extends common_utils_1.TypedEventEmitter {
|
|
|
742
744
|
// in the summarizer and the data will help us plan this.
|
|
743
745
|
this.mc.logger.sendTelemetryEvent({
|
|
744
746
|
eventName,
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
value: this.id,
|
|
752
|
-
tag: telemetry_utils_1.TelemetryDataTag.CodeArtifact,
|
|
753
|
-
},
|
|
754
|
-
fluidDataStorePackagePath: (0, runtime_utils_1.packagePathToTelemetryProperty)(this.dataStoreContext.packagePath),
|
|
747
|
+
...(0, telemetry_utils_1.tagCodeArtifacts)({
|
|
748
|
+
channelType,
|
|
749
|
+
channelId,
|
|
750
|
+
fluidDataStoreId: this.id,
|
|
751
|
+
fluidDataStorePackagePath: this.dataStoreContext.packagePath.join("/"),
|
|
752
|
+
}),
|
|
755
753
|
stack: (0, telemetry_utils_1.generateStack)(),
|
|
756
754
|
});
|
|
757
755
|
this.localChangesTelemetryCount--;
|