@fluidframework/container-runtime 2.0.0-dev-rc.5.0.0.271045 → 2.0.0-dev-rc.5.0.0.271717
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/container-runtime.test-files.tar +0 -0
- package/dist/batchTracker.js +1 -5
- package/dist/batchTracker.js.map +1 -1
- package/dist/blobManager.js +14 -39
- package/dist/blobManager.js.map +1 -1
- package/dist/channelCollection.js +10 -23
- package/dist/channelCollection.js.map +1 -1
- package/dist/connectionTelemetry.js +14 -32
- package/dist/connectionTelemetry.js.map +1 -1
- package/dist/containerHandleContext.js +0 -4
- package/dist/containerHandleContext.js.map +1 -1
- package/dist/containerRuntime.js +26 -138
- package/dist/containerRuntime.js.map +1 -1
- package/dist/dataStore.js +1 -9
- package/dist/dataStore.js.map +1 -1
- package/dist/dataStoreContext.js +99 -141
- package/dist/dataStoreContext.js.map +1 -1
- package/dist/dataStoreContexts.js +28 -29
- package/dist/dataStoreContexts.js.map +1 -1
- package/dist/dataStoreRegistry.js +0 -1
- package/dist/dataStoreRegistry.js.map +1 -1
- package/dist/deltaManagerProxies.js +28 -33
- package/dist/deltaManagerProxies.js.map +1 -1
- package/dist/deltaScheduler.js +9 -13
- package/dist/deltaScheduler.js.map +1 -1
- package/dist/error.js +1 -2
- package/dist/error.js.map +1 -1
- package/dist/gc/garbageCollection.js +15 -37
- package/dist/gc/garbageCollection.js.map +1 -1
- package/dist/gc/gcSummaryStateTracker.js +14 -19
- package/dist/gc/gcSummaryStateTracker.js.map +1 -1
- package/dist/gc/gcTelemetry.js +5 -12
- package/dist/gc/gcTelemetry.js.map +1 -1
- package/dist/gc/gcUnreferencedStateTracker.js +1 -12
- package/dist/gc/gcUnreferencedStateTracker.js.map +1 -1
- package/dist/opLifecycle/batchManager.js +3 -5
- package/dist/opLifecycle/batchManager.js.map +1 -1
- package/dist/opLifecycle/opCompressor.js +0 -1
- package/dist/opLifecycle/opCompressor.js.map +1 -1
- package/dist/opLifecycle/opDecompressor.js +4 -6
- package/dist/opLifecycle/opDecompressor.js.map +1 -1
- package/dist/opLifecycle/opGroupingManager.js +1 -3
- package/dist/opLifecycle/opGroupingManager.js.map +1 -1
- package/dist/opLifecycle/opSplitter.js +0 -6
- package/dist/opLifecycle/opSplitter.js.map +1 -1
- package/dist/opLifecycle/outbox.js +10 -15
- package/dist/opLifecycle/outbox.js.map +1 -1
- package/dist/opLifecycle/remoteMessageProcessor.js +0 -3
- package/dist/opLifecycle/remoteMessageProcessor.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/pendingStateManager.js +14 -20
- package/dist/pendingStateManager.js.map +1 -1
- package/dist/scheduleManager.js +4 -15
- package/dist/scheduleManager.js.map +1 -1
- package/dist/storageServiceWithAttachBlobs.js +0 -1
- package/dist/storageServiceWithAttachBlobs.js.map +1 -1
- package/dist/summary/documentSchema.js +1 -17
- package/dist/summary/documentSchema.js.map +1 -1
- package/dist/summary/orderedClientElection.js +11 -19
- package/dist/summary/orderedClientElection.js.map +1 -1
- package/dist/summary/runWhileConnectedCoordinator.js +2 -4
- package/dist/summary/runWhileConnectedCoordinator.js.map +1 -1
- package/dist/summary/runningSummarizer.js +38 -56
- package/dist/summary/runningSummarizer.js.map +1 -1
- package/dist/summary/summarizer.js +8 -17
- package/dist/summary/summarizer.js.map +1 -1
- package/dist/summary/summarizerClientElection.js +7 -18
- package/dist/summary/summarizerClientElection.js.map +1 -1
- package/dist/summary/summarizerHeuristics.js +25 -30
- package/dist/summary/summarizerHeuristics.js.map +1 -1
- package/dist/summary/summarizerNode/summarizerNode.js +3 -12
- package/dist/summary/summarizerNode/summarizerNode.js.map +1 -1
- package/dist/summary/summarizerNode/summarizerNodeUtils.js +0 -2
- package/dist/summary/summarizerNode/summarizerNodeUtils.js.map +1 -1
- package/dist/summary/summarizerNode/summarizerNodeWithGc.js +6 -20
- package/dist/summary/summarizerNode/summarizerNodeWithGc.js.map +1 -1
- package/dist/summary/summaryCollection.js +11 -23
- package/dist/summary/summaryCollection.js.map +1 -1
- package/dist/summary/summaryGenerator.js +5 -12
- package/dist/summary/summaryGenerator.js.map +1 -1
- package/dist/summary/summaryManager.js +48 -58
- package/dist/summary/summaryManager.js.map +1 -1
- package/dist/throttler.js +1 -4
- package/dist/throttler.js.map +1 -1
- package/lib/batchTracker.js +1 -5
- package/lib/batchTracker.js.map +1 -1
- package/lib/blobManager.js +14 -39
- package/lib/blobManager.js.map +1 -1
- package/lib/channelCollection.js +10 -23
- package/lib/channelCollection.js.map +1 -1
- package/lib/connectionTelemetry.js +14 -32
- package/lib/connectionTelemetry.js.map +1 -1
- package/lib/containerHandleContext.js +0 -4
- package/lib/containerHandleContext.js.map +1 -1
- package/lib/containerRuntime.js +26 -138
- package/lib/containerRuntime.js.map +1 -1
- package/lib/dataStore.js +1 -9
- package/lib/dataStore.js.map +1 -1
- package/lib/dataStoreContext.js +99 -141
- package/lib/dataStoreContext.js.map +1 -1
- package/lib/dataStoreContexts.js +28 -29
- package/lib/dataStoreContexts.js.map +1 -1
- package/lib/dataStoreRegistry.js +0 -1
- package/lib/dataStoreRegistry.js.map +1 -1
- package/lib/deltaManagerProxies.js +28 -33
- package/lib/deltaManagerProxies.js.map +1 -1
- package/lib/deltaScheduler.js +9 -13
- package/lib/deltaScheduler.js.map +1 -1
- package/lib/error.js +1 -2
- package/lib/error.js.map +1 -1
- package/lib/gc/garbageCollection.js +15 -37
- package/lib/gc/garbageCollection.js.map +1 -1
- package/lib/gc/gcSummaryStateTracker.js +14 -19
- package/lib/gc/gcSummaryStateTracker.js.map +1 -1
- package/lib/gc/gcTelemetry.js +5 -12
- package/lib/gc/gcTelemetry.js.map +1 -1
- package/lib/gc/gcUnreferencedStateTracker.js +1 -12
- package/lib/gc/gcUnreferencedStateTracker.js.map +1 -1
- package/lib/opLifecycle/batchManager.js +3 -5
- package/lib/opLifecycle/batchManager.js.map +1 -1
- package/lib/opLifecycle/opCompressor.js +0 -1
- package/lib/opLifecycle/opCompressor.js.map +1 -1
- package/lib/opLifecycle/opDecompressor.js +4 -6
- package/lib/opLifecycle/opDecompressor.js.map +1 -1
- package/lib/opLifecycle/opGroupingManager.js +1 -3
- package/lib/opLifecycle/opGroupingManager.js.map +1 -1
- package/lib/opLifecycle/opSplitter.js +0 -6
- package/lib/opLifecycle/opSplitter.js.map +1 -1
- package/lib/opLifecycle/outbox.js +10 -15
- package/lib/opLifecycle/outbox.js.map +1 -1
- package/lib/opLifecycle/remoteMessageProcessor.js +0 -3
- package/lib/opLifecycle/remoteMessageProcessor.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/pendingStateManager.js +14 -20
- package/lib/pendingStateManager.js.map +1 -1
- package/lib/scheduleManager.js +4 -15
- package/lib/scheduleManager.js.map +1 -1
- package/lib/storageServiceWithAttachBlobs.js +0 -1
- package/lib/storageServiceWithAttachBlobs.js.map +1 -1
- package/lib/summary/documentSchema.js +1 -17
- package/lib/summary/documentSchema.js.map +1 -1
- package/lib/summary/orderedClientElection.js +11 -19
- package/lib/summary/orderedClientElection.js.map +1 -1
- package/lib/summary/runWhileConnectedCoordinator.js +2 -4
- package/lib/summary/runWhileConnectedCoordinator.js.map +1 -1
- package/lib/summary/runningSummarizer.js +38 -56
- package/lib/summary/runningSummarizer.js.map +1 -1
- package/lib/summary/summarizer.js +8 -17
- package/lib/summary/summarizer.js.map +1 -1
- package/lib/summary/summarizerClientElection.js +7 -18
- package/lib/summary/summarizerClientElection.js.map +1 -1
- package/lib/summary/summarizerHeuristics.js +25 -30
- package/lib/summary/summarizerHeuristics.js.map +1 -1
- package/lib/summary/summarizerNode/summarizerNode.js +3 -12
- package/lib/summary/summarizerNode/summarizerNode.js.map +1 -1
- package/lib/summary/summarizerNode/summarizerNodeUtils.js +0 -2
- package/lib/summary/summarizerNode/summarizerNodeUtils.js.map +1 -1
- package/lib/summary/summarizerNode/summarizerNodeWithGc.js +6 -20
- package/lib/summary/summarizerNode/summarizerNodeWithGc.js.map +1 -1
- package/lib/summary/summaryCollection.js +11 -23
- package/lib/summary/summaryCollection.js.map +1 -1
- package/lib/summary/summaryGenerator.js +5 -12
- package/lib/summary/summaryGenerator.js.map +1 -1
- package/lib/summary/summaryManager.js +48 -58
- package/lib/summary/summaryManager.js.map +1 -1
- package/lib/throttler.js +1 -4
- package/lib/throttler.js.map +1 -1
- package/package.json +17 -17
- package/src/packageVersion.ts +1 -1
package/dist/dataStore.js
CHANGED
|
@@ -29,15 +29,6 @@ var AliasState;
|
|
|
29
29
|
AliasState["None"] = "None";
|
|
30
30
|
})(AliasState || (AliasState = {}));
|
|
31
31
|
class DataStore {
|
|
32
|
-
fluidDataStoreChannel;
|
|
33
|
-
internalId;
|
|
34
|
-
channelCollection;
|
|
35
|
-
logger;
|
|
36
|
-
parentContext;
|
|
37
|
-
aliasState = AliasState.None;
|
|
38
|
-
alias;
|
|
39
|
-
pendingAliases;
|
|
40
|
-
aliasResult;
|
|
41
32
|
/**
|
|
42
33
|
* {@inheritDoc @fluidframework/runtime-definitions#IDataStore.trySetAlias}
|
|
43
34
|
*/
|
|
@@ -129,6 +120,7 @@ class DataStore {
|
|
|
129
120
|
this.channelCollection = channelCollection;
|
|
130
121
|
this.logger = logger;
|
|
131
122
|
this.parentContext = parentContext;
|
|
123
|
+
this.aliasState = AliasState.None;
|
|
132
124
|
this.pendingAliases = channelCollection.pendingAliases;
|
|
133
125
|
}
|
|
134
126
|
async ackBasedPromise(executor) {
|
package/dist/dataStore.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dataStore.js","sourceRoot":"","sources":["../src/dataStore.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,iFAAoE;AAGpE,kEAA8E;AAM9E,uEAIkD;AAGlD,uDAAyD;AAazD;;;;;GAKG;AACI,MAAM,uBAAuB,GAAG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BAAqB,GAArB,qBAAqB,CAAwB;QAC7C,eAAU,GAAV,UAAU,CAAQ;QAClB,sBAAiB,GAAjB,iBAAiB,CAAmB;QACpC,WAAM,GAAN,MAAM,CAAqB;QAC3B,kBAAa,GAAb,aAAa,CAAkC;QAEhE,IAAI,CAAC,cAAc,GAAG,iBAAiB,CAAC,cAAc,CAAC;IACxD,CAAC;IAEO,KAAK,CAAC,eAAe,CAC5B,QAGS;QAET,IAAI,oBAAgC,CAAC;QACrC,OAAO,IAAI,OAAO,CAAI,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACzC,oBAAoB,GAAG,GAAG,EAAE,CAC3B,MAAM,CACL,IAAI,KAAK,CAAC,oEAAoE,CAAC,CAC/E,CAAC;YAEH,IAAI,IAAI,CAAC,aAAa,CAAC,gBAAgB,CAAC,QAAQ,EAAE,CAAC;gBAClD,oBAAoB,EAAE,CAAC;gBACvB,OAAO;YACR,CAAC;YAED,IAAI,CAAC,aAAa,CAAC,gBAAgB,CAAC,EAAE,CAAC,SAAS,EAAE,oBAAoB,CAAC,CAAC;YACxE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QAC3B,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE;YACf,IAAI,CAAC,aAAa,CAAC,gBAAgB,CAAC,GAAG,CAAC,SAAS,EAAE,oBAAoB,CAAC,CAAC;QAC1E,CAAC,CAAC,CAAC;IACJ,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { AttachState } from \"@fluidframework/container-definitions\";\nimport { FluidObject } from \"@fluidframework/core-interfaces\";\nimport { type IFluidHandleInternal } from \"@fluidframework/core-interfaces/internal\";\nimport { assert, unreachableCase } from \"@fluidframework/core-utils/internal\";\nimport {\n\tAliasResult,\n\tIDataStore,\n\tIFluidDataStoreChannel,\n} from \"@fluidframework/runtime-definitions/internal\";\nimport {\n\tITelemetryLoggerExt,\n\tTelemetryDataTag,\n\tUsageError,\n} from \"@fluidframework/telemetry-utils/internal\";\n\nimport { ChannelCollection } from \"./channelCollection.js\";\nimport { ContainerMessageType } from \"./messageTypes.js\";\n\n/**\n * Interface for an op to be used for assigning an\n * alias to a datastore\n */\nexport interface IDataStoreAliasMessage {\n\t/** The internal id of the datastore */\n\treadonly internalId: string;\n\t/** The alias name to be assigned to the datastore */\n\treadonly alias: string;\n}\n\n/**\n * Type guard that returns true if the given alias message is actually an instance of\n * a class which implements {@link IDataStoreAliasMessage}\n * @param maybeDataStoreAliasMessage - message object to be validated\n * @returns True if the {@link IDataStoreAliasMessage} is fully implemented, false otherwise\n */\nexport const isDataStoreAliasMessage = (\n\tmaybeDataStoreAliasMessage: any,\n): maybeDataStoreAliasMessage is IDataStoreAliasMessage => {\n\treturn (\n\t\ttypeof maybeDataStoreAliasMessage?.internalId === \"string\" &&\n\t\ttypeof maybeDataStoreAliasMessage?.alias === \"string\"\n\t);\n};\n\nexport const channelToDataStore = (\n\tfluidDataStoreChannel: IFluidDataStoreChannel,\n\tinternalId: string,\n\tchannelCollection: ChannelCollection,\n\tlogger: ITelemetryLoggerExt,\n): IDataStore => new DataStore(fluidDataStoreChannel, internalId, channelCollection, logger);\n\nenum AliasState {\n\tAliased = \"Aliased\",\n\tAliasing = \"Aliasing\",\n\tNone = \"None\",\n}\n\nclass DataStore implements IDataStore {\n\tprivate aliasState: AliasState = AliasState.None;\n\tprivate alias: string | undefined;\n\tprivate readonly pendingAliases: Map<string, Promise<AliasResult>>;\n\tprivate aliasResult: Promise<AliasResult> | undefined;\n\n\t/**\n\t * {@inheritDoc @fluidframework/runtime-definitions#IDataStore.trySetAlias}\n\t */\n\tasync trySetAlias(alias: string): Promise<AliasResult> {\n\t\tif (alias.includes(\"/\")) {\n\t\t\tthrow new UsageError(`The alias cannot contain slashes: '${alias}'`);\n\t\t}\n\n\t\tswitch (this.aliasState) {\n\t\t\t// If we're already aliasing, check if it's for the same value and return\n\t\t\t// the stored promise, otherwise return 'AlreadyAliased'\n\t\t\tcase AliasState.Aliasing:\n\t\t\t\tassert(\n\t\t\t\t\tthis.aliasResult !== undefined,\n\t\t\t\t\t0x316 /* There should be a cached promise of in-progress aliasing */,\n\t\t\t\t);\n\t\t\t\tawait this.aliasResult;\n\t\t\t\treturn this.alias === alias ? \"Success\" : \"AlreadyAliased\";\n\n\t\t\t// If this datastore is already aliased, return true only if this\n\t\t\t// is a repeated call for the same alias\n\t\t\tcase AliasState.Aliased:\n\t\t\t\treturn this.alias === alias ? \"Success\" : \"AlreadyAliased\";\n\n\t\t\tcase AliasState.None: {\n\t\t\t\tconst existingAlias = this.pendingAliases.get(alias);\n\t\t\t\tif (existingAlias !== undefined) {\n\t\t\t\t\t// There is already another datastore which will be aliased\n\t\t\t\t\t// to the same name\n\t\t\t\t\treturn \"Conflict\";\n\t\t\t\t}\n\n\t\t\t\t// There is no current or past alias operation for this datastore,\n\t\t\t\t// or for this alias, so it is safe to continue execution\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tdefault:\n\t\t\t\tunreachableCase(this.aliasState);\n\t\t}\n\n\t\tthis.aliasState = AliasState.Aliasing;\n\t\tthis.aliasResult = this.trySetAliasInternal(alias);\n\t\tthis.pendingAliases.set(alias, this.aliasResult);\n\t\treturn this.aliasResult;\n\t}\n\n\tasync trySetAliasInternal(alias: string): Promise<AliasResult> {\n\t\tconst message: IDataStoreAliasMessage = {\n\t\t\tinternalId: this.internalId,\n\t\t\talias,\n\t\t};\n\t\tthis.fluidDataStoreChannel.makeVisibleAndAttachGraph();\n\n\t\tif (this.parentContext.attachState === AttachState.Detached) {\n\t\t\tconst localResult = this.channelCollection.processAliasMessageCore(\n\t\t\t\tthis.internalId,\n\t\t\t\talias,\n\t\t\t);\n\t\t\t// Explicitly lock-out future attempts of aliasing,\n\t\t\t// regardless of result\n\t\t\tthis.aliasState = AliasState.Aliased;\n\t\t\treturn localResult ? \"Success\" : \"Conflict\";\n\t\t}\n\n\t\tconst aliased = await this.ackBasedPromise<boolean>((resolve) => {\n\t\t\tthis.parentContext.submitMessage(ContainerMessageType.Alias, message, resolve);\n\t\t})\n\t\t\t.catch((error) => {\n\t\t\t\tthis.logger.sendErrorEvent(\n\t\t\t\t\t{\n\t\t\t\t\t\teventName: \"AliasingException\",\n\t\t\t\t\t\talias: {\n\t\t\t\t\t\t\tvalue: alias,\n\t\t\t\t\t\t\ttag: TelemetryDataTag.UserData,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tinternalId: {\n\t\t\t\t\t\t\tvalue: this.internalId,\n\t\t\t\t\t\t\ttag: TelemetryDataTag.CodeArtifact,\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\terror,\n\t\t\t\t);\n\n\t\t\t\treturn false;\n\t\t\t})\n\t\t\t.finally(() => {\n\t\t\t\tthis.pendingAliases.delete(alias);\n\t\t\t});\n\n\t\tif (!aliased) {\n\t\t\tthis.aliasState = AliasState.None;\n\t\t\tthis.aliasResult = undefined;\n\t\t\treturn \"Conflict\";\n\t\t}\n\n\t\tthis.alias = alias;\n\t\tthis.aliasState = AliasState.Aliased;\n\t\treturn \"Success\";\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/runtime-definitions#IDataStore.entryPoint}\n\t */\n\tget entryPoint(): IFluidHandleInternal<FluidObject> {\n\t\treturn this.fluidDataStoreChannel.entryPoint;\n\t}\n\n\tconstructor(\n\t\tprivate readonly fluidDataStoreChannel: IFluidDataStoreChannel,\n\t\tprivate readonly internalId: string,\n\t\tprivate readonly channelCollection: ChannelCollection,\n\t\tprivate readonly logger: ITelemetryLoggerExt,\n\t\tprivate readonly parentContext = channelCollection.parentContext,\n\t) {\n\t\tthis.pendingAliases = channelCollection.pendingAliases;\n\t}\n\n\tprivate async ackBasedPromise<T>(\n\t\texecutor: (\n\t\t\tresolve: (value: T | PromiseLike<T>) => void,\n\t\t\treject: (reason?: any) => void,\n\t\t) => void,\n\t): Promise<T> {\n\t\tlet rejectBecauseDispose: () => void;\n\t\treturn new Promise<T>((resolve, reject) => {\n\t\t\trejectBecauseDispose = () =>\n\t\t\t\treject(\n\t\t\t\t\tnew Error(\"ContainerRuntime disposed while this ack-based Promise was pending\"),\n\t\t\t\t);\n\n\t\t\tif (this.parentContext.containerRuntime.disposed) {\n\t\t\t\trejectBecauseDispose();\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tthis.parentContext.containerRuntime.on(\"dispose\", rejectBecauseDispose);\n\t\t\texecutor(resolve, reject);\n\t\t}).finally(() => {\n\t\t\tthis.parentContext.containerRuntime.off(\"dispose\", rejectBecauseDispose);\n\t\t});\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"dataStore.js","sourceRoot":"","sources":["../src/dataStore.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,iFAAoE;AAGpE,kEAA8E;AAM9E,uEAIkD;AAGlD,uDAAyD;AAazD;;;;;GAKG;AACI,MAAM,uBAAuB,GAAG,CACtC,0BAA+B,EACwB,EAAE;IACzD,OAAO,CACN,OAAO,0BAA0B,EAAE,UAAU,KAAK,QAAQ;QAC1D,OAAO,0BAA0B,EAAE,KAAK,KAAK,QAAQ,CACrD,CAAC;AACH,CAAC,CAAC;AAPW,QAAA,uBAAuB,2BAOlC;AAEK,MAAM,kBAAkB,GAAG,CACjC,qBAA6C,EAC7C,UAAkB,EAClB,iBAAoC,EACpC,MAA2B,EACd,EAAE,CAAC,IAAI,SAAS,CAAC,qBAAqB,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,CAAC,CAAC;AALhF,QAAA,kBAAkB,sBAK8D;AAE7F,IAAK,UAIJ;AAJD,WAAK,UAAU;IACd,iCAAmB,CAAA;IACnB,mCAAqB,CAAA;IACrB,2BAAa,CAAA;AACd,CAAC,EAJI,UAAU,KAAV,UAAU,QAId;AAED,MAAM,SAAS;IAMd;;OAEG;IACH,KAAK,CAAC,WAAW,CAAC,KAAa;QAC9B,IAAI,KAAK,CAAC,QAAQ,CAA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QAC3B,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE;YACf,IAAI,CAAC,aAAa,CAAC,gBAAgB,CAAC,GAAG,CAAC,SAAS,EAAE,oBAAoB,CAAC,CAAC;QAC1E,CAAC,CAAC,CAAC;IACJ,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { AttachState } from \"@fluidframework/container-definitions\";\nimport { FluidObject } from \"@fluidframework/core-interfaces\";\nimport { type IFluidHandleInternal } from \"@fluidframework/core-interfaces/internal\";\nimport { assert, unreachableCase } from \"@fluidframework/core-utils/internal\";\nimport {\n\tAliasResult,\n\tIDataStore,\n\tIFluidDataStoreChannel,\n} from \"@fluidframework/runtime-definitions/internal\";\nimport {\n\tITelemetryLoggerExt,\n\tTelemetryDataTag,\n\tUsageError,\n} from \"@fluidframework/telemetry-utils/internal\";\n\nimport { ChannelCollection } from \"./channelCollection.js\";\nimport { ContainerMessageType } from \"./messageTypes.js\";\n\n/**\n * Interface for an op to be used for assigning an\n * alias to a datastore\n */\nexport interface IDataStoreAliasMessage {\n\t/** The internal id of the datastore */\n\treadonly internalId: string;\n\t/** The alias name to be assigned to the datastore */\n\treadonly alias: string;\n}\n\n/**\n * Type guard that returns true if the given alias message is actually an instance of\n * a class which implements {@link IDataStoreAliasMessage}\n * @param maybeDataStoreAliasMessage - message object to be validated\n * @returns True if the {@link IDataStoreAliasMessage} is fully implemented, false otherwise\n */\nexport const isDataStoreAliasMessage = (\n\tmaybeDataStoreAliasMessage: any,\n): maybeDataStoreAliasMessage is IDataStoreAliasMessage => {\n\treturn (\n\t\ttypeof maybeDataStoreAliasMessage?.internalId === \"string\" &&\n\t\ttypeof maybeDataStoreAliasMessage?.alias === \"string\"\n\t);\n};\n\nexport const channelToDataStore = (\n\tfluidDataStoreChannel: IFluidDataStoreChannel,\n\tinternalId: string,\n\tchannelCollection: ChannelCollection,\n\tlogger: ITelemetryLoggerExt,\n): IDataStore => new DataStore(fluidDataStoreChannel, internalId, channelCollection, logger);\n\nenum AliasState {\n\tAliased = \"Aliased\",\n\tAliasing = \"Aliasing\",\n\tNone = \"None\",\n}\n\nclass DataStore implements IDataStore {\n\tprivate aliasState: AliasState = AliasState.None;\n\tprivate alias: string | undefined;\n\tprivate readonly pendingAliases: Map<string, Promise<AliasResult>>;\n\tprivate aliasResult: Promise<AliasResult> | undefined;\n\n\t/**\n\t * {@inheritDoc @fluidframework/runtime-definitions#IDataStore.trySetAlias}\n\t */\n\tasync trySetAlias(alias: string): Promise<AliasResult> {\n\t\tif (alias.includes(\"/\")) {\n\t\t\tthrow new UsageError(`The alias cannot contain slashes: '${alias}'`);\n\t\t}\n\n\t\tswitch (this.aliasState) {\n\t\t\t// If we're already aliasing, check if it's for the same value and return\n\t\t\t// the stored promise, otherwise return 'AlreadyAliased'\n\t\t\tcase AliasState.Aliasing:\n\t\t\t\tassert(\n\t\t\t\t\tthis.aliasResult !== undefined,\n\t\t\t\t\t0x316 /* There should be a cached promise of in-progress aliasing */,\n\t\t\t\t);\n\t\t\t\tawait this.aliasResult;\n\t\t\t\treturn this.alias === alias ? \"Success\" : \"AlreadyAliased\";\n\n\t\t\t// If this datastore is already aliased, return true only if this\n\t\t\t// is a repeated call for the same alias\n\t\t\tcase AliasState.Aliased:\n\t\t\t\treturn this.alias === alias ? \"Success\" : \"AlreadyAliased\";\n\n\t\t\tcase AliasState.None: {\n\t\t\t\tconst existingAlias = this.pendingAliases.get(alias);\n\t\t\t\tif (existingAlias !== undefined) {\n\t\t\t\t\t// There is already another datastore which will be aliased\n\t\t\t\t\t// to the same name\n\t\t\t\t\treturn \"Conflict\";\n\t\t\t\t}\n\n\t\t\t\t// There is no current or past alias operation for this datastore,\n\t\t\t\t// or for this alias, so it is safe to continue execution\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tdefault:\n\t\t\t\tunreachableCase(this.aliasState);\n\t\t}\n\n\t\tthis.aliasState = AliasState.Aliasing;\n\t\tthis.aliasResult = this.trySetAliasInternal(alias);\n\t\tthis.pendingAliases.set(alias, this.aliasResult);\n\t\treturn this.aliasResult;\n\t}\n\n\tasync trySetAliasInternal(alias: string): Promise<AliasResult> {\n\t\tconst message: IDataStoreAliasMessage = {\n\t\t\tinternalId: this.internalId,\n\t\t\talias,\n\t\t};\n\t\tthis.fluidDataStoreChannel.makeVisibleAndAttachGraph();\n\n\t\tif (this.parentContext.attachState === AttachState.Detached) {\n\t\t\tconst localResult = this.channelCollection.processAliasMessageCore(\n\t\t\t\tthis.internalId,\n\t\t\t\talias,\n\t\t\t);\n\t\t\t// Explicitly lock-out future attempts of aliasing,\n\t\t\t// regardless of result\n\t\t\tthis.aliasState = AliasState.Aliased;\n\t\t\treturn localResult ? \"Success\" : \"Conflict\";\n\t\t}\n\n\t\tconst aliased = await this.ackBasedPromise<boolean>((resolve) => {\n\t\t\tthis.parentContext.submitMessage(ContainerMessageType.Alias, message, resolve);\n\t\t})\n\t\t\t.catch((error) => {\n\t\t\t\tthis.logger.sendErrorEvent(\n\t\t\t\t\t{\n\t\t\t\t\t\teventName: \"AliasingException\",\n\t\t\t\t\t\talias: {\n\t\t\t\t\t\t\tvalue: alias,\n\t\t\t\t\t\t\ttag: TelemetryDataTag.UserData,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tinternalId: {\n\t\t\t\t\t\t\tvalue: this.internalId,\n\t\t\t\t\t\t\ttag: TelemetryDataTag.CodeArtifact,\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\terror,\n\t\t\t\t);\n\n\t\t\t\treturn false;\n\t\t\t})\n\t\t\t.finally(() => {\n\t\t\t\tthis.pendingAliases.delete(alias);\n\t\t\t});\n\n\t\tif (!aliased) {\n\t\t\tthis.aliasState = AliasState.None;\n\t\t\tthis.aliasResult = undefined;\n\t\t\treturn \"Conflict\";\n\t\t}\n\n\t\tthis.alias = alias;\n\t\tthis.aliasState = AliasState.Aliased;\n\t\treturn \"Success\";\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/runtime-definitions#IDataStore.entryPoint}\n\t */\n\tget entryPoint(): IFluidHandleInternal<FluidObject> {\n\t\treturn this.fluidDataStoreChannel.entryPoint;\n\t}\n\n\tconstructor(\n\t\tprivate readonly fluidDataStoreChannel: IFluidDataStoreChannel,\n\t\tprivate readonly internalId: string,\n\t\tprivate readonly channelCollection: ChannelCollection,\n\t\tprivate readonly logger: ITelemetryLoggerExt,\n\t\tprivate readonly parentContext = channelCollection.parentContext,\n\t) {\n\t\tthis.pendingAliases = channelCollection.pendingAliases;\n\t}\n\n\tprivate async ackBasedPromise<T>(\n\t\texecutor: (\n\t\t\tresolve: (value: T | PromiseLike<T>) => void,\n\t\t\treject: (reason?: any) => void,\n\t\t) => void,\n\t): Promise<T> {\n\t\tlet rejectBecauseDispose: () => void;\n\t\treturn new Promise<T>((resolve, reject) => {\n\t\t\trejectBecauseDispose = () =>\n\t\t\t\treject(\n\t\t\t\t\tnew Error(\"ContainerRuntime disposed while this ack-based Promise was pending\"),\n\t\t\t\t);\n\n\t\t\tif (this.parentContext.containerRuntime.disposed) {\n\t\t\t\trejectBecauseDispose();\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tthis.parentContext.containerRuntime.on(\"dispose\", rejectBecauseDispose);\n\t\t\texecutor(resolve, reject);\n\t\t}).finally(() => {\n\t\t\tthis.parentContext.containerRuntime.off(\"dispose\", rejectBecauseDispose);\n\t\t});\n\t}\n}\n"]}
|
package/dist/dataStoreContext.js
CHANGED
|
@@ -32,9 +32,6 @@ exports.createAttributesBlob = createAttributesBlob;
|
|
|
32
32
|
* @internal
|
|
33
33
|
*/
|
|
34
34
|
class FluidDataStoreContext extends client_utils_1.TypedEventEmitter {
|
|
35
|
-
existing;
|
|
36
|
-
isLocalDataStore;
|
|
37
|
-
makeLocallyVisibleFn;
|
|
38
35
|
get packagePath() {
|
|
39
36
|
(0, internal_1.assert)(this.pkg !== undefined, 0x139 /* "Undefined package path" */);
|
|
40
37
|
return this.pkg;
|
|
@@ -76,30 +73,18 @@ class FluidDataStoreContext extends client_utils_1.TypedEventEmitter {
|
|
|
76
73
|
get idCompressor() {
|
|
77
74
|
return this.parentContext.idCompressor;
|
|
78
75
|
}
|
|
79
|
-
_disposed = false;
|
|
80
76
|
get disposed() {
|
|
81
77
|
return this._disposed;
|
|
82
78
|
}
|
|
83
|
-
/**
|
|
84
|
-
* A Tombstoned object has been unreferenced long enough that GC knows it won't be referenced again.
|
|
85
|
-
* Tombstoned objects are eventually deleted by GC.
|
|
86
|
-
*/
|
|
87
|
-
_tombstoned = false;
|
|
88
79
|
get tombstoned() {
|
|
89
80
|
return this._tombstoned;
|
|
90
81
|
}
|
|
91
|
-
/** If true, throw an error when a tombstone data store is used. */
|
|
92
|
-
gcThrowOnTombstoneUsage;
|
|
93
|
-
gcTombstoneEnforcementAllowed;
|
|
94
|
-
/** If true, this means that this data store context and its children have been removed from the runtime */
|
|
95
|
-
deleted = false;
|
|
96
82
|
get attachState() {
|
|
97
83
|
return this._attachState;
|
|
98
84
|
}
|
|
99
85
|
get IFluidDataStoreRegistry() {
|
|
100
86
|
return this.registry;
|
|
101
87
|
}
|
|
102
|
-
baseSnapshotSequenceNumber;
|
|
103
88
|
/**
|
|
104
89
|
* A datastore is considered as root if it
|
|
105
90
|
* 1. is root in memory - see isInMemoryRoot
|
|
@@ -129,41 +114,23 @@ class FluidDataStoreContext extends client_utils_1.TypedEventEmitter {
|
|
|
129
114
|
isInMemoryRoot() {
|
|
130
115
|
return this._isInMemoryRoot;
|
|
131
116
|
}
|
|
132
|
-
registry;
|
|
133
|
-
detachedRuntimeCreation = false;
|
|
134
|
-
channel;
|
|
135
|
-
loaded = false;
|
|
136
|
-
pending = [];
|
|
137
|
-
channelP;
|
|
138
|
-
_baseSnapshot;
|
|
139
|
-
_attachState;
|
|
140
|
-
_isInMemoryRoot = false;
|
|
141
|
-
summarizerNode;
|
|
142
|
-
mc;
|
|
143
|
-
thresholdOpsCounter;
|
|
144
|
-
static pendingOpsCountThreshold = 1000;
|
|
145
|
-
/**
|
|
146
|
-
* If the summarizer makes local changes, a telemetry event is logged. This has the potential to be very noisy.
|
|
147
|
-
* So, adding a count of how many telemetry events are logged per data store context. This can be
|
|
148
|
-
* controlled via feature flags.
|
|
149
|
-
*/
|
|
150
|
-
localChangesTelemetryCount;
|
|
151
|
-
// The used routes of this node as per the last GC run. This is used to update the used routes of the channel
|
|
152
|
-
// if it realizes after GC is run.
|
|
153
|
-
lastUsedRoutes;
|
|
154
|
-
id;
|
|
155
|
-
_containerRuntime;
|
|
156
|
-
parentContext;
|
|
157
|
-
storage;
|
|
158
|
-
scope;
|
|
159
|
-
// Represents the group to which the data store belongs too.
|
|
160
|
-
loadingGroupId;
|
|
161
|
-
pkg;
|
|
162
117
|
constructor(props, existing, isLocalDataStore, makeLocallyVisibleFn) {
|
|
163
118
|
super();
|
|
164
119
|
this.existing = existing;
|
|
165
120
|
this.isLocalDataStore = isLocalDataStore;
|
|
166
121
|
this.makeLocallyVisibleFn = makeLocallyVisibleFn;
|
|
122
|
+
this._disposed = false;
|
|
123
|
+
/**
|
|
124
|
+
* A Tombstoned object has been unreferenced long enough that GC knows it won't be referenced again.
|
|
125
|
+
* Tombstoned objects are eventually deleted by GC.
|
|
126
|
+
*/
|
|
127
|
+
this._tombstoned = false;
|
|
128
|
+
/** If true, this means that this data store context and its children have been removed from the runtime */
|
|
129
|
+
this.deleted = false;
|
|
130
|
+
this.detachedRuntimeCreation = false;
|
|
131
|
+
this.loaded = false;
|
|
132
|
+
this.pending = [];
|
|
133
|
+
this._isInMemoryRoot = false;
|
|
167
134
|
this._containerRuntime = props.parentContext.containerRuntime;
|
|
168
135
|
this.parentContext = props.parentContext;
|
|
169
136
|
this.id = props.id;
|
|
@@ -668,16 +635,68 @@ class FluidDataStoreContext extends client_utils_1.TypedEventEmitter {
|
|
|
668
635
|
}
|
|
669
636
|
}
|
|
670
637
|
exports.FluidDataStoreContext = FluidDataStoreContext;
|
|
638
|
+
FluidDataStoreContext.pendingOpsCountThreshold = 1000;
|
|
671
639
|
/** @internal */
|
|
672
640
|
class RemoteFluidDataStoreContext extends FluidDataStoreContext {
|
|
673
|
-
// Tells whether we need to fetch the snapshot before use. This is to support Data Virtualization.
|
|
674
|
-
snapshotFetchRequired;
|
|
675
|
-
runtime;
|
|
676
|
-
blobContents;
|
|
677
641
|
constructor(props) {
|
|
678
642
|
super(props, true /* existing */, false /* isLocalDataStore */, () => {
|
|
679
643
|
throw new Error("Already attached");
|
|
680
644
|
});
|
|
645
|
+
this.initialSnapshotDetailsP = new internal_1.LazyPromise(async () => {
|
|
646
|
+
// Sequence number of the snapshot.
|
|
647
|
+
let sequenceNumber;
|
|
648
|
+
// Check whether we need to fetch the snapshot first to load.
|
|
649
|
+
if (this.snapshotFetchRequired === undefined && this._baseSnapshot?.groupId !== undefined) {
|
|
650
|
+
(0, internal_1.assert)(this.blobContents !== undefined, 0x97a /* Blob contents should be present to evaluate */);
|
|
651
|
+
(0, internal_1.assert)(this._baseSnapshot !== undefined, 0x97b /* snapshotTree should be present to evaluate */);
|
|
652
|
+
this.snapshotFetchRequired = (0, internal_4.isSnapshotFetchRequiredForLoadingGroupId)(this._baseSnapshot, this.blobContents);
|
|
653
|
+
}
|
|
654
|
+
if (this.snapshotFetchRequired) {
|
|
655
|
+
(0, internal_1.assert)(this.loadingGroupId !== undefined, 0x8f5 /* groupId should be present to fetch snapshot */);
|
|
656
|
+
const snapshot = await this.runtime.getSnapshotForLoadingGroupId([this.loadingGroupId], [this.id]);
|
|
657
|
+
this._baseSnapshot = snapshot.snapshotTree;
|
|
658
|
+
sequenceNumber = snapshot.sequenceNumber;
|
|
659
|
+
this.snapshotFetchRequired = false;
|
|
660
|
+
}
|
|
661
|
+
let tree = this.baseSnapshot;
|
|
662
|
+
let isRootDataStore = true;
|
|
663
|
+
if (!!tree && tree.blobs[index_js_2.dataStoreAttributesBlobName] !== undefined) {
|
|
664
|
+
// Need to get through snapshot and use that to populate extraBlobs
|
|
665
|
+
// eslint-disable-next-line import/no-deprecated
|
|
666
|
+
const attributes = await (0, internal_2.readAndParse)(this.storage, tree.blobs[index_js_2.dataStoreAttributesBlobName]);
|
|
667
|
+
let pkgFromSnapshot;
|
|
668
|
+
// Use the snapshotFormatVersion to determine how the pkg is encoded in the snapshot.
|
|
669
|
+
// For snapshotFormatVersion = "0.1" (1) or above, pkg is jsonified, otherwise it is just a string.
|
|
670
|
+
const formatVersion = (0, index_js_2.getAttributesFormatVersion)(attributes);
|
|
671
|
+
if (formatVersion < 1) {
|
|
672
|
+
pkgFromSnapshot =
|
|
673
|
+
attributes.pkg.startsWith('["') && attributes.pkg.endsWith('"]')
|
|
674
|
+
? JSON.parse(attributes.pkg)
|
|
675
|
+
: [attributes.pkg];
|
|
676
|
+
}
|
|
677
|
+
else {
|
|
678
|
+
pkgFromSnapshot = JSON.parse(attributes.pkg);
|
|
679
|
+
}
|
|
680
|
+
this.pkg = pkgFromSnapshot;
|
|
681
|
+
/**
|
|
682
|
+
* If there is no isRootDataStore in the attributes blob, set it to true. This will ensure that
|
|
683
|
+
* data stores in older documents are not garbage collected incorrectly. This may lead to additional
|
|
684
|
+
* roots in the document but they won't break.
|
|
685
|
+
*/
|
|
686
|
+
isRootDataStore = attributes.isRootDataStore ?? true;
|
|
687
|
+
if ((0, index_js_2.hasIsolatedChannels)(attributes)) {
|
|
688
|
+
tree = tree.trees[internal_3.channelsTreeName];
|
|
689
|
+
(0, internal_1.assert)(tree !== undefined, 0x1fe /* "isolated channels subtree should exist in remote datastore snapshot" */);
|
|
690
|
+
}
|
|
691
|
+
}
|
|
692
|
+
(0, internal_1.assert)(this.pkg !== undefined, 0x8f6 /* The datastore context package should be defined */);
|
|
693
|
+
return {
|
|
694
|
+
pkg: this.pkg,
|
|
695
|
+
isRootDataStore,
|
|
696
|
+
snapshot: tree,
|
|
697
|
+
sequenceNumber,
|
|
698
|
+
};
|
|
699
|
+
});
|
|
681
700
|
this.runtime = props.parentContext.containerRuntime;
|
|
682
701
|
if ((0, internal_2.isInstanceOfISnapshot)(props.snapshot)) {
|
|
683
702
|
this.blobContents = props.snapshot.blobContents;
|
|
@@ -701,61 +720,6 @@ class RemoteFluidDataStoreContext extends FluidDataStoreContext {
|
|
|
701
720
|
4. attach op for this data store is processed - setAttachState() is called.
|
|
702
721
|
*/
|
|
703
722
|
setAttachState(attachState) { }
|
|
704
|
-
initialSnapshotDetailsP = new internal_1.LazyPromise(async () => {
|
|
705
|
-
// Sequence number of the snapshot.
|
|
706
|
-
let sequenceNumber;
|
|
707
|
-
// Check whether we need to fetch the snapshot first to load.
|
|
708
|
-
if (this.snapshotFetchRequired === undefined && this._baseSnapshot?.groupId !== undefined) {
|
|
709
|
-
(0, internal_1.assert)(this.blobContents !== undefined, 0x97a /* Blob contents should be present to evaluate */);
|
|
710
|
-
(0, internal_1.assert)(this._baseSnapshot !== undefined, 0x97b /* snapshotTree should be present to evaluate */);
|
|
711
|
-
this.snapshotFetchRequired = (0, internal_4.isSnapshotFetchRequiredForLoadingGroupId)(this._baseSnapshot, this.blobContents);
|
|
712
|
-
}
|
|
713
|
-
if (this.snapshotFetchRequired) {
|
|
714
|
-
(0, internal_1.assert)(this.loadingGroupId !== undefined, 0x8f5 /* groupId should be present to fetch snapshot */);
|
|
715
|
-
const snapshot = await this.runtime.getSnapshotForLoadingGroupId([this.loadingGroupId], [this.id]);
|
|
716
|
-
this._baseSnapshot = snapshot.snapshotTree;
|
|
717
|
-
sequenceNumber = snapshot.sequenceNumber;
|
|
718
|
-
this.snapshotFetchRequired = false;
|
|
719
|
-
}
|
|
720
|
-
let tree = this.baseSnapshot;
|
|
721
|
-
let isRootDataStore = true;
|
|
722
|
-
if (!!tree && tree.blobs[index_js_2.dataStoreAttributesBlobName] !== undefined) {
|
|
723
|
-
// Need to get through snapshot and use that to populate extraBlobs
|
|
724
|
-
// eslint-disable-next-line import/no-deprecated
|
|
725
|
-
const attributes = await (0, internal_2.readAndParse)(this.storage, tree.blobs[index_js_2.dataStoreAttributesBlobName]);
|
|
726
|
-
let pkgFromSnapshot;
|
|
727
|
-
// Use the snapshotFormatVersion to determine how the pkg is encoded in the snapshot.
|
|
728
|
-
// For snapshotFormatVersion = "0.1" (1) or above, pkg is jsonified, otherwise it is just a string.
|
|
729
|
-
const formatVersion = (0, index_js_2.getAttributesFormatVersion)(attributes);
|
|
730
|
-
if (formatVersion < 1) {
|
|
731
|
-
pkgFromSnapshot =
|
|
732
|
-
attributes.pkg.startsWith('["') && attributes.pkg.endsWith('"]')
|
|
733
|
-
? JSON.parse(attributes.pkg)
|
|
734
|
-
: [attributes.pkg];
|
|
735
|
-
}
|
|
736
|
-
else {
|
|
737
|
-
pkgFromSnapshot = JSON.parse(attributes.pkg);
|
|
738
|
-
}
|
|
739
|
-
this.pkg = pkgFromSnapshot;
|
|
740
|
-
/**
|
|
741
|
-
* If there is no isRootDataStore in the attributes blob, set it to true. This will ensure that
|
|
742
|
-
* data stores in older documents are not garbage collected incorrectly. This may lead to additional
|
|
743
|
-
* roots in the document but they won't break.
|
|
744
|
-
*/
|
|
745
|
-
isRootDataStore = attributes.isRootDataStore ?? true;
|
|
746
|
-
if ((0, index_js_2.hasIsolatedChannels)(attributes)) {
|
|
747
|
-
tree = tree.trees[internal_3.channelsTreeName];
|
|
748
|
-
(0, internal_1.assert)(tree !== undefined, 0x1fe /* "isolated channels subtree should exist in remote datastore snapshot" */);
|
|
749
|
-
}
|
|
750
|
-
}
|
|
751
|
-
(0, internal_1.assert)(this.pkg !== undefined, 0x8f6 /* The datastore context package should be defined */);
|
|
752
|
-
return {
|
|
753
|
-
pkg: this.pkg,
|
|
754
|
-
isRootDataStore,
|
|
755
|
-
snapshot: tree,
|
|
756
|
-
sequenceNumber,
|
|
757
|
-
};
|
|
758
|
-
});
|
|
759
723
|
async getInitialSnapshotDetails() {
|
|
760
724
|
return this.initialSnapshotDetailsP;
|
|
761
725
|
}
|
|
@@ -778,13 +742,39 @@ exports.RemoteFluidDataStoreContext = RemoteFluidDataStoreContext;
|
|
|
778
742
|
* @internal
|
|
779
743
|
*/
|
|
780
744
|
class LocalFluidDataStoreContextBase extends FluidDataStoreContext {
|
|
781
|
-
snapshotTree;
|
|
782
|
-
/**
|
|
783
|
-
* @deprecated 0.16 Issue #1635, #3631
|
|
784
|
-
*/
|
|
785
|
-
createProps;
|
|
786
745
|
constructor(props) {
|
|
787
746
|
super(props, props.snapshotTree !== undefined /* existing */, true /* isLocalDataStore */, props.makeLocallyVisibleFn);
|
|
747
|
+
this.initialSnapshotDetailsP = new internal_1.LazyPromise(async () => {
|
|
748
|
+
let snapshot = this.snapshotTree;
|
|
749
|
+
// eslint-disable-next-line import/no-deprecated
|
|
750
|
+
let attributes;
|
|
751
|
+
let isRootDataStore = false;
|
|
752
|
+
if (snapshot !== undefined) {
|
|
753
|
+
// Get the dataStore attributes.
|
|
754
|
+
// Note: storage can be undefined in special case while detached.
|
|
755
|
+
attributes = await (0, index_js_2.getFluidDataStoreAttributes)(this.storage, snapshot);
|
|
756
|
+
if ((0, index_js_2.hasIsolatedChannels)(attributes)) {
|
|
757
|
+
snapshot = snapshot.trees[internal_3.channelsTreeName];
|
|
758
|
+
(0, internal_1.assert)(snapshot !== undefined, 0x1ff /* "isolated channels subtree should exist in local datastore snapshot" */);
|
|
759
|
+
}
|
|
760
|
+
if (this.pkg === undefined) {
|
|
761
|
+
this.pkg = JSON.parse(attributes.pkg);
|
|
762
|
+
// If there is no isRootDataStore in the attributes blob, set it to true. This ensures that data
|
|
763
|
+
// stores in older documents are not garbage collected incorrectly. This may lead to additional
|
|
764
|
+
// roots in the document but they won't break.
|
|
765
|
+
if (attributes.isRootDataStore ?? true) {
|
|
766
|
+
isRootDataStore = true;
|
|
767
|
+
this.setInMemoryRoot();
|
|
768
|
+
}
|
|
769
|
+
}
|
|
770
|
+
}
|
|
771
|
+
(0, internal_1.assert)(this.pkg !== undefined, 0x152 /* "pkg should be available in local data store" */);
|
|
772
|
+
return {
|
|
773
|
+
pkg: this.pkg,
|
|
774
|
+
isRootDataStore,
|
|
775
|
+
snapshot,
|
|
776
|
+
};
|
|
777
|
+
});
|
|
788
778
|
// Summarizer client should not create local data stores.
|
|
789
779
|
this.identifyLocalChangeInSummarizer("DataStoreCreatedInSummarizer");
|
|
790
780
|
this.snapshotTree = props.snapshotTree;
|
|
@@ -854,37 +844,6 @@ class LocalFluidDataStoreContextBase extends FluidDataStoreContext {
|
|
|
854
844
|
(0, internal_1.assert)(this.channel !== undefined, "There should be a channel when generating attach GC data");
|
|
855
845
|
return this.channel.getAttachGCData(telemetryContext);
|
|
856
846
|
}
|
|
857
|
-
initialSnapshotDetailsP = new internal_1.LazyPromise(async () => {
|
|
858
|
-
let snapshot = this.snapshotTree;
|
|
859
|
-
// eslint-disable-next-line import/no-deprecated
|
|
860
|
-
let attributes;
|
|
861
|
-
let isRootDataStore = false;
|
|
862
|
-
if (snapshot !== undefined) {
|
|
863
|
-
// Get the dataStore attributes.
|
|
864
|
-
// Note: storage can be undefined in special case while detached.
|
|
865
|
-
attributes = await (0, index_js_2.getFluidDataStoreAttributes)(this.storage, snapshot);
|
|
866
|
-
if ((0, index_js_2.hasIsolatedChannels)(attributes)) {
|
|
867
|
-
snapshot = snapshot.trees[internal_3.channelsTreeName];
|
|
868
|
-
(0, internal_1.assert)(snapshot !== undefined, 0x1ff /* "isolated channels subtree should exist in local datastore snapshot" */);
|
|
869
|
-
}
|
|
870
|
-
if (this.pkg === undefined) {
|
|
871
|
-
this.pkg = JSON.parse(attributes.pkg);
|
|
872
|
-
// If there is no isRootDataStore in the attributes blob, set it to true. This ensures that data
|
|
873
|
-
// stores in older documents are not garbage collected incorrectly. This may lead to additional
|
|
874
|
-
// roots in the document but they won't break.
|
|
875
|
-
if (attributes.isRootDataStore ?? true) {
|
|
876
|
-
isRootDataStore = true;
|
|
877
|
-
this.setInMemoryRoot();
|
|
878
|
-
}
|
|
879
|
-
}
|
|
880
|
-
}
|
|
881
|
-
(0, internal_1.assert)(this.pkg !== undefined, 0x152 /* "pkg should be available in local data store" */);
|
|
882
|
-
return {
|
|
883
|
-
pkg: this.pkg,
|
|
884
|
-
isRootDataStore,
|
|
885
|
-
snapshot,
|
|
886
|
-
};
|
|
887
|
-
});
|
|
888
847
|
async getInitialSnapshotDetails() {
|
|
889
848
|
return this.initialSnapshotDetailsP;
|
|
890
849
|
}
|
|
@@ -932,7 +891,6 @@ class LocalDetachedFluidDataStoreContext extends LocalFluidDataStoreContextBase
|
|
|
932
891
|
this.detachedRuntimeCreation = true;
|
|
933
892
|
this.channelToDataStoreFn = props.channelToDataStoreFn;
|
|
934
893
|
}
|
|
935
|
-
channelToDataStoreFn;
|
|
936
894
|
async attachRuntime(registry, dataStoreChannel) {
|
|
937
895
|
(0, internal_1.assert)(this.detachedRuntimeCreation, 0x154 /* "runtime creation is already attached" */);
|
|
938
896
|
this.detachedRuntimeCreation = false;
|