@fluidframework/container-runtime 2.4.0-299707 → 2.5.0-302463
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/container-runtime.test-files.tar +0 -0
- package/dist/blobManager/blobManager.d.ts.map +1 -1
- package/dist/blobManager/blobManager.js +10 -4
- package/dist/blobManager/blobManager.js.map +1 -1
- package/dist/channelCollection.d.ts.map +1 -1
- package/dist/channelCollection.js +10 -2
- package/dist/channelCollection.js.map +1 -1
- package/dist/containerRuntime.d.ts +6 -2
- package/dist/containerRuntime.d.ts.map +1 -1
- package/dist/containerRuntime.js +46 -28
- package/dist/containerRuntime.js.map +1 -1
- package/dist/dataStoreContexts.d.ts.map +1 -1
- package/dist/dataStoreContexts.js +14 -6
- package/dist/dataStoreContexts.js.map +1 -1
- package/dist/opLifecycle/index.d.ts +1 -1
- package/dist/opLifecycle/index.d.ts.map +1 -1
- package/dist/opLifecycle/index.js +2 -1
- package/dist/opLifecycle/index.js.map +1 -1
- package/dist/opLifecycle/outbox.d.ts +6 -0
- package/dist/opLifecycle/outbox.d.ts.map +1 -1
- package/dist/opLifecycle/outbox.js +9 -1
- package/dist/opLifecycle/outbox.js.map +1 -1
- package/dist/opLifecycle/remoteMessageProcessor.d.ts +4 -4
- package/dist/opLifecycle/remoteMessageProcessor.d.ts.map +1 -1
- package/dist/opLifecycle/remoteMessageProcessor.js +6 -18
- package/dist/opLifecycle/remoteMessageProcessor.js.map +1 -1
- package/dist/opProperties.js +1 -1
- package/dist/opProperties.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/summary/documentSchema.js +2 -2
- package/dist/summary/documentSchema.js.map +1 -1
- package/dist/summary/summaryCollection.d.ts.map +1 -1
- package/dist/summary/summaryCollection.js +3 -4
- package/dist/summary/summaryCollection.js.map +1 -1
- package/lib/blobManager/blobManager.d.ts.map +1 -1
- package/lib/blobManager/blobManager.js +10 -4
- package/lib/blobManager/blobManager.js.map +1 -1
- package/lib/channelCollection.d.ts.map +1 -1
- package/lib/channelCollection.js +11 -3
- package/lib/channelCollection.js.map +1 -1
- package/lib/containerRuntime.d.ts +6 -2
- package/lib/containerRuntime.d.ts.map +1 -1
- package/lib/containerRuntime.js +44 -27
- package/lib/containerRuntime.js.map +1 -1
- package/lib/dataStoreContexts.d.ts.map +1 -1
- package/lib/dataStoreContexts.js +15 -7
- package/lib/dataStoreContexts.js.map +1 -1
- package/lib/opLifecycle/index.d.ts +1 -1
- package/lib/opLifecycle/index.d.ts.map +1 -1
- package/lib/opLifecycle/index.js +1 -1
- package/lib/opLifecycle/index.js.map +1 -1
- package/lib/opLifecycle/outbox.d.ts +6 -0
- package/lib/opLifecycle/outbox.d.ts.map +1 -1
- package/lib/opLifecycle/outbox.js +7 -0
- package/lib/opLifecycle/outbox.js.map +1 -1
- package/lib/opLifecycle/remoteMessageProcessor.d.ts +4 -4
- package/lib/opLifecycle/remoteMessageProcessor.d.ts.map +1 -1
- package/lib/opLifecycle/remoteMessageProcessor.js +6 -18
- package/lib/opLifecycle/remoteMessageProcessor.js.map +1 -1
- package/lib/opProperties.js +1 -1
- package/lib/opProperties.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/summary/documentSchema.js +2 -2
- package/lib/summary/documentSchema.js.map +1 -1
- package/lib/summary/summaryCollection.d.ts.map +1 -1
- package/lib/summary/summaryCollection.js +3 -4
- package/lib/summary/summaryCollection.js.map +1 -1
- package/package.json +22 -26
- package/src/blobManager/blobManager.ts +10 -4
- package/src/channelCollection.ts +16 -7
- package/src/containerRuntime.ts +49 -27
- package/src/dataStoreContexts.ts +20 -7
- package/src/opLifecycle/index.ts +1 -1
- package/src/opLifecycle/outbox.ts +11 -0
- package/src/opLifecycle/remoteMessageProcessor.ts +8 -22
- package/src/opProperties.ts +1 -1
- package/src/packageVersion.ts +1 -1
- package/src/summary/documentSchema.ts +2 -2
- package/src/summary/summaryCollection.ts +3 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"documentSchema.js","sourceRoot":"","sources":["../../src/summary/documentSchema.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAC7D,OAAO,EAAE,mBAAmB,EAAE,MAAM,0CAA0C,CAAC;AAE/E,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AA4GlD;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAAG,CAAC,CAAC;AAyB9C,MAAM,eAAe;IACb,GAAG,CAAC,gBAAuB,EAAE,gBAAuB;QAC1D,OAAO,gBAAgB,KAAK,IAAI,IAAI,gBAAgB,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC;IAClF,CAAC;IAEM,EAAE,CAAC,gBAAuB,EAAE,gBAAuB;QACzD,OAAO,gBAAgB,KAAK,IAAI,IAAI,gBAAgB,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC;IAClF,CAAC;IAEM,QAAQ,CAAC,CAAU;QACzB,OAAO,CAAC,KAAK,SAAS,IAAI,CAAC,KAAK,IAAI,CAAC;IACtC,CAAC;CACD;AAED,MAAM,kBAAmB,SAAQ,eAAe;IACxC,GAAG,CAAC,gBAAuB,EAAE,gBAAuB;QAC1D,OAAO,IAAI,CAAC,EAAE,CAAC,gBAAgB,EAAE,gBAAgB,CAAC,CAAC;IACpD,CAAC;CACD;AAED,MAAM,WAAW;IAChB,YAA6B,OAAiB;QAAjB,YAAO,GAAP,OAAO,CAAU;IAAG,CAAC;IAE3C,GAAG,CAAC,gBAAyB,EAAE,gBAAyB;QAC9D,IAAI,gBAAgB,KAAK,SAAS,IAAI,gBAAgB,KAAK,SAAS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E,KAAK,CAAC,qBAAqB,CAC3B,CAAC;QAEF,sFAAsF;QACtF,yBAAyB,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;QAE7C,MAAM,MAAM,GAAoB,EAAE,GAAG,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,CAAC;QACvE,IAAI,CAAC,cAAc,GAAG,MAAgC,CAAC;QACvD,IAAI,CAAC,aAAa,GAAG,GAAG,CAAC,IAAI,CAAC,cAAc,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;QAClE,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,MAAM,KAAK,cAAc,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC;QAEvE,yFAAyF;QACzF,4CAA4C;QAC5C,mFAAmF;QACnF,IAAI,CAAC,qBAAqB,GAAG,IAAI,CAAC;QAElC,mCAAmC;QACnC,sEAAsE;QACtE,6DAA6D;QAC7D,2FAA2F;QAC3F,qGAAqG;QACrG,+DAA+D;QAC/D,IAAI,CAAC,YAAY,GAAG,SAAS,CAAC;QAE9B,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QAExC,OAAO,IAAI,CAAC;IACb,CAAC;IAEM,YAAY;QAClB,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;IACpB,CAAC;CACD;AAED,2CAA2C","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport { DataProcessingError } from \"@fluidframework/telemetry-utils/internal\";\n\nimport { pkgVersion } from \"../packageVersion.js\";\n\n/**\n * Descripe allowed type for properties in document schema.\n * Please note that for all property types we should use undefined to indicate that particular capability is off.\n * Using false, or some string value (like \"off\") will result in clients who do not understand that property failing, whereas\n * we want them to continue to collaborate alongside clients who support that capability, but such capability is shipping dark for now.\n * @legacy\n * @alpha\n */\nexport type DocumentSchemaValueType = string | string[] | true | number | undefined;\n\n/**\n * ID Compressor mode.\n * \"on\" - compressor is On. It's loaded as part of container load. This mode is sticky - once on, compressor is On for all\n * sessions for a given document. This results in IContainerRuntime.idCompressor to be always available.\n * \"delayed\" - ID compressor bundle is loaded only on establishing of first delta connection, i.e. it does not impact boot of cotnainer.\n * In such mode IContainerRuntime.idCompressor is not made available (unless previous sessions of same document had it \"On\").\n * The only thing that is available is IContainerRuntime.generateDocumentUniqueId() that provides opportunistically short IDs.\n * undefined - ID compressor is not loaded.\n * While IContainerRuntime.generateDocumentUniqueId() is available, it will produce long IDs that are do not compress well.\n *\n * @legacy\n * @alpha\n */\nexport type IdCompressorMode = \"on\" | \"delayed\" | undefined;\n\n/**\n * Document schema information.\n * Describes overall shape of document schema, including unknown (to this version) properties.\n *\n * Used by runtime to make a call if it can understand document schema.\n * If it can't, it should not continue with document and immediately fail, preventing random (cryptic) failures\n * down the road and potentially corrupting documents.\n * For now this structure and appropriate interpretation / behavior is focused only on runtime features.\n * In the future that could be interpolated to more areas, including DDSs used, and even possibly - application\n * schema.\n *\n * Runtime will ignore any properties at the root that it does not understand (i.e. IDocumentSchema.app), but will\n * stop (and fail session) on any unknown properties within \"runtime\" sub-tree.\n *\n * In most cases values preserved in the document will not dictate if such features should be enabled in a given session.\n * I.e. if compression is mentioned in document schema, this means that runtime version that opens such document must know\n * how to interpret such ops, but does not need to actually use compression itself. That said, some options could be\n * sticky, i.e. influence feature selection for all runtimes opening a document. ID compression is one such example.\n * Currently there is no mechanism to remove feature from this property bag, i.e. once compression was used, even if it's\n * disabled (through feature gate or code deployment), all existing documents that used compression will continue to fail\n * if opened by clients who do not support compression.\n *\n * For now we are limiting it to just plain properties, and only really simple types, but that can be changed in the future.\n *\n * @legacy\n * @alpha\n */\nexport interface IDocumentSchema {\n\t// version that describes how data is stored in this structure.\n\t// If runtime sees a version it does not understand, it should immediately fail and not\n\t// attempt to interpret any further data.\n\tversion: number;\n\n\t// Sequence number when this schema became active.\n\trefSeq: number;\n\n\truntime: Record<string, DocumentSchemaValueType>;\n}\n\n/**\n * Content of the type=ContainerMessageType.DocumentSchemaChange ops.\n * The meaning of refSeq field is different in such messages (compared to other usages of IDocumentSchemaCurrent)\n * ContainerMessageType.DocumentSchemaChange messages use CAS (Compare-and-swap) semantics, and convey\n * regSeq of last known schema change (known to a client proposing schema change).\n * @see ContainerRuntimeDocumentSchemaMessage\n * @legacy\n * @alpha\n */\nexport type IDocumentSchemaChangeMessage = IDocumentSchema;\n\n/**\n * Settings that this session would like to have, based on options and feature gates.\n *\n * WARNING: This type is used to infer IDocumentSchemaCurrent type!\n * Any changes here (including renaming of properties) are potentially changing document format and should be considered carefully!\n *\n * @legacy\n * @alpha\n */\nexport interface IDocumentSchemaFeatures {\n\t// Tells if client uses legacy behavior of changing schema.\n\t// - Legacy behavior - changing schema without leveraging schema change ops.\n\t// - New behavior - changes in schema require ops and take into affect with delay.\n\texplicitSchemaControl: boolean;\n\tcompressionLz4: boolean;\n\tidCompressorMode: IdCompressorMode;\n\topGroupingEnabled: boolean;\n\n\t/**\n\t * List of disallowed versions of the runtime.\n\t * This option is sticky. Once a version of runtime is added to this list (when supplied to DocumentsSchemaController's constructor)\n\t * it will be added to the list of disallowed versions and stored in document metadata.\n\t * Each runtime checks if its version is in this list on container open. If it is, it immediately exits with error message\n\t * indicating to the user that this version is no longer supported.\n\t * Currently there is no mechanism to remove version from this list. I.e. If it was once added to the list,\n\t * it gets added to any document metadata (documents that gets open by this runtime) and there is no way to clear it from document's\n\t * metadata.\n\t */\n\tdisallowedVersions: string[];\n}\n\n/**\n * Current version known properties that define document schema\n * This must be bumped whenever the format of document schema or protocol for changing the current document schema changes.\n * Ex: adding a new configuration property (under IDocumentSchema.runtime) does not require changing this version.\n * Ex: Changing the 'document schema acceptance' mechanism from convert-and-swap to one requiring consensus does require changing this version.\n * @legacy\n * @alpha\n */\nexport const currentDocumentVersionSchema = 1;\n\n/**\n * Current document schema.\n * @legacy\n * @alpha\n */\n// eslint-disable-next-line @typescript-eslint/consistent-type-definitions\nexport type IDocumentSchemaCurrent = {\n\tversion: 1;\n\trefSeq: number;\n\n\truntime: {\n\t\t[P in keyof IDocumentSchemaFeatures]?: IDocumentSchemaFeatures[P] extends boolean\n\t\t\t? true\n\t\t\t: IDocumentSchemaFeatures[P];\n\t};\n};\n\ninterface IProperty<T = unknown> {\n\tand: (currentDocSchema: T, desiredDocSchema: T) => T;\n\tor: (currentDocSchema: T, desiredDocSchema: T) => T;\n\tvalidate(t: unknown): boolean;\n}\n\nclass TrueOrUndefined implements IProperty<true | undefined> {\n\tpublic and(currentDocSchema?: true, desiredDocSchema?: true) {\n\t\treturn currentDocSchema === true && desiredDocSchema === true ? true : undefined;\n\t}\n\n\tpublic or(currentDocSchema?: true, desiredDocSchema?: true) {\n\t\treturn currentDocSchema === true || desiredDocSchema === true ? true : undefined;\n\t}\n\n\tpublic validate(t: unknown) {\n\t\treturn t === undefined || t === true;\n\t}\n}\n\nclass TrueOrUndefinedMax extends TrueOrUndefined {\n\tpublic and(currentDocSchema?: true, desiredDocSchema?: true) {\n\t\treturn this.or(currentDocSchema, desiredDocSchema);\n\t}\n}\n\nclass MultiChoice implements IProperty<string | undefined> {\n\tconstructor(private readonly choices: string[]) {}\n\n\tpublic and(currentDocSchema?: string, desiredDocSchema?: string) {\n\t\tif (currentDocSchema === undefined || desiredDocSchema === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn this.choices[\n\t\t\tMath.min(this.choices.indexOf(currentDocSchema), this.choices.indexOf(desiredDocSchema))\n\t\t];\n\t}\n\n\tpublic or(currentDocSchema?: string, desiredDocSchema?: string) {\n\t\tif (currentDocSchema === undefined) {\n\t\t\treturn desiredDocSchema;\n\t\t}\n\t\tif (desiredDocSchema === undefined) {\n\t\t\treturn currentDocSchema;\n\t\t}\n\t\treturn this.choices[\n\t\t\tMath.max(this.choices.indexOf(currentDocSchema), this.choices.indexOf(desiredDocSchema))\n\t\t];\n\t}\n\n\tpublic validate(t: unknown) {\n\t\treturn t === undefined || (typeof t === \"string\" && this.choices.includes(t));\n\t}\n}\n\nclass IdCompressorProperty extends MultiChoice {\n\t// document schema always wins!\n\tpublic and(currentDocSchema?: string, desiredDocSchema?: string) {\n\t\treturn currentDocSchema;\n\t}\n}\n\nclass CheckVersions implements IProperty<string[] | undefined> {\n\tpublic or(currentDocSchema: string[] = [], desiredDocSchema: string[] = []) {\n\t\tconst set = new Set<string>([...currentDocSchema, ...desiredDocSchema]);\n\t\treturn arrayToProp([...set.values()]);\n\t}\n\n\t// Once version is there, it stays there forever.\n\tpublic and(currentDocSchema: string[] = [], desiredDocSchema: string[] = []) {\n\t\treturn this.or(currentDocSchema, desiredDocSchema);\n\t}\n\n\tpublic validate(t: unknown) {\n\t\treturn t === undefined || (Array.isArray(t) && !t.includes(pkgVersion));\n\t}\n}\n\n/**\n * Helper structure to valida if a schema is compatible with existing code.\n */\nconst documentSchemaSupportedConfigs = {\n\texplicitSchemaControl: new TrueOrUndefinedMax(), // once new behavior shows up, it's sticky\n\tidCompressorMode: new IdCompressorProperty([\"delayed\", \"on\"]),\n\topGroupingEnabled: new TrueOrUndefined(),\n\tcompressionLz4: new TrueOrUndefined(),\n\tdisallowedVersions: new CheckVersions(),\n};\n\n/**\n * Checks if a given schema is compatible with current code, i.e. if current code can understand all the features of that schema.\n * If schema is not compatible with current code, it throws an exception.\n * @param documentSchema - current schema\n */\nfunction checkRuntimeCompatibility(\n\tdocumentSchema: IDocumentSchema | undefined,\n\tschemaName: string,\n) {\n\t// Back-compat - we can't do anything about legacy documents.\n\t// There is no way to validate them, so we are taking a guess that safe deployment processes used by a given app\n\t// do not run into compat problems.\n\tif (documentSchema === undefined) {\n\t\treturn;\n\t}\n\n\tconst msg = \"Document can't be opened with current version of the code\";\n\tif (documentSchema.version !== currentDocumentVersionSchema) {\n\t\tthrow DataProcessingError.create(\n\t\t\tmsg,\n\t\t\t\"checkRuntimeCompat1\",\n\t\t\tundefined, // message\n\t\t\t{\n\t\t\t\truntimeSchemaVersion: documentSchema.version,\n\t\t\t\tcurrentRuntimeSchemaVersion: currentDocumentVersionSchema,\n\t\t\t\tschemaName,\n\t\t\t},\n\t\t);\n\t}\n\n\tlet unknownProperty: string | undefined;\n\n\tconst regSeq = documentSchema.refSeq;\n\t// defence in depth - it should not be possible to get here anything other than integer, but worth validating it.\n\tif (typeof regSeq !== \"number\" || regSeq < 0 || !Number.isInteger(regSeq)) {\n\t\tunknownProperty = \"refSeq\";\n\t} else if (documentSchema.runtime === null || typeof documentSchema.runtime !== \"object\") {\n\t\tunknownProperty = \"runtime\";\n\t} else {\n\t\tfor (const [name, value] of Object.entries(documentSchema.runtime)) {\n\t\t\tconst validator = documentSchemaSupportedConfigs[name] as IProperty | undefined;\n\t\t\tif (validator === undefined || !validator.validate(value)) {\n\t\t\t\tunknownProperty = `runtime/${name}`;\n\t\t\t}\n\t\t}\n\t}\n\n\tif (unknownProperty !== undefined) {\n\t\tconst value = documentSchema[unknownProperty];\n\t\tthrow DataProcessingError.create(\n\t\t\tmsg,\n\t\t\t\"checkRuntimeCompat2\",\n\t\t\tundefined, // message\n\t\t\t{\n\t\t\t\tcodeVersion: currentDocumentVersionSchema,\n\t\t\t\tproperty: unknownProperty,\n\t\t\t\tvalue,\n\t\t\t\tschemaName,\n\t\t\t},\n\t\t);\n\t}\n}\n\nfunction and(\n\tcurrentDocSchema: IDocumentSchemaCurrent,\n\tdesiredDocSchema: IDocumentSchemaCurrent,\n): IDocumentSchemaCurrent {\n\tconst runtime = {};\n\tfor (const key of new Set([\n\t\t...Object.keys(currentDocSchema.runtime),\n\t\t...Object.keys(desiredDocSchema.runtime),\n\t])) {\n\t\truntime[key] = (documentSchemaSupportedConfigs[key] as IProperty).and(\n\t\t\tcurrentDocSchema.runtime[key],\n\t\t\tdesiredDocSchema.runtime[key],\n\t\t);\n\t}\n\treturn {\n\t\tversion: currentDocumentVersionSchema,\n\t\trefSeq: currentDocSchema.refSeq,\n\t\truntime,\n\t} as unknown as IDocumentSchemaCurrent;\n}\n\nfunction or(\n\tcurrentDocSchema: IDocumentSchemaCurrent,\n\tdesiredDocSchema: IDocumentSchemaCurrent,\n): IDocumentSchemaCurrent {\n\tconst runtime = {};\n\tfor (const key of new Set([\n\t\t...Object.keys(currentDocSchema.runtime),\n\t\t...Object.keys(desiredDocSchema.runtime),\n\t])) {\n\t\truntime[key] = (documentSchemaSupportedConfigs[key] as IProperty).or(\n\t\t\tcurrentDocSchema.runtime[key],\n\t\t\tdesiredDocSchema.runtime[key],\n\t\t);\n\t}\n\treturn {\n\t\tversion: currentDocumentVersionSchema,\n\t\trefSeq: currentDocSchema.refSeq,\n\t\truntime,\n\t} as unknown as IDocumentSchemaCurrent;\n}\n\nfunction same(\n\tcurrentDocSchema: IDocumentSchemaCurrent,\n\tdesiredDocSchema: IDocumentSchemaCurrent,\n): boolean {\n\tfor (const key of new Set([\n\t\t...Object.keys(currentDocSchema.runtime),\n\t\t...Object.keys(desiredDocSchema.runtime),\n\t])) {\n\t\t// If schemas differ only by type of behavior, then we should not send schema change ops!\n\t\tif (\n\t\t\tkey !== \"explicitSchemaControl\" &&\n\t\t\tcurrentDocSchema.runtime[key] !== desiredDocSchema.runtime[key]\n\t\t) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\nfunction boolToProp(b: boolean) {\n\treturn b ? true : undefined;\n}\n\nfunction arrayToProp(arr: string[]) {\n\treturn arr.length === 0 ? undefined : arr;\n}\n\n/* eslint-disable jsdoc/check-indentation */\n\n/**\n * Controller of document schema.\n *\n * Recommended pre-reading: https://github.com/microsoft/FluidFramework/blob/main/packages/dds/SchemaVersioning.md\n *\n * This class manages current document schema and transitions between document schemas.\n * At the moment, it only focuses on subset of document schema, specifically - how FluidFramework runtime serializes data\n * (summary and op format), features & capabilities that a version of runtime has to support and understand in\n * order to collaborate on a document.\n * New features that modify document format have to be included in document schema definition.\n * Usage of such features could only happen after document schema has been updated to reflect such feature.\n *\n * This formality allows clients that do not understand such features to fail right away when they observe\n * document schema listing capabilities that such client does not understand.\n * Old clients will fail in predictable way. This allows us to\n * 1) Immediately see such issues and adjust if features are enabled too early, before changes have been saturated.\n * 2) There is no way to get to 100% saturation with new code. Even if we have 99.99% saturation, there are\n * still 0.01% of clients who will fail. Failing early and predictably ensures they have no chance to limp along\n * and potentially corrupt the document. This is especially true for summarizer client, who could simply \"undo\"\n * changes it does not understands.\n *\n * It's important to note how it overlaps with feature gates and safe velocity.\n * If new feature was in use, that resulted in a number of documents referencing such feature in document schema.\n * But, developers (through code deployment or feature gates) could disable usage of such features.\n * That will stop a process of further document schema changes (for documents that were not using such feature).\n * And documents that already list such capability in their schema will continue to do so. Later ensures that old\n * clients who do not understand such feature will continue to fail to open such documents, as such documents very\n * likely contain data in a new format.\n *\n * Controller operates with 4 schemas:\n * - document schema: whatever we loaded from summary metadata + ops. It follows eventuall consistency rules (i.e. like DDS).\n * - desired schema - what client is asking for to have (i.e. all the desired settings, based on runtime options / feature gates).\n * - session schema - current session schema. It's \"and\" of the above two schemas.\n * - future schema - \"or\" of document and desires schemas.\n *\n * \"or\" & \"and\" operators are defined individually for each property. For Boolean properties it's literally &&, || operators.\n * But for other properties it's more nuanced.\n *\n * Whenver document schema does not match future schema, controller will send an op that attempts to changs documents schema to\n * future schema.\n *\n * Users of this class need to use DocumentsSchemaController.sessionSchema to determine what features can be used.\n *\n * There are two modes this class can operate:\n * 1) Legacy mode. In such mode it does not issue any ops to change document schema. Any changes happen implicitly,\n * right away, and new features are available right away\n * 2) Non-legacy mode. In such mode any changes to schema require an op roundtrip. This class will manage such transitions.\n * However code should assume that any new features that were not enabled in a given document will not be available\n * for a given session. That's because this session may never send any ops (including read-only documents). Or it may\n * fail to convert schema.\n * This class promises eventual movement forward. I.e. if new feature is allowed (let's say - through feature gates),\n * then eventually all documents that are modified will have that feature reflected in their schema. It could require\n * multiple reloads / new sessions to get there (depends on if code reacts to schema changes right away, or only consults\n * schema on document load).\n *\n * How schemas are changed (in non-legacy mode):\n * If a client needs to change a schema, it will attempt to do so as part of normal ops sending process.\n * Changes happen in CAS (Compare-and-swap) fashion, i.e. client tells current schema and schema it wants to change to.\n * When a number of clients race to change a schema, then only one of them will win, all others will fail because they will\n * reference old schema that is no longer in effect.\n * Clients can retry, but current implementation is simply - they will not (and will rely on next session / reload to do\n * recalc and decide if schema needs to be changed or not).\n *\n * @legacy\n * @alpha\n */\nexport class DocumentsSchemaController {\n\tprivate explicitSchemaControl: boolean;\n\tprivate sendOp = true;\n\n\t// schema coming from document metadata (snapshot we loaded from)\n\tprivate documentSchema: IDocumentSchemaCurrent;\n\n\t// desired schema, based on feature gates / runtime options.\n\t// This includes requests to enable to disable functionality\n\tprivate readonly desiredSchema: IDocumentSchemaCurrent;\n\n\t// OR() of document schema and desired schema. It enables all the features that are enabled in either of schemas.\n\tprivate futureSchema: IDocumentSchemaCurrent | undefined;\n\n\t// Current schema this session operates with.\n\t// 1) Legacy mode (explicitSchemaControl === false): this is same as desired schema - all options that were requested to be on are on, and all options requested to be off are off.\n\t// 2) Non-legacy mode (explicitSchemaControl === true): this is AND() of document schema and desired schema. Only options that are enabled in both are enabled here.\n\t// If there are any options that are not enabled in document schema, but are enabled in desired schema, then attempt to change schema\n\t// (and enable such options) will be made through the session.\n\tpublic sessionSchema: IDocumentSchemaCurrent;\n\n\t/**\n\t * Constructs DocumentsSchemaController that controls current schema and processes around it, including changes in schema.\n\t * @param existing - Is the document existing document, or a new doc.\n\t * @param documentMetadataSchema - current document's schema, if present.\n\t * @param features - features of the document schema that current session wants to see enabled.\n\t * @param onSchemaChange - callback that is called whenever schema is changed (not called on creation / load, only when processing document schema change ops)\n\t */\n\tconstructor(\n\t\texisting: boolean,\n\t\tsnapshotSequenceNumber: number,\n\t\tdocumentMetadataSchema: IDocumentSchema | undefined,\n\t\tfeatures: IDocumentSchemaFeatures,\n\t\tprivate readonly onSchemaChange: (schema: IDocumentSchemaCurrent) => void,\n\t) {\n\t\t// For simplicity, let's only support new schema features for explicit schema control mode\n\t\tassert(\n\t\t\tfeatures.disallowedVersions.length === 0 || features.explicitSchemaControl,\n\t\t\t0x949 /* not supported */,\n\t\t);\n\n\t\t// Desired schema by this session - almost all props are coming from arguments\n\t\tthis.desiredSchema = {\n\t\t\tversion: currentDocumentVersionSchema,\n\t\t\trefSeq: documentMetadataSchema?.refSeq ?? 0,\n\t\t\truntime: {\n\t\t\t\texplicitSchemaControl: boolToProp(features.explicitSchemaControl),\n\t\t\t\tcompressionLz4: boolToProp(features.compressionLz4),\n\t\t\t\tidCompressorMode: features.idCompressorMode,\n\t\t\t\topGroupingEnabled: boolToProp(features.opGroupingEnabled),\n\t\t\t\tdisallowedVersions: arrayToProp(features.disallowedVersions),\n\t\t\t},\n\t\t};\n\n\t\t// Schema coming from document metadata (snapshot we loaded from), or if no document exists\n\t\t// (this is a new document) then this is the same as desiredSchema (same as session schema in such case).\n\t\t// Latter is importnat sure that's what will go into summary.\n\t\tthis.documentSchema = !existing\n\t\t\t? this.desiredSchema\n\t\t\t: (documentMetadataSchema as IDocumentSchemaCurrent) ??\n\t\t\t\t({\n\t\t\t\t\tversion: currentDocumentVersionSchema,\n\t\t\t\t\t// see comment in summarizeDocumentSchema() on why it has to stay zero\n\t\t\t\t\trefSeq: 0,\n\t\t\t\t\t// If it's existing document and it has no schema, then it was written by legacy client.\n\t\t\t\t\t// If it's a new document, then we define it's legacy-related behaviors.\n\t\t\t\t\truntime: {\n\t\t\t\t\t\texplicitSchemaControl: boolToProp(!existing && features.explicitSchemaControl),\n\t\t\t\t\t},\n\t\t\t\t} satisfies IDocumentSchemaCurrent);\n\n\t\tcheckRuntimeCompatibility(this.documentSchema, \"document\");\n\t\tthis.validateSeqNumber(this.documentSchema.refSeq, snapshotSequenceNumber, \"summary\");\n\n\t\t// Use legacy behavior only if both document and options tell us to use legacy.\n\t\t// Otherwise it's no longer legacy time!\n\t\tthis.explicitSchemaControl =\n\t\t\tthis.documentSchema.runtime.explicitSchemaControl === true ||\n\t\t\tfeatures.explicitSchemaControl;\n\n\t\t// Calculate\n\t\t// - current session schema (overlap of document schema and desired schema)\n\t\t// - future schema to propose (concatination of document schema and desired schema)\n\t\tif (!this.explicitSchemaControl || !existing) {\n\t\t\tthis.sessionSchema = this.desiredSchema;\n\t\t\tassert(\n\t\t\t\tboolToProp(this.explicitSchemaControl) ===\n\t\t\t\t\tthis.sessionSchema.runtime.explicitSchemaControl,\n\t\t\t\t0x94a /* explicitSchemaControl */,\n\t\t\t);\n\t\t\tthis.futureSchema = undefined;\n\t\t} else {\n\t\t\tthis.sessionSchema = and(this.documentSchema, this.desiredSchema);\n\t\t\tthis.futureSchema = or(this.documentSchema, this.desiredSchema);\n\t\t\tassert(this.sessionSchema.runtime.explicitSchemaControl === true, 0x94b /* legacy */);\n\t\t\tassert(this.futureSchema.runtime.explicitSchemaControl === true, 0x94c /* legacy */);\n\t\t\tif (same(this.documentSchema, this.futureSchema)) {\n\t\t\t\tthis.futureSchema = undefined;\n\t\t\t}\n\t\t}\n\n\t\t// Validate that schema we are operating in is actually a schema we consider compatible with current runtime.\n\t\tcheckRuntimeCompatibility(this.desiredSchema, \"desired\");\n\t\tcheckRuntimeCompatibility(this.sessionSchema, \"session\");\n\t\tcheckRuntimeCompatibility(this.futureSchema, \"future\");\n\t}\n\n\tpublic summarizeDocumentSchema(refSeq: number): IDocumentSchemaCurrent | undefined {\n\t\t// For legacy behavior, we could write nothing (return undefined).\n\t\t// It does not buy us anything, as whatever written in summary does not actually impact clients operating in legacy mode.\n\t\t// But writing current used config (and assuming most of the clients settle on same config over time) will help with transition\n\t\t// out of legacy mode, as clients transitioning out of it would be able to use all the\n\t\t// features that are mentioned in schema right away, without a need to go through schema transition (and thus for a session or\n\t\t// two losing ability to use all the features)\n\n\t\tconst schema = this.explicitSchemaControl ? this.documentSchema : this.desiredSchema;\n\n\t\t// It's important to keep refSeq at zero in legacy mode, such that transition out of it is simple and we do not have\n\t\t// race conditions. If we put any other number (including latest seq number), then we will have two clients\n\t\t// (loading from two different summaries) with different numbers, and eventual consistency will be broken as schema\n\t\t// change ops will be interpretted differently by those two clients.\n\t\tassert(\n\t\t\tthis.explicitSchemaControl || schema.refSeq === 0,\n\t\t\t0x94d /* refSeq should be zero */,\n\t\t);\n\n\t\treturn schema;\n\t}\n\n\t/**\n\t * Called by Container runtime whenever it is about to send some op.\n\t * It gives opportunity for controller to issue its own ops - we do not want to send ops if there are no local changes in document.\n\t * Please consider note above constructor about race conditions - current design is to send op only once in a session lifetime.\n\t * @returns Optional message to send.\n\t */\n\tpublic maybeSendSchemaMessage(): IDocumentSchemaChangeMessage | undefined {\n\t\tif (this.sendOp && this.futureSchema !== undefined) {\n\t\t\tthis.sendOp = false;\n\t\t\tassert(\n\t\t\t\tthis.explicitSchemaControl && this.futureSchema.runtime.explicitSchemaControl === true,\n\t\t\t\t0x94e /* not legacy */,\n\t\t\t);\n\t\t\treturn {\n\t\t\t\t...this.futureSchema,\n\t\t\t\trefSeq: this.documentSchema.refSeq,\n\t\t\t};\n\t\t}\n\t}\n\n\tprivate validateSeqNumber(schemaSeqNumber: number, lastKnowSeqNumber, message: string) {\n\t\tif (!Number.isInteger(schemaSeqNumber) || !(schemaSeqNumber <= lastKnowSeqNumber)) {\n\t\t\tthrow DataProcessingError.create(\n\t\t\t\t\"DocSchema: Incorrect sequence number\",\n\t\t\t\t\"checkRuntimeCompat3\",\n\t\t\t\tundefined, // message\n\t\t\t\t{\n\t\t\t\t\tschemaSeqNumber,\n\t\t\t\t\tsequenceNumber: lastKnowSeqNumber,\n\t\t\t\t\tmessage,\n\t\t\t\t},\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Process document schema change message\n\t * Called by ContainerRuntime whenever it sees document schema messages.\n\t * @param content - content of the message\n\t * @param local - whether op is local\n\t * @param sequenceNumber - sequence number of the op\n\t * @returns - true if schema was accepted, otherwise false (rejected due to failed CAS)\n\t */\n\tpublic processDocumentSchemaOp(\n\t\tcontent: IDocumentSchemaChangeMessage,\n\t\tlocal: boolean,\n\t\tsequenceNumber: number,\n\t) {\n\t\tthis.validateSeqNumber(content.refSeq, this.documentSchema.refSeq, \"content.refSeq\");\n\t\tthis.validateSeqNumber(this.documentSchema.refSeq, sequenceNumber, \"refSeq\");\n\t\t// validate is strickly less, not equal\n\t\tassert(\n\t\t\tthis.documentSchema.refSeq < sequenceNumber,\n\t\t\t0x950 /* time should move forward only! */,\n\t\t);\n\n\t\tif (content.refSeq !== this.documentSchema.refSeq) {\n\t\t\t// CAS failed\n\t\t\treturn false;\n\t\t}\n\n\t\t// This assert should be after checking for successful CAS above.\n\t\t// This will ensure we do not trip on our own messages that are no longer wanted as we processed someone else schema change message.\n\t\tassert(\n\t\t\t!local || (this.explicitSchemaControl && this.futureSchema !== undefined),\n\t\t\t0x951 /* not sending ops */,\n\t\t);\n\n\t\t// Changes are in effect. Immediately check that this client understands these changes\n\t\tcheckRuntimeCompatibility(content, \"change\");\n\n\t\tconst schema: IDocumentSchema = { ...content, refSeq: sequenceNumber };\n\t\tthis.documentSchema = schema as IDocumentSchemaCurrent;\n\t\tthis.sessionSchema = and(this.documentSchema, this.desiredSchema);\n\t\tassert(this.sessionSchema.refSeq === sequenceNumber, 0x97d /* seq# */);\n\n\t\t// legacy behavior is automatically off for the document once someone sends a schema op -\n\t\t// from now on it's fully controlled by ops.\n\t\t// This is very important, as summarizeDocumentSchema() should use this new schema!\n\t\tthis.explicitSchemaControl = true;\n\n\t\t// Stop attempting changing schema.\n\t\t// If it was local op, then we succeeded and do not need to try again.\n\t\t// If it was remote op, then some changes happened to schema.\n\t\t// We would need to recalculate this.futureSchema by merging changes that we just received.\n\t\t// Avoid this complexity for now - a new client session (loading from new summary with these changes)\n\t\t// will automatically do this recalculation and will figure out\n\t\tthis.futureSchema = undefined;\n\n\t\tthis.onSchemaChange(this.sessionSchema);\n\n\t\treturn true;\n\t}\n\n\tpublic onDisconnect() {\n\t\tthis.sendOp = true;\n\t}\n}\n\n/* eslint-enable jsdoc/check-indentation */\n"]}
|
|
1
|
+
{"version":3,"file":"documentSchema.js","source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,GAAG,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,CAAC;QACvE,IAAI,CAAC,cAAc,GAAG,MAAgC,CAAC;QACvD,IAAI,CAAC,aAAa,GAAG,GAAG,CAAC,IAAI,CAAC,cAAc,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;QAClE,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,MAAM,KAAK,cAAc,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC;QAEvE,yFAAyF;QACzF,4CAA4C;QAC5C,mFAAmF;QACnF,IAAI,CAAC,qBAAqB,GAAG,IAAI,CAAC;QAElC,mCAAmC;QACnC,sEAAsE;QACtE,6DAA6D;QAC7D,2FAA2F;QAC3F,qGAAqG;QACrG,+DAA+D;QAC/D,IAAI,CAAC,YAAY,GAAG,SAAS,CAAC;QAE9B,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QAExC,OAAO,IAAI,CAAC;IACb,CAAC;IAEM,YAAY;QAClB,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;IACpB,CAAC;CACD;AAED,2CAA2C","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport { DataProcessingError } from \"@fluidframework/telemetry-utils/internal\";\n\nimport { pkgVersion } from \"../packageVersion.js\";\n\n/**\n * Descripe allowed type for properties in document schema.\n * Please note that for all property types we should use undefined to indicate that particular capability is off.\n * Using false, or some string value (like \"off\") will result in clients who do not understand that property failing, whereas\n * we want them to continue to collaborate alongside clients who support that capability, but such capability is shipping dark for now.\n * @legacy\n * @alpha\n */\nexport type DocumentSchemaValueType = string | string[] | true | number | undefined;\n\n/**\n * ID Compressor mode.\n * \"on\" - compressor is On. It's loaded as part of container load. This mode is sticky - once on, compressor is On for all\n * sessions for a given document. This results in IContainerRuntime.idCompressor to be always available.\n * \"delayed\" - ID compressor bundle is loaded only on establishing of first delta connection, i.e. it does not impact boot of cotnainer.\n * In such mode IContainerRuntime.idCompressor is not made available (unless previous sessions of same document had it \"On\").\n * The only thing that is available is IContainerRuntime.generateDocumentUniqueId() that provides opportunistically short IDs.\n * undefined - ID compressor is not loaded.\n * While IContainerRuntime.generateDocumentUniqueId() is available, it will produce long IDs that are do not compress well.\n *\n * @legacy\n * @alpha\n */\nexport type IdCompressorMode = \"on\" | \"delayed\" | undefined;\n\n/**\n * Document schema information.\n * Describes overall shape of document schema, including unknown (to this version) properties.\n *\n * Used by runtime to make a call if it can understand document schema.\n * If it can't, it should not continue with document and immediately fail, preventing random (cryptic) failures\n * down the road and potentially corrupting documents.\n * For now this structure and appropriate interpretation / behavior is focused only on runtime features.\n * In the future that could be interpolated to more areas, including DDSs used, and even possibly - application\n * schema.\n *\n * Runtime will ignore any properties at the root that it does not understand (i.e. IDocumentSchema.app), but will\n * stop (and fail session) on any unknown properties within \"runtime\" sub-tree.\n *\n * In most cases values preserved in the document will not dictate if such features should be enabled in a given session.\n * I.e. if compression is mentioned in document schema, this means that runtime version that opens such document must know\n * how to interpret such ops, but does not need to actually use compression itself. That said, some options could be\n * sticky, i.e. influence feature selection for all runtimes opening a document. ID compression is one such example.\n * Currently there is no mechanism to remove feature from this property bag, i.e. once compression was used, even if it's\n * disabled (through feature gate or code deployment), all existing documents that used compression will continue to fail\n * if opened by clients who do not support compression.\n *\n * For now we are limiting it to just plain properties, and only really simple types, but that can be changed in the future.\n *\n * @legacy\n * @alpha\n */\nexport interface IDocumentSchema {\n\t// version that describes how data is stored in this structure.\n\t// If runtime sees a version it does not understand, it should immediately fail and not\n\t// attempt to interpret any further data.\n\tversion: number;\n\n\t// Sequence number when this schema became active.\n\trefSeq: number;\n\n\truntime: Record<string, DocumentSchemaValueType>;\n}\n\n/**\n * Content of the type=ContainerMessageType.DocumentSchemaChange ops.\n * The meaning of refSeq field is different in such messages (compared to other usages of IDocumentSchemaCurrent)\n * ContainerMessageType.DocumentSchemaChange messages use CAS (Compare-and-swap) semantics, and convey\n * regSeq of last known schema change (known to a client proposing schema change).\n * @see ContainerRuntimeDocumentSchemaMessage\n * @legacy\n * @alpha\n */\nexport type IDocumentSchemaChangeMessage = IDocumentSchema;\n\n/**\n * Settings that this session would like to have, based on options and feature gates.\n *\n * WARNING: This type is used to infer IDocumentSchemaCurrent type!\n * Any changes here (including renaming of properties) are potentially changing document format and should be considered carefully!\n *\n * @legacy\n * @alpha\n */\nexport interface IDocumentSchemaFeatures {\n\t// Tells if client uses legacy behavior of changing schema.\n\t// - Legacy behavior - changing schema without leveraging schema change ops.\n\t// - New behavior - changes in schema require ops and take into affect with delay.\n\texplicitSchemaControl: boolean;\n\tcompressionLz4: boolean;\n\tidCompressorMode: IdCompressorMode;\n\topGroupingEnabled: boolean;\n\n\t/**\n\t * List of disallowed versions of the runtime.\n\t * This option is sticky. Once a version of runtime is added to this list (when supplied to DocumentsSchemaController's constructor)\n\t * it will be added to the list of disallowed versions and stored in document metadata.\n\t * Each runtime checks if its version is in this list on container open. If it is, it immediately exits with error message\n\t * indicating to the user that this version is no longer supported.\n\t * Currently there is no mechanism to remove version from this list. I.e. If it was once added to the list,\n\t * it gets added to any document metadata (documents that gets open by this runtime) and there is no way to clear it from document's\n\t * metadata.\n\t */\n\tdisallowedVersions: string[];\n}\n\n/**\n * Current version known properties that define document schema\n * This must be bumped whenever the format of document schema or protocol for changing the current document schema changes.\n * Ex: adding a new configuration property (under IDocumentSchema.runtime) does not require changing this version.\n * Ex: Changing the 'document schema acceptance' mechanism from convert-and-swap to one requiring consensus does require changing this version.\n * @legacy\n * @alpha\n */\nexport const currentDocumentVersionSchema = 1;\n\n/**\n * Current document schema.\n * @legacy\n * @alpha\n */\n// eslint-disable-next-line @typescript-eslint/consistent-type-definitions\nexport type IDocumentSchemaCurrent = {\n\tversion: 1;\n\trefSeq: number;\n\n\truntime: {\n\t\t[P in keyof IDocumentSchemaFeatures]?: IDocumentSchemaFeatures[P] extends boolean\n\t\t\t? true\n\t\t\t: IDocumentSchemaFeatures[P];\n\t};\n};\n\ninterface IProperty<T = unknown> {\n\tand: (currentDocSchema: T, desiredDocSchema: T) => T;\n\tor: (currentDocSchema: T, desiredDocSchema: T) => T;\n\tvalidate(t: unknown): boolean;\n}\n\nclass TrueOrUndefined implements IProperty<true | undefined> {\n\tpublic and(currentDocSchema?: true, desiredDocSchema?: true) {\n\t\treturn currentDocSchema === true && desiredDocSchema === true ? true : undefined;\n\t}\n\n\tpublic or(currentDocSchema?: true, desiredDocSchema?: true) {\n\t\treturn currentDocSchema === true || desiredDocSchema === true ? true : undefined;\n\t}\n\n\tpublic validate(t: unknown) {\n\t\treturn t === undefined || t === true;\n\t}\n}\n\nclass TrueOrUndefinedMax extends TrueOrUndefined {\n\tpublic and(currentDocSchema?: true, desiredDocSchema?: true) {\n\t\treturn this.or(currentDocSchema, desiredDocSchema);\n\t}\n}\n\nclass MultiChoice implements IProperty<string | undefined> {\n\tconstructor(private readonly choices: string[]) {}\n\n\tpublic and(currentDocSchema?: string, desiredDocSchema?: string) {\n\t\tif (currentDocSchema === undefined || desiredDocSchema === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn this.choices[\n\t\t\tMath.min(this.choices.indexOf(currentDocSchema), this.choices.indexOf(desiredDocSchema))\n\t\t];\n\t}\n\n\tpublic or(currentDocSchema?: string, desiredDocSchema?: string) {\n\t\tif (currentDocSchema === undefined) {\n\t\t\treturn desiredDocSchema;\n\t\t}\n\t\tif (desiredDocSchema === undefined) {\n\t\t\treturn currentDocSchema;\n\t\t}\n\t\treturn this.choices[\n\t\t\tMath.max(this.choices.indexOf(currentDocSchema), this.choices.indexOf(desiredDocSchema))\n\t\t];\n\t}\n\n\tpublic validate(t: unknown) {\n\t\treturn t === undefined || (typeof t === \"string\" && this.choices.includes(t));\n\t}\n}\n\nclass IdCompressorProperty extends MultiChoice {\n\t// document schema always wins!\n\tpublic and(currentDocSchema?: string, desiredDocSchema?: string) {\n\t\treturn currentDocSchema;\n\t}\n}\n\nclass CheckVersions implements IProperty<string[] | undefined> {\n\tpublic or(currentDocSchema: string[] = [], desiredDocSchema: string[] = []) {\n\t\tconst set = new Set<string>([...currentDocSchema, ...desiredDocSchema]);\n\t\treturn arrayToProp([...set.values()]);\n\t}\n\n\t// Once version is there, it stays there forever.\n\tpublic and(currentDocSchema: string[] = [], desiredDocSchema: string[] = []) {\n\t\treturn this.or(currentDocSchema, desiredDocSchema);\n\t}\n\n\tpublic validate(t: unknown) {\n\t\treturn t === undefined || (Array.isArray(t) && !t.includes(pkgVersion));\n\t}\n}\n\n/**\n * Helper structure to valida if a schema is compatible with existing code.\n */\nconst documentSchemaSupportedConfigs = {\n\texplicitSchemaControl: new TrueOrUndefinedMax(), // once new behavior shows up, it's sticky\n\tidCompressorMode: new IdCompressorProperty([\"delayed\", \"on\"]),\n\topGroupingEnabled: new TrueOrUndefined(),\n\tcompressionLz4: new TrueOrUndefined(),\n\tdisallowedVersions: new CheckVersions(),\n};\n\n/**\n * Checks if a given schema is compatible with current code, i.e. if current code can understand all the features of that schema.\n * If schema is not compatible with current code, it throws an exception.\n * @param documentSchema - current schema\n */\nfunction checkRuntimeCompatibility(\n\tdocumentSchema: IDocumentSchema | undefined,\n\tschemaName: string,\n) {\n\t// Back-compat - we can't do anything about legacy documents.\n\t// There is no way to validate them, so we are taking a guess that safe deployment processes used by a given app\n\t// do not run into compat problems.\n\tif (documentSchema === undefined) {\n\t\treturn;\n\t}\n\n\tconst msg = \"Document can't be opened with current version of the code\";\n\tif (documentSchema.version !== currentDocumentVersionSchema) {\n\t\tthrow DataProcessingError.create(\n\t\t\tmsg,\n\t\t\t\"checkRuntimeCompat1\",\n\t\t\tundefined, // message\n\t\t\t{\n\t\t\t\truntimeSchemaVersion: documentSchema.version,\n\t\t\t\tcurrentRuntimeSchemaVersion: currentDocumentVersionSchema,\n\t\t\t\tschemaName,\n\t\t\t},\n\t\t);\n\t}\n\n\tlet unknownProperty: string | undefined;\n\n\tconst regSeq = documentSchema.refSeq;\n\t// defence in depth - it should not be possible to get here anything other than integer, but worth validating it.\n\tif (typeof regSeq !== \"number\" || regSeq < 0 || !Number.isInteger(regSeq)) {\n\t\tunknownProperty = \"refSeq\";\n\t} else if (documentSchema.runtime === null || typeof documentSchema.runtime !== \"object\") {\n\t\tunknownProperty = \"runtime\";\n\t} else {\n\t\tfor (const [name, value] of Object.entries(documentSchema.runtime)) {\n\t\t\tconst validator = documentSchemaSupportedConfigs[name] as IProperty | undefined;\n\t\t\tif (validator === undefined || !validator.validate(value)) {\n\t\t\t\tunknownProperty = `runtime/${name}`;\n\t\t\t}\n\t\t}\n\t}\n\n\tif (unknownProperty !== undefined) {\n\t\tconst value = documentSchema[unknownProperty];\n\t\tthrow DataProcessingError.create(\n\t\t\tmsg,\n\t\t\t\"checkRuntimeCompat2\",\n\t\t\tundefined, // message\n\t\t\t{\n\t\t\t\tcodeVersion: currentDocumentVersionSchema,\n\t\t\t\tproperty: unknownProperty,\n\t\t\t\tvalue,\n\t\t\t\tschemaName,\n\t\t\t},\n\t\t);\n\t}\n}\n\nfunction and(\n\tcurrentDocSchema: IDocumentSchemaCurrent,\n\tdesiredDocSchema: IDocumentSchemaCurrent,\n): IDocumentSchemaCurrent {\n\tconst runtime = {};\n\tfor (const key of new Set([\n\t\t...Object.keys(currentDocSchema.runtime),\n\t\t...Object.keys(desiredDocSchema.runtime),\n\t])) {\n\t\truntime[key] = (documentSchemaSupportedConfigs[key] as IProperty).and(\n\t\t\tcurrentDocSchema.runtime[key],\n\t\t\tdesiredDocSchema.runtime[key],\n\t\t);\n\t}\n\treturn {\n\t\tversion: currentDocumentVersionSchema,\n\t\trefSeq: currentDocSchema.refSeq,\n\t\truntime,\n\t} as unknown as IDocumentSchemaCurrent;\n}\n\nfunction or(\n\tcurrentDocSchema: IDocumentSchemaCurrent,\n\tdesiredDocSchema: IDocumentSchemaCurrent,\n): IDocumentSchemaCurrent {\n\tconst runtime = {};\n\tfor (const key of new Set([\n\t\t...Object.keys(currentDocSchema.runtime),\n\t\t...Object.keys(desiredDocSchema.runtime),\n\t])) {\n\t\truntime[key] = (documentSchemaSupportedConfigs[key] as IProperty).or(\n\t\t\tcurrentDocSchema.runtime[key],\n\t\t\tdesiredDocSchema.runtime[key],\n\t\t);\n\t}\n\treturn {\n\t\tversion: currentDocumentVersionSchema,\n\t\trefSeq: currentDocSchema.refSeq,\n\t\truntime,\n\t} as unknown as IDocumentSchemaCurrent;\n}\n\nfunction same(\n\tcurrentDocSchema: IDocumentSchemaCurrent,\n\tdesiredDocSchema: IDocumentSchemaCurrent,\n): boolean {\n\tfor (const key of new Set([\n\t\t...Object.keys(currentDocSchema.runtime),\n\t\t...Object.keys(desiredDocSchema.runtime),\n\t])) {\n\t\t// If schemas differ only by type of behavior, then we should not send schema change ops!\n\t\tif (\n\t\t\tkey !== \"explicitSchemaControl\" &&\n\t\t\tcurrentDocSchema.runtime[key] !== desiredDocSchema.runtime[key]\n\t\t) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\nfunction boolToProp(b: boolean) {\n\treturn b ? true : undefined;\n}\n\nfunction arrayToProp(arr: string[]) {\n\treturn arr.length === 0 ? undefined : arr;\n}\n\n/* eslint-disable jsdoc/check-indentation */\n\n/**\n * Controller of document schema.\n *\n * Recommended pre-reading: https://github.com/microsoft/FluidFramework/blob/main/packages/dds/SchemaVersioning.md\n *\n * This class manages current document schema and transitions between document schemas.\n * At the moment, it only focuses on subset of document schema, specifically - how FluidFramework runtime serializes data\n * (summary and op format), features & capabilities that a version of runtime has to support and understand in\n * order to collaborate on a document.\n * New features that modify document format have to be included in document schema definition.\n * Usage of such features could only happen after document schema has been updated to reflect such feature.\n *\n * This formality allows clients that do not understand such features to fail right away when they observe\n * document schema listing capabilities that such client does not understand.\n * Old clients will fail in predictable way. This allows us to\n * 1) Immediately see such issues and adjust if features are enabled too early, before changes have been saturated.\n * 2) There is no way to get to 100% saturation with new code. Even if we have 99.99% saturation, there are\n * still 0.01% of clients who will fail. Failing early and predictably ensures they have no chance to limp along\n * and potentially corrupt the document. This is especially true for summarizer client, who could simply \"undo\"\n * changes it does not understands.\n *\n * It's important to note how it overlaps with feature gates and safe velocity.\n * If new feature was in use, that resulted in a number of documents referencing such feature in document schema.\n * But, developers (through code deployment or feature gates) could disable usage of such features.\n * That will stop a process of further document schema changes (for documents that were not using such feature).\n * And documents that already list such capability in their schema will continue to do so. Later ensures that old\n * clients who do not understand such feature will continue to fail to open such documents, as such documents very\n * likely contain data in a new format.\n *\n * Controller operates with 4 schemas:\n * - document schema: whatever we loaded from summary metadata + ops. It follows eventuall consistency rules (i.e. like DDS).\n * - desired schema - what client is asking for to have (i.e. all the desired settings, based on runtime options / feature gates).\n * - session schema - current session schema. It's \"and\" of the above two schemas.\n * - future schema - \"or\" of document and desires schemas.\n *\n * \"or\" & \"and\" operators are defined individually for each property. For Boolean properties it's literally &&, || operators.\n * But for other properties it's more nuanced.\n *\n * Whenver document schema does not match future schema, controller will send an op that attempts to changs documents schema to\n * future schema.\n *\n * Users of this class need to use DocumentsSchemaController.sessionSchema to determine what features can be used.\n *\n * There are two modes this class can operate:\n * 1) Legacy mode. In such mode it does not issue any ops to change document schema. Any changes happen implicitly,\n * right away, and new features are available right away\n * 2) Non-legacy mode. In such mode any changes to schema require an op roundtrip. This class will manage such transitions.\n * However code should assume that any new features that were not enabled in a given document will not be available\n * for a given session. That's because this session may never send any ops (including read-only documents). Or it may\n * fail to convert schema.\n * This class promises eventual movement forward. I.e. if new feature is allowed (let's say - through feature gates),\n * then eventually all documents that are modified will have that feature reflected in their schema. It could require\n * multiple reloads / new sessions to get there (depends on if code reacts to schema changes right away, or only consults\n * schema on document load).\n *\n * How schemas are changed (in non-legacy mode):\n * If a client needs to change a schema, it will attempt to do so as part of normal ops sending process.\n * Changes happen in CAS (Compare-and-swap) fashion, i.e. client tells current schema and schema it wants to change to.\n * When a number of clients race to change a schema, then only one of them will win, all others will fail because they will\n * reference old schema that is no longer in effect.\n * Clients can retry, but current implementation is simply - they will not (and will rely on next session / reload to do\n * recalc and decide if schema needs to be changed or not).\n *\n * @legacy\n * @alpha\n */\nexport class DocumentsSchemaController {\n\tprivate explicitSchemaControl: boolean;\n\tprivate sendOp = true;\n\n\t// schema coming from document metadata (snapshot we loaded from)\n\tprivate documentSchema: IDocumentSchemaCurrent;\n\n\t// desired schema, based on feature gates / runtime options.\n\t// This includes requests to enable to disable functionality\n\tprivate readonly desiredSchema: IDocumentSchemaCurrent;\n\n\t// OR() of document schema and desired schema. It enables all the features that are enabled in either of schemas.\n\tprivate futureSchema: IDocumentSchemaCurrent | undefined;\n\n\t// Current schema this session operates with.\n\t// 1) Legacy mode (explicitSchemaControl === false): this is same as desired schema - all options that were requested to be on are on, and all options requested to be off are off.\n\t// 2) Non-legacy mode (explicitSchemaControl === true): this is AND() of document schema and desired schema. Only options that are enabled in both are enabled here.\n\t// If there are any options that are not enabled in document schema, but are enabled in desired schema, then attempt to change schema\n\t// (and enable such options) will be made through the session.\n\tpublic sessionSchema: IDocumentSchemaCurrent;\n\n\t/**\n\t * Constructs DocumentsSchemaController that controls current schema and processes around it, including changes in schema.\n\t * @param existing - Is the document existing document, or a new doc.\n\t * @param documentMetadataSchema - current document's schema, if present.\n\t * @param features - features of the document schema that current session wants to see enabled.\n\t * @param onSchemaChange - callback that is called whenever schema is changed (not called on creation / load, only when processing document schema change ops)\n\t */\n\tconstructor(\n\t\texisting: boolean,\n\t\tsnapshotSequenceNumber: number,\n\t\tdocumentMetadataSchema: IDocumentSchema | undefined,\n\t\tfeatures: IDocumentSchemaFeatures,\n\t\tprivate readonly onSchemaChange: (schema: IDocumentSchemaCurrent) => void,\n\t) {\n\t\t// For simplicity, let's only support new schema features for explicit schema control mode\n\t\tassert(\n\t\t\tfeatures.disallowedVersions.length === 0 || features.explicitSchemaControl,\n\t\t\t0x949 /* not supported */,\n\t\t);\n\n\t\t// Desired schema by this session - almost all props are coming from arguments\n\t\tthis.desiredSchema = {\n\t\t\tversion: currentDocumentVersionSchema,\n\t\t\trefSeq: documentMetadataSchema?.refSeq ?? 0,\n\t\t\truntime: {\n\t\t\t\texplicitSchemaControl: boolToProp(features.explicitSchemaControl),\n\t\t\t\tcompressionLz4: boolToProp(features.compressionLz4),\n\t\t\t\tidCompressorMode: features.idCompressorMode,\n\t\t\t\topGroupingEnabled: boolToProp(features.opGroupingEnabled),\n\t\t\t\tdisallowedVersions: arrayToProp(features.disallowedVersions),\n\t\t\t},\n\t\t};\n\n\t\t// Schema coming from document metadata (snapshot we loaded from), or if no document exists\n\t\t// (this is a new document) then this is the same as desiredSchema (same as session schema in such case).\n\t\t// Latter is importnat sure that's what will go into summary.\n\t\tthis.documentSchema = !existing\n\t\t\t? this.desiredSchema\n\t\t\t: ((documentMetadataSchema as IDocumentSchemaCurrent) ??\n\t\t\t\t({\n\t\t\t\t\tversion: currentDocumentVersionSchema,\n\t\t\t\t\t// see comment in summarizeDocumentSchema() on why it has to stay zero\n\t\t\t\t\trefSeq: 0,\n\t\t\t\t\t// If it's existing document and it has no schema, then it was written by legacy client.\n\t\t\t\t\t// If it's a new document, then we define it's legacy-related behaviors.\n\t\t\t\t\truntime: {\n\t\t\t\t\t\texplicitSchemaControl: boolToProp(!existing && features.explicitSchemaControl),\n\t\t\t\t\t},\n\t\t\t\t} satisfies IDocumentSchemaCurrent));\n\n\t\tcheckRuntimeCompatibility(this.documentSchema, \"document\");\n\t\tthis.validateSeqNumber(this.documentSchema.refSeq, snapshotSequenceNumber, \"summary\");\n\n\t\t// Use legacy behavior only if both document and options tell us to use legacy.\n\t\t// Otherwise it's no longer legacy time!\n\t\tthis.explicitSchemaControl =\n\t\t\tthis.documentSchema.runtime.explicitSchemaControl === true ||\n\t\t\tfeatures.explicitSchemaControl;\n\n\t\t// Calculate\n\t\t// - current session schema (overlap of document schema and desired schema)\n\t\t// - future schema to propose (concatination of document schema and desired schema)\n\t\tif (!this.explicitSchemaControl || !existing) {\n\t\t\tthis.sessionSchema = this.desiredSchema;\n\t\t\tassert(\n\t\t\t\tboolToProp(this.explicitSchemaControl) ===\n\t\t\t\t\tthis.sessionSchema.runtime.explicitSchemaControl,\n\t\t\t\t0x94a /* explicitSchemaControl */,\n\t\t\t);\n\t\t\tthis.futureSchema = undefined;\n\t\t} else {\n\t\t\tthis.sessionSchema = and(this.documentSchema, this.desiredSchema);\n\t\t\tthis.futureSchema = or(this.documentSchema, this.desiredSchema);\n\t\t\tassert(this.sessionSchema.runtime.explicitSchemaControl === true, 0x94b /* legacy */);\n\t\t\tassert(this.futureSchema.runtime.explicitSchemaControl === true, 0x94c /* legacy */);\n\t\t\tif (same(this.documentSchema, this.futureSchema)) {\n\t\t\t\tthis.futureSchema = undefined;\n\t\t\t}\n\t\t}\n\n\t\t// Validate that schema we are operating in is actually a schema we consider compatible with current runtime.\n\t\tcheckRuntimeCompatibility(this.desiredSchema, \"desired\");\n\t\tcheckRuntimeCompatibility(this.sessionSchema, \"session\");\n\t\tcheckRuntimeCompatibility(this.futureSchema, \"future\");\n\t}\n\n\tpublic summarizeDocumentSchema(refSeq: number): IDocumentSchemaCurrent | undefined {\n\t\t// For legacy behavior, we could write nothing (return undefined).\n\t\t// It does not buy us anything, as whatever written in summary does not actually impact clients operating in legacy mode.\n\t\t// But writing current used config (and assuming most of the clients settle on same config over time) will help with transition\n\t\t// out of legacy mode, as clients transitioning out of it would be able to use all the\n\t\t// features that are mentioned in schema right away, without a need to go through schema transition (and thus for a session or\n\t\t// two losing ability to use all the features)\n\n\t\tconst schema = this.explicitSchemaControl ? this.documentSchema : this.desiredSchema;\n\n\t\t// It's important to keep refSeq at zero in legacy mode, such that transition out of it is simple and we do not have\n\t\t// race conditions. If we put any other number (including latest seq number), then we will have two clients\n\t\t// (loading from two different summaries) with different numbers, and eventual consistency will be broken as schema\n\t\t// change ops will be interpretted differently by those two clients.\n\t\tassert(\n\t\t\tthis.explicitSchemaControl || schema.refSeq === 0,\n\t\t\t0x94d /* refSeq should be zero */,\n\t\t);\n\n\t\treturn schema;\n\t}\n\n\t/**\n\t * Called by Container runtime whenever it is about to send some op.\n\t * It gives opportunity for controller to issue its own ops - we do not want to send ops if there are no local changes in document.\n\t * Please consider note above constructor about race conditions - current design is to send op only once in a session lifetime.\n\t * @returns Optional message to send.\n\t */\n\tpublic maybeSendSchemaMessage(): IDocumentSchemaChangeMessage | undefined {\n\t\tif (this.sendOp && this.futureSchema !== undefined) {\n\t\t\tthis.sendOp = false;\n\t\t\tassert(\n\t\t\t\tthis.explicitSchemaControl && this.futureSchema.runtime.explicitSchemaControl === true,\n\t\t\t\t0x94e /* not legacy */,\n\t\t\t);\n\t\t\treturn {\n\t\t\t\t...this.futureSchema,\n\t\t\t\trefSeq: this.documentSchema.refSeq,\n\t\t\t};\n\t\t}\n\t}\n\n\tprivate validateSeqNumber(schemaSeqNumber: number, lastKnowSeqNumber, message: string) {\n\t\tif (!Number.isInteger(schemaSeqNumber) || !(schemaSeqNumber <= lastKnowSeqNumber)) {\n\t\t\tthrow DataProcessingError.create(\n\t\t\t\t\"DocSchema: Incorrect sequence number\",\n\t\t\t\t\"checkRuntimeCompat3\",\n\t\t\t\tundefined, // message\n\t\t\t\t{\n\t\t\t\t\tschemaSeqNumber,\n\t\t\t\t\tsequenceNumber: lastKnowSeqNumber,\n\t\t\t\t\tmessage,\n\t\t\t\t},\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Process document schema change message\n\t * Called by ContainerRuntime whenever it sees document schema messages.\n\t * @param content - content of the message\n\t * @param local - whether op is local\n\t * @param sequenceNumber - sequence number of the op\n\t * @returns - true if schema was accepted, otherwise false (rejected due to failed CAS)\n\t */\n\tpublic processDocumentSchemaOp(\n\t\tcontent: IDocumentSchemaChangeMessage,\n\t\tlocal: boolean,\n\t\tsequenceNumber: number,\n\t) {\n\t\tthis.validateSeqNumber(content.refSeq, this.documentSchema.refSeq, \"content.refSeq\");\n\t\tthis.validateSeqNumber(this.documentSchema.refSeq, sequenceNumber, \"refSeq\");\n\t\t// validate is strickly less, not equal\n\t\tassert(\n\t\t\tthis.documentSchema.refSeq < sequenceNumber,\n\t\t\t0x950 /* time should move forward only! */,\n\t\t);\n\n\t\tif (content.refSeq !== this.documentSchema.refSeq) {\n\t\t\t// CAS failed\n\t\t\treturn false;\n\t\t}\n\n\t\t// This assert should be after checking for successful CAS above.\n\t\t// This will ensure we do not trip on our own messages that are no longer wanted as we processed someone else schema change message.\n\t\tassert(\n\t\t\t!local || (this.explicitSchemaControl && this.futureSchema !== undefined),\n\t\t\t0x951 /* not sending ops */,\n\t\t);\n\n\t\t// Changes are in effect. Immediately check that this client understands these changes\n\t\tcheckRuntimeCompatibility(content, \"change\");\n\n\t\tconst schema: IDocumentSchema = { ...content, refSeq: sequenceNumber };\n\t\tthis.documentSchema = schema as IDocumentSchemaCurrent;\n\t\tthis.sessionSchema = and(this.documentSchema, this.desiredSchema);\n\t\tassert(this.sessionSchema.refSeq === sequenceNumber, 0x97d /* seq# */);\n\n\t\t// legacy behavior is automatically off for the document once someone sends a schema op -\n\t\t// from now on it's fully controlled by ops.\n\t\t// This is very important, as summarizeDocumentSchema() should use this new schema!\n\t\tthis.explicitSchemaControl = true;\n\n\t\t// Stop attempting changing schema.\n\t\t// If it was local op, then we succeeded and do not need to try again.\n\t\t// If it was remote op, then some changes happened to schema.\n\t\t// We would need to recalculate this.futureSchema by merging changes that we just received.\n\t\t// Avoid this complexity for now - a new client session (loading from new summary with these changes)\n\t\t// will automatically do this recalculation and will figure out\n\t\tthis.futureSchema = undefined;\n\n\t\tthis.onSchemaChange(this.sessionSchema);\n\n\t\treturn true;\n\t}\n\n\tpublic onDisconnect() {\n\t\tthis.sendOp = true;\n\t}\n}\n\n/* eslint-enable jsdoc/check-indentation */\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"summaryCollection.d.ts","sourceRoot":"","sources":["../../src/summary/summaryCollection.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8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CAA4B;IAE3C,IAAW,SAAS,IAAI,aAAa,GAAG,SAAS,CAEhD;IAEM,IAAI,CAAC,KAAK,EAAE,iBAAiB,EAAE,GAAG,IAAI,EAAE,UAAU,CAAC,qBAAqB,CAAC,GAAG,OAAO;IAI1F,IAAW,eAAe,WAKzB;IAEM,aAAa,CAAC,QAAQ,EAAE,MAAM,IAAI;IAIlC,gBAAgB,CAAC,QAAQ,EAAE,MAAM,IAAI;gBAK1B,YAAY,EAAE,aAAa,CAAC,yBAAyB,EAAE,gBAAgB,CAAC,EACxE,MAAM,EAAE,mBAAmB;IAM7C;;;;OAIG;IACI,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,qBAAqB;IAMtD,aAAa,CAAC,QAAQ,EAAE,MAAM;IAI9B,iCAAiC,CACvC,cAAc,EAAE,MAAM,EACtB,eAAe,EAAE,MAAM,IAAI;IAMrB,mCAAmC;IAK1C;;;OAGG;IACU,WAAW,IAAI,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC;IAW9D;;;;;OAKG;IACU,cAAc,CAAC,uBAAuB,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC;IAUpF,OAAO,CAAC,YAAY;IAUpB;;;OAGG;IACH,OAAO,CAAC,QAAQ;IAqChB,OAAO,CAAC,eAAe;IA0BvB,OAAO,CAAC,gBAAgB;IA2CxB,OAAO,CAAC,iBAAiB;CASzB"}
|
|
@@ -200,11 +200,10 @@ export class SummaryCollection extends TypedEventEmitter {
|
|
|
200
200
|
return this.lastAck;
|
|
201
201
|
}
|
|
202
202
|
parseContent(op) {
|
|
203
|
-
// This should become unconditional once (Loader LTS)
|
|
204
|
-
//
|
|
205
|
-
// Then there will be a long time of needing both cases, until LTS catches up to the change.
|
|
203
|
+
// This should become unconditional once (Loader LTS) reaches 2.4 or later
|
|
204
|
+
// There will be a long time of needing both cases, until LTS catches up to the change.
|
|
206
205
|
// That said, we may instead move to listen for "op" events from ContainerRuntime,
|
|
207
|
-
// and parsing may not be required at all if ContainerRuntime.process()
|
|
206
|
+
// and parsing may not be required at all if ContainerRuntime.process() continues to parse it for all types of ops.
|
|
208
207
|
if (typeof op.contents === "string") {
|
|
209
208
|
op.contents = JSON.parse(op.contents);
|
|
210
209
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"summaryCollection.js","sourceRoot":"","sources":["../../src/summary/summaryCollection.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAGjE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,qCAAqC,CAAC;AACvE,OAAO,EAKN,WAAW,GAEX,MAAM,6CAA6C,CAAC;AAwDrD,IAAK,YAKJ;AALD,WAAK,YAAY;IAChB,iDAAS,CAAA;IACT,yDAAa,CAAA;IACb,iDAAS,CAAA;IACT,oDAAW,CAAA;AACZ,CAAC,EALI,YAAY,KAAZ,YAAY,QAKhB;AAED,MAAM,OAAO;IACL,MAAM,CAAC,WAAW,CAAC,QAAgB,EAAE,oBAA4B;QACvE,OAAO,IAAI,OAAO,CAAC,QAAQ,EAAE,oBAAoB,CAAC,CAAC;IACpD,CAAC;IACM,MAAM,CAAC,YAAY,CAAC,EAAqB;QAC/C,+FAA+F;QAC/F,4EAA4E;QAC5E,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC,EAAE,CAAC,QAAkB,EAAE,EAAE,CAAC,oBAAoB,CAAC,CAAC;QAC5E,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC;QACtB,OAAO,OAAO,CAAC;IAChB,CAAC;IAUD,IAAW,SAAS;QACnB,OAAO,IAAI,CAAC,UAAU,CAAC;IACxB,CAAC;IACD,IAAW,cAAc;QACxB,OAAO,IAAI,CAAC,eAAe,CAAC;IAC7B,CAAC;IAED,YACiB,QAAgB,EAChB,oBAA4B;QAD5B,aAAQ,GAAR,QAAQ,CAAQ;QAChB,yBAAoB,GAApB,oBAAoB,CAAQ;QAj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,EAAE,CAAC;YACb,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;YACpB,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;YAClC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;QACxC,CAAC;IACF,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { TypedEventEmitter } from \"@fluid-internal/client-utils\";\nimport { IDeltaManager } from \"@fluidframework/container-definitions/internal\";\nimport { IDisposable, IEvent } from \"@fluidframework/core-interfaces\";\nimport { assert, Deferred } from \"@fluidframework/core-utils/internal\";\nimport {\n\tIDocumentMessage,\n\tISummaryAck,\n\tISummaryContent,\n\tISummaryNack,\n\tMessageType,\n\tISequencedDocumentMessage,\n} from \"@fluidframework/driver-definitions/internal\";\nimport { ITelemetryLoggerExt } from \"@fluidframework/telemetry-utils/internal\";\n\n/**\n * Interface for summary op messages with typed contents.\n * @legacy\n * @alpha\n */\nexport interface ISummaryOpMessage extends ISequencedDocumentMessage {\n\ttype: MessageType.Summarize;\n\tcontents: ISummaryContent;\n}\n\n/**\n * Interface for summary ack messages with typed contents.\n * @legacy\n * @alpha\n */\nexport interface ISummaryAckMessage extends ISequencedDocumentMessage {\n\ttype: MessageType.SummaryAck;\n\tcontents: ISummaryAck;\n}\n\n/**\n * Interface for summary nack messages with typed contents.\n * @legacy\n * @alpha\n */\nexport interface ISummaryNackMessage extends ISequencedDocumentMessage {\n\ttype: MessageType.SummaryNack;\n\tcontents: ISummaryNack;\n}\n\n/**\n * A single summary which can be tracked as it goes through its life cycle.\n * The life cycle is: Local to Broadcast to Acked/Nacked.\n * @legacy\n * @alpha\n */\nexport interface ISummary {\n\treadonly clientId: string;\n\treadonly clientSequenceNumber: number;\n\twaitBroadcast(): Promise<ISummaryOpMessage>;\n\twaitAckNack(): Promise<ISummaryAckMessage | ISummaryNackMessage>;\n}\n\n/**\n * A single summary which has already been acked by the server.\n * @legacy\n * @alpha\n */\nexport interface IAckedSummary {\n\treadonly summaryOp: ISummaryOpMessage;\n\treadonly summaryAck: ISummaryAckMessage;\n}\n\nenum SummaryState {\n\tLocal = 0,\n\tBroadcast = 1,\n\tAcked = 2,\n\tNacked = -1,\n}\n\nclass Summary implements ISummary {\n\tpublic static createLocal(clientId: string, clientSequenceNumber: number) {\n\t\treturn new Summary(clientId, clientSequenceNumber);\n\t}\n\tpublic static createFromOp(op: ISummaryOpMessage) {\n\t\t// TODO: Verify whether this should be able to handle server-generated ops (with null clientId)\n\t\t// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion\n\t\tconst summary = new Summary(op.clientId as string, op.clientSequenceNumber);\n\t\tsummary.broadcast(op);\n\t\treturn summary;\n\t}\n\n\tprivate state = SummaryState.Local;\n\n\tprivate _summaryOp?: ISummaryOpMessage;\n\tprivate _summaryAckNack?: ISummaryAckMessage | ISummaryNackMessage;\n\n\tprivate readonly defSummaryOp = new Deferred<void>();\n\tprivate readonly defSummaryAck = new Deferred<void>();\n\n\tpublic get summaryOp() {\n\t\treturn this._summaryOp;\n\t}\n\tpublic get summaryAckNack() {\n\t\treturn this._summaryAckNack;\n\t}\n\n\tprivate constructor(\n\t\tpublic readonly clientId: string,\n\t\tpublic readonly clientSequenceNumber: number,\n\t) {}\n\n\tpublic hasBeenAcked(): this is IAckedSummary {\n\t\treturn this.state === SummaryState.Acked;\n\t}\n\n\tpublic broadcast(op: ISummaryOpMessage) {\n\t\tassert(\n\t\t\tthis.state === SummaryState.Local,\n\t\t\t0x175 /* \"Can only broadcast if summarizer starts in local state\" */,\n\t\t);\n\t\tthis._summaryOp = op;\n\t\tthis.defSummaryOp.resolve();\n\t\tthis.state = SummaryState.Broadcast;\n\t\treturn true;\n\t}\n\n\tpublic ackNack(op: ISummaryAckMessage | ISummaryNackMessage) {\n\t\tassert(\n\t\t\tthis.state === SummaryState.Broadcast,\n\t\t\t0x176 /* \"Can only ack/nack if summarizer is in broadcasting state\" */,\n\t\t);\n\t\tthis._summaryAckNack = op;\n\t\tthis.defSummaryAck.resolve();\n\t\tthis.state = op.type === MessageType.SummaryAck ? SummaryState.Acked : SummaryState.Nacked;\n\t\treturn true;\n\t}\n\n\tpublic async waitBroadcast(): Promise<ISummaryOpMessage> {\n\t\tawait this.defSummaryOp.promise;\n\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\treturn this._summaryOp!;\n\t}\n\n\tpublic async waitAckNack(): Promise<ISummaryAckMessage | ISummaryNackMessage> {\n\t\tawait this.defSummaryAck.promise;\n\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\treturn this._summaryAckNack!;\n\t}\n}\n\n/**\n * Watches summaries created by a specific client.\n * @legacy\n * @alpha\n */\nexport interface IClientSummaryWatcher extends IDisposable {\n\twatchSummary(clientSequenceNumber: number): ISummary;\n\twaitFlushed(): Promise<IAckedSummary | undefined>;\n}\n\n/**\n * This class watches summaries created by a specific client.\n * It should be created and managed from a SummaryCollection.\n */\nclass ClientSummaryWatcher implements IClientSummaryWatcher {\n\t// key: clientSeqNum\n\tprivate readonly localSummaries = new Map<number, Summary>();\n\tprivate _disposed = false;\n\n\tpublic get disposed() {\n\t\treturn this._disposed;\n\t}\n\n\tpublic constructor(\n\t\tpublic readonly clientId: string,\n\t\tprivate readonly summaryCollection: SummaryCollection,\n\t) {}\n\n\t/**\n\t * Watches for a specific sent summary op.\n\t * @param clientSequenceNumber - client sequence number of sent summary op\n\t */\n\tpublic watchSummary(clientSequenceNumber: number): ISummary {\n\t\tlet summary = this.localSummaries.get(clientSequenceNumber);\n\t\tif (!summary) {\n\t\t\tsummary = Summary.createLocal(this.clientId, clientSequenceNumber);\n\t\t\tthis.localSummaries.set(summary.clientSequenceNumber, summary);\n\t\t}\n\t\treturn summary;\n\t}\n\n\t/**\n\t * Waits until all of the pending summaries in the underlying SummaryCollection\n\t * are acked/nacked.\n\t */\n\t// eslint-disable-next-line @typescript-eslint/promise-function-async\n\tpublic waitFlushed() {\n\t\treturn this.summaryCollection.waitFlushed();\n\t}\n\n\t/**\n\t * Gets a watched summary or returns undefined if not watched.\n\t * @param clientSequenceNumber - client sequence number of sent summary op\n\t */\n\tpublic tryGetSummary(clientSequenceNumber: number) {\n\t\treturn this.localSummaries.get(clientSequenceNumber);\n\t}\n\n\t/**\n\t * Starts watching a summary made by this client.\n\t * @param summary - summary to start watching\n\t */\n\tpublic setSummary(summary: Summary) {\n\t\tthis.localSummaries.set(summary.clientSequenceNumber, summary);\n\t}\n\n\tpublic dispose() {\n\t\tthis.summaryCollection.removeWatcher(this.clientId);\n\t\tthis._disposed = true;\n\t}\n}\n/**\n * @legacy\n * @alpha\n */\nexport type OpActionEventName =\n\t| MessageType.Summarize\n\t| MessageType.SummaryAck\n\t| MessageType.SummaryNack\n\t| \"default\";\n\n/**\n * @legacy\n * @alpha\n */\nexport type OpActionEventListener = (op: ISequencedDocumentMessage) => void;\n\n/**\n * @legacy\n * @alpha\n */\nexport interface ISummaryCollectionOpEvents extends IEvent {\n\t(event: OpActionEventName, listener: OpActionEventListener);\n}\n\n/**\n * Data structure that looks at the op stream to track summaries as they\n * are broadcast, acked and nacked.\n * It provides functionality for watching specific summaries.\n * @legacy\n * @alpha\n */\nexport class SummaryCollection extends TypedEventEmitter<ISummaryCollectionOpEvents> {\n\t// key: clientId\n\tprivate readonly summaryWatchers = new Map<string, ClientSummaryWatcher>();\n\t// key: summarySeqNum\n\tprivate readonly pendingSummaries = new Map<number, Summary>();\n\tprivate refreshWaitNextAck = new Deferred<void>();\n\n\tprivate lastSummaryTimestamp: number | undefined;\n\tprivate maxAckWaitTime: number | undefined;\n\tprivate pendingAckTimerTimeoutCallback: (() => void) | undefined;\n\tprivate lastAck: IAckedSummary | undefined;\n\n\tpublic get latestAck(): IAckedSummary | undefined {\n\t\treturn this.lastAck;\n\t}\n\n\tpublic emit(event: OpActionEventName, ...args: Parameters<OpActionEventListener>): boolean {\n\t\treturn super.emit(event, ...args);\n\t}\n\n\tpublic get opsSinceLastAck() {\n\t\treturn (\n\t\t\tthis.deltaManager.lastSequenceNumber -\n\t\t\t(this.lastAck?.summaryAck.sequenceNumber ?? this.deltaManager.initialSequenceNumber)\n\t\t);\n\t}\n\n\tpublic addOpListener(listener: () => void) {\n\t\tthis.deltaManager.on(\"op\", listener);\n\t}\n\n\tpublic removeOpListener(listener: () => void) {\n\t\tthis.deltaManager.off(\"op\", listener);\n\t}\n\n\tpublic constructor(\n\t\tprivate readonly deltaManager: IDeltaManager<ISequencedDocumentMessage, IDocumentMessage>,\n\t\tprivate readonly logger: ITelemetryLoggerExt,\n\t) {\n\t\tsuper();\n\t\tthis.deltaManager.on(\"op\", (op) => this.handleOp(op));\n\t}\n\n\t/**\n\t * Creates and returns a summary watcher for a specific client.\n\t * This will allow for local sent summaries to be better tracked.\n\t * @param clientId - client id for watcher\n\t */\n\tpublic createWatcher(clientId: string): IClientSummaryWatcher {\n\t\tconst watcher = new ClientSummaryWatcher(clientId, this);\n\t\tthis.summaryWatchers.set(clientId, watcher);\n\t\treturn watcher;\n\t}\n\n\tpublic removeWatcher(clientId: string) {\n\t\tthis.summaryWatchers.delete(clientId);\n\t}\n\n\tpublic setPendingAckTimerTimeoutCallback(\n\t\tmaxAckWaitTime: number,\n\t\ttimeoutCallback: () => void,\n\t) {\n\t\tthis.maxAckWaitTime = maxAckWaitTime;\n\t\tthis.pendingAckTimerTimeoutCallback = timeoutCallback;\n\t}\n\n\tpublic unsetPendingAckTimerTimeoutCallback() {\n\t\tthis.maxAckWaitTime = undefined;\n\t\tthis.pendingAckTimerTimeoutCallback = undefined;\n\t}\n\n\t/**\n\t * Returns a promise that resolves once all pending summary ops\n\t * have been acked or nacked.\n\t */\n\tpublic async waitFlushed(): Promise<IAckedSummary | undefined> {\n\t\twhile (this.pendingSummaries.size > 0) {\n\t\t\t// eslint-disable-next-line @typescript-eslint/promise-function-async\n\t\t\tconst promises = Array.from(this.pendingSummaries, ([, summary]) =>\n\t\t\t\tsummary.waitAckNack(),\n\t\t\t);\n\t\t\tawait Promise.all(promises);\n\t\t}\n\t\treturn this.lastAck;\n\t}\n\n\t/**\n\t * Returns a promise that resolves once a summary is acked that has a reference\n\t * sequence number greater than or equal to the passed in sequence number.\n\t * @param referenceSequenceNumber - reference sequence number to wait for\n\t * @returns The latest acked summary\n\t */\n\tpublic async waitSummaryAck(referenceSequenceNumber: number): Promise<IAckedSummary> {\n\t\twhile (\n\t\t\t!this.lastAck ||\n\t\t\tthis.lastAck.summaryOp.referenceSequenceNumber < referenceSequenceNumber\n\t\t) {\n\t\t\tawait this.refreshWaitNextAck.promise;\n\t\t}\n\t\treturn this.lastAck;\n\t}\n\n\tprivate parseContent(op: ISequencedDocumentMessage) {\n\t\t// This should become unconditional once (Loader LTS) DeltaManager.processInboundMessage() stops parsing content (ADO #12052)\n\t\t// Note: Until that change is made in the loader, this case will never be hit.\n\t\t// Then there will be a long time of needing both cases, until LTS catches up to the change.\n\t\t// That said, we may instead move to listen for \"op\" events from ContainerRuntime,\n\t\t// and parsing may not be required at all if ContainerRuntime.process() would parse it for all types of ops.\n\t\tif (typeof op.contents === \"string\") {\n\t\t\top.contents = JSON.parse(op.contents);\n\t\t}\n\t}\n\n\t/**\n\t * Handler for ops; only handles ops relating to summaries.\n\t * @param op - op message to handle\n\t */\n\tprivate handleOp(opArg: ISequencedDocumentMessage) {\n\t\tconst op = { ...opArg };\n\n\t\tswitch (op.type) {\n\t\t\tcase MessageType.Summarize:\n\t\t\t\tthis.parseContent(op);\n\t\t\t\treturn this.handleSummaryOp(op as ISummaryOpMessage);\n\t\t\tcase MessageType.SummaryAck:\n\t\t\tcase MessageType.SummaryNack:\n\t\t\t\t// Old files (prior to PR #10077) may not contain this info\n\t\t\t\tif (op.data !== undefined) {\n\t\t\t\t\top.contents = JSON.parse(op.data);\n\t\t\t\t} else {\n\t\t\t\t\tthis.parseContent(op);\n\t\t\t\t}\n\t\t\t\treturn op.type === MessageType.SummaryAck\n\t\t\t\t\t? this.handleSummaryAck(op as ISummaryAckMessage)\n\t\t\t\t\t: this.handleSummaryNack(op as ISummaryNackMessage);\n\t\t\tdefault: {\n\t\t\t\t// If the difference between timestamp of current op and last summary op is greater than\n\t\t\t\t// the maxAckWaitTime, then we need to inform summarizer to not wait and summarize\n\t\t\t\t// immediately as we have already waited for maxAckWaitTime.\n\t\t\t\tconst lastOpTimestamp = op.timestamp;\n\t\t\t\tif (\n\t\t\t\t\tthis.lastSummaryTimestamp !== undefined &&\n\t\t\t\t\tthis.maxAckWaitTime !== undefined &&\n\t\t\t\t\tlastOpTimestamp - this.lastSummaryTimestamp >= this.maxAckWaitTime\n\t\t\t\t) {\n\t\t\t\t\tthis.pendingAckTimerTimeoutCallback?.();\n\t\t\t\t}\n\t\t\t\tthis.emit(\"default\", op);\n\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate handleSummaryOp(op: ISummaryOpMessage) {\n\t\tlet summary: Summary | undefined;\n\n\t\t// Check if summary already being watched, broadcast if so\n\t\t// TODO: Verify whether this should be able to handle server-generated ops (with null clientId)\n\t\t// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion\n\t\tconst watcher = this.summaryWatchers.get(op.clientId as string);\n\t\tif (watcher) {\n\t\t\tsummary = watcher.tryGetSummary(op.clientSequenceNumber);\n\t\t\tif (summary) {\n\t\t\t\tsummary.broadcast(op);\n\t\t\t}\n\t\t}\n\n\t\t// If not watched, create from op\n\t\tif (!summary) {\n\t\t\tsummary = Summary.createFromOp(op);\n\t\t\tif (watcher) {\n\t\t\t\twatcher.setSummary(summary);\n\t\t\t}\n\t\t}\n\t\tthis.pendingSummaries.set(op.sequenceNumber, summary);\n\t\tthis.lastSummaryTimestamp = op.timestamp;\n\t\tthis.emit(MessageType.Summarize, op);\n\t}\n\n\tprivate handleSummaryAck(op: ISummaryAckMessage) {\n\t\tconst seq = op.contents.summaryProposal.summarySequenceNumber;\n\t\tconst summary = this.pendingSummaries.get(seq);\n\t\t// eslint-disable-next-line @typescript-eslint/prefer-optional-chain -- optional chain is not logically equivalent\n\t\tif (!summary || summary.summaryOp === undefined) {\n\t\t\t// Summary ack without an op should be rare. We could fetch the\n\t\t\t// reference sequence number from the snapshot, but instead we\n\t\t\t// will not emit this ack. It should be the case that the summary\n\t\t\t// op that this ack is for is earlier than this file was loaded\n\t\t\t// from. i.e. initialSequenceNumber > summarySequenceNumber.\n\t\t\t// We really don't care about it for now, since it is older than\n\t\t\t// the one we loaded from.\n\t\t\tif (seq > this.deltaManager.initialSequenceNumber) {\n\t\t\t\t// Potential causes for it to be later than our initialSequenceNumber\n\t\t\t\t// are that the summaryOp was nacked then acked, double-acked, or\n\t\t\t\t// the summarySequenceNumber is incorrect.\n\t\t\t\tthis.logger.sendTelemetryEvent({\n\t\t\t\t\teventName: \"SummaryAckWithoutOp\",\n\t\t\t\t\tsequenceNumber: op.sequenceNumber, // summary ack seq #\n\t\t\t\t\tsummarySequenceNumber: seq, // missing summary seq #\n\t\t\t\t\tinitialSequenceNumber: this.deltaManager.initialSequenceNumber,\n\t\t\t\t});\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t\tsummary.ackNack(op);\n\t\tthis.pendingSummaries.delete(seq);\n\n\t\t// Track latest ack\n\t\tif (\n\t\t\t!this.lastAck ||\n\t\t\tseq > this.lastAck.summaryAck.contents.summaryProposal.summarySequenceNumber\n\t\t) {\n\t\t\tthis.lastAck = {\n\t\t\t\tsummaryOp: summary.summaryOp,\n\t\t\t\tsummaryAck: op,\n\t\t\t};\n\t\t\tthis.refreshWaitNextAck.resolve();\n\t\t\tthis.refreshWaitNextAck = new Deferred<void>();\n\t\t\tthis.emit(MessageType.SummaryAck, op);\n\t\t}\n\t}\n\n\tprivate handleSummaryNack(op: ISummaryNackMessage) {\n\t\tconst seq = op.contents.summaryProposal.summarySequenceNumber;\n\t\tconst summary = this.pendingSummaries.get(seq);\n\t\tif (summary) {\n\t\t\tsummary.ackNack(op);\n\t\t\tthis.pendingSummaries.delete(seq);\n\t\t\tthis.emit(MessageType.SummaryNack, op);\n\t\t}\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"summaryCollection.js","sourceRoot":"","sources":["../../src/summary/summaryCollection.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAGjE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,qCAAqC,CAAC;AACvE,OAAO,EAKN,WAAW,GAEX,MAAM,6CAA6C,CAAC;AAwDrD,IAAK,YAKJ;AALD,WAAK,YAAY;IAChB,iDAAS,CAAA;IACT,yDAAa,CAAA;IACb,iDAAS,CAAA;IACT,oDAAW,CAAA;AACZ,CAAC,EALI,YAAY,KAAZ,YAAY,QAKhB;AAED,MAAM,OAAO;IACL,MAAM,CAAC,WAAW,CAAC,QAAgB,EAAE,oBAA4B;QACvE,OAAO,IAAI,OAAO,CAAC,QAAQ,EAAE,oBAAoB,CAAC,CAAC;IACpD,CAAC;IACM,MAAM,CAAC,YAAY,CAAC,EAAqB;QAC/C,+FAA+F;QAC/F,4EAA4E;QAC5E,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC,EAAE,CAAC,QAAkB,EAAE,EAAE,CAAC,oBAAoB,CAAC,CAAC;QAC5E,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC;QACtB,OAAO,OAAO,CAAC;IAChB,CAAC;IAUD,IAAW,SAAS;QACnB,OAAO,IAAI,CAAC,UAAU,CAAC;IACxB,CAAC;IACD,IAAW,cAAc;QACxB,OAAO,IAAI,CAAC,eAAe,CAAC;IAC7B,CAAC;IAED,YACiB,QAAgB,EAChB,oBAA4B;QAD5B,aAAQ,GAAR,QAAQ,CAAQ;QAChB,yBAAoB,GAApB,oBAAoB,CAAQ;QAjBrC,UAAK,GAAG,YAAY,CAAC,KAAK,CAAC;QAKlB,iBAAY,GAAG,IAA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gB,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;YAClC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;QACxC,CAAC;IACF,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { TypedEventEmitter } from \"@fluid-internal/client-utils\";\nimport { IDeltaManager } from \"@fluidframework/container-definitions/internal\";\nimport { IDisposable, IEvent } from \"@fluidframework/core-interfaces\";\nimport { assert, Deferred } from \"@fluidframework/core-utils/internal\";\nimport {\n\tIDocumentMessage,\n\tISummaryAck,\n\tISummaryContent,\n\tISummaryNack,\n\tMessageType,\n\tISequencedDocumentMessage,\n} from \"@fluidframework/driver-definitions/internal\";\nimport { ITelemetryLoggerExt } from \"@fluidframework/telemetry-utils/internal\";\n\n/**\n * Interface for summary op messages with typed contents.\n * @legacy\n * @alpha\n */\nexport interface ISummaryOpMessage extends ISequencedDocumentMessage {\n\ttype: MessageType.Summarize;\n\tcontents: ISummaryContent;\n}\n\n/**\n * Interface for summary ack messages with typed contents.\n * @legacy\n * @alpha\n */\nexport interface ISummaryAckMessage extends ISequencedDocumentMessage {\n\ttype: MessageType.SummaryAck;\n\tcontents: ISummaryAck;\n}\n\n/**\n * Interface for summary nack messages with typed contents.\n * @legacy\n * @alpha\n */\nexport interface ISummaryNackMessage extends ISequencedDocumentMessage {\n\ttype: MessageType.SummaryNack;\n\tcontents: ISummaryNack;\n}\n\n/**\n * A single summary which can be tracked as it goes through its life cycle.\n * The life cycle is: Local to Broadcast to Acked/Nacked.\n * @legacy\n * @alpha\n */\nexport interface ISummary {\n\treadonly clientId: string;\n\treadonly clientSequenceNumber: number;\n\twaitBroadcast(): Promise<ISummaryOpMessage>;\n\twaitAckNack(): Promise<ISummaryAckMessage | ISummaryNackMessage>;\n}\n\n/**\n * A single summary which has already been acked by the server.\n * @legacy\n * @alpha\n */\nexport interface IAckedSummary {\n\treadonly summaryOp: ISummaryOpMessage;\n\treadonly summaryAck: ISummaryAckMessage;\n}\n\nenum SummaryState {\n\tLocal = 0,\n\tBroadcast = 1,\n\tAcked = 2,\n\tNacked = -1,\n}\n\nclass Summary implements ISummary {\n\tpublic static createLocal(clientId: string, clientSequenceNumber: number) {\n\t\treturn new Summary(clientId, clientSequenceNumber);\n\t}\n\tpublic static createFromOp(op: ISummaryOpMessage) {\n\t\t// TODO: Verify whether this should be able to handle server-generated ops (with null clientId)\n\t\t// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion\n\t\tconst summary = new Summary(op.clientId as string, op.clientSequenceNumber);\n\t\tsummary.broadcast(op);\n\t\treturn summary;\n\t}\n\n\tprivate state = SummaryState.Local;\n\n\tprivate _summaryOp?: ISummaryOpMessage;\n\tprivate _summaryAckNack?: ISummaryAckMessage | ISummaryNackMessage;\n\n\tprivate readonly defSummaryOp = new Deferred<void>();\n\tprivate readonly defSummaryAck = new Deferred<void>();\n\n\tpublic get summaryOp() {\n\t\treturn this._summaryOp;\n\t}\n\tpublic get summaryAckNack() {\n\t\treturn this._summaryAckNack;\n\t}\n\n\tprivate constructor(\n\t\tpublic readonly clientId: string,\n\t\tpublic readonly clientSequenceNumber: number,\n\t) {}\n\n\tpublic hasBeenAcked(): this is IAckedSummary {\n\t\treturn this.state === SummaryState.Acked;\n\t}\n\n\tpublic broadcast(op: ISummaryOpMessage) {\n\t\tassert(\n\t\t\tthis.state === SummaryState.Local,\n\t\t\t0x175 /* \"Can only broadcast if summarizer starts in local state\" */,\n\t\t);\n\t\tthis._summaryOp = op;\n\t\tthis.defSummaryOp.resolve();\n\t\tthis.state = SummaryState.Broadcast;\n\t\treturn true;\n\t}\n\n\tpublic ackNack(op: ISummaryAckMessage | ISummaryNackMessage) {\n\t\tassert(\n\t\t\tthis.state === SummaryState.Broadcast,\n\t\t\t0x176 /* \"Can only ack/nack if summarizer is in broadcasting state\" */,\n\t\t);\n\t\tthis._summaryAckNack = op;\n\t\tthis.defSummaryAck.resolve();\n\t\tthis.state = op.type === MessageType.SummaryAck ? SummaryState.Acked : SummaryState.Nacked;\n\t\treturn true;\n\t}\n\n\tpublic async waitBroadcast(): Promise<ISummaryOpMessage> {\n\t\tawait this.defSummaryOp.promise;\n\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\treturn this._summaryOp!;\n\t}\n\n\tpublic async waitAckNack(): Promise<ISummaryAckMessage | ISummaryNackMessage> {\n\t\tawait this.defSummaryAck.promise;\n\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\treturn this._summaryAckNack!;\n\t}\n}\n\n/**\n * Watches summaries created by a specific client.\n * @legacy\n * @alpha\n */\nexport interface IClientSummaryWatcher extends IDisposable {\n\twatchSummary(clientSequenceNumber: number): ISummary;\n\twaitFlushed(): Promise<IAckedSummary | undefined>;\n}\n\n/**\n * This class watches summaries created by a specific client.\n * It should be created and managed from a SummaryCollection.\n */\nclass ClientSummaryWatcher implements IClientSummaryWatcher {\n\t// key: clientSeqNum\n\tprivate readonly localSummaries = new Map<number, Summary>();\n\tprivate _disposed = false;\n\n\tpublic get disposed() {\n\t\treturn this._disposed;\n\t}\n\n\tpublic constructor(\n\t\tpublic readonly clientId: string,\n\t\tprivate readonly summaryCollection: SummaryCollection,\n\t) {}\n\n\t/**\n\t * Watches for a specific sent summary op.\n\t * @param clientSequenceNumber - client sequence number of sent summary op\n\t */\n\tpublic watchSummary(clientSequenceNumber: number): ISummary {\n\t\tlet summary = this.localSummaries.get(clientSequenceNumber);\n\t\tif (!summary) {\n\t\t\tsummary = Summary.createLocal(this.clientId, clientSequenceNumber);\n\t\t\tthis.localSummaries.set(summary.clientSequenceNumber, summary);\n\t\t}\n\t\treturn summary;\n\t}\n\n\t/**\n\t * Waits until all of the pending summaries in the underlying SummaryCollection\n\t * are acked/nacked.\n\t */\n\t// eslint-disable-next-line @typescript-eslint/promise-function-async\n\tpublic waitFlushed() {\n\t\treturn this.summaryCollection.waitFlushed();\n\t}\n\n\t/**\n\t * Gets a watched summary or returns undefined if not watched.\n\t * @param clientSequenceNumber - client sequence number of sent summary op\n\t */\n\tpublic tryGetSummary(clientSequenceNumber: number) {\n\t\treturn this.localSummaries.get(clientSequenceNumber);\n\t}\n\n\t/**\n\t * Starts watching a summary made by this client.\n\t * @param summary - summary to start watching\n\t */\n\tpublic setSummary(summary: Summary) {\n\t\tthis.localSummaries.set(summary.clientSequenceNumber, summary);\n\t}\n\n\tpublic dispose() {\n\t\tthis.summaryCollection.removeWatcher(this.clientId);\n\t\tthis._disposed = true;\n\t}\n}\n/**\n * @legacy\n * @alpha\n */\nexport type OpActionEventName =\n\t| MessageType.Summarize\n\t| MessageType.SummaryAck\n\t| MessageType.SummaryNack\n\t| \"default\";\n\n/**\n * @legacy\n * @alpha\n */\nexport type OpActionEventListener = (op: ISequencedDocumentMessage) => void;\n\n/**\n * @legacy\n * @alpha\n */\nexport interface ISummaryCollectionOpEvents extends IEvent {\n\t(event: OpActionEventName, listener: OpActionEventListener);\n}\n\n/**\n * Data structure that looks at the op stream to track summaries as they\n * are broadcast, acked and nacked.\n * It provides functionality for watching specific summaries.\n * @legacy\n * @alpha\n */\nexport class SummaryCollection extends TypedEventEmitter<ISummaryCollectionOpEvents> {\n\t// key: clientId\n\tprivate readonly summaryWatchers = new Map<string, ClientSummaryWatcher>();\n\t// key: summarySeqNum\n\tprivate readonly pendingSummaries = new Map<number, Summary>();\n\tprivate refreshWaitNextAck = new Deferred<void>();\n\n\tprivate lastSummaryTimestamp: number | undefined;\n\tprivate maxAckWaitTime: number | undefined;\n\tprivate pendingAckTimerTimeoutCallback: (() => void) | undefined;\n\tprivate lastAck: IAckedSummary | undefined;\n\n\tpublic get latestAck(): IAckedSummary | undefined {\n\t\treturn this.lastAck;\n\t}\n\n\tpublic emit(event: OpActionEventName, ...args: Parameters<OpActionEventListener>): boolean {\n\t\treturn super.emit(event, ...args);\n\t}\n\n\tpublic get opsSinceLastAck() {\n\t\treturn (\n\t\t\tthis.deltaManager.lastSequenceNumber -\n\t\t\t(this.lastAck?.summaryAck.sequenceNumber ?? this.deltaManager.initialSequenceNumber)\n\t\t);\n\t}\n\n\tpublic addOpListener(listener: () => void) {\n\t\tthis.deltaManager.on(\"op\", listener);\n\t}\n\n\tpublic removeOpListener(listener: () => void) {\n\t\tthis.deltaManager.off(\"op\", listener);\n\t}\n\n\tpublic constructor(\n\t\tprivate readonly deltaManager: IDeltaManager<ISequencedDocumentMessage, IDocumentMessage>,\n\t\tprivate readonly logger: ITelemetryLoggerExt,\n\t) {\n\t\tsuper();\n\t\tthis.deltaManager.on(\"op\", (op) => this.handleOp(op));\n\t}\n\n\t/**\n\t * Creates and returns a summary watcher for a specific client.\n\t * This will allow for local sent summaries to be better tracked.\n\t * @param clientId - client id for watcher\n\t */\n\tpublic createWatcher(clientId: string): IClientSummaryWatcher {\n\t\tconst watcher = new ClientSummaryWatcher(clientId, this);\n\t\tthis.summaryWatchers.set(clientId, watcher);\n\t\treturn watcher;\n\t}\n\n\tpublic removeWatcher(clientId: string) {\n\t\tthis.summaryWatchers.delete(clientId);\n\t}\n\n\tpublic setPendingAckTimerTimeoutCallback(\n\t\tmaxAckWaitTime: number,\n\t\ttimeoutCallback: () => void,\n\t) {\n\t\tthis.maxAckWaitTime = maxAckWaitTime;\n\t\tthis.pendingAckTimerTimeoutCallback = timeoutCallback;\n\t}\n\n\tpublic unsetPendingAckTimerTimeoutCallback() {\n\t\tthis.maxAckWaitTime = undefined;\n\t\tthis.pendingAckTimerTimeoutCallback = undefined;\n\t}\n\n\t/**\n\t * Returns a promise that resolves once all pending summary ops\n\t * have been acked or nacked.\n\t */\n\tpublic async waitFlushed(): Promise<IAckedSummary | undefined> {\n\t\twhile (this.pendingSummaries.size > 0) {\n\t\t\t// eslint-disable-next-line @typescript-eslint/promise-function-async\n\t\t\tconst promises = Array.from(this.pendingSummaries, ([, summary]) =>\n\t\t\t\tsummary.waitAckNack(),\n\t\t\t);\n\t\t\tawait Promise.all(promises);\n\t\t}\n\t\treturn this.lastAck;\n\t}\n\n\t/**\n\t * Returns a promise that resolves once a summary is acked that has a reference\n\t * sequence number greater than or equal to the passed in sequence number.\n\t * @param referenceSequenceNumber - reference sequence number to wait for\n\t * @returns The latest acked summary\n\t */\n\tpublic async waitSummaryAck(referenceSequenceNumber: number): Promise<IAckedSummary> {\n\t\twhile (\n\t\t\t!this.lastAck ||\n\t\t\tthis.lastAck.summaryOp.referenceSequenceNumber < referenceSequenceNumber\n\t\t) {\n\t\t\tawait this.refreshWaitNextAck.promise;\n\t\t}\n\t\treturn this.lastAck;\n\t}\n\n\tprivate parseContent(op: ISequencedDocumentMessage) {\n\t\t// This should become unconditional once (Loader LTS) reaches 2.4 or later\n\t\t// There will be a long time of needing both cases, until LTS catches up to the change.\n\t\t// That said, we may instead move to listen for \"op\" events from ContainerRuntime,\n\t\t// and parsing may not be required at all if ContainerRuntime.process() continues to parse it for all types of ops.\n\t\tif (typeof op.contents === \"string\") {\n\t\t\top.contents = JSON.parse(op.contents);\n\t\t}\n\t}\n\n\t/**\n\t * Handler for ops; only handles ops relating to summaries.\n\t * @param op - op message to handle\n\t */\n\tprivate handleOp(opArg: ISequencedDocumentMessage) {\n\t\tconst op = { ...opArg };\n\n\t\tswitch (op.type) {\n\t\t\tcase MessageType.Summarize:\n\t\t\t\tthis.parseContent(op);\n\t\t\t\treturn this.handleSummaryOp(op as ISummaryOpMessage);\n\t\t\tcase MessageType.SummaryAck:\n\t\t\tcase MessageType.SummaryNack:\n\t\t\t\t// Old files (prior to PR #10077) may not contain this info\n\t\t\t\tif (op.data !== undefined) {\n\t\t\t\t\top.contents = JSON.parse(op.data);\n\t\t\t\t} else {\n\t\t\t\t\tthis.parseContent(op);\n\t\t\t\t}\n\t\t\t\treturn op.type === MessageType.SummaryAck\n\t\t\t\t\t? this.handleSummaryAck(op as ISummaryAckMessage)\n\t\t\t\t\t: this.handleSummaryNack(op as ISummaryNackMessage);\n\t\t\tdefault: {\n\t\t\t\t// If the difference between timestamp of current op and last summary op is greater than\n\t\t\t\t// the maxAckWaitTime, then we need to inform summarizer to not wait and summarize\n\t\t\t\t// immediately as we have already waited for maxAckWaitTime.\n\t\t\t\tconst lastOpTimestamp = op.timestamp;\n\t\t\t\tif (\n\t\t\t\t\tthis.lastSummaryTimestamp !== undefined &&\n\t\t\t\t\tthis.maxAckWaitTime !== undefined &&\n\t\t\t\t\tlastOpTimestamp - this.lastSummaryTimestamp >= this.maxAckWaitTime\n\t\t\t\t) {\n\t\t\t\t\tthis.pendingAckTimerTimeoutCallback?.();\n\t\t\t\t}\n\t\t\t\tthis.emit(\"default\", op);\n\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate handleSummaryOp(op: ISummaryOpMessage) {\n\t\tlet summary: Summary | undefined;\n\n\t\t// Check if summary already being watched, broadcast if so\n\t\t// TODO: Verify whether this should be able to handle server-generated ops (with null clientId)\n\t\t// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion\n\t\tconst watcher = this.summaryWatchers.get(op.clientId as string);\n\t\tif (watcher) {\n\t\t\tsummary = watcher.tryGetSummary(op.clientSequenceNumber);\n\t\t\tif (summary) {\n\t\t\t\tsummary.broadcast(op);\n\t\t\t}\n\t\t}\n\n\t\t// If not watched, create from op\n\t\tif (!summary) {\n\t\t\tsummary = Summary.createFromOp(op);\n\t\t\tif (watcher) {\n\t\t\t\twatcher.setSummary(summary);\n\t\t\t}\n\t\t}\n\t\tthis.pendingSummaries.set(op.sequenceNumber, summary);\n\t\tthis.lastSummaryTimestamp = op.timestamp;\n\t\tthis.emit(MessageType.Summarize, op);\n\t}\n\n\tprivate handleSummaryAck(op: ISummaryAckMessage) {\n\t\tconst seq = op.contents.summaryProposal.summarySequenceNumber;\n\t\tconst summary = this.pendingSummaries.get(seq);\n\t\t// eslint-disable-next-line @typescript-eslint/prefer-optional-chain -- optional chain is not logically equivalent\n\t\tif (!summary || summary.summaryOp === undefined) {\n\t\t\t// Summary ack without an op should be rare. We could fetch the\n\t\t\t// reference sequence number from the snapshot, but instead we\n\t\t\t// will not emit this ack. It should be the case that the summary\n\t\t\t// op that this ack is for is earlier than this file was loaded\n\t\t\t// from. i.e. initialSequenceNumber > summarySequenceNumber.\n\t\t\t// We really don't care about it for now, since it is older than\n\t\t\t// the one we loaded from.\n\t\t\tif (seq > this.deltaManager.initialSequenceNumber) {\n\t\t\t\t// Potential causes for it to be later than our initialSequenceNumber\n\t\t\t\t// are that the summaryOp was nacked then acked, double-acked, or\n\t\t\t\t// the summarySequenceNumber is incorrect.\n\t\t\t\tthis.logger.sendTelemetryEvent({\n\t\t\t\t\teventName: \"SummaryAckWithoutOp\",\n\t\t\t\t\tsequenceNumber: op.sequenceNumber, // summary ack seq #\n\t\t\t\t\tsummarySequenceNumber: seq, // missing summary seq #\n\t\t\t\t\tinitialSequenceNumber: this.deltaManager.initialSequenceNumber,\n\t\t\t\t});\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t\tsummary.ackNack(op);\n\t\tthis.pendingSummaries.delete(seq);\n\n\t\t// Track latest ack\n\t\tif (\n\t\t\t!this.lastAck ||\n\t\t\tseq > this.lastAck.summaryAck.contents.summaryProposal.summarySequenceNumber\n\t\t) {\n\t\t\tthis.lastAck = {\n\t\t\t\tsummaryOp: summary.summaryOp,\n\t\t\t\tsummaryAck: op,\n\t\t\t};\n\t\t\tthis.refreshWaitNextAck.resolve();\n\t\t\tthis.refreshWaitNextAck = new Deferred<void>();\n\t\t\tthis.emit(MessageType.SummaryAck, op);\n\t\t}\n\t}\n\n\tprivate handleSummaryNack(op: ISummaryNackMessage) {\n\t\tconst seq = op.contents.summaryProposal.summarySequenceNumber;\n\t\tconst summary = this.pendingSummaries.get(seq);\n\t\tif (summary) {\n\t\t\tsummary.ackNack(op);\n\t\t\tthis.pendingSummaries.delete(seq);\n\t\t\tthis.emit(MessageType.SummaryNack, op);\n\t\t}\n\t}\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluidframework/container-runtime",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.5.0-302463",
|
|
4
4
|
"description": "Fluid container runtime",
|
|
5
5
|
"homepage": "https://fluidframework.com",
|
|
6
6
|
"repository": {
|
|
@@ -129,18 +129,18 @@
|
|
|
129
129
|
"temp-directory": "nyc/.nyc_output"
|
|
130
130
|
},
|
|
131
131
|
"dependencies": {
|
|
132
|
-
"@fluid-internal/client-utils": "2.
|
|
133
|
-
"@fluidframework/container-definitions": "2.
|
|
134
|
-
"@fluidframework/container-runtime-definitions": "2.
|
|
135
|
-
"@fluidframework/core-interfaces": "2.
|
|
136
|
-
"@fluidframework/core-utils": "2.
|
|
137
|
-
"@fluidframework/datastore": "2.
|
|
138
|
-
"@fluidframework/driver-definitions": "2.
|
|
139
|
-
"@fluidframework/driver-utils": "2.
|
|
140
|
-
"@fluidframework/id-compressor": "2.
|
|
141
|
-
"@fluidframework/runtime-definitions": "2.
|
|
142
|
-
"@fluidframework/runtime-utils": "2.
|
|
143
|
-
"@fluidframework/telemetry-utils": "2.
|
|
132
|
+
"@fluid-internal/client-utils": "2.5.0-302463",
|
|
133
|
+
"@fluidframework/container-definitions": "2.5.0-302463",
|
|
134
|
+
"@fluidframework/container-runtime-definitions": "2.5.0-302463",
|
|
135
|
+
"@fluidframework/core-interfaces": "2.5.0-302463",
|
|
136
|
+
"@fluidframework/core-utils": "2.5.0-302463",
|
|
137
|
+
"@fluidframework/datastore": "2.5.0-302463",
|
|
138
|
+
"@fluidframework/driver-definitions": "2.5.0-302463",
|
|
139
|
+
"@fluidframework/driver-utils": "2.5.0-302463",
|
|
140
|
+
"@fluidframework/id-compressor": "2.5.0-302463",
|
|
141
|
+
"@fluidframework/runtime-definitions": "2.5.0-302463",
|
|
142
|
+
"@fluidframework/runtime-utils": "2.5.0-302463",
|
|
143
|
+
"@fluidframework/telemetry-utils": "2.5.0-302463",
|
|
144
144
|
"@tylerbu/sorted-btree-es6": "^1.8.0",
|
|
145
145
|
"double-ended-queue": "^2.1.0-0",
|
|
146
146
|
"lz4js": "^0.2.0",
|
|
@@ -148,17 +148,17 @@
|
|
|
148
148
|
},
|
|
149
149
|
"devDependencies": {
|
|
150
150
|
"@arethetypeswrong/cli": "^0.16.4",
|
|
151
|
-
"@biomejs/biome": "~1.
|
|
152
|
-
"@fluid-internal/mocha-test-setup": "2.
|
|
153
|
-
"@fluid-private/stochastic-test-utils": "2.
|
|
154
|
-
"@fluid-private/test-pairwise-generator": "2.
|
|
151
|
+
"@biomejs/biome": "~1.9.3",
|
|
152
|
+
"@fluid-internal/mocha-test-setup": "2.5.0-302463",
|
|
153
|
+
"@fluid-private/stochastic-test-utils": "2.5.0-302463",
|
|
154
|
+
"@fluid-private/test-pairwise-generator": "2.5.0-302463",
|
|
155
155
|
"@fluid-tools/benchmark": "^0.50.0",
|
|
156
|
-
"@fluid-tools/build-cli": "^0.
|
|
156
|
+
"@fluid-tools/build-cli": "^0.49.0",
|
|
157
157
|
"@fluidframework/build-common": "^2.0.3",
|
|
158
|
-
"@fluidframework/build-tools": "^0.
|
|
159
|
-
"@fluidframework/container-runtime-previous": "npm:@fluidframework/container-runtime@~2.
|
|
158
|
+
"@fluidframework/build-tools": "^0.49.0",
|
|
159
|
+
"@fluidframework/container-runtime-previous": "npm:@fluidframework/container-runtime@~2.4.0",
|
|
160
160
|
"@fluidframework/eslint-config-fluid": "^5.4.0",
|
|
161
|
-
"@fluidframework/test-runtime-utils": "2.
|
|
161
|
+
"@fluidframework/test-runtime-utils": "2.5.0-302463",
|
|
162
162
|
"@microsoft/api-extractor": "7.47.8",
|
|
163
163
|
"@types/double-ended-queue": "^2.1.0",
|
|
164
164
|
"@types/mocha": "^9.1.1",
|
|
@@ -179,11 +179,7 @@
|
|
|
179
179
|
"typescript": "~5.4.5"
|
|
180
180
|
},
|
|
181
181
|
"typeValidation": {
|
|
182
|
-
"broken": {
|
|
183
|
-
"Function_isRuntimeMessage": {
|
|
184
|
-
"backCompat": false
|
|
185
|
-
}
|
|
186
|
-
},
|
|
182
|
+
"broken": {},
|
|
187
183
|
"entrypoint": "legacy"
|
|
188
184
|
},
|
|
189
185
|
"scripts": {
|
|
@@ -811,6 +811,13 @@ export class BlobManager extends TypedEventEmitter<IBlobManagerEvents> {
|
|
|
811
811
|
for (const [id, entry] of this.pendingBlobs) {
|
|
812
812
|
if (!localBlobs.has(entry)) {
|
|
813
813
|
localBlobs.add(entry);
|
|
814
|
+
// In order to follow natural blob creation flow we need to:
|
|
815
|
+
// 1 send the blob attach op
|
|
816
|
+
// 2 resolve the blob handle
|
|
817
|
+
// 3 wait for op referencing the blob
|
|
818
|
+
if (!entry.opsent) {
|
|
819
|
+
this.sendBlobAttachOp(id, entry.storageId);
|
|
820
|
+
}
|
|
814
821
|
// Resolving the blob handle to let hosts continue with their operations (it will resolve
|
|
815
822
|
// original createBlob call) and let them attach the blob. This is a lie we told since the upload
|
|
816
823
|
// hasn't finished yet, but it's fine since we will retry on rehydration.
|
|
@@ -843,7 +850,9 @@ export class BlobManager extends TypedEventEmitter<IBlobManagerEvents> {
|
|
|
843
850
|
}
|
|
844
851
|
// Wait for all blobs to be attached. This is important, otherwise serialized container
|
|
845
852
|
// could send the blobAttach op without any op that references the blob, making it useless.
|
|
846
|
-
await Promise.allSettled(attachBlobsP).catch(() => {
|
|
853
|
+
await Promise.allSettled(attachBlobsP).catch(() => {
|
|
854
|
+
return undefined;
|
|
855
|
+
});
|
|
847
856
|
}
|
|
848
857
|
|
|
849
858
|
for (const [id, entry] of this.pendingBlobs) {
|
|
@@ -855,9 +864,6 @@ export class BlobManager extends TypedEventEmitter<IBlobManagerEvents> {
|
|
|
855
864
|
continue;
|
|
856
865
|
}
|
|
857
866
|
assert(entry.attached === true, 0x790 /* stashed blob should be attached */);
|
|
858
|
-
if (!entry.opsent) {
|
|
859
|
-
this.sendBlobAttachOp(id, entry.storageId);
|
|
860
|
-
}
|
|
861
867
|
blobs[id] = {
|
|
862
868
|
blob: bufferToString(entry.blob, "base64"),
|
|
863
869
|
storageId: entry.storageId,
|
package/src/channelCollection.ts
CHANGED
|
@@ -69,15 +69,12 @@ import {
|
|
|
69
69
|
createChildMonitoringContext,
|
|
70
70
|
extractSafePropertiesFromMessage,
|
|
71
71
|
tagCodeArtifacts,
|
|
72
|
+
type IConfigProvider,
|
|
72
73
|
type ITelemetryPropertiesExt,
|
|
73
74
|
} from "@fluidframework/telemetry-utils/internal";
|
|
74
75
|
import { v4 as uuid } from "uuid";
|
|
75
76
|
|
|
76
|
-
import {
|
|
77
|
-
DeletedResponseHeaderKey,
|
|
78
|
-
RuntimeHeaderData,
|
|
79
|
-
defaultRuntimeHeaderData,
|
|
80
|
-
} from "./containerRuntime.js";
|
|
77
|
+
import { DeletedResponseHeaderKey, RuntimeHeaderData } from "./containerRuntime.js";
|
|
81
78
|
import {
|
|
82
79
|
IDataStoreAliasMessage,
|
|
83
80
|
channelToDataStore,
|
|
@@ -127,6 +124,18 @@ interface FluidDataStoreMessage {
|
|
|
127
124
|
type: string;
|
|
128
125
|
}
|
|
129
126
|
|
|
127
|
+
function computeRuntimeHeaderData(
|
|
128
|
+
config: IConfigProvider,
|
|
129
|
+
data: Partial<RuntimeHeaderData>,
|
|
130
|
+
): Required<RuntimeHeaderData> {
|
|
131
|
+
return {
|
|
132
|
+
wait: config.getBoolean("Fluid.ContainerRuntime.WaitHeaderDefault") ?? true,
|
|
133
|
+
viaHandle: false,
|
|
134
|
+
allowTombstone: false,
|
|
135
|
+
...data,
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
|
|
130
139
|
/**
|
|
131
140
|
* Creates a shallow wrapper of {@link IFluidParentContext}. The wrapper can then have its methods overwritten as needed
|
|
132
141
|
*/
|
|
@@ -904,7 +913,7 @@ export class ChannelCollection implements IFluidDataStoreChannel, IDisposable {
|
|
|
904
913
|
requestHeaderData: RuntimeHeaderData,
|
|
905
914
|
originalRequest: IRequest,
|
|
906
915
|
): Promise<IFluidDataStoreContextInternal> {
|
|
907
|
-
const headerData =
|
|
916
|
+
const headerData = computeRuntimeHeaderData(this.mc.config, requestHeaderData);
|
|
908
917
|
if (
|
|
909
918
|
this.checkAndLogIfDeleted(
|
|
910
919
|
id,
|
|
@@ -952,7 +961,7 @@ export class ChannelCollection implements IFluidDataStoreChannel, IDisposable {
|
|
|
952
961
|
) {
|
|
953
962
|
return undefined;
|
|
954
963
|
}
|
|
955
|
-
const headerData =
|
|
964
|
+
const headerData = computeRuntimeHeaderData(this.mc.config, requestHeaderData);
|
|
956
965
|
const context = await this.contexts.getBoundOrRemoted(id, headerData.wait);
|
|
957
966
|
if (context === undefined) {
|
|
958
967
|
return undefined;
|