@fluidframework/datastore 0.59.4001 → 1.1.0-75972
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 +1 -1
- package/dist/channelContext.d.ts +5 -4
- package/dist/channelContext.d.ts.map +1 -1
- package/dist/channelContext.js +4 -4
- package/dist/channelContext.js.map +1 -1
- package/dist/channelDeltaConnection.d.ts +1 -0
- package/dist/channelDeltaConnection.d.ts.map +1 -1
- package/dist/channelDeltaConnection.js +6 -0
- package/dist/channelDeltaConnection.js.map +1 -1
- package/dist/dataStoreRuntime.d.ts +10 -3
- package/dist/dataStoreRuntime.d.ts.map +1 -1
- package/dist/dataStoreRuntime.js +33 -7
- package/dist/dataStoreRuntime.js.map +1 -1
- package/dist/localChannelContext.d.ts +5 -3
- package/dist/localChannelContext.d.ts.map +1 -1
- package/dist/localChannelContext.js +11 -4
- package/dist/localChannelContext.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 +4 -2
- package/dist/remoteChannelContext.d.ts.map +1 -1
- package/dist/remoteChannelContext.js +11 -5
- package/dist/remoteChannelContext.js.map +1 -1
- package/lib/channelContext.d.ts +5 -4
- package/lib/channelContext.d.ts.map +1 -1
- package/lib/channelContext.js +4 -4
- package/lib/channelContext.js.map +1 -1
- package/lib/channelDeltaConnection.d.ts +1 -0
- package/lib/channelDeltaConnection.d.ts.map +1 -1
- package/lib/channelDeltaConnection.js +6 -0
- package/lib/channelDeltaConnection.js.map +1 -1
- package/lib/dataStoreRuntime.d.ts +10 -3
- package/lib/dataStoreRuntime.d.ts.map +1 -1
- package/lib/dataStoreRuntime.js +35 -9
- package/lib/dataStoreRuntime.js.map +1 -1
- package/lib/localChannelContext.d.ts +5 -3
- package/lib/localChannelContext.d.ts.map +1 -1
- package/lib/localChannelContext.js +11 -4
- package/lib/localChannelContext.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 +4 -2
- package/lib/remoteChannelContext.d.ts.map +1 -1
- package/lib/remoteChannelContext.js +11 -5
- package/lib/remoteChannelContext.js.map +1 -1
- package/package.json +18 -31
- package/src/channelContext.ts +12 -3
- package/src/channelDeltaConnection.ts +7 -0
- package/src/dataStoreRuntime.ts +45 -8
- package/src/localChannelContext.ts +16 -4
- package/src/packageVersion.ts +1 -1
- package/src/remoteChannelContext.ts +24 -5
|
@@ -19,9 +19,10 @@ class RemoteChannelContext {
|
|
|
19
19
|
this.attachMessageType = attachMessageType;
|
|
20
20
|
this.isLoaded = false;
|
|
21
21
|
this.pending = [];
|
|
22
|
+
(0, common_utils_1.assert)(!this.id.includes("/"), 0x310 /* Channel context ID cannot contain slashes */);
|
|
22
23
|
this.subLogger = telemetry_utils_1.ChildLogger.create(this.runtime.logger, "RemoteChannelContext");
|
|
23
24
|
this.services = (0, channelContext_1.createServiceEndpoints)(this.id, this.dataStoreContext.connected, submitFn, () => dirtyFn(this.id), addedGCOutboundReferenceFn, storageService, this.subLogger, baseSnapshot, extraBlobs);
|
|
24
|
-
const thisSummarizeInternal = async (fullTree, trackState) => this.summarizeInternal(fullTree, trackState);
|
|
25
|
+
const thisSummarizeInternal = async (fullTree, trackState, telemetryContext) => this.summarizeInternal(fullTree, trackState, telemetryContext);
|
|
25
26
|
this.summarizerNode = createSummarizerNode(thisSummarizeInternal, async (fullGC) => this.getGCDataInternal(fullGC), async () => getBaseGCDetails());
|
|
26
27
|
this.thresholdOpsCounter = new telemetry_utils_1.ThresholdCounter(RemoteChannelContext.pendingOpsCountThreshold, this.subLogger);
|
|
27
28
|
}
|
|
@@ -59,17 +60,22 @@ class RemoteChannelContext {
|
|
|
59
60
|
(0, common_utils_1.assert)(this.isLoaded, 0x196 /* "Remote channel must be loaded when resubmitting op" */);
|
|
60
61
|
this.services.deltaConnection.reSubmit(content, localOpMetadata);
|
|
61
62
|
}
|
|
63
|
+
rollback(content, localOpMetadata) {
|
|
64
|
+
(0, common_utils_1.assert)(this.isLoaded, 0x2f0 /* "Remote channel must be loaded when rolling back op" */);
|
|
65
|
+
this.services.deltaConnection.rollback(content, localOpMetadata);
|
|
66
|
+
}
|
|
62
67
|
/**
|
|
63
68
|
* Returns a summary at the current sequence number.
|
|
64
69
|
* @param fullTree - true to bypass optimizations and force a full summary tree
|
|
65
70
|
* @param trackState - This tells whether we should track state from this summary.
|
|
71
|
+
* @param telemetryContext - summary data passed through the layers for telemetry purposes
|
|
66
72
|
*/
|
|
67
|
-
async summarize(fullTree = false, trackState = true) {
|
|
68
|
-
return this.summarizerNode.summarize(fullTree, trackState);
|
|
73
|
+
async summarize(fullTree = false, trackState = true, telemetryContext) {
|
|
74
|
+
return this.summarizerNode.summarize(fullTree, trackState, telemetryContext);
|
|
69
75
|
}
|
|
70
|
-
async summarizeInternal(fullTree, trackState) {
|
|
76
|
+
async summarizeInternal(fullTree, trackState, telemetryContext) {
|
|
71
77
|
const channel = await this.getChannel();
|
|
72
|
-
const summarizeResult = await (0, channelContext_1.summarizeChannelAsync)(channel, fullTree, trackState);
|
|
78
|
+
const summarizeResult = await (0, channelContext_1.summarizeChannelAsync)(channel, fullTree, trackState, telemetryContext);
|
|
73
79
|
return Object.assign(Object.assign({}, summarizeResult), { id: this.id });
|
|
74
80
|
}
|
|
75
81
|
async loadChannel() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"remoteChannelContext.js","sourceRoot":"","sources":["../src/remoteChannelContext.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,+DAAsD;AACtD,qEAAsE;AAStE,+DAA4D;AAc5D,qEAAkG;AAClG,qDAK0B;AAK1B,MAAa,oBAAoB;IAc7B,YACqB,OAA+B,EAC/B,gBAAwC,EACzD,cAA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CAAC,eAAe,CAAC,OAAO,CAAC,OAAO,EAAE,KAAK,EAAE,SAAS,CAAC,qBAAqB,CAAC,CAAC;SAC1F;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;IACxB,CAAC;IAED;;;;;;OAMG;IACI,KAAK,CAAC,SAAS,CAAC,SAAkB,KAAK;QAC1C,OAAO,IAAI,CAAC,cAAc,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IACjD,CAAC;IAED;;;;OAIG;IACK,KAAK,CAAC,iBAAiB,CAAC,SAAkB,KAAK;QACnD,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,UAAU,EAAE,CAAC;QACxC,OAAO,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IACrC,CAAC;IAEM,gBAAgB,CAAC,UAAoB,EAAE,WAAoB;QAC9D;;;;;WAKG;QACH,IAAI,CAAC,cAAc,CAAC,gBAAgB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAC/C,CAAC;;AA7PL,oDA8PC;AAlP2B,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 IChannel,\n IChannelAttributes,\n IFluidDataStoreRuntime,\n IChannelFactory,\n} from \"@fluidframework/datastore-definitions\";\nimport { IDocumentStorageService } from \"@fluidframework/driver-definitions\";\nimport { readAndParse } from \"@fluidframework/driver-utils\";\nimport {\n ISequencedDocumentMessage,\n ISnapshotTree,\n} from \"@fluidframework/protocol-definitions\";\nimport {\n CreateChildSummarizerNodeFn,\n IFluidDataStoreContext,\n IGarbageCollectionData,\n IGarbageCollectionDetailsBase,\n ISummarizeInternalResult,\n ISummarizeResult,\n ISummarizerNodeWithGC,\n} from \"@fluidframework/runtime-definitions\";\nimport { ChildLogger, TelemetryDataTag, ThresholdCounter } from \"@fluidframework/telemetry-utils\";\nimport {\n attributesBlobKey,\n createServiceEndpoints,\n IChannelContext,\n summarizeChannelAsync,\n} from \"./channelContext\";\nimport { ChannelDeltaConnection } from \"./channelDeltaConnection\";\nimport { ChannelStorageService } from \"./channelStorageService\";\nimport { ISharedObjectRegistry } from \"./dataStoreRuntime\";\n\nexport class RemoteChannelContext implements IChannelContext {\n private isLoaded = false;\n private pending: ISequencedDocumentMessage[] | undefined = [];\n private channelP: Promise<IChannel> | undefined;\n private channel: IChannel | undefined;\n private readonly services: {\n readonly deltaConnection: ChannelDeltaConnection;\n readonly objectStorage: ChannelStorageService;\n };\n private readonly summarizerNode: ISummarizerNodeWithGC;\n private readonly subLogger: ITelemetryLogger;\n private readonly thresholdOpsCounter: ThresholdCounter;\n private static readonly pendingOpsCountThreshold = 1000;\n\n constructor(\n private readonly runtime: IFluidDataStoreRuntime,\n private readonly dataStoreContext: IFluidDataStoreContext,\n storageService: IDocumentStorageService,\n submitFn: (content: any, localOpMetadata: unknown) => void,\n dirtyFn: (address: string) => void,\n addedGCOutboundReferenceFn: (srcHandle: IFluidHandle, outboundHandle: IFluidHandle) => void,\n private readonly id: string,\n baseSnapshot: ISnapshotTree,\n private readonly registry: ISharedObjectRegistry,\n extraBlobs: Map<string, ArrayBufferLike> | undefined,\n createSummarizerNode: CreateChildSummarizerNodeFn,\n getBaseGCDetails: () => Promise<IGarbageCollectionDetailsBase>,\n private readonly attachMessageType?: string,\n ) {\n this.subLogger = ChildLogger.create(this.runtime.logger, \"RemoteChannelContext\");\n\n this.services = createServiceEndpoints(\n this.id,\n this.dataStoreContext.connected,\n submitFn,\n () => dirtyFn(this.id),\n addedGCOutboundReferenceFn,\n storageService,\n this.subLogger,\n baseSnapshot,\n extraBlobs);\n\n const thisSummarizeInternal =\n async (fullTree: boolean, trackState: boolean) => this.summarizeInternal(fullTree, trackState);\n\n this.summarizerNode = createSummarizerNode(\n thisSummarizeInternal,\n async (fullGC?: boolean) => this.getGCDataInternal(fullGC),\n async () => getBaseGCDetails(),\n );\n\n this.thresholdOpsCounter = new ThresholdCounter(\n RemoteChannelContext.pendingOpsCountThreshold,\n this.subLogger,\n );\n }\n\n // eslint-disable-next-line @typescript-eslint/promise-function-async\n public getChannel(): Promise<IChannel> {\n if (this.channelP === undefined) {\n this.channelP = this.loadChannel();\n }\n\n return this.channelP;\n }\n\n public setConnectionState(connected: boolean, clientId?: string) {\n // Connection events are ignored if the data store is not yet loaded\n if (!this.isLoaded) {\n return;\n }\n\n this.services.deltaConnection.setConnectionState(connected);\n }\n\n public applyStashedOp(message: ISequencedDocumentMessage): unknown {\n assert(this.isLoaded, 0x194 /* \"Remote channel must be loaded when rebasing op\" */);\n return this.services.deltaConnection.applyStashedOp(message);\n }\n\n public processOp(message: ISequencedDocumentMessage, local: boolean, localOpMetadata: unknown): void {\n this.summarizerNode.invalidate(message.sequenceNumber);\n\n if (this.isLoaded) {\n this.services.deltaConnection.process(message, local, localOpMetadata);\n } else {\n assert(!local, 0x195 /* \"Remote channel must not be local when processing op\" */);\n assert(this.pending !== undefined, 0x23e /* \"pending is undefined\" */);\n this.pending.push(message);\n this.thresholdOpsCounter.sendIfMultiple(\"StorePendingOps\", this.pending.length);\n }\n }\n\n public reSubmit(content: any, localOpMetadata: unknown) {\n assert(this.isLoaded, 0x196 /* \"Remote channel must be loaded when resubmitting op\" */);\n\n this.services.deltaConnection.reSubmit(content, localOpMetadata);\n }\n\n /**\n * Returns a summary at the current sequence number.\n * @param fullTree - true to bypass optimizations and force a full summary tree\n * @param trackState - This tells whether we should track state from this summary.\n */\n public async summarize(fullTree: boolean = false, trackState: boolean = true): Promise<ISummarizeResult> {\n return this.summarizerNode.summarize(fullTree, trackState);\n }\n\n private async summarizeInternal(fullTree: boolean, trackState: boolean): Promise<ISummarizeInternalResult> {\n const channel = await this.getChannel();\n const summarizeResult = await summarizeChannelAsync(channel, fullTree, trackState);\n return { ...summarizeResult, id: this.id };\n }\n\n private async loadChannel(): Promise<IChannel> {\n assert(!this.isLoaded, 0x197 /* \"Remote channel must not already be loaded when loading\" */);\n\n let attributes: IChannelAttributes | undefined;\n if (await this.services.objectStorage.contains(attributesBlobKey)) {\n attributes = await readAndParse<IChannelAttributes | undefined>(\n this.services.objectStorage,\n attributesBlobKey);\n }\n\n let factory: IChannelFactory | undefined;\n // this is a backward compatibility case where\n // the attach message doesn't include\n // the attributes. Since old attach messages\n // will not have attributes we need to keep\n // this as long as we support old attach messages\n if (attributes === undefined) {\n if (this.attachMessageType === undefined) {\n // TODO: dataStoreId may require a different tag from PackageData #7488\n throw new DataCorruptionError(\"channelTypeNotAvailable\", {\n channelId: {\n value: this.id,\n tag: TelemetryDataTag.PackageData,\n },\n dataStoreId: {\n value: this.dataStoreContext.id,\n tag: TelemetryDataTag.PackageData,\n },\n dataStorePackagePath: this.dataStoreContext.packagePath.join(\"/\"),\n });\n }\n factory = this.registry.get(this.attachMessageType);\n if (factory === undefined) {\n // TODO: dataStoreId may require a different tag from PackageData #7488\n throw new DataCorruptionError(\"channelFactoryNotRegisteredForAttachMessageType\", {\n channelId: {\n value: this.id,\n tag: TelemetryDataTag.PackageData,\n },\n dataStoreId: {\n value: this.dataStoreContext.id,\n tag: TelemetryDataTag.PackageData,\n },\n dataStorePackagePath: this.dataStoreContext.packagePath.join(\"/\"),\n channelFactoryType: this.attachMessageType,\n });\n }\n attributes = factory.attributes;\n } else {\n factory = this.registry.get(attributes.type);\n if (factory === undefined) {\n // TODO: dataStoreId may require a different tag from PackageData #7488\n throw new DataCorruptionError(\"channelFactoryNotRegisteredForGivenType\", {\n channelId: {\n value: this.id,\n tag: TelemetryDataTag.PackageData,\n },\n dataStoreId: {\n value: this.dataStoreContext.id,\n tag: TelemetryDataTag.PackageData,\n },\n dataStorePackagePath: this.dataStoreContext.packagePath.join(\"/\"),\n channelFactoryType: attributes.type,\n });\n }\n }\n\n // Compare snapshot version to collaborative object version\n if (attributes.snapshotFormatVersion !== undefined\n && attributes.snapshotFormatVersion !== factory.attributes.snapshotFormatVersion) {\n this.subLogger.sendTelemetryEvent(\n {\n eventName: \"ChannelAttributesVersionMismatch\",\n channelType: { value: attributes.type, tag: TelemetryDataTag.PackageData },\n channelSnapshotVersion: {\n value: `${attributes.snapshotFormatVersion}@${attributes.packageVersion}`,\n tag: TelemetryDataTag.PackageData,\n },\n channelCodeVersion: {\n value: `${factory.attributes.snapshotFormatVersion}@${factory.attributes.packageVersion}`,\n tag: TelemetryDataTag.PackageData,\n },\n },\n );\n }\n\n const channel = await factory.load(\n this.runtime,\n this.id,\n this.services,\n attributes);\n\n // Send all pending messages to the channel\n assert(this.pending !== undefined, 0x23f /* \"pending undefined\" */);\n for (const message of this.pending) {\n this.services.deltaConnection.process(message, false, undefined /* localOpMetadata */);\n }\n this.thresholdOpsCounter.send(\"ProcessPendingOps\", this.pending.length);\n\n // Commit changes.\n this.channel = channel;\n this.pending = undefined;\n this.isLoaded = true;\n\n // Because have some await between we created the service and here, the connection state might have changed\n // and we don't propagate the connection state when we are not loaded. So we have to set it again here.\n this.services.deltaConnection.setConnectionState(this.dataStoreContext.connected);\n return this.channel;\n }\n\n /**\n * Returns the data used for garbage collection. This includes a list of GC nodes that represent this context.\n * Each node has a set of outbound routes to other GC nodes in the document.\n * If there is no new data in this context since the last summary, previous GC data is used.\n * If there is new data, the GC data is generated again (by calling getGCDataInternal).\n * @param fullGC - true to bypass optimizations and force full generation of GC data.\n */\n public async getGCData(fullGC: boolean = false): Promise<IGarbageCollectionData> {\n return this.summarizerNode.getGCData(fullGC);\n }\n\n /**\n * Generates the data used for garbage collection. This is called when there is new data since last summary. It\n * loads the context and calls into the channel to get its GC data.\n * @param fullGC - true to bypass optimizations and force full generation of GC data.\n */\n private async getGCDataInternal(fullGC: boolean = false): Promise<IGarbageCollectionData> {\n const channel = await this.getChannel();\n return channel.getGCData(fullGC);\n }\n\n public updateUsedRoutes(usedRoutes: string[], gcTimestamp?: number) {\n /**\n * Currently, DDSs are always considered referenced and are not garbage collected. Update the summarizer node's\n * used routes to contain a route to this channel context.\n * Once we have GC at DDS level, this will be updated to use the passed usedRoutes. See -\n * https://github.com/microsoft/FluidFramework/issues/4611\n */\n this.summarizerNode.updateUsedRoutes([\"\"]);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"remoteChannelContext.js","sourceRoot":"","sources":["../src/remoteChannelContext.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,+DAAsD;AACtD,qEAAsE;AAStE,+DAA4D;AAe5D,qEAAkG;AAClG,qDAK0B;AAK1B,MAAa,oBAAoB;IAc7B,YACqB,OAA+B,EAC/B,gBAAwC,EACzD,cAAuC,EACvC,QAA0D,EAC1D,OAAkC,EAClC,0BAA2F,EAC1E,EAAU,EAC3B,YAA2B,EACV,QAA+B,EAChD,UAAoD,EACpD,oBAAiD,EACjD,gBAA8D,EAC7C,iBAA0B;QAZ1B,YAAO,GAAP,OAAO,CAAwB;QAC/B,qBAAgB,GAAhB,gBAAgB,CAAwB;QAKxC,OAAE,GAAF,EAAE,CAAQ;QAEV,aAAQ,GAAR,QAAQ,CAAuB;QAI/B,sBAAiB,GAAjB,iBAAiB,CAAS;QA1BvC,aAAQ,GAAG,KAAK,CAAC;QACjB,YAAO,GAA4C,EAAE,CAAC;QA2B1D,IAAA,qBAAM,E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YAChC,IAAI,CAAC,QAAQ,CAAC,eAAe,CAAC,OAAO,CAAC,OAAO,EAAE,KAAK,EAAE,SAAS,CAAC,qBAAqB,CAAC,CAAC;SAC1F;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;IACxB,CAAC;IAED;;;;;;OAMG;IACI,KAAK,CAAC,SAAS,CAAC,SAAkB,KAAK;QAC1C,OAAO,IAAI,CAAC,cAAc,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IACjD,CAAC;IAED;;;;OAIG;IACK,KAAK,CAAC,iBAAiB,CAAC,SAAkB,KAAK;QACnD,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,UAAU,EAAE,CAAC;QACxC,OAAO,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IACrC,CAAC;IAEM,gBAAgB,CAAC,UAAoB,EAAE,WAAoB;QAC9D;;;;;WAKG;QACH,IAAI,CAAC,cAAc,CAAC,gBAAgB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAC/C,CAAC;;AA/QL,oDAgRC;AApQ2B,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 IChannel,\n IChannelAttributes,\n IFluidDataStoreRuntime,\n IChannelFactory,\n} from \"@fluidframework/datastore-definitions\";\nimport { IDocumentStorageService } from \"@fluidframework/driver-definitions\";\nimport { readAndParse } from \"@fluidframework/driver-utils\";\nimport {\n ISequencedDocumentMessage,\n ISnapshotTree,\n} from \"@fluidframework/protocol-definitions\";\nimport {\n CreateChildSummarizerNodeFn,\n IFluidDataStoreContext,\n IGarbageCollectionData,\n IGarbageCollectionDetailsBase,\n ISummarizeInternalResult,\n ISummarizeResult,\n ISummarizerNodeWithGC,\n ITelemetryContext,\n} from \"@fluidframework/runtime-definitions\";\nimport { ChildLogger, TelemetryDataTag, ThresholdCounter } from \"@fluidframework/telemetry-utils\";\nimport {\n attributesBlobKey,\n createServiceEndpoints,\n IChannelContext,\n summarizeChannelAsync,\n} from \"./channelContext\";\nimport { ChannelDeltaConnection } from \"./channelDeltaConnection\";\nimport { ChannelStorageService } from \"./channelStorageService\";\nimport { ISharedObjectRegistry } from \"./dataStoreRuntime\";\n\nexport class RemoteChannelContext implements IChannelContext {\n private isLoaded = false;\n private pending: ISequencedDocumentMessage[] | undefined = [];\n private channelP: Promise<IChannel> | undefined;\n private channel: IChannel | undefined;\n private readonly services: {\n readonly deltaConnection: ChannelDeltaConnection;\n readonly objectStorage: ChannelStorageService;\n };\n private readonly summarizerNode: ISummarizerNodeWithGC;\n private readonly subLogger: ITelemetryLogger;\n private readonly thresholdOpsCounter: ThresholdCounter;\n private static readonly pendingOpsCountThreshold = 1000;\n\n constructor(\n private readonly runtime: IFluidDataStoreRuntime,\n private readonly dataStoreContext: IFluidDataStoreContext,\n storageService: IDocumentStorageService,\n submitFn: (content: any, localOpMetadata: unknown) => void,\n dirtyFn: (address: string) => void,\n addedGCOutboundReferenceFn: (srcHandle: IFluidHandle, outboundHandle: IFluidHandle) => void,\n private readonly id: string,\n baseSnapshot: ISnapshotTree,\n private readonly registry: ISharedObjectRegistry,\n extraBlobs: Map<string, ArrayBufferLike> | undefined,\n createSummarizerNode: CreateChildSummarizerNodeFn,\n getBaseGCDetails: () => Promise<IGarbageCollectionDetailsBase>,\n private readonly attachMessageType?: string,\n ) {\n assert(!this.id.includes(\"/\"), 0x310 /* Channel context ID cannot contain slashes */);\n\n this.subLogger = ChildLogger.create(this.runtime.logger, \"RemoteChannelContext\");\n\n this.services = createServiceEndpoints(\n this.id,\n this.dataStoreContext.connected,\n submitFn,\n () => dirtyFn(this.id),\n addedGCOutboundReferenceFn,\n storageService,\n this.subLogger,\n baseSnapshot,\n extraBlobs);\n\n const thisSummarizeInternal =\n async (fullTree: boolean, trackState: boolean, telemetryContext?: ITelemetryContext) =>\n this.summarizeInternal(fullTree, trackState, telemetryContext);\n\n this.summarizerNode = createSummarizerNode(\n thisSummarizeInternal,\n async (fullGC?: boolean) => this.getGCDataInternal(fullGC),\n async () => getBaseGCDetails(),\n );\n\n this.thresholdOpsCounter = new ThresholdCounter(\n RemoteChannelContext.pendingOpsCountThreshold,\n this.subLogger,\n );\n }\n\n // eslint-disable-next-line @typescript-eslint/promise-function-async\n public getChannel(): Promise<IChannel> {\n if (this.channelP === undefined) {\n this.channelP = this.loadChannel();\n }\n\n return this.channelP;\n }\n\n public setConnectionState(connected: boolean, clientId?: string) {\n // Connection events are ignored if the data store is not yet loaded\n if (!this.isLoaded) {\n return;\n }\n\n this.services.deltaConnection.setConnectionState(connected);\n }\n\n public applyStashedOp(message: ISequencedDocumentMessage): unknown {\n assert(this.isLoaded, 0x194 /* \"Remote channel must be loaded when rebasing op\" */);\n return this.services.deltaConnection.applyStashedOp(message);\n }\n\n public processOp(message: ISequencedDocumentMessage, local: boolean, localOpMetadata: unknown): void {\n this.summarizerNode.invalidate(message.sequenceNumber);\n\n if (this.isLoaded) {\n this.services.deltaConnection.process(message, local, localOpMetadata);\n } else {\n assert(!local, 0x195 /* \"Remote channel must not be local when processing op\" */);\n assert(this.pending !== undefined, 0x23e /* \"pending is undefined\" */);\n this.pending.push(message);\n this.thresholdOpsCounter.sendIfMultiple(\"StorePendingOps\", this.pending.length);\n }\n }\n\n public reSubmit(content: any, localOpMetadata: unknown) {\n assert(this.isLoaded, 0x196 /* \"Remote channel must be loaded when resubmitting op\" */);\n\n this.services.deltaConnection.reSubmit(content, localOpMetadata);\n }\n\n public rollback(content: any, localOpMetadata: unknown) {\n assert(this.isLoaded, 0x2f0 /* \"Remote channel must be loaded when rolling back op\" */);\n\n this.services.deltaConnection.rollback(content, localOpMetadata);\n }\n\n /**\n * Returns a summary at the current sequence number.\n * @param fullTree - true to bypass optimizations and force a full summary tree\n * @param trackState - This tells whether we should track state from this summary.\n * @param telemetryContext - summary data passed through the layers for telemetry purposes\n */\n public async summarize(\n fullTree: boolean = false,\n trackState: boolean = true,\n telemetryContext?: ITelemetryContext,\n ): Promise<ISummarizeResult> {\n return this.summarizerNode.summarize(fullTree, trackState, telemetryContext);\n }\n\n private async summarizeInternal(\n fullTree: boolean,\n trackState: boolean,\n telemetryContext?: ITelemetryContext,\n ): Promise<ISummarizeInternalResult> {\n const channel = await this.getChannel();\n const summarizeResult = await summarizeChannelAsync(channel, fullTree, trackState, telemetryContext);\n return { ...summarizeResult, id: this.id };\n }\n\n private async loadChannel(): Promise<IChannel> {\n assert(!this.isLoaded, 0x197 /* \"Remote channel must not already be loaded when loading\" */);\n\n let attributes: IChannelAttributes | undefined;\n if (await this.services.objectStorage.contains(attributesBlobKey)) {\n attributes = await readAndParse<IChannelAttributes | undefined>(\n this.services.objectStorage,\n attributesBlobKey);\n }\n\n let factory: IChannelFactory | undefined;\n // this is a backward compatibility case where\n // the attach message doesn't include\n // the attributes. Since old attach messages\n // will not have attributes we need to keep\n // this as long as we support old attach messages\n if (attributes === undefined) {\n if (this.attachMessageType === undefined) {\n // TODO: dataStoreId may require a different tag from PackageData #7488\n throw new DataCorruptionError(\"channelTypeNotAvailable\", {\n channelId: {\n value: this.id,\n tag: TelemetryDataTag.PackageData,\n },\n dataStoreId: {\n value: this.dataStoreContext.id,\n tag: TelemetryDataTag.PackageData,\n },\n dataStorePackagePath: this.dataStoreContext.packagePath.join(\"/\"),\n });\n }\n factory = this.registry.get(this.attachMessageType);\n if (factory === undefined) {\n // TODO: dataStoreId may require a different tag from PackageData #7488\n throw new DataCorruptionError(\"channelFactoryNotRegisteredForAttachMessageType\", {\n channelId: {\n value: this.id,\n tag: TelemetryDataTag.PackageData,\n },\n dataStoreId: {\n value: this.dataStoreContext.id,\n tag: TelemetryDataTag.PackageData,\n },\n dataStorePackagePath: this.dataStoreContext.packagePath.join(\"/\"),\n channelFactoryType: this.attachMessageType,\n });\n }\n attributes = factory.attributes;\n } else {\n factory = this.registry.get(attributes.type);\n if (factory === undefined) {\n // TODO: dataStoreId may require a different tag from PackageData #7488\n throw new DataCorruptionError(\"channelFactoryNotRegisteredForGivenType\", {\n channelId: {\n value: this.id,\n tag: TelemetryDataTag.PackageData,\n },\n dataStoreId: {\n value: this.dataStoreContext.id,\n tag: TelemetryDataTag.PackageData,\n },\n dataStorePackagePath: this.dataStoreContext.packagePath.join(\"/\"),\n channelFactoryType: attributes.type,\n });\n }\n }\n\n // Compare snapshot version to collaborative object version\n if (attributes.snapshotFormatVersion !== undefined\n && attributes.snapshotFormatVersion !== factory.attributes.snapshotFormatVersion) {\n this.subLogger.sendTelemetryEvent(\n {\n eventName: \"ChannelAttributesVersionMismatch\",\n channelType: { value: attributes.type, tag: TelemetryDataTag.PackageData },\n channelSnapshotVersion: {\n value: `${attributes.snapshotFormatVersion}@${attributes.packageVersion}`,\n tag: TelemetryDataTag.PackageData,\n },\n channelCodeVersion: {\n value: `${factory.attributes.snapshotFormatVersion}@${factory.attributes.packageVersion}`,\n tag: TelemetryDataTag.PackageData,\n },\n },\n );\n }\n\n const channel = await factory.load(\n this.runtime,\n this.id,\n this.services,\n attributes);\n\n // Send all pending messages to the channel\n assert(this.pending !== undefined, 0x23f /* \"pending undefined\" */);\n for (const message of this.pending) {\n this.services.deltaConnection.process(message, false, undefined /* localOpMetadata */);\n }\n this.thresholdOpsCounter.send(\"ProcessPendingOps\", this.pending.length);\n\n // Commit changes.\n this.channel = channel;\n this.pending = undefined;\n this.isLoaded = true;\n\n // Because have some await between we created the service and here, the connection state might have changed\n // and we don't propagate the connection state when we are not loaded. So we have to set it again here.\n this.services.deltaConnection.setConnectionState(this.dataStoreContext.connected);\n return this.channel;\n }\n\n /**\n * Returns the data used for garbage collection. This includes a list of GC nodes that represent this context.\n * Each node has a set of outbound routes to other GC nodes in the document.\n * If there is no new data in this context since the last summary, previous GC data is used.\n * If there is new data, the GC data is generated again (by calling getGCDataInternal).\n * @param fullGC - true to bypass optimizations and force full generation of GC data.\n */\n public async getGCData(fullGC: boolean = false): Promise<IGarbageCollectionData> {\n return this.summarizerNode.getGCData(fullGC);\n }\n\n /**\n * Generates the data used for garbage collection. This is called when there is new data since last summary. It\n * loads the context and calls into the channel to get its GC data.\n * @param fullGC - true to bypass optimizations and force full generation of GC data.\n */\n private async getGCDataInternal(fullGC: boolean = false): Promise<IGarbageCollectionData> {\n const channel = await this.getChannel();\n return channel.getGCData(fullGC);\n }\n\n public updateUsedRoutes(usedRoutes: string[], gcTimestamp?: number) {\n /**\n * Currently, DDSs are always considered referenced and are not garbage collected. Update the summarizer node's\n * used routes to contain a route to this channel context.\n * Once we have GC at DDS level, this will be updated to use the passed usedRoutes. See -\n * https://github.com/microsoft/FluidFramework/issues/4611\n */\n this.summarizerNode.updateUsedRoutes([\"\"]);\n }\n}\n"]}
|
package/lib/channelContext.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ import { IFluidHandle } from "@fluidframework/core-interfaces";
|
|
|
7
7
|
import { IChannel } from "@fluidframework/datastore-definitions";
|
|
8
8
|
import { IDocumentStorageService } from "@fluidframework/driver-definitions";
|
|
9
9
|
import { ISequencedDocumentMessage, ISnapshotTree } from "@fluidframework/protocol-definitions";
|
|
10
|
-
import { IGarbageCollectionData, ISummarizeResult, ISummaryTreeWithStats } from "@fluidframework/runtime-definitions";
|
|
10
|
+
import { IGarbageCollectionData, ISummarizeResult, ISummaryTreeWithStats, ITelemetryContext } from "@fluidframework/runtime-definitions";
|
|
11
11
|
import { ChannelDeltaConnection } from "./channelDeltaConnection";
|
|
12
12
|
import { ChannelStorageService } from "./channelStorageService";
|
|
13
13
|
export declare const attributesBlobKey = ".attributes";
|
|
@@ -15,9 +15,10 @@ export interface IChannelContext {
|
|
|
15
15
|
getChannel(): Promise<IChannel>;
|
|
16
16
|
setConnectionState(connected: boolean, clientId?: string): any;
|
|
17
17
|
processOp(message: ISequencedDocumentMessage, local: boolean, localOpMetadata?: unknown): void;
|
|
18
|
-
summarize(fullTree?: boolean, trackState?: boolean): Promise<ISummarizeResult>;
|
|
18
|
+
summarize(fullTree?: boolean, trackState?: boolean, telemetryContext?: ITelemetryContext): Promise<ISummarizeResult>;
|
|
19
19
|
reSubmit(content: any, localOpMetadata: unknown): void;
|
|
20
20
|
applyStashedOp(content: any): unknown;
|
|
21
|
+
rollback(message: any, localOpMetadata: unknown): void;
|
|
21
22
|
/**
|
|
22
23
|
* Returns the data used for garbage collection. This includes a list of GC nodes that represent this context
|
|
23
24
|
* including any of its children. Each node has a set of outbound routes to other GC nodes in the document.
|
|
@@ -37,6 +38,6 @@ export declare function createServiceEndpoints(id: string, connected: boolean, s
|
|
|
37
38
|
deltaConnection: ChannelDeltaConnection;
|
|
38
39
|
objectStorage: ChannelStorageService;
|
|
39
40
|
};
|
|
40
|
-
export declare function summarizeChannel(channel: IChannel, fullTree?: boolean, trackState?: boolean): ISummaryTreeWithStats;
|
|
41
|
-
export declare function summarizeChannelAsync(channel: IChannel, fullTree?: boolean, trackState?: boolean): Promise<ISummaryTreeWithStats>;
|
|
41
|
+
export declare function summarizeChannel(channel: IChannel, fullTree?: boolean, trackState?: boolean, telemetryContext?: ITelemetryContext): ISummaryTreeWithStats;
|
|
42
|
+
export declare function summarizeChannelAsync(channel: IChannel, fullTree?: boolean, trackState?: boolean, telemetryContext?: ITelemetryContext): Promise<ISummaryTreeWithStats>;
|
|
42
43
|
//# sourceMappingURL=channelContext.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"channelContext.d.ts","sourceRoot":"","sources":["../src/channelContext.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AACtE,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,MAAM,uCAAuC,CAAC;AACjE,OAAO,EAAE,uBAAuB,EAAE,MAAM,oCAAoC,CAAC;AAC7E,OAAO,EAAE,yBAAyB,EAAE,aAAa,EAAE,MAAM,sCAAsC,CAAC;AAChG,OAAO,EACH,sBAAsB,EACtB,gBAAgB,EAChB,qBAAqB,
|
|
1
|
+
{"version":3,"file":"channelContext.d.ts","sourceRoot":"","sources":["../src/channelContext.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AACtE,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,MAAM,uCAAuC,CAAC;AACjE,OAAO,EAAE,uBAAuB,EAAE,MAAM,oCAAoC,CAAC;AAC7E,OAAO,EAAE,yBAAyB,EAAE,aAAa,EAAE,MAAM,sCAAsC,CAAC;AAChG,OAAO,EACH,sBAAsB,EACtB,gBAAgB,EAChB,qBAAqB,EACrB,iBAAiB,EACpB,MAAM,qCAAqC,CAAC;AAE7C,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAEhE,eAAO,MAAM,iBAAiB,gBAAgB,CAAC;AAE/C,MAAM,WAAW,eAAe;IAC5B,UAAU,IAAI,OAAO,CAAC,QAAQ,CAAC,CAAC;IAEhC,kBAAk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,OAAe,EACzB,UAAU,GAAE,OAAe,EAC3B,gBAAgB,CAAC,EAAE,iBAAiB,GACrC,qBAAqB,CAMvB;AAED,wBAAsB,qBAAqB,CACvC,OAAO,EAAE,QAAQ,EACjB,QAAQ,GAAE,OAAe,EACzB,UAAU,GAAE,OAAe,EAC3B,gBAAgB,CAAC,EAAE,iBAAiB,GACrC,OAAO,CAAC,qBAAqB,CAAC,CAMhC"}
|
package/lib/channelContext.js
CHANGED
|
@@ -14,14 +14,14 @@ export function createServiceEndpoints(id, connected, submitFn, dirtyFn, addedGC
|
|
|
14
14
|
objectStorage,
|
|
15
15
|
};
|
|
16
16
|
}
|
|
17
|
-
export function summarizeChannel(channel, fullTree = false, trackState = false) {
|
|
18
|
-
const summarizeResult = channel.getAttachSummary(fullTree, trackState);
|
|
17
|
+
export function summarizeChannel(channel, fullTree = false, trackState = false, telemetryContext) {
|
|
18
|
+
const summarizeResult = channel.getAttachSummary(fullTree, trackState, telemetryContext);
|
|
19
19
|
// Add the channel attributes to the returned result.
|
|
20
20
|
addBlobToSummary(summarizeResult, attributesBlobKey, JSON.stringify(channel.attributes));
|
|
21
21
|
return summarizeResult;
|
|
22
22
|
}
|
|
23
|
-
export async function summarizeChannelAsync(channel, fullTree = false, trackState = false) {
|
|
24
|
-
const summarizeResult = await channel.summarize(fullTree, trackState);
|
|
23
|
+
export async function summarizeChannelAsync(channel, fullTree = false, trackState = false, telemetryContext) {
|
|
24
|
+
const summarizeResult = await channel.summarize(fullTree, trackState, telemetryContext);
|
|
25
25
|
// Add the channel attributes to the returned result.
|
|
26
26
|
addBlobToSummary(summarizeResult, attributesBlobKey, JSON.stringify(channel.attributes));
|
|
27
27
|
return summarizeResult;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"channelContext.js","sourceRoot":"","sources":["../src/channelContext.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"channelContext.js","sourceRoot":"","sources":["../src/channelContext.ts"],"names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CAAC,QAAQ,EAAE,UAAU,EAAE,gBAAgB,CAAC,CAAC;IAExF,qDAAqD;IACrD,gBAAgB,CAAC,eAAe,EAAE,iBAAiB,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC;IACzF,OAAO,eAAe,CAAC;AAC3B,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 { IFluidHandle } from \"@fluidframework/core-interfaces\";\nimport { IChannel } from \"@fluidframework/datastore-definitions\";\nimport { IDocumentStorageService } from \"@fluidframework/driver-definitions\";\nimport { ISequencedDocumentMessage, ISnapshotTree } from \"@fluidframework/protocol-definitions\";\nimport {\n IGarbageCollectionData,\n ISummarizeResult,\n ISummaryTreeWithStats,\n ITelemetryContext,\n} from \"@fluidframework/runtime-definitions\";\nimport { addBlobToSummary } from \"@fluidframework/runtime-utils\";\nimport { ChannelDeltaConnection } from \"./channelDeltaConnection\";\nimport { ChannelStorageService } from \"./channelStorageService\";\n\nexport const attributesBlobKey = \".attributes\";\n\nexport interface IChannelContext {\n getChannel(): Promise<IChannel>;\n\n setConnectionState(connected: boolean, clientId?: string);\n\n processOp(message: ISequencedDocumentMessage, local: boolean, localOpMetadata?: unknown): void;\n\n summarize(\n fullTree?: boolean,\n trackState?: boolean,\n telemetryContext?: ITelemetryContext,\n ): Promise<ISummarizeResult>;\n\n reSubmit(content: any, localOpMetadata: unknown): void;\n\n applyStashedOp(content: any): unknown;\n\n rollback(message: any, localOpMetadata: unknown): void;\n\n /**\n * Returns the data used for garbage collection. This includes a list of GC nodes that represent this context\n * including any of its children. Each node has a set of outbound routes to other GC nodes in the document.\n * @param fullGC - true to bypass optimizations and force full generation of GC data.\n */\n getGCData(fullGC?: boolean): Promise<IGarbageCollectionData>;\n\n /**\n * After GC has run, called to notify this context of routes that are used in it. These are used for the following:\n * 1. To identify if this context is being referenced in the document or not.\n * 2. To identify if this context or any of its children's used routes changed since last summary.\n * 3. They are added to the summary generated by this context.\n * 4. To update the timestamp when this context is marked as unreferenced.\n */\n updateUsedRoutes(usedRoutes: string[], gcTimestamp?: number): void;\n}\n\nexport function createServiceEndpoints(\n id: string,\n connected: boolean,\n submitFn: (content: any, localOpMetadata: unknown) => void,\n dirtyFn: () => void,\n addedGCOutboundReferenceFn: (srcHandle: IFluidHandle, outboundHandle: IFluidHandle) => void,\n storageService: IDocumentStorageService,\n logger: ITelemetryLogger,\n tree?: ISnapshotTree,\n extraBlobs?: Map<string, ArrayBufferLike>,\n) {\n const deltaConnection = new ChannelDeltaConnection(\n id,\n connected,\n (message, localOpMetadata) => submitFn(message, localOpMetadata),\n dirtyFn,\n addedGCOutboundReferenceFn);\n const objectStorage = new ChannelStorageService(tree, storageService, logger, extraBlobs);\n\n return {\n deltaConnection,\n objectStorage,\n };\n}\n\nexport function summarizeChannel(\n channel: IChannel,\n fullTree: boolean = false,\n trackState: boolean = false,\n telemetryContext?: ITelemetryContext,\n): ISummaryTreeWithStats {\n const summarizeResult = channel.getAttachSummary(fullTree, trackState, telemetryContext);\n\n // Add the channel attributes to the returned result.\n addBlobToSummary(summarizeResult, attributesBlobKey, JSON.stringify(channel.attributes));\n return summarizeResult;\n}\n\nexport async function summarizeChannelAsync(\n channel: IChannel,\n fullTree: boolean = false,\n trackState: boolean = false,\n telemetryContext?: ITelemetryContext,\n): Promise<ISummaryTreeWithStats> {\n const summarizeResult = await channel.summarize(fullTree, trackState, telemetryContext);\n\n // Add the channel attributes to the returned result.\n addBlobToSummary(summarizeResult, attributesBlobKey, JSON.stringify(channel.attributes));\n return summarizeResult;\n}\n"]}
|
|
@@ -19,6 +19,7 @@ export declare class ChannelDeltaConnection implements IDeltaConnection {
|
|
|
19
19
|
setConnectionState(connected: boolean): void;
|
|
20
20
|
process(message: ISequencedDocumentMessage, local: boolean, localOpMetadata: unknown): void;
|
|
21
21
|
reSubmit(content: any, localOpMetadata: unknown): void;
|
|
22
|
+
rollback(content: any, localOpMetadata: unknown): void;
|
|
22
23
|
applyStashedOp(message: ISequencedDocumentMessage): unknown;
|
|
23
24
|
}
|
|
24
25
|
//# sourceMappingURL=channelDeltaConnection.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"channelDeltaConnection.d.ts","sourceRoot":"","sources":["../src/channelDeltaConnection.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,gBAAgB,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAC;AACnG,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,uCAAuC,CAAC;AAExF,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAE/D,qBAAa,sBAAuB,YAAW,gBAAgB;IAYhD,QAAQ,EAAE,MAAM;IACvB,OAAO,CAAC,UAAU;aACF,MAAM,EAAE,CAAC,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,OAAO,KAAK,IAAI;aACrE,KAAK,EAAE,MAAM,IAAI;aACjB,wBAAwB,EAAE,CAAC,SAAS,EAAE,YAAY,EAAE,cAAc,EAAE,YAAY,KAAK,IAAI;IAf7G,OAAO,CAAC,QAAQ,CAA4B;IAE5C,OAAO,KAAK,OAAO,GAGlB;IACD,IAAW,SAAS,IAAI,OAAO,CAE9B;gBAGU,QAAQ,EAAE,MAAM,EACf,UAAU,EAAE,OAAO,EACX,MAAM,EAAE,CAAC,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,OAAO,KAAK,IAAI,EACrE,KAAK,EAAE,MAAM,IAAI,EACjB,wBAAwB,EAAE,CAAC,SAAS,EAAE,YAAY,EAAE,cAAc,EAAE,YAAY,KAAK,IAAI;IAGtG,MAAM,CAAC,OAAO,EAAE,aAAa;IAK7B,kBAAkB,CAAC,SAAS,EAAE,OAAO;IAKrC,OAAO,CAAC,OAAO,EAAE,yBAAyB,EAAE,KAAK,EAAE,OAA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AAQ,CAAC,OAAO,EAAE,GAAG,EAAE,eAAe,EAAE,OAAO;IAI/C,QAAQ,CAAC,OAAO,EAAE,GAAG,EAAE,eAAe,EAAE,OAAO;IAO/C,cAAc,CAAC,OAAO,EAAE,yBAAyB,GAAG,OAAO;CAGrE"}
|
|
@@ -39,6 +39,12 @@ export class ChannelDeltaConnection {
|
|
|
39
39
|
reSubmit(content, localOpMetadata) {
|
|
40
40
|
this.handler.reSubmit(content, localOpMetadata);
|
|
41
41
|
}
|
|
42
|
+
rollback(content, localOpMetadata) {
|
|
43
|
+
if (this.handler.rollback === undefined) {
|
|
44
|
+
throw new Error("Handler doesn't support rollback");
|
|
45
|
+
}
|
|
46
|
+
this.handler.rollback(content, localOpMetadata);
|
|
47
|
+
}
|
|
42
48
|
applyStashedOp(message) {
|
|
43
49
|
return this.handler.applyStashedOp(message);
|
|
44
50
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"channelDeltaConnection.js","sourceRoot":"","sources":["../src/channelDeltaConnection.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AAGtD,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAGtE,MAAM,OAAO,sBAAsB;IAW/B,YACW,QAAgB,EACf,UAAmB,EACX,MAAqE,EACrE,KAAiB,EACjB,wBAAyF;QAJlG,aAAQ,GAAR,QAAQ,CAAQ;QACf,eAAU,GAAV,UAAU,CAAS;QACX,WAAM,GAAN,MAAM,CAA+D;QACrE,UAAK,GAAL,KAAK,CAAY;QACjB,6BAAwB,GAAxB,wBAAwB,CAAiE;IAC7G,CAAC;IAdD,IAAY,OAAO;QACf,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,EAAE,KAAK,CAAC,6BAA6B,CAAC,CAAC;QAC7D,OAAO,IAAI,CAAC,QAAQ,CAAC;IACzB,CAAC;IACD,IAAW,SAAS;QAChB,OAAO,IAAI,CAAC,UAAU,CAAC;IAC3B,CAAC;IAUM,MAAM,CAAC,OAAsB;QAChC,MAAM,CAAC,IAAI,CAAC,QAAQ,KAAK,SAAS,EAAE,KAAK,CAAC,uCAAuC,CAAC,CAAC;QACnF,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;IAC5B,CAAC;IAEM,kBAAkB,CAAC,SAAkB;QACxC,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;QAC5B,IAAI,CAAC,OAAO,CAAC,kBAAkB,CAAC,SAAS,CAAC,CAAC;IAC/C,CAAC;IAEM,OAAO,CAAC,OAAkC,EAAE,KAAc,EAAE,eAAwB;QACvF,IAAI;YACA,sFAAsF;YACtF,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,EAAE,KAAK,EAAE,eAAe,CAAC,CAAC;SACzD;QAAC,OAAO,KAAK,EAAE;YACZ,MAAM,mBAAmB,CAAC,kBAAkB,CACxC,KAAK,EAAE,8CAA8C,EAAE,OAAO,CAAC,CAAC;SACvE;IACL,CAAC;IAEM,QAAQ,CAAC,OAAY,EAAE,eAAwB;QAClD,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,OAAO,EAAE,eAAe,CAAC,CAAC;IACpD,CAAC;IAEM,cAAc,CAAC,OAAkC;QACpD,OAAO,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;IAChD,CAAC;CACJ","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/common-utils\";\nimport { IDocumentMessage, ISequencedDocumentMessage } from \"@fluidframework/protocol-definitions\";\nimport { IDeltaConnection, IDeltaHandler } from \"@fluidframework/datastore-definitions\";\nimport { DataProcessingError } from \"@fluidframework/container-utils\";\nimport { IFluidHandle } from \"@fluidframework/core-interfaces\";\n\nexport class ChannelDeltaConnection implements IDeltaConnection {\n private _handler: IDeltaHandler | undefined;\n\n private get handler(): IDeltaHandler {\n assert(!!this._handler, 0x177 /* \"Missing delta handler\" */);\n return this._handler;\n }\n public get connected(): boolean {\n return this._connected;\n }\n\n constructor(\n public objectId: string,\n private _connected: boolean,\n public readonly submit: (message: IDocumentMessage, localOpMetadata: unknown) => void,\n public readonly dirty: () => void,\n public readonly addedGCOutboundReference: (srcHandle: IFluidHandle, outboundHandle: IFluidHandle) => void) {\n }\n\n public attach(handler: IDeltaHandler) {\n assert(this._handler === undefined, 0x178 /* \"Missing delta handler on attach\" */);\n this._handler = handler;\n }\n\n public setConnectionState(connected: boolean) {\n this._connected = connected;\n this.handler.setConnectionState(connected);\n }\n\n public process(message: ISequencedDocumentMessage, local: boolean, localOpMetadata: unknown) {\n try {\n // catches as data processing error whether or not they come from async pending queues\n this.handler.process(message, local, localOpMetadata);\n } catch (error) {\n throw DataProcessingError.wrapIfUnrecognized(\n error, \"channelDeltaConnectionFailedToProcessMessage\", message);\n }\n }\n\n public reSubmit(content: any, localOpMetadata: unknown) {\n this.handler.reSubmit(content, localOpMetadata);\n }\n\n public applyStashedOp(message: ISequencedDocumentMessage): unknown {\n return this.handler.applyStashedOp(message);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"channelDeltaConnection.js","sourceRoot":"","sources":["../src/channelDeltaConnection.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AAGtD,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAGtE,MAAM,OAAO,sBAAsB;IAW/B,YACW,QAAgB,EACf,UAAmB,EACX,MAAqE,EACrE,KAAiB,EACjB,wBAAyF;QAJlG,aAAQ,GAAR,QAAQ,CAAQ;QACf,eAAU,GAAV,UAAU,CAAS;QACX,WAAM,GAAN,MAAM,CAA+D;QACrE,UAAK,GAAL,KAAK,CAAY;QACjB,6BAAwB,GAAxB,wBAAwB,CAAiE;IAC7G,CAAC;IAdD,IAAY,OAAO;QACf,MAAM,C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CAAC,OAAO,CAAC,CAAC;IAChD,CAAC;CACJ","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/common-utils\";\nimport { IDocumentMessage, ISequencedDocumentMessage } from \"@fluidframework/protocol-definitions\";\nimport { IDeltaConnection, IDeltaHandler } from \"@fluidframework/datastore-definitions\";\nimport { DataProcessingError } from \"@fluidframework/container-utils\";\nimport { IFluidHandle } from \"@fluidframework/core-interfaces\";\n\nexport class ChannelDeltaConnection implements IDeltaConnection {\n private _handler: IDeltaHandler | undefined;\n\n private get handler(): IDeltaHandler {\n assert(!!this._handler, 0x177 /* \"Missing delta handler\" */);\n return this._handler;\n }\n public get connected(): boolean {\n return this._connected;\n }\n\n constructor(\n public objectId: string,\n private _connected: boolean,\n public readonly submit: (message: IDocumentMessage, localOpMetadata: unknown) => void,\n public readonly dirty: () => void,\n public readonly addedGCOutboundReference: (srcHandle: IFluidHandle, outboundHandle: IFluidHandle) => void) {\n }\n\n public attach(handler: IDeltaHandler) {\n assert(this._handler === undefined, 0x178 /* \"Missing delta handler on attach\" */);\n this._handler = handler;\n }\n\n public setConnectionState(connected: boolean) {\n this._connected = connected;\n this.handler.setConnectionState(connected);\n }\n\n public process(message: ISequencedDocumentMessage, local: boolean, localOpMetadata: unknown) {\n try {\n // catches as data processing error whether or not they come from async pending queues\n this.handler.process(message, local, localOpMetadata);\n } catch (error) {\n throw DataProcessingError.wrapIfUnrecognized(\n error, \"channelDeltaConnectionFailedToProcessMessage\", message);\n }\n }\n\n public reSubmit(content: any, localOpMetadata: unknown) {\n this.handler.reSubmit(content, localOpMetadata);\n }\n\n public rollback(content: any, localOpMetadata: unknown) {\n if (this.handler.rollback === undefined) {\n throw new Error(\"Handler doesn't support rollback\");\n }\n this.handler.rollback(content, localOpMetadata);\n }\n\n public applyStashedOp(message: ISequencedDocumentMessage): unknown {\n return this.handler.applyStashedOp(message);\n }\n}\n"]}
|
|
@@ -7,7 +7,7 @@ import { IFluidHandle, IFluidHandleContext, IRequest, IResponse } from "@fluidfr
|
|
|
7
7
|
import { IAudience, IDeltaManager, AttachState, ILoaderOptions } from "@fluidframework/container-definitions";
|
|
8
8
|
import { TypedEventEmitter } from "@fluidframework/common-utils";
|
|
9
9
|
import { IClientDetails, IDocumentMessage, ISequencedDocumentMessage, IQuorumClients } from "@fluidframework/protocol-definitions";
|
|
10
|
-
import { IFluidDataStoreContext, IFluidDataStoreChannel, IGarbageCollectionData, IInboundSignalMessage, ISummaryTreeWithStats, VisibilityState } from "@fluidframework/runtime-definitions";
|
|
10
|
+
import { IFluidDataStoreContext, IFluidDataStoreChannel, IGarbageCollectionData, IInboundSignalMessage, ISummaryTreeWithStats, VisibilityState, ITelemetryContext } from "@fluidframework/runtime-definitions";
|
|
11
11
|
import { IChannel, IFluidDataStoreRuntime, IFluidDataStoreRuntimeEvents, IChannelFactory } from "@fluidframework/datastore-definitions";
|
|
12
12
|
export declare enum DataStoreMessageType {
|
|
13
13
|
Attach = "attach",
|
|
@@ -150,9 +150,10 @@ export declare class FluidDataStoreRuntime extends TypedEventEmitter<IFluidDataS
|
|
|
150
150
|
* Returns a summary at the current sequence number.
|
|
151
151
|
* @param fullTree - true to bypass optimizations and force a full summary tree
|
|
152
152
|
* @param trackState - This tells whether we should track state from this summary.
|
|
153
|
+
* @param telemetryContext - summary data passed through the layers for telemetry purposes
|
|
153
154
|
*/
|
|
154
|
-
summarize(fullTree?: boolean, trackState?: boolean): Promise<ISummaryTreeWithStats>;
|
|
155
|
-
getAttachSummary(): ISummaryTreeWithStats;
|
|
155
|
+
summarize(fullTree?: boolean, trackState?: boolean, telemetryContext?: ITelemetryContext): Promise<ISummaryTreeWithStats>;
|
|
156
|
+
getAttachSummary(telemetryContext?: ITelemetryContext): ISummaryTreeWithStats;
|
|
156
157
|
submitMessage(type: DataStoreMessageType, content: any, localOpMetadata: unknown): void;
|
|
157
158
|
submitSignal(type: string, content: any): void;
|
|
158
159
|
/**
|
|
@@ -173,6 +174,12 @@ export declare class FluidDataStoreRuntime extends TypedEventEmitter<IFluidDataS
|
|
|
173
174
|
* @param localOpMetadata - The local metadata associated with the original message.
|
|
174
175
|
*/
|
|
175
176
|
reSubmit(type: DataStoreMessageType, content: any, localOpMetadata: unknown): void;
|
|
177
|
+
/**
|
|
178
|
+
* Revert a local op.
|
|
179
|
+
* @param content - The content of the original message.
|
|
180
|
+
* @param localOpMetadata - The local metadata associated with the original message.
|
|
181
|
+
*/
|
|
182
|
+
rollback?(type: DataStoreMessageType, content: any, localOpMetadata: unknown): void;
|
|
176
183
|
applyStashedOp(content: any): Promise<unknown>;
|
|
177
184
|
private setChannelDirty;
|
|
178
185
|
private processChannelOp;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dataStoreRuntime.d.ts","sourceRoot":"","sources":["../src/dataStoreRuntime.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AACtE,OAAO,EACH,YAAY,EACZ,mBAAmB,EACnB,QAAQ,EACR,SAAS,EACZ,MAAM,iCAAiC,CAAC;AACzC,OAAO,EACH,SAAS,EACT,aAAa,EAEb,WAAW,EACX,cAAc,EACjB,MAAM,uCAAuC,CAAC;AAE/C,OAAO,EAIH,iBAAiB,EAEpB,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"dataStoreRuntime.d.ts","sourceRoot":"","sources":["../src/dataStoreRuntime.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AACtE,OAAO,EACH,YAAY,EACZ,mBAAmB,EACnB,QAAQ,EACR,SAAS,EACZ,MAAM,iCAAiC,CAAC;AACzC,OAAO,EACH,SAAS,EACT,aAAa,EAEb,WAAW,EACX,cAAc,EACjB,MAAM,uCAAuC,CAAC;AAE/C,OAAO,EAIH,iBAAiB,EAEpB,M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AE,OAAO,EAAE,GAAG;IAK9C;;OAEG;IACU,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC;IAI1C;;OAEG;IACH,OAAO,CAAC,aAAa;IA6BrB,OAAO,CAAC,eAAe;IAKvB,OAAO,CAAC,MAAM;IAQd;;;;;;OAMG;IACI,QAAQ,CAAC,IAAI,EAAE,oBAAoB,EAAE,OAAO,EAAE,GAAG,EAAE,eAAe,EAAE,OAAO;IAsBlF;;;;OAIG;IACI,QAAQ,CAAC,CAAC,IAAI,EAAE,oBAAoB,EAAE,OAAO,EAAE,GAAG,EAAE,eAAe,EAAE,OAAO;IAkBtE,cAAc,CAAC,OAAO,EAAE,GAAG,GAAG,OAAO,CAAC,OAAO,CAAC;IAQ3D,OAAO,CAAC,eAAe;IAKvB,OAAO,CAAC,gBAAgB;IAiBxB,OAAO,CAAC,cAAc;IAsCtB,OAAO,CAAC,eAAe;CAK1B;AAED;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,6BACF,QAAQ,WAAW,qBAAqB,KAAK,QAAQ,SAAS,CAAC,SACnF,4BAA4B,iCASD,CAAC;AAEtC;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,sBACT,qBAAqB,KAAK,QAAQ;IAAE,IAAI,EAAE,MAAM,EAAE,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;CAAE,GAAG,SAAS,CAAE,SACjG,4BAA4B,iCAiCD,CAAC"}
|
package/lib/dataStoreRuntime.js
CHANGED
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
import { BindState, AttachState, } from "@fluidframework/container-definitions";
|
|
6
|
-
import { DataProcessingError } from "@fluidframework/container-utils";
|
|
6
|
+
import { DataProcessingError, UsageError } from "@fluidframework/container-utils";
|
|
7
7
|
import { assert, Deferred, LazyPromise, TypedEventEmitter, unreachableCase, } from "@fluidframework/common-utils";
|
|
8
|
-
import { ChildLogger, raiseConnectedEvent, } from "@fluidframework/telemetry-utils";
|
|
8
|
+
import { ChildLogger, LoggingError, raiseConnectedEvent, } from "@fluidframework/telemetry-utils";
|
|
9
9
|
import { buildSnapshotTree } from "@fluidframework/driver-utils";
|
|
10
10
|
import { SummaryType, } from "@fluidframework/protocol-definitions";
|
|
11
11
|
import { CreateSummarizerNodeSource, VisibilityState, } from "@fluidframework/runtime-definitions";
|
|
@@ -39,6 +39,7 @@ export class FluidDataStoreRuntime extends TypedEventEmitter {
|
|
|
39
39
|
// A list of handles that are bound when the data store is not visible. We have to make them visible when the data
|
|
40
40
|
// store becomes visible.
|
|
41
41
|
this.pendingHandlesToMakeVisible = new Set();
|
|
42
|
+
assert(!dataStoreContext.id.includes("/"), 0x30e /* Id cannot contain slashes. DataStoreContext should have validated this. */);
|
|
42
43
|
this.logger = ChildLogger.create(dataStoreContext.logger, "FluidDataStoreRuntime", { all: { dataStoreId: uuid() } });
|
|
43
44
|
this.id = dataStoreContext.id;
|
|
44
45
|
this.options = dataStoreContext.options;
|
|
@@ -196,6 +197,9 @@ export class FluidDataStoreRuntime extends TypedEventEmitter {
|
|
|
196
197
|
return channel;
|
|
197
198
|
}
|
|
198
199
|
createChannel(id = uuid(), type) {
|
|
200
|
+
if (id.includes("/")) {
|
|
201
|
+
throw new UsageError(`Id cannot contain slashes: ${id}`);
|
|
202
|
+
}
|
|
199
203
|
this.verifyNotClosed();
|
|
200
204
|
assert(!this.contexts.has(id), 0x179 /* "createChannel() with existing ID" */);
|
|
201
205
|
this.notBoundedChannelContextSet.add(id);
|
|
@@ -475,8 +479,9 @@ export class FluidDataStoreRuntime extends TypedEventEmitter {
|
|
|
475
479
|
* Returns a summary at the current sequence number.
|
|
476
480
|
* @param fullTree - true to bypass optimizations and force a full summary tree
|
|
477
481
|
* @param trackState - This tells whether we should track state from this summary.
|
|
482
|
+
* @param telemetryContext - summary data passed through the layers for telemetry purposes
|
|
478
483
|
*/
|
|
479
|
-
async summarize(fullTree = false, trackState = true) {
|
|
484
|
+
async summarize(fullTree = false, trackState = true, telemetryContext) {
|
|
480
485
|
const summaryBuilder = new SummaryTreeBuilder();
|
|
481
486
|
// Iterate over each data store and ask it to summarize
|
|
482
487
|
await Promise.all(Array.from(this.contexts)
|
|
@@ -488,12 +493,12 @@ export class FluidDataStoreRuntime extends TypedEventEmitter {
|
|
|
488
493
|
// (i.e. it has a base mapping) - then we go ahead and summarize
|
|
489
494
|
return isAttached;
|
|
490
495
|
}).map(async ([contextId, context]) => {
|
|
491
|
-
const contextSummary = await context.summarize(fullTree, trackState);
|
|
496
|
+
const contextSummary = await context.summarize(fullTree, trackState, telemetryContext);
|
|
492
497
|
summaryBuilder.addWithStats(contextId, contextSummary);
|
|
493
498
|
}));
|
|
494
499
|
return summaryBuilder.getSummaryTree();
|
|
495
500
|
}
|
|
496
|
-
getAttachSummary() {
|
|
501
|
+
getAttachSummary(telemetryContext) {
|
|
497
502
|
/**
|
|
498
503
|
* back-compat 0.59.1000 - getAttachSummary() is called when making a data store globally visible (previously
|
|
499
504
|
* attaching state). Ideally, attachGraph() should have already be called making it locally visible. However,
|
|
@@ -516,12 +521,12 @@ export class FluidDataStoreRuntime extends TypedEventEmitter {
|
|
|
516
521
|
// Craft the .attributes file for each shared object
|
|
517
522
|
for (const [contextId, context] of this.contexts) {
|
|
518
523
|
if (!(context instanceof LocalChannelContextBase)) {
|
|
519
|
-
throw new
|
|
524
|
+
throw new LoggingError("Should only be called with local channel handles");
|
|
520
525
|
}
|
|
521
526
|
if (!this.notBoundedChannelContextSet.has(contextId)) {
|
|
522
527
|
let summaryTree;
|
|
523
528
|
if (context.isLoaded) {
|
|
524
|
-
const contextSummary = context.getAttachSummary();
|
|
529
|
+
const contextSummary = context.getAttachSummary(telemetryContext);
|
|
525
530
|
assert(contextSummary.summary.type === SummaryType.Tree, 0x180 /* "getAttachSummary should always return a tree" */);
|
|
526
531
|
summaryTree = { stats: contextSummary.stats, summary: contextSummary.summary };
|
|
527
532
|
}
|
|
@@ -609,6 +614,27 @@ export class FluidDataStoreRuntime extends TypedEventEmitter {
|
|
|
609
614
|
unreachableCase(type);
|
|
610
615
|
}
|
|
611
616
|
}
|
|
617
|
+
/**
|
|
618
|
+
* Revert a local op.
|
|
619
|
+
* @param content - The content of the original message.
|
|
620
|
+
* @param localOpMetadata - The local metadata associated with the original message.
|
|
621
|
+
*/
|
|
622
|
+
rollback(type, content, localOpMetadata) {
|
|
623
|
+
this.verifyNotClosed();
|
|
624
|
+
switch (type) {
|
|
625
|
+
case DataStoreMessageType.ChannelOp:
|
|
626
|
+
{
|
|
627
|
+
// For Operations, find the right channel and trigger resubmission on it.
|
|
628
|
+
const envelope = content;
|
|
629
|
+
const channelContext = this.contexts.get(envelope.address);
|
|
630
|
+
assert(!!channelContext, 0x2ed /* "There should be a channel context for the op" */);
|
|
631
|
+
channelContext.rollback(envelope.contents, localOpMetadata);
|
|
632
|
+
break;
|
|
633
|
+
}
|
|
634
|
+
default:
|
|
635
|
+
throw new LoggingError(`Can't rollback ${type} message`);
|
|
636
|
+
}
|
|
637
|
+
}
|
|
612
638
|
async applyStashedOp(content) {
|
|
613
639
|
const envelope = content;
|
|
614
640
|
const channelContext = this.contexts.get(envelope.address);
|
|
@@ -662,7 +688,7 @@ export class FluidDataStoreRuntime extends TypedEventEmitter {
|
|
|
662
688
|
}
|
|
663
689
|
verifyNotClosed() {
|
|
664
690
|
if (this._disposed) {
|
|
665
|
-
throw new
|
|
691
|
+
throw new LoggingError("Runtime is closed");
|
|
666
692
|
}
|
|
667
693
|
}
|
|
668
694
|
}
|
|
@@ -691,7 +717,7 @@ export const mixinSummaryHandler = (handler, Base = FluidDataStoreRuntime) => cl
|
|
|
691
717
|
addBlob(summary, path, content) {
|
|
692
718
|
const firstName = path.shift();
|
|
693
719
|
if (firstName === undefined) {
|
|
694
|
-
throw new
|
|
720
|
+
throw new LoggingError("Path can't be empty");
|
|
695
721
|
}
|
|
696
722
|
let blob = {
|
|
697
723
|
type: SummaryType.Blob,
|