@fluidframework/driver-utils 1.4.0-121020 → 2.0.0-dev-rc.1.0.0.224419
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.js +17 -7
- package/.mocharc.js +12 -0
- package/CHANGELOG.md +141 -0
- package/README.md +68 -1
- package/api-extractor-lint.json +4 -0
- package/api-extractor.json +2 -2
- package/api-report/driver-utils.api.md +401 -0
- package/dist/adapters/compression/compressionTypes.cjs +20 -0
- package/dist/adapters/compression/compressionTypes.cjs.map +1 -0
- package/dist/adapters/compression/compressionTypes.d.ts +23 -0
- package/dist/adapters/compression/compressionTypes.d.ts.map +1 -0
- package/dist/adapters/compression/documentServiceCompressionAdapter.cjs +23 -0
- package/dist/adapters/compression/documentServiceCompressionAdapter.cjs.map +1 -0
- package/dist/adapters/compression/documentServiceCompressionAdapter.d.ts +13 -0
- package/dist/adapters/compression/documentServiceCompressionAdapter.d.ts.map +1 -0
- package/dist/adapters/compression/documentServiceFactoryCompressionAdapter.cjs +31 -0
- package/dist/adapters/compression/documentServiceFactoryCompressionAdapter.cjs.map +1 -0
- package/dist/adapters/compression/documentServiceFactoryCompressionAdapter.d.ts +16 -0
- package/dist/adapters/compression/documentServiceFactoryCompressionAdapter.d.ts.map +1 -0
- package/dist/adapters/compression/index.cjs +15 -0
- package/dist/adapters/compression/index.cjs.map +1 -0
- package/dist/adapters/compression/index.d.ts +8 -0
- package/dist/adapters/compression/index.d.ts.map +1 -0
- package/dist/adapters/compression/summaryblob/documentStorageServiceSummaryBlobCompressionAdapter.cjs +370 -0
- package/dist/adapters/compression/summaryblob/documentStorageServiceSummaryBlobCompressionAdapter.cjs.map +1 -0
- package/dist/adapters/compression/summaryblob/documentStorageServiceSummaryBlobCompressionAdapter.d.ts +165 -0
- package/dist/adapters/compression/summaryblob/documentStorageServiceSummaryBlobCompressionAdapter.d.ts.map +1 -0
- package/dist/adapters/compression/summaryblob/index.cjs +11 -0
- package/dist/adapters/compression/summaryblob/index.cjs.map +1 -0
- package/dist/adapters/compression/summaryblob/index.d.ts +6 -0
- package/dist/adapters/compression/summaryblob/index.d.ts.map +1 -0
- package/dist/adapters/index.cjs +14 -0
- package/dist/adapters/index.cjs.map +1 -0
- package/dist/adapters/index.d.ts +7 -0
- package/dist/adapters/index.d.ts.map +1 -0
- package/dist/adapters/predefinedAdapters.cjs +52 -0
- package/dist/adapters/predefinedAdapters.cjs.map +1 -0
- package/dist/adapters/predefinedAdapters.d.ts +21 -0
- package/dist/adapters/predefinedAdapters.d.ts.map +1 -0
- package/dist/blob.cjs +65 -0
- package/dist/blob.cjs.map +1 -0
- package/dist/blob.d.ts +56 -0
- package/dist/blob.d.ts.map +1 -0
- package/dist/{buildSnapshotTree.js → buildSnapshotTree.cjs} +7 -5
- package/dist/buildSnapshotTree.cjs.map +1 -0
- package/dist/buildSnapshotTree.d.ts +1 -0
- package/dist/buildSnapshotTree.d.ts.map +1 -1
- package/dist/documentServiceFactoryProxy.cjs +27 -0
- package/dist/documentServiceFactoryProxy.cjs.map +1 -0
- package/dist/documentServiceFactoryProxy.d.ts +19 -0
- package/dist/documentServiceFactoryProxy.d.ts.map +1 -0
- package/dist/documentServiceProxy.cjs +36 -0
- package/dist/documentServiceProxy.cjs.map +1 -0
- package/dist/documentServiceProxy.d.ts +21 -0
- package/dist/documentServiceProxy.d.ts.map +1 -0
- package/dist/{documentStorageServiceProxy.js → documentStorageServiceProxy.cjs} +10 -8
- package/dist/documentStorageServiceProxy.cjs.map +1 -0
- package/dist/documentStorageServiceProxy.d.ts +5 -2
- package/dist/documentStorageServiceProxy.d.ts.map +1 -1
- package/dist/driver-utils-alpha.d.ts +163 -0
- package/dist/driver-utils-beta.d.ts +178 -0
- package/dist/driver-utils-public.d.ts +178 -0
- package/dist/driver-utils-untrimmed.d.ts +590 -0
- package/dist/{error.js → error.cjs} +10 -3
- package/dist/error.cjs.map +1 -0
- package/dist/error.d.ts +8 -3
- package/dist/error.d.ts.map +1 -1
- package/dist/index.cjs +69 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +16 -21
- package/dist/index.d.ts.map +1 -1
- package/dist/{insecureUrlResolver.js → insecureUrlResolver.cjs} +10 -11
- package/dist/insecureUrlResolver.cjs.map +1 -0
- package/dist/insecureUrlResolver.d.ts +1 -0
- package/dist/insecureUrlResolver.d.ts.map +1 -1
- package/dist/messageRecognition.cjs +38 -0
- package/dist/messageRecognition.cjs.map +1 -0
- package/dist/messageRecognition.d.ts +16 -26
- package/dist/messageRecognition.d.ts.map +1 -1
- package/dist/{network.js → network.cjs} +86 -24
- package/dist/network.cjs.map +1 -0
- package/dist/network.d.ts +69 -20
- package/dist/network.d.ts.map +1 -1
- package/dist/networkUtils.cjs +29 -0
- package/dist/networkUtils.cjs.map +1 -0
- package/dist/networkUtils.d.ts +4 -10
- package/dist/networkUtils.d.ts.map +1 -1
- package/dist/{packageVersion.js → packageVersion.cjs} +2 -2
- package/dist/packageVersion.cjs.map +1 -0
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.d.ts.map +1 -1
- package/dist/{parallelRequests.js → parallelRequests.cjs} +146 -74
- package/dist/parallelRequests.cjs.map +1 -0
- package/dist/parallelRequests.d.ts +19 -6
- package/dist/parallelRequests.d.ts.map +1 -1
- package/dist/{prefetchDocumentStorageService.js → prefetchDocumentStorageService.cjs} +7 -4
- package/dist/prefetchDocumentStorageService.cjs.map +1 -0
- package/dist/prefetchDocumentStorageService.d.ts +4 -2
- package/dist/prefetchDocumentStorageService.d.ts.map +1 -1
- package/dist/{rateLimiter.js → rateLimiter.cjs} +6 -3
- package/dist/rateLimiter.cjs.map +1 -0
- package/dist/rateLimiter.d.ts +3 -0
- package/dist/rateLimiter.d.ts.map +1 -1
- package/dist/readAndParse.cjs +28 -0
- package/dist/readAndParse.cjs.map +1 -0
- package/dist/readAndParse.d.ts +10 -4
- package/dist/readAndParse.d.ts.map +1 -1
- package/dist/runWithRetry.cjs +108 -0
- package/dist/runWithRetry.cjs.map +1 -0
- package/dist/runWithRetry.d.ts +26 -7
- package/dist/runWithRetry.d.ts.map +1 -1
- package/dist/{summaryForCreateNew.js → summaryForCreateNew.cjs} +20 -19
- package/dist/summaryForCreateNew.cjs.map +1 -0
- package/dist/summaryForCreateNew.d.ts +17 -4
- package/dist/summaryForCreateNew.d.ts.map +1 -1
- package/dist/{treeConversions.js → treeConversions.cjs} +16 -18
- package/dist/treeConversions.cjs.map +1 -0
- package/dist/treeConversions.d.ts +1 -0
- package/dist/treeConversions.d.ts.map +1 -1
- package/dist/tsdoc-metadata.json +11 -0
- package/lib/adapters/compression/compressionTypes.d.mts +23 -0
- package/lib/adapters/compression/compressionTypes.d.mts.map +1 -0
- package/lib/adapters/compression/compressionTypes.mjs +17 -0
- package/lib/adapters/compression/compressionTypes.mjs.map +1 -0
- package/lib/adapters/compression/documentServiceCompressionAdapter.d.mts +13 -0
- package/lib/adapters/compression/documentServiceCompressionAdapter.d.mts.map +1 -0
- package/lib/adapters/compression/documentServiceCompressionAdapter.mjs +19 -0
- package/lib/adapters/compression/documentServiceCompressionAdapter.mjs.map +1 -0
- package/lib/adapters/compression/documentServiceFactoryCompressionAdapter.d.mts +16 -0
- package/lib/adapters/compression/documentServiceFactoryCompressionAdapter.d.mts.map +1 -0
- package/lib/adapters/compression/documentServiceFactoryCompressionAdapter.mjs +27 -0
- package/lib/adapters/compression/documentServiceFactoryCompressionAdapter.mjs.map +1 -0
- package/lib/adapters/compression/index.d.mts +8 -0
- package/lib/adapters/compression/index.d.mts.map +1 -0
- package/lib/adapters/compression/index.mjs +8 -0
- package/lib/adapters/compression/index.mjs.map +1 -0
- package/lib/adapters/compression/summaryblob/documentStorageServiceSummaryBlobCompressionAdapter.d.mts +165 -0
- package/lib/adapters/compression/summaryblob/documentStorageServiceSummaryBlobCompressionAdapter.d.mts.map +1 -0
- package/lib/adapters/compression/summaryblob/documentStorageServiceSummaryBlobCompressionAdapter.mjs +366 -0
- package/lib/adapters/compression/summaryblob/documentStorageServiceSummaryBlobCompressionAdapter.mjs.map +1 -0
- package/lib/adapters/compression/summaryblob/index.d.mts +6 -0
- package/lib/adapters/compression/summaryblob/index.d.mts.map +1 -0
- package/lib/adapters/compression/summaryblob/index.mjs +6 -0
- package/lib/adapters/compression/summaryblob/index.mjs.map +1 -0
- package/lib/adapters/index.d.mts +7 -0
- package/lib/adapters/index.d.mts.map +1 -0
- package/lib/adapters/index.mjs +7 -0
- package/lib/adapters/index.mjs.map +1 -0
- package/lib/adapters/predefinedAdapters.d.mts +21 -0
- package/lib/adapters/predefinedAdapters.d.mts.map +1 -0
- package/lib/adapters/predefinedAdapters.mjs +47 -0
- package/lib/adapters/predefinedAdapters.mjs.map +1 -0
- package/lib/blob.d.mts +56 -0
- package/lib/blob.d.mts.map +1 -0
- package/lib/blob.mjs +59 -0
- package/lib/blob.mjs.map +1 -0
- package/lib/{buildSnapshotTree.d.ts → buildSnapshotTree.d.mts} +1 -0
- package/lib/buildSnapshotTree.d.mts.map +1 -0
- package/lib/{buildSnapshotTree.js → buildSnapshotTree.mjs} +6 -4
- package/lib/buildSnapshotTree.mjs.map +1 -0
- package/lib/documentServiceFactoryProxy.d.mts +19 -0
- package/lib/documentServiceFactoryProxy.d.mts.map +1 -0
- package/lib/documentServiceFactoryProxy.mjs +23 -0
- package/lib/documentServiceFactoryProxy.mjs.map +1 -0
- package/lib/documentServiceProxy.d.mts +21 -0
- package/lib/documentServiceProxy.d.mts.map +1 -0
- package/lib/documentServiceProxy.mjs +32 -0
- package/lib/documentServiceProxy.mjs.map +1 -0
- package/lib/{documentStorageServiceProxy.d.ts → documentStorageServiceProxy.d.mts} +5 -2
- package/lib/documentStorageServiceProxy.d.mts.map +1 -0
- package/lib/{documentStorageServiceProxy.js → documentStorageServiceProxy.mjs} +10 -8
- package/lib/documentStorageServiceProxy.mjs.map +1 -0
- package/lib/driver-utils-alpha.d.mts +163 -0
- package/lib/driver-utils-beta.d.mts +178 -0
- package/lib/driver-utils-public.d.mts +178 -0
- package/lib/driver-utils-untrimmed.d.mts +590 -0
- package/lib/error.d.mts +16 -0
- package/lib/error.d.mts.map +1 -0
- package/lib/error.mjs +19 -0
- package/lib/error.mjs.map +1 -0
- package/lib/index.d.mts +21 -0
- package/lib/index.d.mts.map +1 -0
- package/lib/index.mjs +21 -0
- package/lib/index.mjs.map +1 -0
- package/lib/{insecureUrlResolver.d.ts → insecureUrlResolver.d.mts} +1 -0
- package/lib/insecureUrlResolver.d.mts.map +1 -0
- package/lib/{insecureUrlResolver.js → insecureUrlResolver.mjs} +10 -11
- package/lib/insecureUrlResolver.mjs.map +1 -0
- package/lib/messageRecognition.d.mts +24 -0
- package/lib/messageRecognition.d.mts.map +1 -0
- package/lib/messageRecognition.mjs +29 -0
- package/lib/messageRecognition.mjs.map +1 -0
- package/lib/{network.d.ts → network.d.mts} +69 -20
- package/lib/network.d.mts.map +1 -0
- package/lib/{network.js → network.mjs} +85 -23
- package/lib/network.mjs.map +1 -0
- package/lib/networkUtils.d.mts +11 -0
- package/lib/networkUtils.d.mts.map +1 -0
- package/lib/networkUtils.mjs +25 -0
- package/lib/networkUtils.mjs.map +1 -0
- package/lib/{packageVersion.d.ts → packageVersion.d.mts} +1 -1
- package/lib/{packageVersion.d.ts.map → packageVersion.d.mts.map} +1 -1
- package/lib/{packageVersion.js → packageVersion.mjs} +2 -2
- package/lib/packageVersion.mjs.map +1 -0
- package/lib/{parallelRequests.d.ts → parallelRequests.d.mts} +19 -6
- package/lib/parallelRequests.d.mts.map +1 -0
- package/lib/{parallelRequests.js → parallelRequests.mjs} +119 -52
- package/lib/parallelRequests.mjs.map +1 -0
- package/lib/{prefetchDocumentStorageService.d.ts → prefetchDocumentStorageService.d.mts} +5 -7
- package/lib/prefetchDocumentStorageService.d.mts.map +1 -0
- package/lib/{prefetchDocumentStorageService.js → prefetchDocumentStorageService.mjs} +7 -8
- package/lib/prefetchDocumentStorageService.mjs.map +1 -0
- package/lib/{rateLimiter.d.ts → rateLimiter.d.mts} +3 -0
- package/lib/rateLimiter.d.mts.map +1 -0
- package/lib/{rateLimiter.js → rateLimiter.mjs} +5 -2
- package/lib/rateLimiter.mjs.map +1 -0
- package/lib/readAndParse.d.mts +20 -0
- package/lib/readAndParse.d.mts.map +1 -0
- package/lib/readAndParse.mjs +24 -0
- package/lib/readAndParse.mjs.map +1 -0
- package/lib/{runWithRetry.d.ts → runWithRetry.d.mts} +26 -7
- package/lib/runWithRetry.d.mts.map +1 -0
- package/lib/runWithRetry.mjs +103 -0
- package/lib/runWithRetry.mjs.map +1 -0
- package/lib/{summaryForCreateNew.d.ts → summaryForCreateNew.d.mts} +17 -4
- package/lib/summaryForCreateNew.d.mts.map +1 -0
- package/lib/{summaryForCreateNew.js → summaryForCreateNew.mjs} +18 -17
- package/lib/summaryForCreateNew.mjs.map +1 -0
- package/lib/{treeConversions.d.ts → treeConversions.d.mts} +1 -0
- package/lib/treeConversions.d.mts.map +1 -0
- package/lib/{treeConversions.js → treeConversions.mjs} +12 -14
- package/lib/treeConversions.mjs.map +1 -0
- package/package.json +88 -64
- package/prettier.config.cjs +8 -0
- package/src/adapters/compression/compressionTypes.ts +25 -0
- package/src/adapters/compression/documentServiceCompressionAdapter.ts +28 -0
- package/src/adapters/compression/documentServiceFactoryCompressionAdapter.ts +54 -0
- package/src/adapters/compression/index.ts +12 -0
- package/src/adapters/compression/summaryblob/documentStorageServiceSummaryBlobCompressionAdapter.ts +451 -0
- package/src/adapters/compression/summaryblob/index.ts +9 -0
- package/src/adapters/index.ts +13 -0
- package/src/adapters/predefinedAdapters.ts +74 -0
- package/src/blob.ts +77 -0
- package/src/buildSnapshotTree.ts +58 -53
- package/src/documentServiceFactoryProxy.ts +47 -0
- package/src/documentServiceProxy.ts +46 -0
- package/src/documentStorageServiceProxy.ts +52 -37
- package/src/error.ts +13 -8
- package/src/index.ts +51 -21
- package/src/insecureUrlResolver.ts +125 -120
- package/src/messageRecognition.ts +24 -53
- package/src/network.ts +189 -111
- package/src/networkUtils.ts +24 -49
- package/src/packageVersion.ts +1 -1
- package/src/parallelRequests.ts +630 -519
- package/src/prefetchDocumentStorageService.ts +79 -74
- package/src/rateLimiter.ts +33 -30
- package/src/readAndParse.ts +18 -9
- package/src/runWithRetry.ts +145 -85
- package/src/summaryForCreateNew.ts +48 -29
- package/src/treeConversions.ts +49 -70
- package/tsc-multi.test.json +4 -0
- package/tsconfig.json +10 -12
- package/dist/blobAggregationStorage.d.ts +0 -43
- package/dist/blobAggregationStorage.d.ts.map +0 -1
- package/dist/blobAggregationStorage.js +0 -318
- package/dist/blobAggregationStorage.js.map +0 -1
- package/dist/blobCacheStorageService.d.ts +0 -16
- package/dist/blobCacheStorageService.d.ts.map +0 -1
- package/dist/blobCacheStorageService.js +0 -29
- package/dist/blobCacheStorageService.js.map +0 -1
- package/dist/buildSnapshotTree.js.map +0 -1
- package/dist/documentStorageServiceProxy.js.map +0 -1
- package/dist/emptyDocumentDeltaStorageService.d.ts +0 -13
- package/dist/emptyDocumentDeltaStorageService.d.ts.map +0 -1
- package/dist/emptyDocumentDeltaStorageService.js +0 -20
- package/dist/emptyDocumentDeltaStorageService.js.map +0 -1
- package/dist/error.js.map +0 -1
- package/dist/fluidResolvedUrl.d.ts +0 -8
- package/dist/fluidResolvedUrl.d.ts.map +0 -1
- package/dist/fluidResolvedUrl.js +0 -16
- package/dist/fluidResolvedUrl.js.map +0 -1
- package/dist/index.js +0 -38
- package/dist/index.js.map +0 -1
- package/dist/insecureUrlResolver.js.map +0 -1
- package/dist/messageRecognition.js +0 -73
- package/dist/messageRecognition.js.map +0 -1
- package/dist/multiDocumentServiceFactory.d.ts +0 -16
- package/dist/multiDocumentServiceFactory.d.ts.map +0 -1
- package/dist/multiDocumentServiceFactory.js +0 -63
- package/dist/multiDocumentServiceFactory.js.map +0 -1
- package/dist/multiUrlResolver.d.ts +0 -20
- package/dist/multiUrlResolver.d.ts.map +0 -1
- package/dist/multiUrlResolver.js +0 -45
- package/dist/multiUrlResolver.js.map +0 -1
- package/dist/network.js.map +0 -1
- package/dist/networkUtils.js +0 -59
- package/dist/networkUtils.js.map +0 -1
- package/dist/packageVersion.js.map +0 -1
- package/dist/parallelRequests.js.map +0 -1
- package/dist/prefetchDocumentStorageService.js.map +0 -1
- package/dist/rateLimiter.js.map +0 -1
- package/dist/readAndParse.js +0 -22
- package/dist/readAndParse.js.map +0 -1
- package/dist/runWithRetry.js +0 -69
- package/dist/runWithRetry.js.map +0 -1
- package/dist/summaryForCreateNew.js.map +0 -1
- package/dist/treeConversions.js.map +0 -1
- package/dist/treeUtils.d.ts +0 -51
- package/dist/treeUtils.d.ts.map +0 -1
- package/dist/treeUtils.js +0 -85
- package/dist/treeUtils.js.map +0 -1
- package/lib/blobAggregationStorage.d.ts +0 -43
- package/lib/blobAggregationStorage.d.ts.map +0 -1
- package/lib/blobAggregationStorage.js +0 -313
- package/lib/blobAggregationStorage.js.map +0 -1
- package/lib/blobCacheStorageService.d.ts +0 -16
- package/lib/blobCacheStorageService.d.ts.map +0 -1
- package/lib/blobCacheStorageService.js +0 -25
- package/lib/blobCacheStorageService.js.map +0 -1
- package/lib/buildSnapshotTree.d.ts.map +0 -1
- package/lib/buildSnapshotTree.js.map +0 -1
- package/lib/documentStorageServiceProxy.d.ts.map +0 -1
- package/lib/documentStorageServiceProxy.js.map +0 -1
- package/lib/emptyDocumentDeltaStorageService.d.ts +0 -13
- package/lib/emptyDocumentDeltaStorageService.d.ts.map +0 -1
- package/lib/emptyDocumentDeltaStorageService.js +0 -16
- package/lib/emptyDocumentDeltaStorageService.js.map +0 -1
- package/lib/error.d.ts +0 -11
- package/lib/error.d.ts.map +0 -1
- package/lib/error.js +0 -13
- package/lib/error.js.map +0 -1
- package/lib/fluidResolvedUrl.d.ts +0 -8
- package/lib/fluidResolvedUrl.d.ts.map +0 -1
- package/lib/fluidResolvedUrl.js +0 -11
- package/lib/fluidResolvedUrl.js.map +0 -1
- package/lib/index.d.ts +0 -26
- package/lib/index.d.ts.map +0 -1
- package/lib/index.js +0 -26
- package/lib/index.js.map +0 -1
- package/lib/insecureUrlResolver.d.ts.map +0 -1
- package/lib/insecureUrlResolver.js.map +0 -1
- package/lib/messageRecognition.d.ts +0 -38
- package/lib/messageRecognition.d.ts.map +0 -1
- package/lib/messageRecognition.js +0 -67
- package/lib/messageRecognition.js.map +0 -1
- package/lib/multiDocumentServiceFactory.d.ts +0 -16
- package/lib/multiDocumentServiceFactory.d.ts.map +0 -1
- package/lib/multiDocumentServiceFactory.js +0 -59
- package/lib/multiDocumentServiceFactory.js.map +0 -1
- package/lib/multiUrlResolver.d.ts +0 -20
- package/lib/multiUrlResolver.d.ts.map +0 -1
- package/lib/multiUrlResolver.js +0 -40
- package/lib/multiUrlResolver.js.map +0 -1
- package/lib/network.d.ts.map +0 -1
- package/lib/network.js.map +0 -1
- package/lib/networkUtils.d.ts +0 -17
- package/lib/networkUtils.d.ts.map +0 -1
- package/lib/networkUtils.js +0 -54
- package/lib/networkUtils.js.map +0 -1
- package/lib/packageVersion.js.map +0 -1
- package/lib/parallelRequests.d.ts.map +0 -1
- package/lib/parallelRequests.js.map +0 -1
- package/lib/prefetchDocumentStorageService.d.ts.map +0 -1
- package/lib/prefetchDocumentStorageService.js.map +0 -1
- package/lib/rateLimiter.d.ts.map +0 -1
- package/lib/rateLimiter.js.map +0 -1
- package/lib/readAndParse.d.ts +0 -14
- package/lib/readAndParse.d.ts.map +0 -1
- package/lib/readAndParse.js +0 -18
- package/lib/readAndParse.js.map +0 -1
- package/lib/runWithRetry.d.ts.map +0 -1
- package/lib/runWithRetry.js +0 -65
- package/lib/runWithRetry.js.map +0 -1
- package/lib/summaryForCreateNew.d.ts.map +0 -1
- package/lib/summaryForCreateNew.js.map +0 -1
- package/lib/treeConversions.d.ts.map +0 -1
- package/lib/treeConversions.js.map +0 -1
- package/lib/treeUtils.d.ts +0 -51
- package/lib/treeUtils.d.ts.map +0 -1
- package/lib/treeUtils.js +0 -80
- package/lib/treeUtils.js.map +0 -1
- package/src/blobAggregationStorage.ts +0 -374
- package/src/blobCacheStorageService.ts +0 -32
- package/src/emptyDocumentDeltaStorageService.ts +0 -24
- package/src/fluidResolvedUrl.ts +0 -15
- package/src/multiDocumentServiceFactory.ts +0 -80
- package/src/multiUrlResolver.ts +0 -51
- package/src/treeUtils.ts +0 -111
- package/tsconfig.esnext.json +0 -7
package/src/parallelRequests.ts
CHANGED
|
@@ -2,18 +2,20 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
5
|
+
import { performance } from "@fluid-internal/client-utils";
|
|
6
|
+
import { ITelemetryProperties } from "@fluidframework/core-interfaces";
|
|
7
|
+
import { assert, Deferred } from "@fluidframework/core-utils";
|
|
8
|
+
import { ITelemetryLoggerExt, PerformanceEvent } from "@fluidframework/telemetry-utils";
|
|
8
9
|
import { ISequencedDocumentMessage } from "@fluidframework/protocol-definitions";
|
|
9
10
|
import { IDeltasFetchResult, IStream, IStreamResult } from "@fluidframework/driver-definitions";
|
|
10
11
|
import { getRetryDelayFromError, canRetryOnError, createGenericNetworkError } from "./network";
|
|
11
|
-
import {
|
|
12
|
+
import { logNetworkFailure } from "./networkUtils";
|
|
12
13
|
// For now, this package is versioned and released in unison with the specific drivers
|
|
13
14
|
import { pkgVersion as driverVersion } from "./packageVersion";
|
|
15
|
+
import { calculateMaxWaitTime } from "./runWithRetry";
|
|
14
16
|
|
|
15
|
-
|
|
16
|
-
const MissingFetchDelayInMs =
|
|
17
|
+
// We double this value in first try in when we calculate time to wait for in "calculateMaxWaitTime" function.
|
|
18
|
+
const MissingFetchDelayInMs = 50;
|
|
17
19
|
|
|
18
20
|
type WorkingState = "working" | "done" | "canceled";
|
|
19
21
|
|
|
@@ -23,329 +25,378 @@ type WorkingState = "working" | "done" | "canceled";
|
|
|
23
25
|
* data in the right order. Take a look at UT for examples.
|
|
24
26
|
* @param concurrency - level of concurrency
|
|
25
27
|
* @param from - starting point of fetching data (inclusive)
|
|
26
|
-
* @param to
|
|
28
|
+
* @param to - ending point of fetching data. exclusive, or undefined if unknown
|
|
27
29
|
* @param payloadSize - batch size
|
|
28
30
|
* @param logger - logger to use
|
|
29
31
|
* @param requestCallback - callback to request batches
|
|
30
|
-
* @returns
|
|
32
|
+
* @returns Queue that can be used to retrieve data
|
|
33
|
+
* @internal
|
|
31
34
|
*/
|
|
32
35
|
export class ParallelRequests<T> {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
36
|
+
private latestRequested: number;
|
|
37
|
+
private nextToDeliver: number;
|
|
38
|
+
private readonly results = new Map<number, T[]>();
|
|
39
|
+
private workingState: WorkingState = "working";
|
|
40
|
+
private requestsInFlight = 0;
|
|
41
|
+
private readonly endEvent = new Deferred<void>();
|
|
42
|
+
private requests = 0;
|
|
43
|
+
private readonly knewTo: boolean;
|
|
44
|
+
|
|
45
|
+
private get working() {
|
|
46
|
+
return this.workingState === "working";
|
|
47
|
+
}
|
|
48
|
+
public get canceled() {
|
|
49
|
+
return this.workingState === "canceled";
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
constructor(
|
|
53
|
+
from: number,
|
|
54
|
+
private to: number | undefined,
|
|
55
|
+
private readonly payloadSize: number,
|
|
56
|
+
private readonly logger: ITelemetryLoggerExt,
|
|
57
|
+
private readonly requestCallback: (
|
|
58
|
+
request: number,
|
|
59
|
+
from: number,
|
|
60
|
+
to: number,
|
|
61
|
+
strongTo: boolean,
|
|
62
|
+
props: ITelemetryProperties,
|
|
63
|
+
) => Promise<{ partial: boolean; cancel: boolean; payload: T[] }>,
|
|
64
|
+
private readonly responseCallback: (payload: T[]) => void,
|
|
65
|
+
) {
|
|
66
|
+
this.latestRequested = from;
|
|
67
|
+
this.nextToDeliver = from;
|
|
68
|
+
this.knewTo = to !== undefined;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
public cancel() {
|
|
72
|
+
if (this.working) {
|
|
73
|
+
this.workingState = "canceled";
|
|
74
|
+
this.endEvent.resolve();
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
public async run(concurrency: number) {
|
|
79
|
+
assert(concurrency > 0, 0x102 /* "invalid level of concurrency" */);
|
|
80
|
+
assert(this.working, 0x103 /* "trying to parallel run while not working" */);
|
|
81
|
+
|
|
82
|
+
let c = concurrency;
|
|
83
|
+
while (c > 0) {
|
|
84
|
+
c--;
|
|
85
|
+
this.addRequest();
|
|
86
|
+
}
|
|
87
|
+
this.dispatch(); // will recalculate and trigger this.endEvent if needed
|
|
88
|
+
return this.endEvent.promise;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
private done() {
|
|
92
|
+
// We should satisfy request fully.
|
|
93
|
+
assert(this.to !== undefined, 0x104 /* "undefined end point for parallel fetch" */);
|
|
94
|
+
assert(
|
|
95
|
+
this.nextToDeliver >= this.to,
|
|
96
|
+
0x105 /* "unexpected end point for parallel fetch" */,
|
|
97
|
+
);
|
|
98
|
+
if (this.working) {
|
|
99
|
+
this.workingState = "done";
|
|
100
|
+
this.endEvent.resolve();
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
private fail(error) {
|
|
105
|
+
if (this.working) {
|
|
106
|
+
this.workingState = "done";
|
|
107
|
+
this.endEvent.reject(error);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
private dispatch() {
|
|
112
|
+
while (this.working) {
|
|
113
|
+
const value = this.results.get(this.nextToDeliver);
|
|
114
|
+
if (value === undefined) {
|
|
115
|
+
break;
|
|
116
|
+
}
|
|
117
|
+
this.results.delete(this.nextToDeliver);
|
|
118
|
+
assert(
|
|
119
|
+
value.length <= this.payloadSize,
|
|
120
|
+
0x1d9 /* "addRequestCore() should break into smaller chunks" */,
|
|
121
|
+
);
|
|
122
|
+
this.nextToDeliver += value.length;
|
|
123
|
+
this.responseCallback(value);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// Account for cancellation - state might be not in consistent state on cancelling operation
|
|
127
|
+
if (this.working) {
|
|
128
|
+
if (this.requestsInFlight === 0) {
|
|
129
|
+
// we should have dispatched everything, no matter whether we knew about the end or not.
|
|
130
|
+
// see comment in addRequestCore() around throwing away chunk if it's above this.to
|
|
131
|
+
assert(
|
|
132
|
+
this.results.size === 0,
|
|
133
|
+
0x107 /* "ending dispatch with remaining results to be sent" */,
|
|
134
|
+
);
|
|
135
|
+
this.done();
|
|
136
|
+
} else if (this.to !== undefined && this.nextToDeliver >= this.to) {
|
|
137
|
+
// Learned about the end and dispatched all the ops up to it.
|
|
138
|
+
// Ignore all the in-flight requests above boundary - unblock caller sooner.
|
|
139
|
+
assert(
|
|
140
|
+
!this.knewTo,
|
|
141
|
+
0x108 /* "ending results dispatch but knew in advance about more requests" */,
|
|
142
|
+
);
|
|
143
|
+
this.done();
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
private getNextChunk() {
|
|
149
|
+
if (!this.working) {
|
|
150
|
+
return undefined;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
const from = this.latestRequested;
|
|
154
|
+
if (this.to !== undefined) {
|
|
155
|
+
if (this.to <= from) {
|
|
156
|
+
return undefined;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
// this.latestRequested
|
|
161
|
+
// inclusive on the right side! Exclusive on the left.
|
|
162
|
+
this.latestRequested += this.payloadSize;
|
|
163
|
+
|
|
164
|
+
if (this.to !== undefined) {
|
|
165
|
+
this.latestRequested = Math.min(this.to, this.latestRequested);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
assert(from < this.latestRequested, 0x109 /* "unexpected next chunk position" */);
|
|
169
|
+
|
|
170
|
+
return { from, to: this.latestRequested };
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
private addRequest() {
|
|
174
|
+
const chunk = this.getNextChunk();
|
|
175
|
+
if (chunk === undefined) {
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
this.addRequestCore(chunk.from, chunk.to).catch(this.fail.bind(this));
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
private async addRequestCore(fromArg: number, toArg: number) {
|
|
182
|
+
assert(this.working, 0x10a /* "cannot add parallel request while not working" */);
|
|
183
|
+
|
|
184
|
+
let from = fromArg;
|
|
185
|
+
let to = toArg;
|
|
186
|
+
|
|
187
|
+
// to & from are exclusive
|
|
188
|
+
this.requestsInFlight++;
|
|
189
|
+
while (this.working) {
|
|
190
|
+
const requestedLength = to - from;
|
|
191
|
+
assert(requestedLength > 0, 0x10b /* "invalid parallel request range" */);
|
|
192
|
+
|
|
193
|
+
// We should not be wasting time asking for something useless.
|
|
194
|
+
if (this.to !== undefined) {
|
|
195
|
+
assert(from < this.to, 0x10c /* "invalid parallel request start point" */);
|
|
196
|
+
assert(to <= this.to, 0x10d /* "invalid parallel request end point" */);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
this.requests++;
|
|
200
|
+
|
|
201
|
+
const promise = this.requestCallback(
|
|
202
|
+
this.requests,
|
|
203
|
+
from,
|
|
204
|
+
to,
|
|
205
|
+
this.to !== undefined,
|
|
206
|
+
{},
|
|
207
|
+
);
|
|
208
|
+
|
|
209
|
+
// dispatch any prior received data
|
|
210
|
+
this.dispatch();
|
|
211
|
+
|
|
212
|
+
const { payload, cancel, partial } = await promise;
|
|
213
|
+
|
|
214
|
+
if (cancel) {
|
|
215
|
+
this.cancel();
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
if (this.to !== undefined && from >= this.to) {
|
|
219
|
+
// while we were waiting for response, we learned on what is the boundary
|
|
220
|
+
// We can get here (with actual result!) if situation changed while this request was in
|
|
221
|
+
// flight, i.e. the end was extended over what we learn in some other request
|
|
222
|
+
// While it's useful not to throw this result, this is very corner cases and makes logic
|
|
223
|
+
// (including consistency checks) much harder to write correctly.
|
|
224
|
+
// So for now, we are throwing this result out the window.
|
|
225
|
+
assert(
|
|
226
|
+
!this.knewTo,
|
|
227
|
+
0x10e /* "should not throw result if we knew about boundary in advance" */,
|
|
228
|
+
);
|
|
229
|
+
// Learn how often it happens and if it's too wasteful to throw these chunks.
|
|
230
|
+
// If it pops into our view a lot, we would need to reconsider how we approach it.
|
|
231
|
+
// Note that this is not visible to user other than potentially not hitting 100% of
|
|
232
|
+
// what we can in perf domain.
|
|
233
|
+
if (payload.length !== 0) {
|
|
234
|
+
this.logger.sendErrorEvent({
|
|
235
|
+
eventName: "ParallelRequests_GotExtra",
|
|
236
|
+
from,
|
|
237
|
+
to,
|
|
238
|
+
end: this.to,
|
|
239
|
+
length: payload.length,
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
break;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
if (this.working) {
|
|
247
|
+
const fromOrig = from;
|
|
248
|
+
const length = payload.length;
|
|
249
|
+
let fullChunk = requestedLength <= length; // we can possible get more than we asked.
|
|
250
|
+
|
|
251
|
+
if (length !== 0) {
|
|
252
|
+
// We can get more than we asked for!
|
|
253
|
+
// This can screw up logic in dispatch!
|
|
254
|
+
// So push only batch size, and keep the rest for later - if conditions are favorable, we
|
|
255
|
+
// will be able to use it. If not (parallel request overlapping these ops), it's easier to
|
|
256
|
+
// discard them and wait for another (overlapping) request to come in later.
|
|
257
|
+
if (requestedLength < length) {
|
|
258
|
+
// This is error in a sense that it's not expected and likely points bug in other layer.
|
|
259
|
+
// This layer copes with this situation just fine.
|
|
260
|
+
this.logger.sendTelemetryEvent({
|
|
261
|
+
eventName: "ParallelRequests_Over",
|
|
262
|
+
from,
|
|
263
|
+
to,
|
|
264
|
+
length,
|
|
265
|
+
});
|
|
266
|
+
}
|
|
267
|
+
const data = payload.splice(0, requestedLength);
|
|
268
|
+
this.results.set(from, data);
|
|
269
|
+
from += data.length;
|
|
270
|
+
} else {
|
|
271
|
+
// 1. empty (partial) chunks should not be returned by various caching / adapter layers -
|
|
272
|
+
// they should fall back to next layer. This might be important invariant to hold to ensure
|
|
273
|
+
// that we are less likely have bugs where such layer would keep returning empty partial
|
|
274
|
+
// result on each call.
|
|
275
|
+
// 2. Current invariant is that callback does retries until it gets something,
|
|
276
|
+
// with the goal of failing if zero data is retrieved in given amount of time.
|
|
277
|
+
// This is very specific property of storage / ops, so this logic is not here, but given only
|
|
278
|
+
// one user of this class, we assert that to catch issues earlier.
|
|
279
|
+
// These invariant can be relaxed if needed.
|
|
280
|
+
assert(
|
|
281
|
+
!partial,
|
|
282
|
+
0x10f /* "empty/partial chunks should not be returned by caching" */,
|
|
283
|
+
);
|
|
284
|
+
assert(
|
|
285
|
+
!this.knewTo,
|
|
286
|
+
0x110 /* "callback should retry until valid fetch before it learns new boundary" */,
|
|
287
|
+
);
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
if (!partial && !fullChunk) {
|
|
291
|
+
if (!this.knewTo) {
|
|
292
|
+
if (this.to === undefined || this.to > from) {
|
|
293
|
+
// The END
|
|
294
|
+
this.to = from;
|
|
295
|
+
}
|
|
296
|
+
break;
|
|
297
|
+
}
|
|
298
|
+
// We know that there are more items to be retrieved
|
|
299
|
+
// Can we get partial chunk? Ideally storage indicates that's not a full chunk
|
|
300
|
+
// Note that it's possible that not all ops hit storage yet.
|
|
301
|
+
// We will come back to request more, and if we can't get any more ops soon, it's
|
|
302
|
+
// catastrophic failure (see comment above on responsibility of callback to return something)
|
|
303
|
+
// This layer will just keep trying until it gets full set.
|
|
304
|
+
this.logger.sendPerformanceEvent({
|
|
305
|
+
eventName: "ParallelRequests_Partial",
|
|
306
|
+
from: fromOrig,
|
|
307
|
+
to,
|
|
308
|
+
length,
|
|
309
|
+
});
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
if (to === this.latestRequested) {
|
|
313
|
+
// we can go after full chunk at the end if we received partial chunk, or more than asked
|
|
314
|
+
// Also if we got more than we asked to, we can actually use those ops!
|
|
315
|
+
while (payload.length !== 0) {
|
|
316
|
+
const data = payload.splice(0, requestedLength);
|
|
317
|
+
this.results.set(from, data);
|
|
318
|
+
from += data.length;
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
this.latestRequested = from;
|
|
322
|
+
fullChunk = true;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
if (fullChunk) {
|
|
326
|
+
const chunk = this.getNextChunk();
|
|
327
|
+
if (chunk === undefined) {
|
|
328
|
+
break;
|
|
329
|
+
}
|
|
330
|
+
from = chunk.from;
|
|
331
|
+
to = chunk.to;
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
this.requestsInFlight--;
|
|
336
|
+
this.dispatch();
|
|
337
|
+
}
|
|
301
338
|
}
|
|
302
339
|
|
|
303
340
|
/**
|
|
304
341
|
* Helper queue class to allow async push / pull
|
|
305
342
|
* It's essentially a pipe allowing multiple writers, and single reader
|
|
343
|
+
* @internal
|
|
306
344
|
*/
|
|
307
345
|
export class Queue<T> implements IStream<T> {
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
346
|
+
private readonly queue: Promise<IStreamResult<T>>[] = [];
|
|
347
|
+
private deferred: Deferred<IStreamResult<T>> | undefined;
|
|
348
|
+
private done = false;
|
|
349
|
+
|
|
350
|
+
public pushValue(value: T) {
|
|
351
|
+
this.pushCore(Promise.resolve({ done: false, value }));
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
public pushError(error: any) {
|
|
355
|
+
this.pushCore(Promise.reject(error));
|
|
356
|
+
this.done = true;
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
public pushDone() {
|
|
360
|
+
this.pushCore(Promise.resolve({ done: true }));
|
|
361
|
+
this.done = true;
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
protected pushCore(value: Promise<IStreamResult<T>>) {
|
|
365
|
+
assert(!this.done, 0x112 /* "cannot push onto queue if done" */);
|
|
366
|
+
if (this.deferred) {
|
|
367
|
+
assert(this.queue.length === 0, 0x113 /* "deferred queue should be empty" */);
|
|
368
|
+
this.deferred.resolve(value);
|
|
369
|
+
this.deferred = undefined;
|
|
370
|
+
} else {
|
|
371
|
+
this.queue.push(value);
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
public async read(): Promise<IStreamResult<T>> {
|
|
376
|
+
assert(this.deferred === undefined, 0x114 /* "cannot pop if deferred" */);
|
|
377
|
+
const value = this.queue.shift();
|
|
378
|
+
if (value !== undefined) {
|
|
379
|
+
return value;
|
|
380
|
+
}
|
|
381
|
+
assert(!this.done, 0x115 /* "queue should not be done during pop" */);
|
|
382
|
+
this.deferred = new Deferred<IStreamResult<T>>();
|
|
383
|
+
return this.deferred.promise;
|
|
384
|
+
}
|
|
347
385
|
}
|
|
348
386
|
|
|
387
|
+
const waitForOnline = async (): Promise<void> => {
|
|
388
|
+
// Only wait if we have a strong signal that we're offline - otherwise assume we're online.
|
|
389
|
+
if (globalThis.navigator?.onLine === false && globalThis.addEventListener !== undefined) {
|
|
390
|
+
return new Promise<void>((resolve) => {
|
|
391
|
+
const resolveAndRemoveListener = () => {
|
|
392
|
+
resolve();
|
|
393
|
+
globalThis.removeEventListener("online", resolveAndRemoveListener);
|
|
394
|
+
};
|
|
395
|
+
globalThis.addEventListener("online", resolveAndRemoveListener);
|
|
396
|
+
});
|
|
397
|
+
}
|
|
398
|
+
};
|
|
399
|
+
|
|
349
400
|
/**
|
|
350
401
|
* Retrieve single batch of ops
|
|
351
402
|
* @param request - request index
|
|
@@ -357,96 +408,118 @@ export class Queue<T> implements IStream<T> {
|
|
|
357
408
|
* @param logger - logger object to use to log progress & errors
|
|
358
409
|
* @param signal - cancelation signal
|
|
359
410
|
* @param scenarioName - reason for fetching ops
|
|
360
|
-
* @returns
|
|
411
|
+
* @returns An object with resulting ops and cancellation / partial result flags
|
|
361
412
|
*/
|
|
362
413
|
async function getSingleOpBatch(
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
414
|
+
get: (telemetryProps: ITelemetryProperties) => Promise<IDeltasFetchResult>,
|
|
415
|
+
props: ITelemetryProperties,
|
|
416
|
+
strongTo: boolean,
|
|
417
|
+
logger: ITelemetryLoggerExt,
|
|
418
|
+
signal?: AbortSignal,
|
|
419
|
+
scenarioName?: string,
|
|
420
|
+
): Promise<{ partial: boolean; cancel: boolean; payload: ISequencedDocumentMessage[] }> {
|
|
421
|
+
let lastSuccessTime: number | undefined;
|
|
422
|
+
let totalRetryAfterTime = 0;
|
|
423
|
+
let telemetryEvent: PerformanceEvent | undefined;
|
|
424
|
+
let retry: number = 0;
|
|
425
|
+
const nothing = { partial: false, cancel: true, payload: [] };
|
|
426
|
+
let waitStartTime: number = 0;
|
|
427
|
+
let waitTime = MissingFetchDelayInMs;
|
|
428
|
+
|
|
429
|
+
while (signal?.aborted !== true) {
|
|
430
|
+
retry++;
|
|
431
|
+
let lastError: unknown;
|
|
432
|
+
const startTime = performance.now();
|
|
433
|
+
|
|
434
|
+
try {
|
|
435
|
+
// Issue async request for deltas
|
|
436
|
+
const { messages, partialResult } = await get(
|
|
437
|
+
{ ...props, retry } /* telemetry props */,
|
|
438
|
+
);
|
|
439
|
+
|
|
440
|
+
// If we got messages back, return them. Return regardless of whether we got messages back if we didn't
|
|
441
|
+
// specify a "to", since we don't have an expectation of how many to receive.
|
|
442
|
+
if (messages.length !== 0 || !strongTo) {
|
|
443
|
+
// Report this event if we waited to fetch ops due to being offline or throttling.
|
|
444
|
+
telemetryEvent?.end({
|
|
445
|
+
duration: totalRetryAfterTime,
|
|
446
|
+
...props,
|
|
447
|
+
reason: scenarioName,
|
|
448
|
+
});
|
|
449
|
+
return { payload: messages, cancel: false, partial: partialResult };
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
// Otherwise, the storage gave us back an empty set of ops but we were expecting a non-empty set.
|
|
453
|
+
|
|
454
|
+
if (lastSuccessTime === undefined) {
|
|
455
|
+
// Take timestamp of the first time server responded successfully, even though it wasn't with the ops we asked for.
|
|
456
|
+
// If we keep getting empty responses we'll eventually fail out below.
|
|
457
|
+
lastSuccessTime = performance.now();
|
|
458
|
+
} else if (performance.now() - lastSuccessTime > 30000) {
|
|
459
|
+
// If we are connected and receiving proper responses from server, but can't get any ops back,
|
|
460
|
+
// then give up after some time. This likely indicates the issue with ordering service not flushing
|
|
461
|
+
// ops to storage quick enough, and possibly waiting for summaries, while summarizer can't get
|
|
462
|
+
// current as it can't get ops.
|
|
463
|
+
throw createGenericNetworkError(
|
|
464
|
+
// pre-0.58 error message: failedToRetrieveOpsFromStorage:TooManyRetries
|
|
465
|
+
"Failed to retrieve ops from storage (Too Many Retries)",
|
|
466
|
+
{ canRetry: false },
|
|
467
|
+
{
|
|
468
|
+
retry,
|
|
469
|
+
driverVersion,
|
|
470
|
+
...props,
|
|
471
|
+
},
|
|
472
|
+
);
|
|
473
|
+
}
|
|
474
|
+
} catch (error) {
|
|
475
|
+
lastError = error;
|
|
476
|
+
const canRetry = canRetryOnError(error);
|
|
477
|
+
|
|
478
|
+
const retryAfter = getRetryDelayFromError(error);
|
|
479
|
+
|
|
480
|
+
// This will log to error table only if the error is non-retryable
|
|
481
|
+
logNetworkFailure(
|
|
482
|
+
logger,
|
|
483
|
+
{
|
|
484
|
+
eventName: "GetDeltas_Error",
|
|
485
|
+
...props,
|
|
486
|
+
retry,
|
|
487
|
+
duration: performance.now() - startTime,
|
|
488
|
+
retryAfter,
|
|
489
|
+
reason: scenarioName,
|
|
490
|
+
},
|
|
491
|
+
error,
|
|
492
|
+
);
|
|
493
|
+
|
|
494
|
+
if (!canRetry) {
|
|
495
|
+
// It's game over scenario.
|
|
496
|
+
throw error;
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
if (telemetryEvent === undefined) {
|
|
501
|
+
waitStartTime = performance.now();
|
|
502
|
+
telemetryEvent = PerformanceEvent.start(logger, {
|
|
503
|
+
eventName: "GetDeltasWaitTime",
|
|
504
|
+
});
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
waitTime = calculateMaxWaitTime(waitTime, lastError);
|
|
508
|
+
|
|
509
|
+
// If we get here something has gone wrong - either got an unexpected empty set of messages back or a real error.
|
|
510
|
+
// Either way we will wait a little bit before retrying.
|
|
511
|
+
await new Promise<void>((resolve) => {
|
|
512
|
+
setTimeout(resolve, waitTime);
|
|
513
|
+
});
|
|
514
|
+
|
|
515
|
+
// If we believe we're offline, we assume there's no point in trying until we at least think we're online.
|
|
516
|
+
// NOTE: This isn't strictly true for drivers that don't require network (e.g. local driver). Really this logic
|
|
517
|
+
// should probably live in the driver.
|
|
518
|
+
await waitForOnline();
|
|
519
|
+
totalRetryAfterTime += performance.now() - waitStartTime;
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
return nothing;
|
|
450
523
|
}
|
|
451
524
|
|
|
452
525
|
/**
|
|
@@ -459,130 +532,168 @@ async function getSingleOpBatch(
|
|
|
459
532
|
* @param logger - Logger to log progress and errors
|
|
460
533
|
* @param signal - Cancelation signal
|
|
461
534
|
* @param scenarioName - Reason for fetching ops
|
|
462
|
-
* @returns
|
|
535
|
+
* @returns Messages fetched
|
|
536
|
+
* @internal
|
|
463
537
|
*/
|
|
464
538
|
export function requestOps(
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
539
|
+
get: (
|
|
540
|
+
from: number,
|
|
541
|
+
to: number,
|
|
542
|
+
telemetryProps: ITelemetryProperties,
|
|
543
|
+
) => Promise<IDeltasFetchResult>,
|
|
544
|
+
concurrency: number,
|
|
545
|
+
fromTotal: number,
|
|
546
|
+
toTotal: number | undefined,
|
|
547
|
+
payloadSize: number,
|
|
548
|
+
logger: ITelemetryLoggerExt,
|
|
549
|
+
signal?: AbortSignal,
|
|
550
|
+
scenarioName?: string,
|
|
473
551
|
): IStream<ISequencedDocumentMessage[]> {
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
552
|
+
let requests = 0;
|
|
553
|
+
let lastFetch: number | undefined;
|
|
554
|
+
let length = 0;
|
|
555
|
+
const queue = new Queue<ISequencedDocumentMessage[]>();
|
|
556
|
+
|
|
557
|
+
const propsTotal: ITelemetryProperties = {
|
|
558
|
+
fromTotal,
|
|
559
|
+
toTotal,
|
|
560
|
+
};
|
|
561
|
+
|
|
562
|
+
const telemetryEvent = PerformanceEvent.start(logger, {
|
|
563
|
+
eventName: "GetDeltas",
|
|
564
|
+
...propsTotal,
|
|
565
|
+
reason: scenarioName,
|
|
566
|
+
});
|
|
567
|
+
|
|
568
|
+
const manager = new ParallelRequests<ISequencedDocumentMessage>(
|
|
569
|
+
fromTotal,
|
|
570
|
+
toTotal,
|
|
571
|
+
payloadSize,
|
|
572
|
+
logger,
|
|
573
|
+
async (
|
|
574
|
+
request: number,
|
|
575
|
+
from: number,
|
|
576
|
+
to: number,
|
|
577
|
+
strongTo: boolean,
|
|
578
|
+
propsPerRequest: ITelemetryProperties,
|
|
579
|
+
) => {
|
|
580
|
+
requests++;
|
|
581
|
+
return getSingleOpBatch(
|
|
582
|
+
async (propsAll) => get(from, to, propsAll),
|
|
583
|
+
{ request, from, to, ...propsTotal, ...propsPerRequest },
|
|
584
|
+
strongTo,
|
|
585
|
+
logger,
|
|
586
|
+
signal,
|
|
587
|
+
scenarioName,
|
|
588
|
+
);
|
|
589
|
+
},
|
|
590
|
+
(deltas: ISequencedDocumentMessage[]) => {
|
|
591
|
+
// Assert continuing and right start.
|
|
592
|
+
if (lastFetch === undefined) {
|
|
593
|
+
assert(deltas[0].sequenceNumber === fromTotal, 0x26d /* "wrong start" */);
|
|
594
|
+
} else {
|
|
595
|
+
assert(deltas[0].sequenceNumber === lastFetch + 1, 0x26e /* "wrong start" */);
|
|
596
|
+
}
|
|
597
|
+
lastFetch = deltas[deltas.length - 1].sequenceNumber;
|
|
598
|
+
assert(
|
|
599
|
+
lastFetch - deltas[0].sequenceNumber + 1 === deltas.length,
|
|
600
|
+
0x26f /* "continuous and no duplicates" */,
|
|
601
|
+
);
|
|
602
|
+
length += deltas.length;
|
|
603
|
+
queue.pushValue(deltas);
|
|
604
|
+
},
|
|
605
|
+
);
|
|
606
|
+
|
|
607
|
+
// Implement faster cancellation. getSingleOpBatch() checks signal, but only in between
|
|
608
|
+
// waits (up to 10 seconds) and fetches (can take infinite amount of time).
|
|
609
|
+
// While every such case should be improved and take into account signal (and thus cancel immediately),
|
|
610
|
+
// it is beneficial to have catch-all
|
|
611
|
+
const listener = (event: Event) => {
|
|
612
|
+
manager.cancel();
|
|
613
|
+
};
|
|
614
|
+
if (signal !== undefined) {
|
|
615
|
+
signal.addEventListener("abort", listener);
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
manager
|
|
619
|
+
.run(concurrency)
|
|
620
|
+
.finally(() => {
|
|
621
|
+
if (signal !== undefined) {
|
|
622
|
+
signal.removeEventListener("abort", listener);
|
|
623
|
+
}
|
|
624
|
+
})
|
|
625
|
+
.then(() => {
|
|
626
|
+
const props = {
|
|
627
|
+
lastFetch,
|
|
628
|
+
length,
|
|
629
|
+
requests,
|
|
630
|
+
};
|
|
631
|
+
if (manager.canceled) {
|
|
632
|
+
telemetryEvent.cancel({ ...props, error: "ops request cancelled by client" });
|
|
633
|
+
} else {
|
|
634
|
+
assert(
|
|
635
|
+
toTotal === undefined || (lastFetch !== undefined && lastFetch >= toTotal - 1),
|
|
636
|
+
0x270 /* "All requested ops fetched" */,
|
|
637
|
+
);
|
|
638
|
+
telemetryEvent.end(props);
|
|
639
|
+
}
|
|
640
|
+
queue.pushDone();
|
|
641
|
+
})
|
|
642
|
+
.catch((error) => {
|
|
643
|
+
telemetryEvent.cancel(
|
|
644
|
+
{
|
|
645
|
+
lastFetch,
|
|
646
|
+
length,
|
|
647
|
+
requests,
|
|
648
|
+
},
|
|
649
|
+
error,
|
|
650
|
+
);
|
|
651
|
+
queue.pushError(error);
|
|
652
|
+
});
|
|
653
|
+
|
|
654
|
+
return queue;
|
|
559
655
|
}
|
|
560
656
|
|
|
657
|
+
/**
|
|
658
|
+
* @internal
|
|
659
|
+
*/
|
|
561
660
|
export const emptyMessageStream: IStream<ISequencedDocumentMessage[]> = {
|
|
562
|
-
|
|
661
|
+
read: async () => {
|
|
662
|
+
return { done: true };
|
|
663
|
+
},
|
|
563
664
|
};
|
|
564
665
|
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
666
|
+
/**
|
|
667
|
+
* @internal
|
|
668
|
+
*/
|
|
669
|
+
export function streamFromMessages(
|
|
670
|
+
messagesArg: Promise<ISequencedDocumentMessage[]>,
|
|
671
|
+
): IStream<ISequencedDocumentMessage[]> {
|
|
672
|
+
let messages: Promise<ISequencedDocumentMessage[]> | undefined = messagesArg;
|
|
673
|
+
return {
|
|
674
|
+
read: async () => {
|
|
675
|
+
if (messages === undefined) {
|
|
676
|
+
return { done: true };
|
|
677
|
+
}
|
|
678
|
+
const value = await messages;
|
|
679
|
+
messages = undefined;
|
|
680
|
+
return value.length === 0 ? { done: true } : { done: false, value };
|
|
681
|
+
},
|
|
682
|
+
};
|
|
578
683
|
}
|
|
579
684
|
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
685
|
+
/**
|
|
686
|
+
* @internal
|
|
687
|
+
*/
|
|
688
|
+
export function streamObserver<T>(
|
|
689
|
+
stream: IStream<T>,
|
|
690
|
+
handler: (value: IStreamResult<T>) => void,
|
|
691
|
+
): IStream<T> {
|
|
692
|
+
return {
|
|
693
|
+
read: async () => {
|
|
694
|
+
const value = await stream.read();
|
|
695
|
+
handler(value);
|
|
696
|
+
return value;
|
|
697
|
+
},
|
|
698
|
+
};
|
|
588
699
|
}
|