@fluidframework/driver-utils 2.20.0 → 2.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/README.md +1 -0
- package/dist/adapters/compression/summaryblob/documentStorageServiceSummaryBlobCompressionAdapter.d.ts.map +1 -1
- package/dist/adapters/compression/summaryblob/documentStorageServiceSummaryBlobCompressionAdapter.js +1 -2
- package/dist/adapters/compression/summaryblob/documentStorageServiceSummaryBlobCompressionAdapter.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/parallelRequests.js +6 -6
- package/dist/parallelRequests.js.map +1 -1
- package/dist/prefetchDocumentStorageService.d.ts.map +1 -1
- package/dist/prefetchDocumentStorageService.js +3 -4
- package/dist/prefetchDocumentStorageService.js.map +1 -1
- package/dist/runWithRetry.js +5 -5
- package/dist/runWithRetry.js.map +1 -1
- package/lib/adapters/compression/summaryblob/documentStorageServiceSummaryBlobCompressionAdapter.d.ts.map +1 -1
- package/lib/adapters/compression/summaryblob/documentStorageServiceSummaryBlobCompressionAdapter.js +1 -2
- package/lib/adapters/compression/summaryblob/documentStorageServiceSummaryBlobCompressionAdapter.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/parallelRequests.js +7 -7
- package/lib/parallelRequests.js.map +1 -1
- package/lib/prefetchDocumentStorageService.d.ts.map +1 -1
- package/lib/prefetchDocumentStorageService.js +3 -4
- package/lib/prefetchDocumentStorageService.js.map +1 -1
- package/lib/runWithRetry.js +6 -6
- package/lib/runWithRetry.js.map +1 -1
- package/package.json +12 -12
- package/src/adapters/compression/summaryblob/documentStorageServiceSummaryBlobCompressionAdapter.ts +1 -3
- package/src/packageVersion.ts +1 -1
- package/src/parallelRequests.ts +7 -7
- package/src/prefetchDocumentStorageService.ts +3 -4
- package/src/runWithRetry.ts +6 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"documentStorageServiceSummaryBlobCompressionAdapter.d.ts","sourceRoot":"","sources":["../../../../src/adapters/compression/summaryblob/documentStorageServiceSummaryBlobCompressionAdapter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAEN,cAAc,EACd,YAAY,EAGZ,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EACN,uBAAuB,EACvB,eAAe,EACf,aAAa,EACb,QAAQ,EACR,MAAM,6CAA6C,CAAC;AAGrD,OAAO,EAAE,2BAA2B,EAAE,MAAM,yCAAyC,CAAC;AACtF,OAAO,EAAE,yBAAyB,EAA+B,MAAM,aAAa,CAAC;AAErF;;GAEG;AACH,eAAO,MAAM,mBAAmB,0BAA0B,CAAC;AAG3D;;;;;;;;;;;GAWG;AACH,qBAAa,wCAAyC,SAAQ,2BAA2B;IAKvF,OAAO,CAAC,QAAQ,CAAC,OAAO;IAJzB,OAAO,CAAC,qBAAqB,CAAkB;gBAG9C,OAAO,EAAE,uBAAuB,EACf,OAAO,EAAE,yBAAyB;IAKpD,IAAW,OAAO,IAAI,uBAAuB,CAE5C;IAED;;;;OAIG;IACH,OAAO,CAAC,MAAM,CAAC,SAAS;IAMxB;;;OAGG;IACH,OAAO,CAAC,MAAM,CAAC,qBAAqB;IAOpC;;;;;OAKG;IACH,OAAO,CAAC,MAAM,CAAC,oBAAoB;IAsBnC;;;;OAIG;IACH,OAAO,CAAC,MAAM,CAAC,6BAA6B;IAK5C;;;;;;OAMG;IACH,OAAO,CAAC,MAAM,CAAC,aAAa;IAI5B;;;;;;OAMG;IACH,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,WAAW,CAqBjC;IAEF;;;;OAIG;IACH,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,WAAW,CAgBjC;IAEF;;;;;OAKG;IACH,OAAO,CAAC,MAAM,CAAC,UAAU;IAwBzB;;;;OAIG;IACH,OAAO,CAAC,MAAM,CAAC,UAAU;IAqBzB;;;;;;;;;;OAUG;IACH,OAAO,CAAC,MAAM,CAAC,kBAAkB;IAoCjC;;;;;;OAMG;IACH,OAAO,CAAC,MAAM,CAAC,yBAAyB;
|
|
1
|
+
{"version":3,"file":"documentStorageServiceSummaryBlobCompressionAdapter.d.ts","sourceRoot":"","sources":["../../../../src/adapters/compression/summaryblob/documentStorageServiceSummaryBlobCompressionAdapter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAEN,cAAc,EACd,YAAY,EAGZ,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EACN,uBAAuB,EACvB,eAAe,EACf,aAAa,EACb,QAAQ,EACR,MAAM,6CAA6C,CAAC;AAGrD,OAAO,EAAE,2BAA2B,EAAE,MAAM,yCAAyC,CAAC;AACtF,OAAO,EAAE,yBAAyB,EAA+B,MAAM,aAAa,CAAC;AAErF;;GAEG;AACH,eAAO,MAAM,mBAAmB,0BAA0B,CAAC;AAG3D;;;;;;;;;;;GAWG;AACH,qBAAa,wCAAyC,SAAQ,2BAA2B;IAKvF,OAAO,CAAC,QAAQ,CAAC,OAAO;IAJzB,OAAO,CAAC,qBAAqB,CAAkB;gBAG9C,OAAO,EAAE,uBAAuB,EACf,OAAO,EAAE,yBAAyB;IAKpD,IAAW,OAAO,IAAI,uBAAuB,CAE5C;IAED;;;;OAIG;IACH,OAAO,CAAC,MAAM,CAAC,SAAS;IAMxB;;;OAGG;IACH,OAAO,CAAC,MAAM,CAAC,qBAAqB;IAOpC;;;;;OAKG;IACH,OAAO,CAAC,MAAM,CAAC,oBAAoB;IAsBnC;;;;OAIG;IACH,OAAO,CAAC,MAAM,CAAC,6BAA6B;IAK5C;;;;;;OAMG;IACH,OAAO,CAAC,MAAM,CAAC,aAAa;IAI5B;;;;;;OAMG;IACH,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,WAAW,CAqBjC;IAEF;;;;OAIG;IACH,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,WAAW,CAgBjC;IAEF;;;;;OAKG;IACH,OAAO,CAAC,MAAM,CAAC,UAAU;IAwBzB;;;;OAIG;IACH,OAAO,CAAC,MAAM,CAAC,UAAU;IAqBzB;;;;;;;;;;OAUG;IACH,OAAO,CAAC,MAAM,CAAC,kBAAkB;IAoCjC;;;;;;OAMG;IACH,OAAO,CAAC,MAAM,CAAC,yBAAyB;IAgBxC;;;;;OAKG;IACH,OAAO,CAAC,MAAM,CAAC,qBAAqB;IAOpC;;;OAGG;IACH,OAAO,CAAC,MAAM,CAAC,oBAAoB;IASnC;;;;;;OAMG;IACH,OAAO,CAAC,MAAM,CAAC,oBAAoB;IAsBnC;;;;;OAKG;WACW,eAAe,CAC5B,OAAO,EAAE,YAAY,EACrB,MAAM,EAAE,yBAAyB,GAC/B,YAAY;IAaf;;;;OAIG;IACmB,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC;IAYpE;;;;;;;OAOG;IACmB,eAAe,CACpC,OAAO,CAAC,EAAE,QAAQ,GAAG,SAAS,EAC9B,YAAY,CAAC,EAAE,MAAM,GAAG,SAAS,GAE/B,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC;IAShC;;;;;OAKG;IACmB,wBAAwB,CAC7C,OAAO,EAAE,YAAY,EACrB,OAAO,EAAE,eAAe,GACtB,OAAO,CAAC,MAAM,CAAC;IAQlB;;;;OAIG;IACmB,eAAe,CAAC,EAAE,EAAE,cAAc,GAAG,OAAO,CAAC,YAAY,CAAC;CAYhF"}
|
package/lib/adapters/compression/summaryblob/documentStorageServiceSummaryBlobCompressionAdapter.js
CHANGED
|
@@ -190,8 +190,7 @@ export class DocumentStorageServiceCompressionAdapter extends DocumentStorageSer
|
|
|
190
190
|
*/
|
|
191
191
|
static findMetadataHolderSummary(summary) {
|
|
192
192
|
assert(typeof summary === "object", 0x6f7 /* summary must be a non-null object */);
|
|
193
|
-
for (const key of Object.
|
|
194
|
-
const value = summary.tree[key];
|
|
193
|
+
for (const [key, value] of Object.entries(summary.tree)) {
|
|
195
194
|
if (Boolean(value) && value.type === SummaryType.Tree) {
|
|
196
195
|
const found = this.findMetadataHolderSummary(value);
|
|
197
196
|
if (found) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"documentStorageServiceSummaryBlobCompressionAdapter.js","sourceRoot":"","sources":["../../../../src/adapters/compression/summaryblob/documentStorageServiceSummaryBlobCompressionAdapter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACzD,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAC7D,OAAO,EAKN,WAAW,GACX,MAAM,oCAAoC,CAAC;AAO5C,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAE7C,OAAO,EAAE,2BAA2B,EAAE,MAAM,yCAAyC,CAAC;AACtF,OAAO,EAA6B,2BAA2B,EAAE,MAAM,aAAa,CAAC;AAErF;;GAEG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,uBAAuB,CAAC;AAC3D,MAAM,gBAAgB,GAAG,WAAW,CAAC;AAErC;;;;;;;;;;;GAWG;AACH,MAAM,OAAO,wCAAyC,SAAQ,2BAA2B;IAGxF,YACC,OAAgC,EACf,OAAkC;QAEnD,KAAK,CAAC,OAAO,CAAC,CAAC;QAFE,YAAO,GAAP,OAAO,CAA2B;QAJ5C,0BAAqB,GAAY,KAAK,CAAC;IAO/C,CAAC;IAED,IAAW,OAAO;QACjB,OAAO,IAAI,CAAC,sBAAsB,CAAC;IACpC,CAAC;IAED;;;;OAIG;IACK,MAAM,CAAC,SAAS,CAAC,IAAqB;QAC7C,MAAM,SAAS,GAAG,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;QAC1C,sCAAsC;QACtC,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC,KAAK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AAoB,EAAiB,EAAE;IAC7E,IAAI,KAAK,CAAC,IAAI,KAAK,WAAW,CAAC,IAAI,EAAE,CAAC;QACrC,MAAM,WAAW,GAAiB,KAAK,CAAC;QACxC,MAAM,QAAQ,GAAe,wCAAwC,CAAC,aAAa,CAClF,WAAW,CAAC,OAAO,CACnB,CAAC;QACF,MAAM,SAAS,GACd,wCAAwC,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;QAC/D,MAAM,cAAc,GAAG;YACtB,IAAI,EAAE,WAAW,CAAC,IAAI;YACtB,OAAO,EAAE,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC;SAClC,CAAC;QACF,OAAO,cAAc,CAAC;IACvB,CAAC;SAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACd,CAAC;AACF,CAAC,AAhBkC,CAgBjC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IsoBuffer } from \"@fluid-internal/client-utils\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport {\n\tISummaryBlob,\n\tISummaryHandle,\n\tISummaryTree,\n\tSummaryObject,\n\tSummaryType,\n} from \"@fluidframework/driver-definitions\";\nimport {\n\tIDocumentStorageService,\n\tISummaryContext,\n\tISnapshotTree,\n\tIVersion,\n} from \"@fluidframework/driver-definitions/internal\";\nimport { compress, decompress } from \"lz4js\";\n\nimport { DocumentStorageServiceProxy } from \"../../../documentStorageServiceProxy.js\";\nimport { ICompressionStorageConfig, SummaryCompressionAlgorithm } from \"../index.js\";\n\n/**\n * @internal\n */\nexport const blobHeadersBlobName = \".metadata.blobHeaders\";\nconst metadataBlobName = \".metadata\";\n\n/**\n * This class is a proxy for the IDocumentStorageService that compresses and decompresses blobs in the summary.\n * The identification of the compressed blobs is done by adding a compression markup blob to the summary.\n * Even if the markup blob is present, it does not mean that all blobs are compressed. The blob,\n * which is compressed also contain the compression algorithm enumerated value from the\n * SummaryCompressionAlgorithm enumeration in the first byte . If the blob is not\n * commpressed, it contains the first byte equals to SummaryCompressionAlgorithm.None .\n * In case, the markup blob is present, it is expected that the first byte of the markup blob\n * will contain the info about the compression. If the first byte is not present, it is assumed\n * that the compression is not enabled and no first prefix byte is present in the blobs.\n * @public\n */\nexport class DocumentStorageServiceCompressionAdapter extends DocumentStorageServiceProxy {\n\tprivate _isCompressionEnabled: boolean = false;\n\n\tconstructor(\n\t\tservice: IDocumentStorageService,\n\t\tprivate readonly _config: ICompressionStorageConfig,\n\t) {\n\t\tsuper(service);\n\t}\n\n\tpublic get service(): IDocumentStorageService {\n\t\treturn this.internalStorageService;\n\t}\n\n\t/**\n\t * This method returns `true` if there is a compression markup byte in the blob, otherwise `false`.\n\t * @param blob - The blob to compress.\n\t * @returns `true` if there is a compression markup byte in the blob, otherwise `false`.\n\t */\n\tprivate static hasPrefix(blob: ArrayBufferLike): boolean {\n\t\tconst firstByte = IsoBuffer.from(blob)[0];\n\t\t// eslint-disable-next-line no-bitwise\n\t\treturn (firstByte & 0xf0) === 0xb0;\n\t}\n\n\t/**\n\t * This method reads the first byte from the given blob and maps that byte to the compression algorithm.\n\t * @param blob - The maybe compressed blob.\n\t */\n\tprivate static readAlgorithmFromBlob(blob: ArrayBufferLike): number {\n\t\treturn !this.hasPrefix(blob)\n\t\t\t? SummaryCompressionAlgorithm.None\n\t\t\t: // eslint-disable-next-line no-bitwise\n\t\t\t\tIsoBuffer.from(blob)[0] & 0x0f;\n\t}\n\n\t/**\n\t * This method writes the given algorithm to the blob as the first byte.\n\t * @param blob - The blob to write the algorithm to.\n\t * @param algorithm - The algorithm to write.\n\t * @returns The blob with the algorithm as the first byte.\n\t */\n\tprivate static writeAlgorithmToBlob(\n\t\tblob: ArrayBufferLike,\n\t\talgorithm: number,\n\t): ArrayBufferLike {\n\t\tif (algorithm === SummaryCompressionAlgorithm.None) {\n\t\t\tconst firstByte = IsoBuffer.from(blob)[0];\n\t\t\t// eslint-disable-next-line no-bitwise\n\t\t\tif ((firstByte & 0xf0) !== 0xb0) {\n\t\t\t\treturn blob;\n\t\t\t}\n\t\t}\n\t\tassert(algorithm < 0x10, 0x6f5 /* Algorithm should be less than 0x10 */);\n\t\tconst blobView = new Uint8Array(blob);\n\t\tconst blobLength = blobView.length;\n\t\tconst newBlob = new Uint8Array(blobLength + 1);\n\t\t// eslint-disable-next-line no-bitwise\n\t\tconst prefix = 0xb0 | algorithm;\n\t\tnewBlob[0] = prefix;\n\t\tnewBlob.set(blobView, 1);\n\t\treturn IsoBuffer.from(newBlob);\n\t}\n\n\t/**\n\t * This method removes the algorithm markup prefix from the blob (1 byte)\n\t * @param blob - The blob to remove the prefix from.\n\t * @returns The blob without the prefix.\n\t */\n\tprivate static removePrefixFromBlobIfPresent(blob: ArrayBufferLike): ArrayBufferLike {\n\t\tconst blobView = new Uint8Array(blob);\n\t\treturn this.hasPrefix(blob) ? IsoBuffer.from(blobView.subarray(1)) : blob;\n\t}\n\n\t/**\n\t * This method converts the given argument to Uint8Array. If the parameter is already Uint8Array,\n\t * it is just returned as is. If the parameter is string, it is converted to Uint8Array using\n\t * TextEncoder.\n\t * @param input - The input to convert to Uint8Array.\n\t * @returns The Uint8Array representation of the input.\n\t */\n\tprivate static toBinaryArray(input: string | Uint8Array): Uint8Array {\n\t\treturn typeof input === \"string\" ? new TextEncoder().encode(input) : input;\n\t}\n\n\t/**\n\t * This method encodes the blob inside the given summary object of the SummaryType.Blob type using the given config\n\t * containing the compression algorithm.\n\t * @param input - The summary object to encode.\n\t * @param config - The config containing the compression algorithm.\n\t * @returns The summary object with the encoded blob.\n\t */\n\tprivate static readonly blobEncoder = (\n\t\tinput: SummaryObject,\n\t\tconfig: ICompressionStorageConfig,\n\t): SummaryObject => {\n\t\tif (input.type === SummaryType.Blob) {\n\t\t\tconst summaryBlob: ISummaryBlob = input;\n\t\t\tconst original: ArrayBufferLike = DocumentStorageServiceCompressionAdapter.toBinaryArray(\n\t\t\t\tsummaryBlob.content,\n\t\t\t);\n\t\t\tconst processed: ArrayBufferLike = DocumentStorageServiceCompressionAdapter.encodeBlob(\n\t\t\t\toriginal,\n\t\t\t\tconfig,\n\t\t\t);\n\t\t\tconst newSummaryBlob = {\n\t\t\t\ttype: SummaryType.Blob,\n\t\t\t\tcontent: IsoBuffer.from(processed),\n\t\t\t};\n\t\t\treturn newSummaryBlob;\n\t\t} else {\n\t\t\treturn input;\n\t\t}\n\t};\n\n\t/**\n\t * This method decodes the blob inside the given summary object of the SummaryType.Blob type.\n\t * @param input - The summary object to decode.\n\t * @returns The summary object with the decoded blob.\n\t */\n\tprivate static readonly blobDecoder = (input: SummaryObject): SummaryObject => {\n\t\tif (input.type === SummaryType.Blob) {\n\t\t\tconst summaryBlob: ISummaryBlob = input;\n\t\t\tconst original: Uint8Array = DocumentStorageServiceCompressionAdapter.toBinaryArray(\n\t\t\t\tsummaryBlob.content,\n\t\t\t);\n\t\t\tconst processed: ArrayBufferLike =\n\t\t\t\tDocumentStorageServiceCompressionAdapter.decodeBlob(original);\n\t\t\tconst newSummaryBlob = {\n\t\t\t\ttype: SummaryType.Blob,\n\t\t\t\tcontent: IsoBuffer.from(processed),\n\t\t\t};\n\t\t\treturn newSummaryBlob;\n\t\t} else {\n\t\t\treturn input;\n\t\t}\n\t};\n\n\t/**\n\t * This method encodes the given blob according to the given config.\n\t * @param file - The blob to encode.\n\t * @param config - The config to use for encoding.\n\t * @returns The encoded blob.\n\t */\n\tprivate static encodeBlob(\n\t\tfile: ArrayBufferLike,\n\t\tconfig: ICompressionStorageConfig,\n\t): ArrayBufferLike {\n\t\tlet maybeCompressed: ArrayBufferLike;\n\t\tlet algorithm = config.algorithm;\n\t\tif (new Uint8Array(file).length < config.minSizeToCompress) {\n\t\t\tmaybeCompressed = file;\n\t\t\talgorithm = SummaryCompressionAlgorithm.None;\n\t\t} else if (algorithm === SummaryCompressionAlgorithm.None) {\n\t\t\tmaybeCompressed = file;\n\t\t} else if (algorithm === SummaryCompressionAlgorithm.LZ4) {\n\t\t\tconst compressed = compress(file) as ArrayBufferLike;\n\t\t\tmaybeCompressed = compressed;\n\t\t} else {\n\t\t\tthrow new Error(`Unknown Algorithm ${config.algorithm}`);\n\t\t}\n\t\tmaybeCompressed = DocumentStorageServiceCompressionAdapter.writeAlgorithmToBlob(\n\t\t\tmaybeCompressed,\n\t\t\talgorithm,\n\t\t);\n\t\treturn maybeCompressed;\n\t}\n\n\t/**\n\t * This method decodes the given blob.\n\t * @param file - The blob to decode.\n\t * @returns The decoded blob.\n\t */\n\tprivate static decodeBlob(file: ArrayBufferLike): ArrayBufferLike {\n\t\tlet decompressed: ArrayBufferLike;\n\t\tlet originalBlob;\n\t\tlet algorithm;\n\t\tif (this.hasPrefix(file)) {\n\t\t\talgorithm = DocumentStorageServiceCompressionAdapter.readAlgorithmFromBlob(file);\n\t\t\toriginalBlob = this.removePrefixFromBlobIfPresent(file);\n\t\t} else {\n\t\t\talgorithm = SummaryCompressionAlgorithm.None;\n\t\t\toriginalBlob = file;\n\t\t}\n\t\tif (algorithm === SummaryCompressionAlgorithm.None) {\n\t\t\tdecompressed = originalBlob;\n\t\t} else if (algorithm === SummaryCompressionAlgorithm.LZ4) {\n\t\t\tdecompressed = decompress(originalBlob) as ArrayBufferLike;\n\t\t} else {\n\t\t\tthrow new Error(`Unknown Algorithm ${algorithm}`);\n\t\t}\n\t\treturn decompressed;\n\t}\n\n\t/**\n\t * This method traverses the SummaryObject recursively. If it finds the ISummaryBlob object,\n\t * it applies encoding/decoding on it according to the given isEncode flag.\n\t * @param isEncode - True if the encoding should be applied, false if the decoding should be applied.\n\t * @param input - The summary object to traverse.\n\t * @param encoder - The encoder function to use.\n\t * @param decoder - The decoder function to use.\n\t * @param config - The config to use for encoding.\n\t * @param context - The summary context.\n\t * @returns The summary object with the encoded/decoded blob.\n\t */\n\tprivate static recursivelyReplace(\n\t\tisEncode: boolean,\n\t\tinput: SummaryObject,\n\t\tencoder: (input: SummaryObject, config: ICompressionStorageConfig) => SummaryObject,\n\t\tdecoder: (input: SummaryObject) => SummaryObject,\n\t\tconfig: ICompressionStorageConfig,\n\t\tcontext?: ISummaryContext,\n\t): SummaryObject {\n\t\tassert(typeof input === \"object\", 0x6f6 /* input must be a non-null object */);\n\t\tconst maybeReplaced = isEncode ? encoder(input, config) : decoder(input);\n\n\t\tif (maybeReplaced !== input) {\n\t\t\treturn maybeReplaced;\n\t\t}\n\t\tlet clone: object | undefined;\n\t\tfor (const key of Object.keys(input)) {\n\t\t\tconst value = input[key];\n\n\t\t\tif (Boolean(value) && typeof value === \"object\") {\n\t\t\t\tconst replaced = this.recursivelyReplace(\n\t\t\t\t\tisEncode,\n\t\t\t\t\tvalue as SummaryObject,\n\t\t\t\t\tencoder,\n\t\t\t\t\tdecoder,\n\t\t\t\t\tconfig,\n\t\t\t\t\tcontext,\n\t\t\t\t);\n\t\t\t\tif (replaced !== value) {\n\t\t\t\t\tclone = clone ?? (Array.isArray(input) ? [...input] : { ...input });\n\t\t\t\t\tclone[key] = replaced;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn (clone ?? input) as SummaryObject;\n\t}\n\n\t/**\n\t * This method traverses the SummaryTree recursively. If it finds the ISummaryBlob object with the key '.metadata',\n\t * it returns the summary tree containing that blob.\n\t *\n\t * @param summary - The summary tree to traverse.\n\t * @returns The summary tree containing the metadata blob.\n\t */\n\tprivate static findMetadataHolderSummary(summary: ISummaryTree): ISummaryTree | undefined {\n\t\tassert(typeof summary === \"object\", 0x6f7 /* summary must be a non-null object */);\n\t\tfor (const key of Object.keys(summary.tree)) {\n\t\t\tconst value = summary.tree[key];\n\n\t\t\tif (Boolean(value) && value.type === SummaryType.Tree) {\n\t\t\t\tconst found = this.findMetadataHolderSummary(value);\n\t\t\t\tif (found) {\n\t\t\t\t\treturn found;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (Boolean(value) && key === metadataBlobName && value.type === SummaryType.Blob) {\n\t\t\t\treturn summary;\n\t\t\t}\n\t\t}\n\t\treturn undefined;\n\t}\n\n\t/**\n\t * This method obtains the summary tree containing the metadata blob. It returns the content\n\t * of the tree atribute.\n\t * @param summary - The summary tree to traverse.\n\t * @returns The content of the tree attribute of the summary tree containing the metadata blob.\n\t */\n\tprivate static getMetadataHolderTree(summary: ISummaryTree) {\n\t\tconst metadataHolder = this.findMetadataHolderSummary(summary);\n\t\tassert(metadataHolder !== undefined, 0x6f8 /* metadataHolder must be a non-null object */);\n\t\tconst metadataHolderTree = metadataHolder.tree;\n\t\treturn metadataHolderTree;\n\t}\n\n\t/**\n\t * This method adds the compression markup blob to the nested summary tree containing the metadata blob.\n\t * @param summary - The top summary tree to put the compression markup blob into.\n\t */\n\tprivate static putCompressionMarkup(summary: ISummaryTree): void {\n\t\tconst metadataHolderTree =\n\t\t\tDocumentStorageServiceCompressionAdapter.getMetadataHolderTree(summary);\n\t\tmetadataHolderTree[blobHeadersBlobName] = {\n\t\t\ttype: 2,\n\t\t\tcontent: \"\",\n\t\t};\n\t}\n\n\t/**\n\t * This method traverses the SnapshotTree recursively. If it finds the ISummaryBlob object with the key '.metadata',\n\t * it checks, if the SummaryTree holder of that object also contains the compression markup blob. If it is found,\n\t * it returns true, otherwise false.\n\t * @param snapshot - The snapshot tree to traverse.\n\t * @returns True if the compression markup blob is found, otherwise false.\n\t */\n\tprivate static hasCompressionMarkup(snapshot: ISnapshotTree): boolean {\n\t\tassert(typeof snapshot === \"object\", 0x6f9 /* snapshot must be a non-null object */);\n\t\tfor (const key of Object.keys(snapshot.blobs)) {\n\t\t\tif (key === metadataBlobName) {\n\t\t\t\tconst value = snapshot.blobs[blobHeadersBlobName];\n\t\t\t\tif (value !== undefined) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfor (const key of Object.keys(snapshot.trees)) {\n\t\t\tconst value = snapshot[key] as ISnapshotTree;\n\t\t\tif (value !== undefined) {\n\t\t\t\tconst found = this.hasCompressionMarkup(value);\n\t\t\t\tif (found) {\n\t\t\t\t\treturn found;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn false;\n\t}\n\n\t/**\n\t * This method performs compression of the blobs in the summary tree.\n\t * @param summary - The summary tree to compress.\n\t * @param config - The compression config.\n\t * @returns The compressed summary tree.\n\t */\n\tpublic static compressSummary(\n\t\tsummary: ISummaryTree,\n\t\tconfig: ICompressionStorageConfig,\n\t): ISummaryTree {\n\t\tthis.putCompressionMarkup(summary);\n\t\tconst prep = DocumentStorageServiceCompressionAdapter.recursivelyReplace(\n\t\t\ttrue,\n\t\t\tsummary,\n\t\t\tDocumentStorageServiceCompressionAdapter.blobEncoder,\n\t\t\tDocumentStorageServiceCompressionAdapter.blobDecoder,\n\t\t\tconfig,\n\t\t) as ISummaryTree;\n\t\t//\tconsole.log(`Miso summary-blob Summary Upload: ${JSON.stringify(prep).length}`);\n\t\treturn prep;\n\t}\n\n\t/**\n\t * This method read blob from the storage and decompresses it if it is compressed.\n\t * @param id - The id of the blob to read.\n\t * @returns The decompressed blob.\n\t */\n\tpublic override async readBlob(id: string): Promise<ArrayBufferLike> {\n\t\tconst originalBlob = await super.readBlob(id);\n\t\tif (!this._isCompressionEnabled) {\n\t\t\treturn originalBlob;\n\t\t} else {\n\t\t\tconst decompressedBlob =\n\t\t\t\tDocumentStorageServiceCompressionAdapter.decodeBlob(originalBlob);\n\t\t\t//\t\t\tconsole.log(`Miso summary-blob Blob read END : ${id} ${decompressedBlob.byteLength}`);\n\t\t\treturn decompressedBlob;\n\t\t}\n\t}\n\n\t/**\n\t * This method loads the snapshot tree from the server. It also checks, if the compression markup blob is present\n\t * and setups the compression flag accordingly. It also identifies the blobs that are not compressed and do not contain\n\t * algorithm byte prefix and store them.\n\t * @param version - The version of the snapshot tree to load.\n\t * @param scenarioName - The scenario name of the snapshot tree to load.\n\t * @returns The snapshot tree.\n\t */\n\tpublic override async getSnapshotTree(\n\t\tversion?: IVersion | undefined,\n\t\tscenarioName?: string | undefined,\n\t\t// eslint-disable-next-line @rushstack/no-new-null\n\t): Promise<ISnapshotTree | null> {\n\t\tconst snapshotTree = await super.getSnapshotTree(version, scenarioName);\n\t\tthis._isCompressionEnabled =\n\t\t\tsnapshotTree !== undefined &&\n\t\t\tsnapshotTree !== null &&\n\t\t\tDocumentStorageServiceCompressionAdapter.hasCompressionMarkup(snapshotTree);\n\t\treturn snapshotTree;\n\t}\n\n\t/**\n\t * This method uploads the summary to the storage. It performs compression of the blobs in the summary tree.\n\t * @param summary - The summary tree to upload.\n\t * @param context - The summary context.\n\t * @returns The ID of the uploaded summary.\n\t */\n\tpublic override async uploadSummaryWithContext(\n\t\tsummary: ISummaryTree,\n\t\tcontext: ISummaryContext,\n\t): Promise<string> {\n\t\tconst prep = DocumentStorageServiceCompressionAdapter.compressSummary(\n\t\t\tsummary,\n\t\t\tthis._config,\n\t\t);\n\t\treturn super.uploadSummaryWithContext(prep, context);\n\t}\n\n\t/**\n\t * This method downloads the summary from the storage and then applies decompression on the compressed blobs.\n\t * @param id - The ID of the summary to be downloaded\n\t * @returns The summary with decompressed blobs\n\t */\n\tpublic override async downloadSummary(id: ISummaryHandle): Promise<ISummaryTree> {\n\t\tconst summary = await super.downloadSummary(id);\n\t\treturn !this._isCompressionEnabled\n\t\t\t? summary\n\t\t\t: (DocumentStorageServiceCompressionAdapter.recursivelyReplace(\n\t\t\t\t\tfalse,\n\t\t\t\t\tsummary,\n\t\t\t\t\tDocumentStorageServiceCompressionAdapter.blobEncoder,\n\t\t\t\t\tDocumentStorageServiceCompressionAdapter.blobDecoder,\n\t\t\t\t\tthis._config,\n\t\t\t\t) as ISummaryTree);\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"documentStorageServiceSummaryBlobCompressionAdapter.js","sourceRoot":"","sources":["../../../../src/adapters/compression/summaryblob/documentStorageServiceSummaryBlobCompressionAdapter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACzD,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,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C;IACd,CAAC;AACF,CAAC,AAhBkC,CAgBjC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IsoBuffer } from \"@fluid-internal/client-utils\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport {\n\tISummaryBlob,\n\tISummaryHandle,\n\tISummaryTree,\n\tSummaryObject,\n\tSummaryType,\n} from \"@fluidframework/driver-definitions\";\nimport {\n\tIDocumentStorageService,\n\tISummaryContext,\n\tISnapshotTree,\n\tIVersion,\n} from \"@fluidframework/driver-definitions/internal\";\nimport { compress, decompress } from \"lz4js\";\n\nimport { DocumentStorageServiceProxy } from \"../../../documentStorageServiceProxy.js\";\nimport { ICompressionStorageConfig, SummaryCompressionAlgorithm } from \"../index.js\";\n\n/**\n * @internal\n */\nexport const blobHeadersBlobName = \".metadata.blobHeaders\";\nconst metadataBlobName = \".metadata\";\n\n/**\n * This class is a proxy for the IDocumentStorageService that compresses and decompresses blobs in the summary.\n * The identification of the compressed blobs is done by adding a compression markup blob to the summary.\n * Even if the markup blob is present, it does not mean that all blobs are compressed. The blob,\n * which is compressed also contain the compression algorithm enumerated value from the\n * SummaryCompressionAlgorithm enumeration in the first byte . If the blob is not\n * commpressed, it contains the first byte equals to SummaryCompressionAlgorithm.None .\n * In case, the markup blob is present, it is expected that the first byte of the markup blob\n * will contain the info about the compression. If the first byte is not present, it is assumed\n * that the compression is not enabled and no first prefix byte is present in the blobs.\n * @public\n */\nexport class DocumentStorageServiceCompressionAdapter extends DocumentStorageServiceProxy {\n\tprivate _isCompressionEnabled: boolean = false;\n\n\tconstructor(\n\t\tservice: IDocumentStorageService,\n\t\tprivate readonly _config: ICompressionStorageConfig,\n\t) {\n\t\tsuper(service);\n\t}\n\n\tpublic get service(): IDocumentStorageService {\n\t\treturn this.internalStorageService;\n\t}\n\n\t/**\n\t * This method returns `true` if there is a compression markup byte in the blob, otherwise `false`.\n\t * @param blob - The blob to compress.\n\t * @returns `true` if there is a compression markup byte in the blob, otherwise `false`.\n\t */\n\tprivate static hasPrefix(blob: ArrayBufferLike): boolean {\n\t\tconst firstByte = IsoBuffer.from(blob)[0];\n\t\t// eslint-disable-next-line no-bitwise\n\t\treturn (firstByte & 0xf0) === 0xb0;\n\t}\n\n\t/**\n\t * This method reads the first byte from the given blob and maps that byte to the compression algorithm.\n\t * @param blob - The maybe compressed blob.\n\t */\n\tprivate static readAlgorithmFromBlob(blob: ArrayBufferLike): number {\n\t\treturn !this.hasPrefix(blob)\n\t\t\t? SummaryCompressionAlgorithm.None\n\t\t\t: // eslint-disable-next-line no-bitwise\n\t\t\t\tIsoBuffer.from(blob)[0] & 0x0f;\n\t}\n\n\t/**\n\t * This method writes the given algorithm to the blob as the first byte.\n\t * @param blob - The blob to write the algorithm to.\n\t * @param algorithm - The algorithm to write.\n\t * @returns The blob with the algorithm as the first byte.\n\t */\n\tprivate static writeAlgorithmToBlob(\n\t\tblob: ArrayBufferLike,\n\t\talgorithm: number,\n\t): ArrayBufferLike {\n\t\tif (algorithm === SummaryCompressionAlgorithm.None) {\n\t\t\tconst firstByte = IsoBuffer.from(blob)[0];\n\t\t\t// eslint-disable-next-line no-bitwise\n\t\t\tif ((firstByte & 0xf0) !== 0xb0) {\n\t\t\t\treturn blob;\n\t\t\t}\n\t\t}\n\t\tassert(algorithm < 0x10, 0x6f5 /* Algorithm should be less than 0x10 */);\n\t\tconst blobView = new Uint8Array(blob);\n\t\tconst blobLength = blobView.length;\n\t\tconst newBlob = new Uint8Array(blobLength + 1);\n\t\t// eslint-disable-next-line no-bitwise\n\t\tconst prefix = 0xb0 | algorithm;\n\t\tnewBlob[0] = prefix;\n\t\tnewBlob.set(blobView, 1);\n\t\treturn IsoBuffer.from(newBlob);\n\t}\n\n\t/**\n\t * This method removes the algorithm markup prefix from the blob (1 byte)\n\t * @param blob - The blob to remove the prefix from.\n\t * @returns The blob without the prefix.\n\t */\n\tprivate static removePrefixFromBlobIfPresent(blob: ArrayBufferLike): ArrayBufferLike {\n\t\tconst blobView = new Uint8Array(blob);\n\t\treturn this.hasPrefix(blob) ? IsoBuffer.from(blobView.subarray(1)) : blob;\n\t}\n\n\t/**\n\t * This method converts the given argument to Uint8Array. If the parameter is already Uint8Array,\n\t * it is just returned as is. If the parameter is string, it is converted to Uint8Array using\n\t * TextEncoder.\n\t * @param input - The input to convert to Uint8Array.\n\t * @returns The Uint8Array representation of the input.\n\t */\n\tprivate static toBinaryArray(input: string | Uint8Array): Uint8Array {\n\t\treturn typeof input === \"string\" ? new TextEncoder().encode(input) : input;\n\t}\n\n\t/**\n\t * This method encodes the blob inside the given summary object of the SummaryType.Blob type using the given config\n\t * containing the compression algorithm.\n\t * @param input - The summary object to encode.\n\t * @param config - The config containing the compression algorithm.\n\t * @returns The summary object with the encoded blob.\n\t */\n\tprivate static readonly blobEncoder = (\n\t\tinput: SummaryObject,\n\t\tconfig: ICompressionStorageConfig,\n\t): SummaryObject => {\n\t\tif (input.type === SummaryType.Blob) {\n\t\t\tconst summaryBlob: ISummaryBlob = input;\n\t\t\tconst original: ArrayBufferLike = DocumentStorageServiceCompressionAdapter.toBinaryArray(\n\t\t\t\tsummaryBlob.content,\n\t\t\t);\n\t\t\tconst processed: ArrayBufferLike = DocumentStorageServiceCompressionAdapter.encodeBlob(\n\t\t\t\toriginal,\n\t\t\t\tconfig,\n\t\t\t);\n\t\t\tconst newSummaryBlob = {\n\t\t\t\ttype: SummaryType.Blob,\n\t\t\t\tcontent: IsoBuffer.from(processed),\n\t\t\t};\n\t\t\treturn newSummaryBlob;\n\t\t} else {\n\t\t\treturn input;\n\t\t}\n\t};\n\n\t/**\n\t * This method decodes the blob inside the given summary object of the SummaryType.Blob type.\n\t * @param input - The summary object to decode.\n\t * @returns The summary object with the decoded blob.\n\t */\n\tprivate static readonly blobDecoder = (input: SummaryObject): SummaryObject => {\n\t\tif (input.type === SummaryType.Blob) {\n\t\t\tconst summaryBlob: ISummaryBlob = input;\n\t\t\tconst original: Uint8Array = DocumentStorageServiceCompressionAdapter.toBinaryArray(\n\t\t\t\tsummaryBlob.content,\n\t\t\t);\n\t\t\tconst processed: ArrayBufferLike =\n\t\t\t\tDocumentStorageServiceCompressionAdapter.decodeBlob(original);\n\t\t\tconst newSummaryBlob = {\n\t\t\t\ttype: SummaryType.Blob,\n\t\t\t\tcontent: IsoBuffer.from(processed),\n\t\t\t};\n\t\t\treturn newSummaryBlob;\n\t\t} else {\n\t\t\treturn input;\n\t\t}\n\t};\n\n\t/**\n\t * This method encodes the given blob according to the given config.\n\t * @param file - The blob to encode.\n\t * @param config - The config to use for encoding.\n\t * @returns The encoded blob.\n\t */\n\tprivate static encodeBlob(\n\t\tfile: ArrayBufferLike,\n\t\tconfig: ICompressionStorageConfig,\n\t): ArrayBufferLike {\n\t\tlet maybeCompressed: ArrayBufferLike;\n\t\tlet algorithm = config.algorithm;\n\t\tif (new Uint8Array(file).length < config.minSizeToCompress) {\n\t\t\tmaybeCompressed = file;\n\t\t\talgorithm = SummaryCompressionAlgorithm.None;\n\t\t} else if (algorithm === SummaryCompressionAlgorithm.None) {\n\t\t\tmaybeCompressed = file;\n\t\t} else if (algorithm === SummaryCompressionAlgorithm.LZ4) {\n\t\t\tconst compressed = compress(file) as ArrayBufferLike;\n\t\t\tmaybeCompressed = compressed;\n\t\t} else {\n\t\t\tthrow new Error(`Unknown Algorithm ${config.algorithm}`);\n\t\t}\n\t\tmaybeCompressed = DocumentStorageServiceCompressionAdapter.writeAlgorithmToBlob(\n\t\t\tmaybeCompressed,\n\t\t\talgorithm,\n\t\t);\n\t\treturn maybeCompressed;\n\t}\n\n\t/**\n\t * This method decodes the given blob.\n\t * @param file - The blob to decode.\n\t * @returns The decoded blob.\n\t */\n\tprivate static decodeBlob(file: ArrayBufferLike): ArrayBufferLike {\n\t\tlet decompressed: ArrayBufferLike;\n\t\tlet originalBlob;\n\t\tlet algorithm;\n\t\tif (this.hasPrefix(file)) {\n\t\t\talgorithm = DocumentStorageServiceCompressionAdapter.readAlgorithmFromBlob(file);\n\t\t\toriginalBlob = this.removePrefixFromBlobIfPresent(file);\n\t\t} else {\n\t\t\talgorithm = SummaryCompressionAlgorithm.None;\n\t\t\toriginalBlob = file;\n\t\t}\n\t\tif (algorithm === SummaryCompressionAlgorithm.None) {\n\t\t\tdecompressed = originalBlob;\n\t\t} else if (algorithm === SummaryCompressionAlgorithm.LZ4) {\n\t\t\tdecompressed = decompress(originalBlob) as ArrayBufferLike;\n\t\t} else {\n\t\t\tthrow new Error(`Unknown Algorithm ${algorithm}`);\n\t\t}\n\t\treturn decompressed;\n\t}\n\n\t/**\n\t * This method traverses the SummaryObject recursively. If it finds the ISummaryBlob object,\n\t * it applies encoding/decoding on it according to the given isEncode flag.\n\t * @param isEncode - True if the encoding should be applied, false if the decoding should be applied.\n\t * @param input - The summary object to traverse.\n\t * @param encoder - The encoder function to use.\n\t * @param decoder - The decoder function to use.\n\t * @param config - The config to use for encoding.\n\t * @param context - The summary context.\n\t * @returns The summary object with the encoded/decoded blob.\n\t */\n\tprivate static recursivelyReplace(\n\t\tisEncode: boolean,\n\t\tinput: SummaryObject,\n\t\tencoder: (input: SummaryObject, config: ICompressionStorageConfig) => SummaryObject,\n\t\tdecoder: (input: SummaryObject) => SummaryObject,\n\t\tconfig: ICompressionStorageConfig,\n\t\tcontext?: ISummaryContext,\n\t): SummaryObject {\n\t\tassert(typeof input === \"object\", 0x6f6 /* input must be a non-null object */);\n\t\tconst maybeReplaced = isEncode ? encoder(input, config) : decoder(input);\n\n\t\tif (maybeReplaced !== input) {\n\t\t\treturn maybeReplaced;\n\t\t}\n\t\tlet clone: object | undefined;\n\t\tfor (const key of Object.keys(input)) {\n\t\t\tconst value = input[key];\n\n\t\t\tif (Boolean(value) && typeof value === \"object\") {\n\t\t\t\tconst replaced = this.recursivelyReplace(\n\t\t\t\t\tisEncode,\n\t\t\t\t\tvalue as SummaryObject,\n\t\t\t\t\tencoder,\n\t\t\t\t\tdecoder,\n\t\t\t\t\tconfig,\n\t\t\t\t\tcontext,\n\t\t\t\t);\n\t\t\t\tif (replaced !== value) {\n\t\t\t\t\tclone = clone ?? (Array.isArray(input) ? [...input] : { ...input });\n\t\t\t\t\tclone[key] = replaced;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn (clone ?? input) as SummaryObject;\n\t}\n\n\t/**\n\t * This method traverses the SummaryTree recursively. If it finds the ISummaryBlob object with the key '.metadata',\n\t * it returns the summary tree containing that blob.\n\t *\n\t * @param summary - The summary tree to traverse.\n\t * @returns The summary tree containing the metadata blob.\n\t */\n\tprivate static findMetadataHolderSummary(summary: ISummaryTree): ISummaryTree | undefined {\n\t\tassert(typeof summary === \"object\", 0x6f7 /* summary must be a non-null object */);\n\t\tfor (const [key, value] of Object.entries(summary.tree)) {\n\t\t\tif (Boolean(value) && value.type === SummaryType.Tree) {\n\t\t\t\tconst found = this.findMetadataHolderSummary(value);\n\t\t\t\tif (found) {\n\t\t\t\t\treturn found;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (Boolean(value) && key === metadataBlobName && value.type === SummaryType.Blob) {\n\t\t\t\treturn summary;\n\t\t\t}\n\t\t}\n\t\treturn undefined;\n\t}\n\n\t/**\n\t * This method obtains the summary tree containing the metadata blob. It returns the content\n\t * of the tree atribute.\n\t * @param summary - The summary tree to traverse.\n\t * @returns The content of the tree attribute of the summary tree containing the metadata blob.\n\t */\n\tprivate static getMetadataHolderTree(summary: ISummaryTree) {\n\t\tconst metadataHolder = this.findMetadataHolderSummary(summary);\n\t\tassert(metadataHolder !== undefined, 0x6f8 /* metadataHolder must be a non-null object */);\n\t\tconst metadataHolderTree = metadataHolder.tree;\n\t\treturn metadataHolderTree;\n\t}\n\n\t/**\n\t * This method adds the compression markup blob to the nested summary tree containing the metadata blob.\n\t * @param summary - The top summary tree to put the compression markup blob into.\n\t */\n\tprivate static putCompressionMarkup(summary: ISummaryTree): void {\n\t\tconst metadataHolderTree =\n\t\t\tDocumentStorageServiceCompressionAdapter.getMetadataHolderTree(summary);\n\t\tmetadataHolderTree[blobHeadersBlobName] = {\n\t\t\ttype: 2,\n\t\t\tcontent: \"\",\n\t\t};\n\t}\n\n\t/**\n\t * This method traverses the SnapshotTree recursively. If it finds the ISummaryBlob object with the key '.metadata',\n\t * it checks, if the SummaryTree holder of that object also contains the compression markup blob. If it is found,\n\t * it returns true, otherwise false.\n\t * @param snapshot - The snapshot tree to traverse.\n\t * @returns True if the compression markup blob is found, otherwise false.\n\t */\n\tprivate static hasCompressionMarkup(snapshot: ISnapshotTree): boolean {\n\t\tassert(typeof snapshot === \"object\", 0x6f9 /* snapshot must be a non-null object */);\n\t\tfor (const key of Object.keys(snapshot.blobs)) {\n\t\t\tif (key === metadataBlobName) {\n\t\t\t\tconst value = snapshot.blobs[blobHeadersBlobName];\n\t\t\t\tif (value !== undefined) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfor (const key of Object.keys(snapshot.trees)) {\n\t\t\tconst value = snapshot[key] as ISnapshotTree;\n\t\t\tif (value !== undefined) {\n\t\t\t\tconst found = this.hasCompressionMarkup(value);\n\t\t\t\tif (found) {\n\t\t\t\t\treturn found;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn false;\n\t}\n\n\t/**\n\t * This method performs compression of the blobs in the summary tree.\n\t * @param summary - The summary tree to compress.\n\t * @param config - The compression config.\n\t * @returns The compressed summary tree.\n\t */\n\tpublic static compressSummary(\n\t\tsummary: ISummaryTree,\n\t\tconfig: ICompressionStorageConfig,\n\t): ISummaryTree {\n\t\tthis.putCompressionMarkup(summary);\n\t\tconst prep = DocumentStorageServiceCompressionAdapter.recursivelyReplace(\n\t\t\ttrue,\n\t\t\tsummary,\n\t\t\tDocumentStorageServiceCompressionAdapter.blobEncoder,\n\t\t\tDocumentStorageServiceCompressionAdapter.blobDecoder,\n\t\t\tconfig,\n\t\t) as ISummaryTree;\n\t\t//\tconsole.log(`Miso summary-blob Summary Upload: ${JSON.stringify(prep).length}`);\n\t\treturn prep;\n\t}\n\n\t/**\n\t * This method read blob from the storage and decompresses it if it is compressed.\n\t * @param id - The id of the blob to read.\n\t * @returns The decompressed blob.\n\t */\n\tpublic override async readBlob(id: string): Promise<ArrayBufferLike> {\n\t\tconst originalBlob = await super.readBlob(id);\n\t\tif (!this._isCompressionEnabled) {\n\t\t\treturn originalBlob;\n\t\t} else {\n\t\t\tconst decompressedBlob =\n\t\t\t\tDocumentStorageServiceCompressionAdapter.decodeBlob(originalBlob);\n\t\t\t//\t\t\tconsole.log(`Miso summary-blob Blob read END : ${id} ${decompressedBlob.byteLength}`);\n\t\t\treturn decompressedBlob;\n\t\t}\n\t}\n\n\t/**\n\t * This method loads the snapshot tree from the server. It also checks, if the compression markup blob is present\n\t * and setups the compression flag accordingly. It also identifies the blobs that are not compressed and do not contain\n\t * algorithm byte prefix and store them.\n\t * @param version - The version of the snapshot tree to load.\n\t * @param scenarioName - The scenario name of the snapshot tree to load.\n\t * @returns The snapshot tree.\n\t */\n\tpublic override async getSnapshotTree(\n\t\tversion?: IVersion | undefined,\n\t\tscenarioName?: string | undefined,\n\t\t// eslint-disable-next-line @rushstack/no-new-null\n\t): Promise<ISnapshotTree | null> {\n\t\tconst snapshotTree = await super.getSnapshotTree(version, scenarioName);\n\t\tthis._isCompressionEnabled =\n\t\t\tsnapshotTree !== undefined &&\n\t\t\tsnapshotTree !== null &&\n\t\t\tDocumentStorageServiceCompressionAdapter.hasCompressionMarkup(snapshotTree);\n\t\treturn snapshotTree;\n\t}\n\n\t/**\n\t * This method uploads the summary to the storage. It performs compression of the blobs in the summary tree.\n\t * @param summary - The summary tree to upload.\n\t * @param context - The summary context.\n\t * @returns The ID of the uploaded summary.\n\t */\n\tpublic override async uploadSummaryWithContext(\n\t\tsummary: ISummaryTree,\n\t\tcontext: ISummaryContext,\n\t): Promise<string> {\n\t\tconst prep = DocumentStorageServiceCompressionAdapter.compressSummary(\n\t\t\tsummary,\n\t\t\tthis._config,\n\t\t);\n\t\treturn super.uploadSummaryWithContext(prep, context);\n\t}\n\n\t/**\n\t * This method downloads the summary from the storage and then applies decompression on the compressed blobs.\n\t * @param id - The ID of the summary to be downloaded\n\t * @returns The summary with decompressed blobs\n\t */\n\tpublic override async downloadSummary(id: ISummaryHandle): Promise<ISummaryTree> {\n\t\tconst summary = await super.downloadSummary(id);\n\t\treturn !this._isCompressionEnabled\n\t\t\t? summary\n\t\t\t: (DocumentStorageServiceCompressionAdapter.recursivelyReplace(\n\t\t\t\t\tfalse,\n\t\t\t\t\tsummary,\n\t\t\t\t\tDocumentStorageServiceCompressionAdapter.blobEncoder,\n\t\t\t\t\tDocumentStorageServiceCompressionAdapter.blobDecoder,\n\t\t\t\t\tthis._config,\n\t\t\t\t) as ISummaryTree);\n\t}\n}\n"]}
|
package/lib/packageVersion.d.ts
CHANGED
|
@@ -5,5 +5,5 @@
|
|
|
5
5
|
* THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
|
|
6
6
|
*/
|
|
7
7
|
export declare const pkgName = "@fluidframework/driver-utils";
|
|
8
|
-
export declare const pkgVersion = "2.
|
|
8
|
+
export declare const pkgVersion = "2.22.0";
|
|
9
9
|
//# sourceMappingURL=packageVersion.d.ts.map
|
package/lib/packageVersion.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,OAAO,GAAG,8BAA8B,CAAC;AACtD,MAAM,CAAC,MAAM,UAAU,GAAG,QAAQ,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/driver-utils\";\nexport const pkgVersion = \"2.
|
|
1
|
+
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,OAAO,GAAG,8BAA8B,CAAC;AACtD,MAAM,CAAC,MAAM,UAAU,GAAG,QAAQ,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/driver-utils\";\nexport const pkgVersion = \"2.22.0\";\n"]}
|
package/lib/parallelRequests.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
import {
|
|
5
|
+
import { performanceNow } from "@fluid-internal/client-utils";
|
|
6
6
|
import { assert, Deferred } from "@fluidframework/core-utils/internal";
|
|
7
7
|
import { PerformanceEvent, } from "@fluidframework/telemetry-utils/internal";
|
|
8
8
|
import { canRetryOnError, createGenericNetworkError, getRetryDelayFromError, } from "./network.js";
|
|
@@ -339,7 +339,7 @@ async function getSingleOpBatch(get, props, strongTo, logger, signal, scenarioNa
|
|
|
339
339
|
while (signal?.aborted !== true) {
|
|
340
340
|
retry++;
|
|
341
341
|
let lastError;
|
|
342
|
-
const startTime =
|
|
342
|
+
const startTime = performanceNow();
|
|
343
343
|
try {
|
|
344
344
|
// Issue async request for deltas
|
|
345
345
|
const { messages, partialResult } = await get({ ...props, retry } /* telemetry props */);
|
|
@@ -358,9 +358,9 @@ async function getSingleOpBatch(get, props, strongTo, logger, signal, scenarioNa
|
|
|
358
358
|
if (lastSuccessTime === undefined) {
|
|
359
359
|
// Take timestamp of the first time server responded successfully, even though it wasn't with the ops we asked for.
|
|
360
360
|
// If we keep getting empty responses we'll eventually fail out below.
|
|
361
|
-
lastSuccessTime =
|
|
361
|
+
lastSuccessTime = performanceNow();
|
|
362
362
|
}
|
|
363
|
-
else if (
|
|
363
|
+
else if (performanceNow() - lastSuccessTime > 30000) {
|
|
364
364
|
// If we are connected and receiving proper responses from server, but can't get any ops back,
|
|
365
365
|
// then give up after some time. This likely indicates the issue with ordering service not flushing
|
|
366
366
|
// ops to storage quick enough, and possibly waiting for summaries, while summarizer can't get
|
|
@@ -383,7 +383,7 @@ async function getSingleOpBatch(get, props, strongTo, logger, signal, scenarioNa
|
|
|
383
383
|
eventName: "GetDeltas_Error",
|
|
384
384
|
...props,
|
|
385
385
|
retry,
|
|
386
|
-
duration:
|
|
386
|
+
duration: performanceNow() - startTime,
|
|
387
387
|
retryAfter,
|
|
388
388
|
reason: scenarioName,
|
|
389
389
|
}, error);
|
|
@@ -393,7 +393,7 @@ async function getSingleOpBatch(get, props, strongTo, logger, signal, scenarioNa
|
|
|
393
393
|
}
|
|
394
394
|
}
|
|
395
395
|
if (telemetryEvent === undefined) {
|
|
396
|
-
waitStartTime =
|
|
396
|
+
waitStartTime = performanceNow();
|
|
397
397
|
telemetryEvent = PerformanceEvent.start(logger, {
|
|
398
398
|
eventName: "GetDeltasWaitTime",
|
|
399
399
|
});
|
|
@@ -408,7 +408,7 @@ async function getSingleOpBatch(get, props, strongTo, logger, signal, scenarioNa
|
|
|
408
408
|
// NOTE: This isn't strictly true for drivers that don't require network (e.g. local driver). Really this logic
|
|
409
409
|
// should probably live in the driver.
|
|
410
410
|
await waitForOnline();
|
|
411
|
-
totalRetryAfterTime +=
|
|
411
|
+
totalRetryAfterTime += performanceNow() - waitStartTime;
|
|
412
412
|
}
|
|
413
413
|
return nothing;
|
|
414
414
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parallelRequests.js","sourceRoot":"","sources":["../src/parallelRequests.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAE3D,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,qC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ACT,MAAM;YACN,QAAQ;SACR,EACD,KAAK,CACL,CAAC;QACF,KAAK,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IACxB,CAAC,CAAC,CAAC;IAEJ,OAAO,KAAK,CAAC;AACd,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAyC;IACvE,IAAI,EAAE,KAAK,IAAI,EAAE;QAChB,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;IACvB,CAAC;CACD,CAAC;AAEF;;GAEG;AACH,MAAM,UAAU,kBAAkB,CACjC,WAAiD;IAEjD,IAAI,QAAQ,GAAqD,WAAW,CAAC;IAC7E,OAAO;QACN,IAAI,EAAE,KAAK,IAAI,EAAE;YAChB,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;gBAC5B,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;YACvB,CAAC;YACD,MAAM,KAAK,GAAG,MAAM,QAAQ,CAAC;YAC7B,QAAQ,GAAG,SAAS,CAAC;YACrB,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;QACrE,CAAC;KACD,CAAC;AACH,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,cAAc,CAC7B,MAAkB,EAClB,OAA0C;IAE1C,OAAO;QACN,IAAI,EAAE,KAAK,IAAI,EAAE;YAChB,MAAM,KAAK,GAAG,MAAM,MAAM,CAAC,IAAI,EAAE,CAAC;YAClC,OAAO,CAAC,KAAK,CAAC,CAAC;YACf,OAAO,KAAK,CAAC;QACd,CAAC;KACD,CAAC;AACH,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { performance } from \"@fluid-internal/client-utils\";\nimport { ITelemetryBaseProperties } from \"@fluidframework/core-interfaces\";\nimport { assert, Deferred } from \"@fluidframework/core-utils/internal\";\nimport {\n\tIDeltasFetchResult,\n\tIStream,\n\tIStreamResult,\n\tISequencedDocumentMessage,\n} from \"@fluidframework/driver-definitions/internal\";\nimport {\n\tITelemetryLoggerExt,\n\tPerformanceEvent,\n} from \"@fluidframework/telemetry-utils/internal\";\n\nimport {\n\tcanRetryOnError,\n\tcreateGenericNetworkError,\n\tgetRetryDelayFromError,\n} from \"./network.js\";\nimport { logNetworkFailure } from \"./networkUtils.js\";\n// For now, this package is versioned and released in unison with the specific drivers\nimport { pkgVersion as driverVersion } from \"./packageVersion.js\";\nimport { calculateMaxWaitTime } from \"./runWithRetry.js\";\n\n// We double this value in first try in when we calculate time to wait for in \"calculateMaxWaitTime\" function.\nconst MissingFetchDelayInMs = 50;\n\ntype WorkingState = \"working\" | \"done\" | \"canceled\";\n\n/**\n * Helper class to organize parallel fetching of data\n * It can be used to concurrently do many requests, while consuming\n * data in the right order. Take a look at UT for examples.\n * @param concurrency - level of concurrency\n * @param from - starting point of fetching data (inclusive)\n * @param to - ending point of fetching data. exclusive, or undefined if unknown\n * @param payloadSize - batch size\n * @param logger - logger to use\n * @param requestCallback - callback to request batches\n * @returns Queue that can be used to retrieve data\n * @internal\n */\nexport class ParallelRequests<T> {\n\tprivate latestRequested: number;\n\tprivate nextToDeliver: number;\n\tprivate readonly results = new Map<number, T[]>();\n\tprivate workingState: WorkingState = \"working\";\n\tprivate requestsInFlight = 0;\n\tprivate readonly endEvent = new Deferred<void>();\n\tprivate requests = 0;\n\tprivate readonly knewTo: boolean;\n\n\tprivate get working() {\n\t\treturn this.workingState === \"working\";\n\t}\n\tpublic get canceled() {\n\t\treturn this.workingState === \"canceled\";\n\t}\n\n\tconstructor(\n\t\tfrom: number,\n\t\tprivate to: number | undefined,\n\t\tprivate readonly payloadSize: number,\n\t\tprivate readonly logger: ITelemetryLoggerExt,\n\t\tprivate readonly requestCallback: (\n\t\t\trequest: number,\n\t\t\tfrom: number,\n\t\t\tto: number,\n\t\t\tstrongTo: boolean,\n\t\t\tprops: ITelemetryBaseProperties,\n\t\t) => Promise<{ partial: boolean; cancel: boolean; payload: T[] }>,\n\t\tprivate readonly responseCallback: (payload: T[]) => void,\n\t) {\n\t\tthis.latestRequested = from;\n\t\tthis.nextToDeliver = from;\n\t\tthis.knewTo = to !== undefined;\n\t}\n\n\tpublic cancel() {\n\t\tif (this.working) {\n\t\t\tthis.workingState = \"canceled\";\n\t\t\tthis.endEvent.resolve();\n\t\t}\n\t}\n\n\tpublic async run(concurrency: number) {\n\t\tassert(concurrency > 0, 0x102 /* \"invalid level of concurrency\" */);\n\t\tassert(this.working, 0x103 /* \"trying to parallel run while not working\" */);\n\n\t\tlet c = concurrency;\n\t\twhile (c > 0) {\n\t\t\tc--;\n\t\t\tthis.addRequest();\n\t\t}\n\t\tthis.dispatch(); // will recalculate and trigger this.endEvent if needed\n\t\treturn this.endEvent.promise;\n\t}\n\n\tprivate done() {\n\t\t// We should satisfy request fully.\n\t\tassert(this.to !== undefined, 0x104 /* \"undefined end point for parallel fetch\" */);\n\t\tassert(\n\t\t\tthis.nextToDeliver >= this.to,\n\t\t\t0x105 /* \"unexpected end point for parallel fetch\" */,\n\t\t);\n\t\tif (this.working) {\n\t\t\tthis.workingState = \"done\";\n\t\t\tthis.endEvent.resolve();\n\t\t}\n\t}\n\n\tprivate fail(error) {\n\t\tif (this.working) {\n\t\t\tthis.workingState = \"done\";\n\t\t\tthis.endEvent.reject(error);\n\t\t}\n\t}\n\n\tprivate dispatch() {\n\t\twhile (this.working) {\n\t\t\tconst value = this.results.get(this.nextToDeliver);\n\t\t\tif (value === undefined) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tthis.results.delete(this.nextToDeliver);\n\t\t\tassert(\n\t\t\t\tvalue.length <= this.payloadSize,\n\t\t\t\t0x1d9 /* \"addRequestCore() should break into smaller chunks\" */,\n\t\t\t);\n\t\t\tthis.nextToDeliver += value.length;\n\t\t\tthis.responseCallback(value);\n\t\t}\n\n\t\t// Account for cancellation - state might be not in consistent state on cancelling operation\n\t\tif (this.working) {\n\t\t\tif (this.requestsInFlight === 0) {\n\t\t\t\t// we should have dispatched everything, no matter whether we knew about the end or not.\n\t\t\t\t// see comment in addRequestCore() around throwing away chunk if it's above this.to\n\t\t\t\tassert(\n\t\t\t\t\tthis.results.size === 0,\n\t\t\t\t\t0x107 /* \"ending dispatch with remaining results to be sent\" */,\n\t\t\t\t);\n\t\t\t\tthis.done();\n\t\t\t} else if (this.to !== undefined && this.nextToDeliver >= this.to) {\n\t\t\t\t// Learned about the end and dispatched all the ops up to it.\n\t\t\t\t// Ignore all the in-flight requests above boundary - unblock caller sooner.\n\t\t\t\tassert(\n\t\t\t\t\t!this.knewTo,\n\t\t\t\t\t0x108 /* \"ending results dispatch but knew in advance about more requests\" */,\n\t\t\t\t);\n\t\t\t\tthis.done();\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate getNextChunk() {\n\t\tif (!this.working) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst from = this.latestRequested;\n\t\tif (this.to !== undefined) {\n\t\t\tif (this.to <= from) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t}\n\n\t\t// this.latestRequested\n\t\t// inclusive on the right side! Exclusive on the left.\n\t\tthis.latestRequested += this.payloadSize;\n\n\t\tif (this.to !== undefined) {\n\t\t\tthis.latestRequested = Math.min(this.to, this.latestRequested);\n\t\t}\n\n\t\tassert(from < this.latestRequested, 0x109 /* \"unexpected next chunk position\" */);\n\n\t\treturn { from, to: this.latestRequested };\n\t}\n\n\tprivate addRequest() {\n\t\tconst chunk = this.getNextChunk();\n\t\tif (chunk === undefined) {\n\t\t\treturn;\n\t\t}\n\t\tthis.addRequestCore(chunk.from, chunk.to).catch(this.fail.bind(this));\n\t}\n\n\tprivate async addRequestCore(fromArg: number, toArg: number) {\n\t\tassert(this.working, 0x10a /* \"cannot add parallel request while not working\" */);\n\n\t\tlet from = fromArg;\n\t\tlet to = toArg;\n\n\t\t// to & from are exclusive\n\t\tthis.requestsInFlight++;\n\t\twhile (this.working) {\n\t\t\tconst requestedLength = to - from;\n\t\t\tassert(requestedLength > 0, 0x10b /* \"invalid parallel request range\" */);\n\n\t\t\t// We should not be wasting time asking for something useless.\n\t\t\tif (this.to !== undefined) {\n\t\t\t\tassert(from < this.to, 0x10c /* \"invalid parallel request start point\" */);\n\t\t\t\tassert(to <= this.to, 0x10d /* \"invalid parallel request end point\" */);\n\t\t\t}\n\n\t\t\tthis.requests++;\n\n\t\t\tconst promise = this.requestCallback(this.requests, from, to, this.to !== undefined, {});\n\n\t\t\t// dispatch any prior received data\n\t\t\tthis.dispatch();\n\n\t\t\tconst { payload, cancel, partial } = await promise;\n\n\t\t\tif (cancel) {\n\t\t\t\tthis.cancel();\n\t\t\t}\n\n\t\t\tif (this.to !== undefined && from >= this.to) {\n\t\t\t\t// while we were waiting for response, we learned on what is the boundary\n\t\t\t\t// We can get here (with actual result!) if situation changed while this request was in\n\t\t\t\t// flight, i.e. the end was extended over what we learn in some other request\n\t\t\t\t// While it's useful not to throw this result, this is very corner cases and makes logic\n\t\t\t\t// (including consistency checks) much harder to write correctly.\n\t\t\t\t// So for now, we are throwing this result out the window.\n\t\t\t\tassert(\n\t\t\t\t\t!this.knewTo,\n\t\t\t\t\t0x10e /* \"should not throw result if we knew about boundary in advance\" */,\n\t\t\t\t);\n\t\t\t\t// Learn how often it happens and if it's too wasteful to throw these chunks.\n\t\t\t\t// If it pops into our view a lot, we would need to reconsider how we approach it.\n\t\t\t\t// Note that this is not visible to user other than potentially not hitting 100% of\n\t\t\t\t// what we can in perf domain.\n\t\t\t\tif (payload.length !== 0) {\n\t\t\t\t\tthis.logger.sendErrorEvent({\n\t\t\t\t\t\teventName: \"ParallelRequests_GotExtra\",\n\t\t\t\t\t\tfrom,\n\t\t\t\t\t\tto,\n\t\t\t\t\t\tend: this.to,\n\t\t\t\t\t\tlength: payload.length,\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tif (this.working) {\n\t\t\t\tconst fromOrig = from;\n\t\t\t\tconst length = payload.length;\n\t\t\t\tlet fullChunk = requestedLength <= length; // we can possible get more than we asked.\n\n\t\t\t\tif (length !== 0) {\n\t\t\t\t\t// We can get more than we asked for!\n\t\t\t\t\t// This can screw up logic in dispatch!\n\t\t\t\t\t// So push only batch size, and keep the rest for later - if conditions are favorable, we\n\t\t\t\t\t// will be able to use it. If not (parallel request overlapping these ops), it's easier to\n\t\t\t\t\t// discard them and wait for another (overlapping) request to come in later.\n\t\t\t\t\tif (requestedLength < length) {\n\t\t\t\t\t\t// This is error in a sense that it's not expected and likely points bug in other layer.\n\t\t\t\t\t\t// This layer copes with this situation just fine.\n\t\t\t\t\t\tthis.logger.sendTelemetryEvent({\n\t\t\t\t\t\t\teventName: \"ParallelRequests_Over\",\n\t\t\t\t\t\t\tfrom,\n\t\t\t\t\t\t\tto,\n\t\t\t\t\t\t\tlength,\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t\tconst data = payload.splice(0, requestedLength);\n\t\t\t\t\tthis.results.set(from, data);\n\t\t\t\t\tfrom += data.length;\n\t\t\t\t} else {\n\t\t\t\t\t// 1. empty (partial) chunks should not be returned by various caching / adapter layers -\n\t\t\t\t\t// they should fall back to next layer. This might be important invariant to hold to ensure\n\t\t\t\t\t// that we are less likely have bugs where such layer would keep returning empty partial\n\t\t\t\t\t// result on each call.\n\t\t\t\t\t// 2. Current invariant is that callback does retries until it gets something,\n\t\t\t\t\t// with the goal of failing if zero data is retrieved in given amount of time.\n\t\t\t\t\t// This is very specific property of storage / ops, so this logic is not here, but given only\n\t\t\t\t\t// one user of this class, we assert that to catch issues earlier.\n\t\t\t\t\t// These invariant can be relaxed if needed.\n\t\t\t\t\tassert(\n\t\t\t\t\t\t!partial,\n\t\t\t\t\t\t0x10f /* \"empty/partial chunks should not be returned by caching\" */,\n\t\t\t\t\t);\n\t\t\t\t\tassert(\n\t\t\t\t\t\t!this.knewTo,\n\t\t\t\t\t\t0x110 /* \"callback should retry until valid fetch before it learns new boundary\" */,\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tif (!partial && !fullChunk) {\n\t\t\t\t\tif (!this.knewTo) {\n\t\t\t\t\t\tif (this.to === undefined || this.to > from) {\n\t\t\t\t\t\t\t// The END\n\t\t\t\t\t\t\tthis.to = from;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\t// We know that there are more items to be retrieved\n\t\t\t\t\t// Can we get partial chunk? Ideally storage indicates that's not a full chunk\n\t\t\t\t\t// Note that it's possible that not all ops hit storage yet.\n\t\t\t\t\t// We will come back to request more, and if we can't get any more ops soon, it's\n\t\t\t\t\t// catastrophic failure (see comment above on responsibility of callback to return something)\n\t\t\t\t\t// This layer will just keep trying until it gets full set.\n\t\t\t\t\tthis.logger.sendPerformanceEvent({\n\t\t\t\t\t\teventName: \"ParallelRequests_Partial\",\n\t\t\t\t\t\tfrom: fromOrig,\n\t\t\t\t\t\tto,\n\t\t\t\t\t\tlength,\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\tif (to === this.latestRequested) {\n\t\t\t\t\t// we can go after full chunk at the end if we received partial chunk, or more than asked\n\t\t\t\t\t// Also if we got more than we asked to, we can actually use those ops!\n\t\t\t\t\twhile (payload.length !== 0) {\n\t\t\t\t\t\tconst data = payload.splice(0, requestedLength);\n\t\t\t\t\t\tthis.results.set(from, data);\n\t\t\t\t\t\tfrom += data.length;\n\t\t\t\t\t}\n\n\t\t\t\t\tthis.latestRequested = from;\n\t\t\t\t\tfullChunk = true;\n\t\t\t\t}\n\n\t\t\t\tif (fullChunk) {\n\t\t\t\t\tconst chunk = this.getNextChunk();\n\t\t\t\t\tif (chunk === undefined) {\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tfrom = chunk.from;\n\t\t\t\t\tto = chunk.to;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tthis.requestsInFlight--;\n\t\tthis.dispatch();\n\t}\n}\n\n/**\n * Helper queue class to allow async push / pull\n * It's essentially a pipe allowing multiple writers, and single reader\n * @internal\n */\nexport class Queue<T> implements IStream<T> {\n\tprivate readonly queue: Promise<IStreamResult<T>>[] = [];\n\tprivate deferred: Deferred<IStreamResult<T>> | undefined;\n\tprivate done = false;\n\n\tpublic pushValue(value: T) {\n\t\tthis.pushCore(Promise.resolve({ done: false, value }));\n\t}\n\n\tpublic pushError(error: any) {\n\t\tthis.pushCore(Promise.reject(error));\n\t\tthis.done = true;\n\t}\n\n\tpublic pushDone() {\n\t\tthis.pushCore(Promise.resolve({ done: true }));\n\t\tthis.done = true;\n\t}\n\n\tprotected pushCore(value: Promise<IStreamResult<T>>) {\n\t\tassert(!this.done, 0x112 /* \"cannot push onto queue if done\" */);\n\t\tif (this.deferred) {\n\t\t\tassert(this.queue.length === 0, 0x113 /* \"deferred queue should be empty\" */);\n\t\t\tthis.deferred.resolve(value);\n\t\t\tthis.deferred = undefined;\n\t\t} else {\n\t\t\tthis.queue.push(value);\n\t\t}\n\t}\n\n\tpublic async read(): Promise<IStreamResult<T>> {\n\t\tassert(this.deferred === undefined, 0x114 /* \"cannot pop if deferred\" */);\n\t\tconst value = this.queue.shift();\n\t\tif (value !== undefined) {\n\t\t\treturn value;\n\t\t}\n\t\tassert(!this.done, 0x115 /* \"queue should not be done during pop\" */);\n\t\tthis.deferred = new Deferred<IStreamResult<T>>();\n\t\treturn this.deferred.promise;\n\t}\n}\n\nconst waitForOnline = async (): Promise<void> => {\n\t// Only wait if we have a strong signal that we're offline - otherwise assume we're online.\n\tif (globalThis.navigator?.onLine === false && globalThis.addEventListener !== undefined) {\n\t\treturn new Promise<void>((resolve) => {\n\t\t\tconst resolveAndRemoveListener = () => {\n\t\t\t\tresolve();\n\t\t\t\tglobalThis.removeEventListener(\"online\", resolveAndRemoveListener);\n\t\t\t};\n\t\t\tglobalThis.addEventListener(\"online\", resolveAndRemoveListener);\n\t\t});\n\t}\n};\n\n/**\n * Retrieve single batch of ops\n * @param request - request index\n * @param from - inclusive boundary\n * @param to - exclusive boundary\n * @param telemetryEvent - telemetry event used to track consecutive batch of requests\n * @param strongTo - tells if ops in range from...to have to be there and have to be retrieved.\n * If false, returning less ops would mean we reached end of file.\n * @param logger - logger object to use to log progress & errors\n * @param signal - cancelation signal\n * @param scenarioName - reason for fetching ops\n * @returns An object with resulting ops and cancellation / partial result flags\n */\nasync function getSingleOpBatch(\n\tget: (telemetryProps: ITelemetryBaseProperties) => Promise<IDeltasFetchResult>,\n\tprops: ITelemetryBaseProperties,\n\tstrongTo: boolean,\n\tlogger: ITelemetryLoggerExt,\n\tsignal?: AbortSignal,\n\tscenarioName?: string,\n): Promise<{ partial: boolean; cancel: boolean; payload: ISequencedDocumentMessage[] }> {\n\tlet lastSuccessTime: number | undefined;\n\tlet totalRetryAfterTime = 0;\n\tlet telemetryEvent: PerformanceEvent | undefined;\n\tlet retry: number = 0;\n\tconst nothing = { partial: false, cancel: true, payload: [] };\n\tlet waitStartTime: number = 0;\n\tlet waitTime = MissingFetchDelayInMs;\n\n\twhile (signal?.aborted !== true) {\n\t\tretry++;\n\t\tlet lastError: unknown;\n\t\tconst startTime = performance.now();\n\n\t\ttry {\n\t\t\t// Issue async request for deltas\n\t\t\tconst { messages, partialResult } = await get({ ...props, retry } /* telemetry props */);\n\n\t\t\t// If we got messages back, return them. Return regardless of whether we got messages back if we didn't\n\t\t\t// specify a \"to\", since we don't have an expectation of how many to receive.\n\t\t\tif (messages.length !== 0 || !strongTo) {\n\t\t\t\t// Report this event if we waited to fetch ops due to being offline or throttling.\n\t\t\t\ttelemetryEvent?.end({\n\t\t\t\t\tduration: totalRetryAfterTime,\n\t\t\t\t\t...props,\n\t\t\t\t\treason: scenarioName,\n\t\t\t\t});\n\t\t\t\treturn { payload: messages, cancel: false, partial: partialResult };\n\t\t\t}\n\n\t\t\t// Otherwise, the storage gave us back an empty set of ops but we were expecting a non-empty set.\n\n\t\t\tif (lastSuccessTime === undefined) {\n\t\t\t\t// Take timestamp of the first time server responded successfully, even though it wasn't with the ops we asked for.\n\t\t\t\t// If we keep getting empty responses we'll eventually fail out below.\n\t\t\t\tlastSuccessTime = performance.now();\n\t\t\t} else if (performance.now() - lastSuccessTime > 30000) {\n\t\t\t\t// If we are connected and receiving proper responses from server, but can't get any ops back,\n\t\t\t\t// then give up after some time. This likely indicates the issue with ordering service not flushing\n\t\t\t\t// ops to storage quick enough, and possibly waiting for summaries, while summarizer can't get\n\t\t\t\t// current as it can't get ops.\n\t\t\t\tthrow createGenericNetworkError(\n\t\t\t\t\t// pre-0.58 error message: failedToRetrieveOpsFromStorage:TooManyRetries\n\t\t\t\t\t\"Failed to retrieve ops from storage (Too Many Retries)\",\n\t\t\t\t\t{ canRetry: false },\n\t\t\t\t\t{\n\t\t\t\t\t\tretry,\n\t\t\t\t\t\tdriverVersion,\n\t\t\t\t\t\t...props,\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tlastError = error;\n\t\t\tconst canRetry = canRetryOnError(error);\n\n\t\t\tconst retryAfter = getRetryDelayFromError(error);\n\n\t\t\t// This will log to error table only if the error is non-retryable\n\t\t\tlogNetworkFailure(\n\t\t\t\tlogger,\n\t\t\t\t{\n\t\t\t\t\teventName: \"GetDeltas_Error\",\n\t\t\t\t\t...props,\n\t\t\t\t\tretry,\n\t\t\t\t\tduration: performance.now() - startTime,\n\t\t\t\t\tretryAfter,\n\t\t\t\t\treason: scenarioName,\n\t\t\t\t},\n\t\t\t\terror,\n\t\t\t);\n\n\t\t\tif (!canRetry) {\n\t\t\t\t// It's game over scenario.\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t}\n\n\t\tif (telemetryEvent === undefined) {\n\t\t\twaitStartTime = performance.now();\n\t\t\ttelemetryEvent = PerformanceEvent.start(logger, {\n\t\t\t\teventName: \"GetDeltasWaitTime\",\n\t\t\t});\n\t\t}\n\n\t\twaitTime = calculateMaxWaitTime(waitTime, lastError);\n\n\t\t// If we get here something has gone wrong - either got an unexpected empty set of messages back or a real error.\n\t\t// Either way we will wait a little bit before retrying.\n\t\tawait new Promise<void>((resolve) => {\n\t\t\tsetTimeout(resolve, waitTime);\n\t\t});\n\n\t\t// If we believe we're offline, we assume there's no point in trying until we at least think we're online.\n\t\t// NOTE: This isn't strictly true for drivers that don't require network (e.g. local driver). Really this logic\n\t\t// should probably live in the driver.\n\t\tawait waitForOnline();\n\t\ttotalRetryAfterTime += performance.now() - waitStartTime;\n\t}\n\n\treturn nothing;\n}\n\n/**\n * Request ops from storage\n * @param get - Getter callback to get individual batches\n * @param concurrency - Number of concurrent requests to make\n * @param fromTotal - starting sequence number to fetch (inclusive)\n * @param toTotal - max (exclusive) sequence number to fetch\n * @param payloadSize - Payload size\n * @param logger - Logger to log progress and errors\n * @param signal - Cancelation signal\n * @param scenarioName - Reason for fetching ops\n * @returns Messages fetched\n * @internal\n */\nexport function requestOps(\n\tget: (\n\t\tfrom: number,\n\t\tto: number,\n\t\ttelemetryProps: ITelemetryBaseProperties,\n\t) => Promise<IDeltasFetchResult>,\n\tconcurrency: number,\n\tfromTotal: number,\n\ttoTotal: number | undefined,\n\tpayloadSize: number,\n\tlogger: ITelemetryLoggerExt,\n\tsignal?: AbortSignal,\n\tscenarioName?: string,\n): IStream<ISequencedDocumentMessage[]> {\n\tlet requests = 0;\n\tlet lastFetch: number | undefined;\n\tlet length = 0;\n\tconst queue = new Queue<ISequencedDocumentMessage[]>();\n\n\tconst propsTotal: ITelemetryBaseProperties = {\n\t\tfromTotal,\n\t\ttoTotal,\n\t};\n\n\tconst telemetryEvent = PerformanceEvent.start(logger, {\n\t\teventName: \"GetDeltas\",\n\t\t...propsTotal,\n\t\treason: scenarioName,\n\t});\n\n\tconst manager = new ParallelRequests<ISequencedDocumentMessage>(\n\t\tfromTotal,\n\t\ttoTotal,\n\t\tpayloadSize,\n\t\tlogger,\n\t\tasync (\n\t\t\trequest: number,\n\t\t\tfrom: number,\n\t\t\tto: number,\n\t\t\tstrongTo: boolean,\n\t\t\tpropsPerRequest: ITelemetryBaseProperties,\n\t\t) => {\n\t\t\trequests++;\n\t\t\treturn getSingleOpBatch(\n\t\t\t\tasync (propsAll) => get(from, to, propsAll),\n\t\t\t\t{ request, from, to, ...propsTotal, ...propsPerRequest },\n\t\t\t\tstrongTo,\n\t\t\t\tlogger,\n\t\t\t\tsignal,\n\t\t\t\tscenarioName,\n\t\t\t);\n\t\t},\n\t\t(deltas: ISequencedDocumentMessage[]) => {\n\t\t\t// Assert continuing and right start.\n\t\t\tif (lastFetch === undefined) {\n\t\t\t\tassert(deltas[0].sequenceNumber === fromTotal, 0x26d /* \"wrong start\" */);\n\t\t\t} else {\n\t\t\t\tassert(deltas[0].sequenceNumber === lastFetch + 1, 0x26e /* \"wrong start\" */);\n\t\t\t}\n\t\t\tlastFetch = deltas[deltas.length - 1].sequenceNumber;\n\t\t\tassert(\n\t\t\t\tlastFetch - deltas[0].sequenceNumber + 1 === deltas.length,\n\t\t\t\t0x26f /* \"continuous and no duplicates\" */,\n\t\t\t);\n\t\t\tlength += deltas.length;\n\t\t\tqueue.pushValue(deltas);\n\t\t},\n\t);\n\n\t// Implement faster cancellation. getSingleOpBatch() checks signal, but only in between\n\t// waits (up to 10 seconds) and fetches (can take infinite amount of time).\n\t// While every such case should be improved and take into account signal (and thus cancel immediately),\n\t// it is beneficial to have catch-all\n\tconst listener = (event: Event) => {\n\t\tmanager.cancel();\n\t};\n\tif (signal !== undefined) {\n\t\tsignal.addEventListener(\"abort\", listener);\n\t}\n\n\tmanager\n\t\t.run(concurrency)\n\t\t.finally(() => {\n\t\t\tif (signal !== undefined) {\n\t\t\t\tsignal.removeEventListener(\"abort\", listener);\n\t\t\t}\n\t\t})\n\t\t.then(() => {\n\t\t\tconst props = {\n\t\t\t\tlastFetch,\n\t\t\t\tlength,\n\t\t\t\trequests,\n\t\t\t};\n\t\t\tif (manager.canceled) {\n\t\t\t\ttelemetryEvent.cancel({ ...props, error: \"ops request cancelled by client\" });\n\t\t\t} else {\n\t\t\t\tassert(\n\t\t\t\t\ttoTotal === undefined || (lastFetch !== undefined && lastFetch >= toTotal - 1),\n\t\t\t\t\t0x270 /* \"All requested ops fetched\" */,\n\t\t\t\t);\n\t\t\t\ttelemetryEvent.end(props);\n\t\t\t}\n\t\t\tqueue.pushDone();\n\t\t})\n\t\t.catch((error) => {\n\t\t\ttelemetryEvent.cancel(\n\t\t\t\t{\n\t\t\t\t\tlastFetch,\n\t\t\t\t\tlength,\n\t\t\t\t\trequests,\n\t\t\t\t},\n\t\t\t\terror,\n\t\t\t);\n\t\t\tqueue.pushError(error);\n\t\t});\n\n\treturn queue;\n}\n\n/**\n * @internal\n */\nexport const emptyMessageStream: IStream<ISequencedDocumentMessage[]> = {\n\tread: async () => {\n\t\treturn { done: true };\n\t},\n};\n\n/**\n * @internal\n */\nexport function streamFromMessages(\n\tmessagesArg: Promise<ISequencedDocumentMessage[]>,\n): IStream<ISequencedDocumentMessage[]> {\n\tlet messages: Promise<ISequencedDocumentMessage[]> | undefined = messagesArg;\n\treturn {\n\t\tread: async () => {\n\t\t\tif (messages === undefined) {\n\t\t\t\treturn { done: true };\n\t\t\t}\n\t\t\tconst value = await messages;\n\t\t\tmessages = undefined;\n\t\t\treturn value.length === 0 ? { done: true } : { done: false, value };\n\t\t},\n\t};\n}\n\n/**\n * @internal\n */\nexport function streamObserver<T>(\n\tstream: IStream<T>,\n\thandler: (value: IStreamResult<T>) => void,\n): IStream<T> {\n\treturn {\n\t\tread: async () => {\n\t\t\tconst value = await stream.read();\n\t\t\thandler(value);\n\t\t\treturn value;\n\t\t},\n\t};\n}\n"]}
|
|
1
|
+
{"version":3,"file":"parallelRequests.js","sourceRoot":"","sources":["../src/parallelRequests.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAE9D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EACD,KAAK,CACL,CAAC;QACF,KAAK,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IACxB,CAAC,CAAC,CAAC;IAEJ,OAAO,KAAK,CAAC;AACd,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAyC;IACvE,IAAI,EAAE,KAAK,IAAI,EAAE;QAChB,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;IACvB,CAAC;CACD,CAAC;AAEF;;GAEG;AACH,MAAM,UAAU,kBAAkB,CACjC,WAAiD;IAEjD,IAAI,QAAQ,GAAqD,WAAW,CAAC;IAC7E,OAAO;QACN,IAAI,EAAE,KAAK,IAAI,EAAE;YAChB,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;gBAC5B,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;YACvB,CAAC;YACD,MAAM,KAAK,GAAG,MAAM,QAAQ,CAAC;YAC7B,QAAQ,GAAG,SAAS,CAAC;YACrB,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;QACrE,CAAC;KACD,CAAC;AACH,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,cAAc,CAC7B,MAAkB,EAClB,OAA0C;IAE1C,OAAO;QACN,IAAI,EAAE,KAAK,IAAI,EAAE;YAChB,MAAM,KAAK,GAAG,MAAM,MAAM,CAAC,IAAI,EAAE,CAAC;YAClC,OAAO,CAAC,KAAK,CAAC,CAAC;YACf,OAAO,KAAK,CAAC;QACd,CAAC;KACD,CAAC;AACH,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { performanceNow } from \"@fluid-internal/client-utils\";\nimport { ITelemetryBaseProperties } from \"@fluidframework/core-interfaces\";\nimport { assert, Deferred } from \"@fluidframework/core-utils/internal\";\nimport {\n\tIDeltasFetchResult,\n\tIStream,\n\tIStreamResult,\n\tISequencedDocumentMessage,\n} from \"@fluidframework/driver-definitions/internal\";\nimport {\n\tITelemetryLoggerExt,\n\tPerformanceEvent,\n} from \"@fluidframework/telemetry-utils/internal\";\n\nimport {\n\tcanRetryOnError,\n\tcreateGenericNetworkError,\n\tgetRetryDelayFromError,\n} from \"./network.js\";\nimport { logNetworkFailure } from \"./networkUtils.js\";\n// For now, this package is versioned and released in unison with the specific drivers\nimport { pkgVersion as driverVersion } from \"./packageVersion.js\";\nimport { calculateMaxWaitTime } from \"./runWithRetry.js\";\n\n// We double this value in first try in when we calculate time to wait for in \"calculateMaxWaitTime\" function.\nconst MissingFetchDelayInMs = 50;\n\ntype WorkingState = \"working\" | \"done\" | \"canceled\";\n\n/**\n * Helper class to organize parallel fetching of data\n * It can be used to concurrently do many requests, while consuming\n * data in the right order. Take a look at UT for examples.\n * @param concurrency - level of concurrency\n * @param from - starting point of fetching data (inclusive)\n * @param to - ending point of fetching data. exclusive, or undefined if unknown\n * @param payloadSize - batch size\n * @param logger - logger to use\n * @param requestCallback - callback to request batches\n * @returns Queue that can be used to retrieve data\n * @internal\n */\nexport class ParallelRequests<T> {\n\tprivate latestRequested: number;\n\tprivate nextToDeliver: number;\n\tprivate readonly results = new Map<number, T[]>();\n\tprivate workingState: WorkingState = \"working\";\n\tprivate requestsInFlight = 0;\n\tprivate readonly endEvent = new Deferred<void>();\n\tprivate requests = 0;\n\tprivate readonly knewTo: boolean;\n\n\tprivate get working() {\n\t\treturn this.workingState === \"working\";\n\t}\n\tpublic get canceled() {\n\t\treturn this.workingState === \"canceled\";\n\t}\n\n\tconstructor(\n\t\tfrom: number,\n\t\tprivate to: number | undefined,\n\t\tprivate readonly payloadSize: number,\n\t\tprivate readonly logger: ITelemetryLoggerExt,\n\t\tprivate readonly requestCallback: (\n\t\t\trequest: number,\n\t\t\tfrom: number,\n\t\t\tto: number,\n\t\t\tstrongTo: boolean,\n\t\t\tprops: ITelemetryBaseProperties,\n\t\t) => Promise<{ partial: boolean; cancel: boolean; payload: T[] }>,\n\t\tprivate readonly responseCallback: (payload: T[]) => void,\n\t) {\n\t\tthis.latestRequested = from;\n\t\tthis.nextToDeliver = from;\n\t\tthis.knewTo = to !== undefined;\n\t}\n\n\tpublic cancel() {\n\t\tif (this.working) {\n\t\t\tthis.workingState = \"canceled\";\n\t\t\tthis.endEvent.resolve();\n\t\t}\n\t}\n\n\tpublic async run(concurrency: number) {\n\t\tassert(concurrency > 0, 0x102 /* \"invalid level of concurrency\" */);\n\t\tassert(this.working, 0x103 /* \"trying to parallel run while not working\" */);\n\n\t\tlet c = concurrency;\n\t\twhile (c > 0) {\n\t\t\tc--;\n\t\t\tthis.addRequest();\n\t\t}\n\t\tthis.dispatch(); // will recalculate and trigger this.endEvent if needed\n\t\treturn this.endEvent.promise;\n\t}\n\n\tprivate done() {\n\t\t// We should satisfy request fully.\n\t\tassert(this.to !== undefined, 0x104 /* \"undefined end point for parallel fetch\" */);\n\t\tassert(\n\t\t\tthis.nextToDeliver >= this.to,\n\t\t\t0x105 /* \"unexpected end point for parallel fetch\" */,\n\t\t);\n\t\tif (this.working) {\n\t\t\tthis.workingState = \"done\";\n\t\t\tthis.endEvent.resolve();\n\t\t}\n\t}\n\n\tprivate fail(error) {\n\t\tif (this.working) {\n\t\t\tthis.workingState = \"done\";\n\t\t\tthis.endEvent.reject(error);\n\t\t}\n\t}\n\n\tprivate dispatch() {\n\t\twhile (this.working) {\n\t\t\tconst value = this.results.get(this.nextToDeliver);\n\t\t\tif (value === undefined) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tthis.results.delete(this.nextToDeliver);\n\t\t\tassert(\n\t\t\t\tvalue.length <= this.payloadSize,\n\t\t\t\t0x1d9 /* \"addRequestCore() should break into smaller chunks\" */,\n\t\t\t);\n\t\t\tthis.nextToDeliver += value.length;\n\t\t\tthis.responseCallback(value);\n\t\t}\n\n\t\t// Account for cancellation - state might be not in consistent state on cancelling operation\n\t\tif (this.working) {\n\t\t\tif (this.requestsInFlight === 0) {\n\t\t\t\t// we should have dispatched everything, no matter whether we knew about the end or not.\n\t\t\t\t// see comment in addRequestCore() around throwing away chunk if it's above this.to\n\t\t\t\tassert(\n\t\t\t\t\tthis.results.size === 0,\n\t\t\t\t\t0x107 /* \"ending dispatch with remaining results to be sent\" */,\n\t\t\t\t);\n\t\t\t\tthis.done();\n\t\t\t} else if (this.to !== undefined && this.nextToDeliver >= this.to) {\n\t\t\t\t// Learned about the end and dispatched all the ops up to it.\n\t\t\t\t// Ignore all the in-flight requests above boundary - unblock caller sooner.\n\t\t\t\tassert(\n\t\t\t\t\t!this.knewTo,\n\t\t\t\t\t0x108 /* \"ending results dispatch but knew in advance about more requests\" */,\n\t\t\t\t);\n\t\t\t\tthis.done();\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate getNextChunk() {\n\t\tif (!this.working) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst from = this.latestRequested;\n\t\tif (this.to !== undefined) {\n\t\t\tif (this.to <= from) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t}\n\n\t\t// this.latestRequested\n\t\t// inclusive on the right side! Exclusive on the left.\n\t\tthis.latestRequested += this.payloadSize;\n\n\t\tif (this.to !== undefined) {\n\t\t\tthis.latestRequested = Math.min(this.to, this.latestRequested);\n\t\t}\n\n\t\tassert(from < this.latestRequested, 0x109 /* \"unexpected next chunk position\" */);\n\n\t\treturn { from, to: this.latestRequested };\n\t}\n\n\tprivate addRequest() {\n\t\tconst chunk = this.getNextChunk();\n\t\tif (chunk === undefined) {\n\t\t\treturn;\n\t\t}\n\t\tthis.addRequestCore(chunk.from, chunk.to).catch(this.fail.bind(this));\n\t}\n\n\tprivate async addRequestCore(fromArg: number, toArg: number) {\n\t\tassert(this.working, 0x10a /* \"cannot add parallel request while not working\" */);\n\n\t\tlet from = fromArg;\n\t\tlet to = toArg;\n\n\t\t// to & from are exclusive\n\t\tthis.requestsInFlight++;\n\t\twhile (this.working) {\n\t\t\tconst requestedLength = to - from;\n\t\t\tassert(requestedLength > 0, 0x10b /* \"invalid parallel request range\" */);\n\n\t\t\t// We should not be wasting time asking for something useless.\n\t\t\tif (this.to !== undefined) {\n\t\t\t\tassert(from < this.to, 0x10c /* \"invalid parallel request start point\" */);\n\t\t\t\tassert(to <= this.to, 0x10d /* \"invalid parallel request end point\" */);\n\t\t\t}\n\n\t\t\tthis.requests++;\n\n\t\t\tconst promise = this.requestCallback(this.requests, from, to, this.to !== undefined, {});\n\n\t\t\t// dispatch any prior received data\n\t\t\tthis.dispatch();\n\n\t\t\tconst { payload, cancel, partial } = await promise;\n\n\t\t\tif (cancel) {\n\t\t\t\tthis.cancel();\n\t\t\t}\n\n\t\t\tif (this.to !== undefined && from >= this.to) {\n\t\t\t\t// while we were waiting for response, we learned on what is the boundary\n\t\t\t\t// We can get here (with actual result!) if situation changed while this request was in\n\t\t\t\t// flight, i.e. the end was extended over what we learn in some other request\n\t\t\t\t// While it's useful not to throw this result, this is very corner cases and makes logic\n\t\t\t\t// (including consistency checks) much harder to write correctly.\n\t\t\t\t// So for now, we are throwing this result out the window.\n\t\t\t\tassert(\n\t\t\t\t\t!this.knewTo,\n\t\t\t\t\t0x10e /* \"should not throw result if we knew about boundary in advance\" */,\n\t\t\t\t);\n\t\t\t\t// Learn how often it happens and if it's too wasteful to throw these chunks.\n\t\t\t\t// If it pops into our view a lot, we would need to reconsider how we approach it.\n\t\t\t\t// Note that this is not visible to user other than potentially not hitting 100% of\n\t\t\t\t// what we can in perf domain.\n\t\t\t\tif (payload.length !== 0) {\n\t\t\t\t\tthis.logger.sendErrorEvent({\n\t\t\t\t\t\teventName: \"ParallelRequests_GotExtra\",\n\t\t\t\t\t\tfrom,\n\t\t\t\t\t\tto,\n\t\t\t\t\t\tend: this.to,\n\t\t\t\t\t\tlength: payload.length,\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tif (this.working) {\n\t\t\t\tconst fromOrig = from;\n\t\t\t\tconst length = payload.length;\n\t\t\t\tlet fullChunk = requestedLength <= length; // we can possible get more than we asked.\n\n\t\t\t\tif (length !== 0) {\n\t\t\t\t\t// We can get more than we asked for!\n\t\t\t\t\t// This can screw up logic in dispatch!\n\t\t\t\t\t// So push only batch size, and keep the rest for later - if conditions are favorable, we\n\t\t\t\t\t// will be able to use it. If not (parallel request overlapping these ops), it's easier to\n\t\t\t\t\t// discard them and wait for another (overlapping) request to come in later.\n\t\t\t\t\tif (requestedLength < length) {\n\t\t\t\t\t\t// This is error in a sense that it's not expected and likely points bug in other layer.\n\t\t\t\t\t\t// This layer copes with this situation just fine.\n\t\t\t\t\t\tthis.logger.sendTelemetryEvent({\n\t\t\t\t\t\t\teventName: \"ParallelRequests_Over\",\n\t\t\t\t\t\t\tfrom,\n\t\t\t\t\t\t\tto,\n\t\t\t\t\t\t\tlength,\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t\tconst data = payload.splice(0, requestedLength);\n\t\t\t\t\tthis.results.set(from, data);\n\t\t\t\t\tfrom += data.length;\n\t\t\t\t} else {\n\t\t\t\t\t// 1. empty (partial) chunks should not be returned by various caching / adapter layers -\n\t\t\t\t\t// they should fall back to next layer. This might be important invariant to hold to ensure\n\t\t\t\t\t// that we are less likely have bugs where such layer would keep returning empty partial\n\t\t\t\t\t// result on each call.\n\t\t\t\t\t// 2. Current invariant is that callback does retries until it gets something,\n\t\t\t\t\t// with the goal of failing if zero data is retrieved in given amount of time.\n\t\t\t\t\t// This is very specific property of storage / ops, so this logic is not here, but given only\n\t\t\t\t\t// one user of this class, we assert that to catch issues earlier.\n\t\t\t\t\t// These invariant can be relaxed if needed.\n\t\t\t\t\tassert(\n\t\t\t\t\t\t!partial,\n\t\t\t\t\t\t0x10f /* \"empty/partial chunks should not be returned by caching\" */,\n\t\t\t\t\t);\n\t\t\t\t\tassert(\n\t\t\t\t\t\t!this.knewTo,\n\t\t\t\t\t\t0x110 /* \"callback should retry until valid fetch before it learns new boundary\" */,\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tif (!partial && !fullChunk) {\n\t\t\t\t\tif (!this.knewTo) {\n\t\t\t\t\t\tif (this.to === undefined || this.to > from) {\n\t\t\t\t\t\t\t// The END\n\t\t\t\t\t\t\tthis.to = from;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\t// We know that there are more items to be retrieved\n\t\t\t\t\t// Can we get partial chunk? Ideally storage indicates that's not a full chunk\n\t\t\t\t\t// Note that it's possible that not all ops hit storage yet.\n\t\t\t\t\t// We will come back to request more, and if we can't get any more ops soon, it's\n\t\t\t\t\t// catastrophic failure (see comment above on responsibility of callback to return something)\n\t\t\t\t\t// This layer will just keep trying until it gets full set.\n\t\t\t\t\tthis.logger.sendPerformanceEvent({\n\t\t\t\t\t\teventName: \"ParallelRequests_Partial\",\n\t\t\t\t\t\tfrom: fromOrig,\n\t\t\t\t\t\tto,\n\t\t\t\t\t\tlength,\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\tif (to === this.latestRequested) {\n\t\t\t\t\t// we can go after full chunk at the end if we received partial chunk, or more than asked\n\t\t\t\t\t// Also if we got more than we asked to, we can actually use those ops!\n\t\t\t\t\twhile (payload.length !== 0) {\n\t\t\t\t\t\tconst data = payload.splice(0, requestedLength);\n\t\t\t\t\t\tthis.results.set(from, data);\n\t\t\t\t\t\tfrom += data.length;\n\t\t\t\t\t}\n\n\t\t\t\t\tthis.latestRequested = from;\n\t\t\t\t\tfullChunk = true;\n\t\t\t\t}\n\n\t\t\t\tif (fullChunk) {\n\t\t\t\t\tconst chunk = this.getNextChunk();\n\t\t\t\t\tif (chunk === undefined) {\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tfrom = chunk.from;\n\t\t\t\t\tto = chunk.to;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tthis.requestsInFlight--;\n\t\tthis.dispatch();\n\t}\n}\n\n/**\n * Helper queue class to allow async push / pull\n * It's essentially a pipe allowing multiple writers, and single reader\n * @internal\n */\nexport class Queue<T> implements IStream<T> {\n\tprivate readonly queue: Promise<IStreamResult<T>>[] = [];\n\tprivate deferred: Deferred<IStreamResult<T>> | undefined;\n\tprivate done = false;\n\n\tpublic pushValue(value: T) {\n\t\tthis.pushCore(Promise.resolve({ done: false, value }));\n\t}\n\n\tpublic pushError(error: any) {\n\t\tthis.pushCore(Promise.reject(error));\n\t\tthis.done = true;\n\t}\n\n\tpublic pushDone() {\n\t\tthis.pushCore(Promise.resolve({ done: true }));\n\t\tthis.done = true;\n\t}\n\n\tprotected pushCore(value: Promise<IStreamResult<T>>) {\n\t\tassert(!this.done, 0x112 /* \"cannot push onto queue if done\" */);\n\t\tif (this.deferred) {\n\t\t\tassert(this.queue.length === 0, 0x113 /* \"deferred queue should be empty\" */);\n\t\t\tthis.deferred.resolve(value);\n\t\t\tthis.deferred = undefined;\n\t\t} else {\n\t\t\tthis.queue.push(value);\n\t\t}\n\t}\n\n\tpublic async read(): Promise<IStreamResult<T>> {\n\t\tassert(this.deferred === undefined, 0x114 /* \"cannot pop if deferred\" */);\n\t\tconst value = this.queue.shift();\n\t\tif (value !== undefined) {\n\t\t\treturn value;\n\t\t}\n\t\tassert(!this.done, 0x115 /* \"queue should not be done during pop\" */);\n\t\tthis.deferred = new Deferred<IStreamResult<T>>();\n\t\treturn this.deferred.promise;\n\t}\n}\n\nconst waitForOnline = async (): Promise<void> => {\n\t// Only wait if we have a strong signal that we're offline - otherwise assume we're online.\n\tif (globalThis.navigator?.onLine === false && globalThis.addEventListener !== undefined) {\n\t\treturn new Promise<void>((resolve) => {\n\t\t\tconst resolveAndRemoveListener = () => {\n\t\t\t\tresolve();\n\t\t\t\tglobalThis.removeEventListener(\"online\", resolveAndRemoveListener);\n\t\t\t};\n\t\t\tglobalThis.addEventListener(\"online\", resolveAndRemoveListener);\n\t\t});\n\t}\n};\n\n/**\n * Retrieve single batch of ops\n * @param request - request index\n * @param from - inclusive boundary\n * @param to - exclusive boundary\n * @param telemetryEvent - telemetry event used to track consecutive batch of requests\n * @param strongTo - tells if ops in range from...to have to be there and have to be retrieved.\n * If false, returning less ops would mean we reached end of file.\n * @param logger - logger object to use to log progress & errors\n * @param signal - cancelation signal\n * @param scenarioName - reason for fetching ops\n * @returns An object with resulting ops and cancellation / partial result flags\n */\nasync function getSingleOpBatch(\n\tget: (telemetryProps: ITelemetryBaseProperties) => Promise<IDeltasFetchResult>,\n\tprops: ITelemetryBaseProperties,\n\tstrongTo: boolean,\n\tlogger: ITelemetryLoggerExt,\n\tsignal?: AbortSignal,\n\tscenarioName?: string,\n): Promise<{ partial: boolean; cancel: boolean; payload: ISequencedDocumentMessage[] }> {\n\tlet lastSuccessTime: number | undefined;\n\tlet totalRetryAfterTime = 0;\n\tlet telemetryEvent: PerformanceEvent | undefined;\n\tlet retry: number = 0;\n\tconst nothing = { partial: false, cancel: true, payload: [] };\n\tlet waitStartTime: number = 0;\n\tlet waitTime = MissingFetchDelayInMs;\n\n\twhile (signal?.aborted !== true) {\n\t\tretry++;\n\t\tlet lastError: unknown;\n\t\tconst startTime = performanceNow();\n\n\t\ttry {\n\t\t\t// Issue async request for deltas\n\t\t\tconst { messages, partialResult } = await get({ ...props, retry } /* telemetry props */);\n\n\t\t\t// If we got messages back, return them. Return regardless of whether we got messages back if we didn't\n\t\t\t// specify a \"to\", since we don't have an expectation of how many to receive.\n\t\t\tif (messages.length !== 0 || !strongTo) {\n\t\t\t\t// Report this event if we waited to fetch ops due to being offline or throttling.\n\t\t\t\ttelemetryEvent?.end({\n\t\t\t\t\tduration: totalRetryAfterTime,\n\t\t\t\t\t...props,\n\t\t\t\t\treason: scenarioName,\n\t\t\t\t});\n\t\t\t\treturn { payload: messages, cancel: false, partial: partialResult };\n\t\t\t}\n\n\t\t\t// Otherwise, the storage gave us back an empty set of ops but we were expecting a non-empty set.\n\n\t\t\tif (lastSuccessTime === undefined) {\n\t\t\t\t// Take timestamp of the first time server responded successfully, even though it wasn't with the ops we asked for.\n\t\t\t\t// If we keep getting empty responses we'll eventually fail out below.\n\t\t\t\tlastSuccessTime = performanceNow();\n\t\t\t} else if (performanceNow() - lastSuccessTime > 30000) {\n\t\t\t\t// If we are connected and receiving proper responses from server, but can't get any ops back,\n\t\t\t\t// then give up after some time. This likely indicates the issue with ordering service not flushing\n\t\t\t\t// ops to storage quick enough, and possibly waiting for summaries, while summarizer can't get\n\t\t\t\t// current as it can't get ops.\n\t\t\t\tthrow createGenericNetworkError(\n\t\t\t\t\t// pre-0.58 error message: failedToRetrieveOpsFromStorage:TooManyRetries\n\t\t\t\t\t\"Failed to retrieve ops from storage (Too Many Retries)\",\n\t\t\t\t\t{ canRetry: false },\n\t\t\t\t\t{\n\t\t\t\t\t\tretry,\n\t\t\t\t\t\tdriverVersion,\n\t\t\t\t\t\t...props,\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tlastError = error;\n\t\t\tconst canRetry = canRetryOnError(error);\n\n\t\t\tconst retryAfter = getRetryDelayFromError(error);\n\n\t\t\t// This will log to error table only if the error is non-retryable\n\t\t\tlogNetworkFailure(\n\t\t\t\tlogger,\n\t\t\t\t{\n\t\t\t\t\teventName: \"GetDeltas_Error\",\n\t\t\t\t\t...props,\n\t\t\t\t\tretry,\n\t\t\t\t\tduration: performanceNow() - startTime,\n\t\t\t\t\tretryAfter,\n\t\t\t\t\treason: scenarioName,\n\t\t\t\t},\n\t\t\t\terror,\n\t\t\t);\n\n\t\t\tif (!canRetry) {\n\t\t\t\t// It's game over scenario.\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t}\n\n\t\tif (telemetryEvent === undefined) {\n\t\t\twaitStartTime = performanceNow();\n\t\t\ttelemetryEvent = PerformanceEvent.start(logger, {\n\t\t\t\teventName: \"GetDeltasWaitTime\",\n\t\t\t});\n\t\t}\n\n\t\twaitTime = calculateMaxWaitTime(waitTime, lastError);\n\n\t\t// If we get here something has gone wrong - either got an unexpected empty set of messages back or a real error.\n\t\t// Either way we will wait a little bit before retrying.\n\t\tawait new Promise<void>((resolve) => {\n\t\t\tsetTimeout(resolve, waitTime);\n\t\t});\n\n\t\t// If we believe we're offline, we assume there's no point in trying until we at least think we're online.\n\t\t// NOTE: This isn't strictly true for drivers that don't require network (e.g. local driver). Really this logic\n\t\t// should probably live in the driver.\n\t\tawait waitForOnline();\n\t\ttotalRetryAfterTime += performanceNow() - waitStartTime;\n\t}\n\n\treturn nothing;\n}\n\n/**\n * Request ops from storage\n * @param get - Getter callback to get individual batches\n * @param concurrency - Number of concurrent requests to make\n * @param fromTotal - starting sequence number to fetch (inclusive)\n * @param toTotal - max (exclusive) sequence number to fetch\n * @param payloadSize - Payload size\n * @param logger - Logger to log progress and errors\n * @param signal - Cancelation signal\n * @param scenarioName - Reason for fetching ops\n * @returns Messages fetched\n * @internal\n */\nexport function requestOps(\n\tget: (\n\t\tfrom: number,\n\t\tto: number,\n\t\ttelemetryProps: ITelemetryBaseProperties,\n\t) => Promise<IDeltasFetchResult>,\n\tconcurrency: number,\n\tfromTotal: number,\n\ttoTotal: number | undefined,\n\tpayloadSize: number,\n\tlogger: ITelemetryLoggerExt,\n\tsignal?: AbortSignal,\n\tscenarioName?: string,\n): IStream<ISequencedDocumentMessage[]> {\n\tlet requests = 0;\n\tlet lastFetch: number | undefined;\n\tlet length = 0;\n\tconst queue = new Queue<ISequencedDocumentMessage[]>();\n\n\tconst propsTotal: ITelemetryBaseProperties = {\n\t\tfromTotal,\n\t\ttoTotal,\n\t};\n\n\tconst telemetryEvent = PerformanceEvent.start(logger, {\n\t\teventName: \"GetDeltas\",\n\t\t...propsTotal,\n\t\treason: scenarioName,\n\t});\n\n\tconst manager = new ParallelRequests<ISequencedDocumentMessage>(\n\t\tfromTotal,\n\t\ttoTotal,\n\t\tpayloadSize,\n\t\tlogger,\n\t\tasync (\n\t\t\trequest: number,\n\t\t\tfrom: number,\n\t\t\tto: number,\n\t\t\tstrongTo: boolean,\n\t\t\tpropsPerRequest: ITelemetryBaseProperties,\n\t\t) => {\n\t\t\trequests++;\n\t\t\treturn getSingleOpBatch(\n\t\t\t\tasync (propsAll) => get(from, to, propsAll),\n\t\t\t\t{ request, from, to, ...propsTotal, ...propsPerRequest },\n\t\t\t\tstrongTo,\n\t\t\t\tlogger,\n\t\t\t\tsignal,\n\t\t\t\tscenarioName,\n\t\t\t);\n\t\t},\n\t\t(deltas: ISequencedDocumentMessage[]) => {\n\t\t\t// Assert continuing and right start.\n\t\t\tif (lastFetch === undefined) {\n\t\t\t\tassert(deltas[0].sequenceNumber === fromTotal, 0x26d /* \"wrong start\" */);\n\t\t\t} else {\n\t\t\t\tassert(deltas[0].sequenceNumber === lastFetch + 1, 0x26e /* \"wrong start\" */);\n\t\t\t}\n\t\t\tlastFetch = deltas[deltas.length - 1].sequenceNumber;\n\t\t\tassert(\n\t\t\t\tlastFetch - deltas[0].sequenceNumber + 1 === deltas.length,\n\t\t\t\t0x26f /* \"continuous and no duplicates\" */,\n\t\t\t);\n\t\t\tlength += deltas.length;\n\t\t\tqueue.pushValue(deltas);\n\t\t},\n\t);\n\n\t// Implement faster cancellation. getSingleOpBatch() checks signal, but only in between\n\t// waits (up to 10 seconds) and fetches (can take infinite amount of time).\n\t// While every such case should be improved and take into account signal (and thus cancel immediately),\n\t// it is beneficial to have catch-all\n\tconst listener = (event: Event) => {\n\t\tmanager.cancel();\n\t};\n\tif (signal !== undefined) {\n\t\tsignal.addEventListener(\"abort\", listener);\n\t}\n\n\tmanager\n\t\t.run(concurrency)\n\t\t.finally(() => {\n\t\t\tif (signal !== undefined) {\n\t\t\t\tsignal.removeEventListener(\"abort\", listener);\n\t\t\t}\n\t\t})\n\t\t.then(() => {\n\t\t\tconst props = {\n\t\t\t\tlastFetch,\n\t\t\t\tlength,\n\t\t\t\trequests,\n\t\t\t};\n\t\t\tif (manager.canceled) {\n\t\t\t\ttelemetryEvent.cancel({ ...props, error: \"ops request cancelled by client\" });\n\t\t\t} else {\n\t\t\t\tassert(\n\t\t\t\t\ttoTotal === undefined || (lastFetch !== undefined && lastFetch >= toTotal - 1),\n\t\t\t\t\t0x270 /* \"All requested ops fetched\" */,\n\t\t\t\t);\n\t\t\t\ttelemetryEvent.end(props);\n\t\t\t}\n\t\t\tqueue.pushDone();\n\t\t})\n\t\t.catch((error) => {\n\t\t\ttelemetryEvent.cancel(\n\t\t\t\t{\n\t\t\t\t\tlastFetch,\n\t\t\t\t\tlength,\n\t\t\t\t\trequests,\n\t\t\t\t},\n\t\t\t\terror,\n\t\t\t);\n\t\t\tqueue.pushError(error);\n\t\t});\n\n\treturn queue;\n}\n\n/**\n * @internal\n */\nexport const emptyMessageStream: IStream<ISequencedDocumentMessage[]> = {\n\tread: async () => {\n\t\treturn { done: true };\n\t},\n};\n\n/**\n * @internal\n */\nexport function streamFromMessages(\n\tmessagesArg: Promise<ISequencedDocumentMessage[]>,\n): IStream<ISequencedDocumentMessage[]> {\n\tlet messages: Promise<ISequencedDocumentMessage[]> | undefined = messagesArg;\n\treturn {\n\t\tread: async () => {\n\t\t\tif (messages === undefined) {\n\t\t\t\treturn { done: true };\n\t\t\t}\n\t\t\tconst value = await messages;\n\t\t\tmessages = undefined;\n\t\t\treturn value.length === 0 ? { done: true } : { done: false, value };\n\t\t},\n\t};\n}\n\n/**\n * @internal\n */\nexport function streamObserver<T>(\n\tstream: IStream<T>,\n\thandler: (value: IStreamResult<T>) => void,\n): IStream<T> {\n\treturn {\n\t\tread: async () => {\n\t\t\tconst value = await stream.read();\n\t\t\thandler(value);\n\t\t\treturn value;\n\t\t},\n\t};\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prefetchDocumentStorageService.d.ts","sourceRoot":"","sources":["../src/prefetchDocumentStorageService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EACX,+BAA+B,E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StorageService extends DocumentStorageServiceProxy
|
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
69
|
prefetchTreeCore(tree, secondary) {
|
|
70
|
-
for (const blobKey of Object.
|
|
71
|
-
const blob = tree.blobs[blobKey];
|
|
70
|
+
for (const [blobKey, blob] of Object.entries(tree.blobs)) {
|
|
72
71
|
if (blobKey.startsWith(".") || blobKey === "header" || blobKey.startsWith("quorum")) {
|
|
73
72
|
if (blob !== null) {
|
|
74
73
|
// We don't care if the prefetch succeeds
|
|
@@ -81,8 +80,8 @@ export class PrefetchDocumentStorageService extends DocumentStorageServiceProxy
|
|
|
81
80
|
}
|
|
82
81
|
}
|
|
83
82
|
}
|
|
84
|
-
for (const subTree of Object.
|
|
85
|
-
this.prefetchTreeCore(
|
|
83
|
+
for (const subTree of Object.values(tree.trees)) {
|
|
84
|
+
this.prefetchTreeCore(subTree, secondary);
|
|
86
85
|
}
|
|
87
86
|
}
|
|
88
87
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prefetchDocumentStorageService.js","sourceRoot":"","sources":["../src/prefetchDocumentStorageService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAOH,OAAO,EAAE,mBAAmB,EAAE,MAAM,6CAA6C,CAAC;AAElF,OAAO,EAAE,2BAA2B,EAAE,MAAM,kCAAkC,CAAC;AAC/E,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAE/C;;GAEG;AACH,MAAM,OAAO,8BAA+B,SAAQ,2BAA2B;IAA/E;;QACC,qCAAqC;QACpB,kBAAa,GAAG,IAAI,GAAG,EAAoC,CAAC;QACrE,oBAAe,GAAG,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"prefetchDocumentStorageService.js","sourceRoot":"","sources":["../src/prefetchDocumentStorageService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAOH,OAAO,EAAE,mBAAmB,EAAE,MAAM,6CAA6C,CAAC;AAElF,OAAO,EAAE,2BAA2B,EAAE,MAAM,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,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;gBAC5B,CAAC;YACF,CAAC;iBAAM,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;gBAC1C,IAAI,IAAI,KAAK,IAAI,EAAE,CAAC;oBACnB,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;gBACtB,CAAC;YACF,CAAC;QACF,CAAC;QAED,KAAK,MAAM,OAAO,IAAI,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;YACjD,IAAI,CAAC,gBAAgB,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;QAC3C,CAAC;IACF,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type {\n\tIDocumentStorageServicePolicies,\n\tISnapshotTree,\n\tIVersion,\n} from \"@fluidframework/driver-definitions/internal\";\nimport { LoaderCachingPolicy } from \"@fluidframework/driver-definitions/internal\";\n\nimport { DocumentStorageServiceProxy } from \"./documentStorageServiceProxy.js\";\nimport { canRetryOnError } from \"./network.js\";\n\n/**\n * @internal\n */\nexport class PrefetchDocumentStorageService extends DocumentStorageServiceProxy {\n\t// BlobId -> blob prefetchCache cache\n\tprivate readonly prefetchCache = new Map<string, Promise<ArrayBufferLike>>();\n\tprivate prefetchEnabled = true;\n\n\tpublic get policies(): IDocumentStorageServicePolicies | undefined {\n\t\tconst policies = this.internalStorageService.policies;\n\t\tif (policies) {\n\t\t\treturn { ...policies, caching: LoaderCachingPolicy.NoCaching };\n\t\t}\n\t}\n\n\tpublic async getSnapshotTree(version?: IVersion): Promise<ISnapshotTree | null> {\n\t\tconst p = this.internalStorageService.getSnapshotTree(version);\n\t\tif (this.prefetchEnabled) {\n\t\t\t// We don't care if the prefetch succeeds\n\t\t\tvoid p.then((tree: ISnapshotTree | null | undefined) => {\n\t\t\t\tif (tree === null || tree === undefined) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tthis.prefetchTree(tree);\n\t\t\t});\n\t\t}\n\t\treturn p;\n\t}\n\n\tpublic async readBlob(blobId: string): Promise<ArrayBufferLike> {\n\t\treturn this.cachedRead(blobId);\n\t}\n\tpublic stopPrefetch() {\n\t\tthis.prefetchEnabled = false;\n\t\tthis.prefetchCache.clear();\n\t}\n\n\tprivate async cachedRead(blobId: string): Promise<ArrayBufferLike> {\n\t\tif (this.prefetchEnabled) {\n\t\t\tconst prefetchedBlobP = this.prefetchCache.get(blobId);\n\t\t\tif (prefetchedBlobP !== undefined) {\n\t\t\t\treturn prefetchedBlobP;\n\t\t\t}\n\t\t\tconst prefetchedBlobPFromStorage = this.internalStorageService.readBlob(blobId);\n\t\t\tthis.prefetchCache.set(\n\t\t\t\tblobId,\n\t\t\t\tprefetchedBlobPFromStorage.catch((error) => {\n\t\t\t\t\tif (canRetryOnError(error)) {\n\t\t\t\t\t\tthis.prefetchCache.delete(blobId);\n\t\t\t\t\t}\n\t\t\t\t\tthrow error;\n\t\t\t\t}),\n\t\t\t);\n\t\t\treturn prefetchedBlobPFromStorage;\n\t\t}\n\t\treturn this.internalStorageService.readBlob(blobId);\n\t}\n\n\tprivate prefetchTree(tree: ISnapshotTree) {\n\t\tconst secondary: string[] = [];\n\t\tthis.prefetchTreeCore(tree, secondary);\n\n\t\tfor (const blob of secondary) {\n\t\t\t// We don't care if the prefetch succeeds\n\t\t\tvoid this.cachedRead(blob);\n\t\t}\n\t}\n\n\tprivate prefetchTreeCore(tree: ISnapshotTree, secondary: string[]) {\n\t\tfor (const [blobKey, blob] of Object.entries(tree.blobs)) {\n\t\t\tif (blobKey.startsWith(\".\") || blobKey === \"header\" || blobKey.startsWith(\"quorum\")) {\n\t\t\t\tif (blob !== null) {\n\t\t\t\t\t// We don't care if the prefetch succeeds\n\t\t\t\t\tvoid this.cachedRead(blob);\n\t\t\t\t}\n\t\t\t} else if (!blobKey.startsWith(\"deltas\")) {\n\t\t\t\tif (blob !== null) {\n\t\t\t\t\tsecondary.push(blob);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tfor (const subTree of Object.values(tree.trees)) {\n\t\t\tthis.prefetchTreeCore(subTree, secondary);\n\t\t}\n\t}\n}\n"]}
|
package/lib/runWithRetry.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
import {
|
|
5
|
+
import { performanceNow } from "@fluid-internal/client-utils";
|
|
6
6
|
import { delay } from "@fluidframework/core-utils/internal";
|
|
7
7
|
import { DriverErrorTypes } from "@fluidframework/driver-definitions/internal";
|
|
8
8
|
import { isFluidError } from "@fluidframework/telemetry-utils/internal";
|
|
@@ -17,7 +17,7 @@ export async function runWithRetry(api, fetchCallName, logger, progress) {
|
|
|
17
17
|
// We double this value in first try in when we calculate time to wait for in "calculateMaxWaitTime" function.
|
|
18
18
|
let retryAfterMs = 500; // has to be positive!
|
|
19
19
|
let numRetries = 0;
|
|
20
|
-
const startTime =
|
|
20
|
+
const startTime = performanceNow();
|
|
21
21
|
let lastError;
|
|
22
22
|
do {
|
|
23
23
|
try {
|
|
@@ -30,7 +30,7 @@ export async function runWithRetry(api, fetchCallName, logger, progress) {
|
|
|
30
30
|
logger.sendTelemetryEvent({
|
|
31
31
|
eventName: `${fetchCallName}_cancel`,
|
|
32
32
|
retry: numRetries,
|
|
33
|
-
duration:
|
|
33
|
+
duration: performanceNow() - startTime,
|
|
34
34
|
fetchCallName,
|
|
35
35
|
}, err);
|
|
36
36
|
throw err;
|
|
@@ -39,7 +39,7 @@ export async function runWithRetry(api, fetchCallName, logger, progress) {
|
|
|
39
39
|
logger.sendTelemetryEvent({
|
|
40
40
|
eventName: `${fetchCallName}_runWithRetryAborted`,
|
|
41
41
|
retry: numRetries,
|
|
42
|
-
duration:
|
|
42
|
+
duration: performanceNow() - startTime,
|
|
43
43
|
fetchCallName,
|
|
44
44
|
reason: progress.cancel.reason,
|
|
45
45
|
}, err);
|
|
@@ -55,7 +55,7 @@ export async function runWithRetry(api, fetchCallName, logger, progress) {
|
|
|
55
55
|
if (numRetries === 0) {
|
|
56
56
|
logger.sendTelemetryEvent({
|
|
57
57
|
eventName: `${fetchCallName}_firstFailed`,
|
|
58
|
-
duration:
|
|
58
|
+
duration: performanceNow() - startTime,
|
|
59
59
|
fetchCallName,
|
|
60
60
|
}, err);
|
|
61
61
|
}
|
|
@@ -73,7 +73,7 @@ export async function runWithRetry(api, fetchCallName, logger, progress) {
|
|
|
73
73
|
logger.sendTelemetryEvent({
|
|
74
74
|
eventName: `${fetchCallName}_lastError`,
|
|
75
75
|
retry: numRetries,
|
|
76
|
-
duration:
|
|
76
|
+
duration: performanceNow() - startTime,
|
|
77
77
|
fetchCallName,
|
|
78
78
|
}, lastError);
|
|
79
79
|
}
|
package/lib/runWithRetry.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runWithRetry.js","sourceRoot":"","sources":["../src/runWithRetry.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"runWithRetry.js","sourceRoot":"","sources":["../src/runWithRetry.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAE,KAAK,EAAE,MAAM,qCAAqC,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAAE,MAAM,6CAA6C,CAAC;AAC/E,OAAO,EAAuB,YAAY,EAAE,MAAM,0CAA0C,CAAC;AAE7F,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AAC1F,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAmCjD;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CACjC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V,YAAY,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,sBAAsB,EAAE,CAAC,eAAe,KAAK,IAAI;QAC7E,CAAC,CAAC,4CAA4C;QAC9C,CAAC,CAAC,+CAA+C,CAClD,CAAC;IACF,OAAO,UAAU,CAAC;AACnB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { performanceNow } from \"@fluid-internal/client-utils\";\nimport { delay } from \"@fluidframework/core-utils/internal\";\nimport { DriverErrorTypes } from \"@fluidframework/driver-definitions/internal\";\nimport { ITelemetryLoggerExt, isFluidError } from \"@fluidframework/telemetry-utils/internal\";\n\nimport { NonRetryableError, canRetryOnError, getRetryDelayFromError } from \"./network.js\";\nimport { pkgVersion } from \"./packageVersion.js\";\n\n/**\n * Interface describing an object passed to various network APIs.\n * It allows caller to control cancellation, as well as learn about any delays.\n * @internal\n */\nexport interface IProgress {\n\t/**\n\t * Abort signal used to cancel operation.\n\t *\n\t * @remarks Note that most of the layers do not use this signal yet. We need to change that over time.\n\t * Please consult with API documentation / implementation.\n\t * Note that number of layers may not check this signal while holding this request in a queue,\n\t * so it may take a while it takes effect. This can be improved in the future.\n\t *\n\t * The layers in question are:\n\t *\n\t * - driver (RateLimiter)\n\t *\n\t * - runWithRetry\n\t */\n\tcancel?: AbortSignal;\n\n\t/**\n\t * Called whenever api returns cancellable error and the call is going to be retried.\n\t * Any exception thrown from this call back result in cancellation of operation\n\t * and propagation of thrown exception.\n\t * @param delayInMs - delay before next retry. This value will depend on internal back-off logic,\n\t * as well as information provided by service (like 429 error asking to wait for some time before retry)\n\t * @param error - error object returned from the call.\n\t */\n\tonRetry?(delayInMs: number, error: any): void;\n}\n\n/**\n * @internal\n */\nexport async function runWithRetry<T>(\n\tapi: (cancel?: AbortSignal) => Promise<T>,\n\tfetchCallName: string,\n\tlogger: ITelemetryLoggerExt,\n\tprogress: IProgress,\n): Promise<T> {\n\tlet result: T | undefined;\n\tlet success = false;\n\t// We double this value in first try in when we calculate time to wait for in \"calculateMaxWaitTime\" function.\n\tlet retryAfterMs = 500; // has to be positive!\n\tlet numRetries = 0;\n\tconst startTime = performanceNow();\n\tlet lastError: any;\n\tdo {\n\t\ttry {\n\t\t\tresult = await api(progress.cancel);\n\t\t\tsuccess = true;\n\t\t} catch (err) {\n\t\t\t// If it is not retriable, then just throw the error.\n\t\t\tif (!canRetryOnError(err)) {\n\t\t\t\tlogger.sendTelemetryEvent(\n\t\t\t\t\t{\n\t\t\t\t\t\teventName: `${fetchCallName}_cancel`,\n\t\t\t\t\t\tretry: numRetries,\n\t\t\t\t\t\tduration: performanceNow() - startTime,\n\t\t\t\t\t\tfetchCallName,\n\t\t\t\t\t},\n\t\t\t\t\terr,\n\t\t\t\t);\n\t\t\t\tthrow err;\n\t\t\t}\n\n\t\t\tif (progress.cancel?.aborted === true) {\n\t\t\t\tlogger.sendTelemetryEvent(\n\t\t\t\t\t{\n\t\t\t\t\t\teventName: `${fetchCallName}_runWithRetryAborted`,\n\t\t\t\t\t\tretry: numRetries,\n\t\t\t\t\t\tduration: performanceNow() - startTime,\n\t\t\t\t\t\tfetchCallName,\n\t\t\t\t\t\treason: progress.cancel.reason,\n\t\t\t\t\t},\n\t\t\t\t\terr,\n\t\t\t\t);\n\t\t\t\tthrow new NonRetryableError(\n\t\t\t\t\t\"runWithRetry was Aborted\",\n\t\t\t\t\tDriverErrorTypes.genericError,\n\t\t\t\t\t{\n\t\t\t\t\t\tdriverVersion: pkgVersion,\n\t\t\t\t\t\tfetchCallName,\n\t\t\t\t\t\treason: progress.cancel.reason,\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t}\n\n\t\t\t// logging the first failed retry instead of every attempt. We want to avoid filling telemetry\n\t\t\t// when we have tight loop of retrying in offline mode, but we also want to know what caused\n\t\t\t// the failure in the first place\n\t\t\tif (numRetries === 0) {\n\t\t\t\tlogger.sendTelemetryEvent(\n\t\t\t\t\t{\n\t\t\t\t\t\teventName: `${fetchCallName}_firstFailed`,\n\t\t\t\t\t\tduration: performanceNow() - startTime,\n\t\t\t\t\t\tfetchCallName,\n\t\t\t\t\t},\n\t\t\t\t\terr,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tnumRetries++;\n\t\t\tlastError = err;\n\t\t\t// Wait for the calculated time before retrying.\n\t\t\tretryAfterMs = calculateMaxWaitTime(retryAfterMs, err);\n\t\t\tif (progress.onRetry) {\n\t\t\t\tprogress.onRetry(retryAfterMs, err);\n\t\t\t}\n\t\t\tawait delay(retryAfterMs);\n\t\t}\n\t} while (!success);\n\tif (numRetries > 0) {\n\t\tlogger.sendTelemetryEvent(\n\t\t\t{\n\t\t\t\teventName: `${fetchCallName}_lastError`,\n\t\t\t\tretry: numRetries,\n\t\t\t\tduration: performanceNow() - startTime,\n\t\t\t\tfetchCallName,\n\t\t\t},\n\t\t\tlastError,\n\t\t);\n\t}\n\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\treturn result!;\n}\n\nconst MaxReconnectDelayInMsWhenEndpointIsReachable = 60000;\nconst MaxReconnectDelayInMsWhenEndpointIsNotReachable = 8000;\n\n/**\n * Calculates time to wait for after an error based on the error and wait time for previous iteration.\n * In case endpoint(service or socket) is not reachable, then we maybe offline or may have got some\n * transient error not related to endpoint, in that case we want to try at faster pace and hence the\n * max wait is lesser 8s as compared to when endpoint is reachable in which case it is 60s.\n * @param delayMs - wait time for previous iteration\n * @param error - error based on which we decide wait time.\n * @returns Wait time to wait for.\n * @internal\n */\nexport function calculateMaxWaitTime(delayMs: number, error: unknown): number {\n\tconst retryDelayFromError = getRetryDelayFromError(error);\n\tlet newDelayMs = Math.max(retryDelayFromError ?? 0, delayMs * 2);\n\tnewDelayMs = Math.min(\n\t\tnewDelayMs,\n\t\tisFluidError(error) && error.getTelemetryProperties().endpointReached === true\n\t\t\t? MaxReconnectDelayInMsWhenEndpointIsReachable\n\t\t\t: MaxReconnectDelayInMsWhenEndpointIsNotReachable,\n\t);\n\treturn newDelayMs;\n}\n"]}
|