@fluidframework/driver-utils 2.0.0-internal.3.0.5 → 2.0.0-internal.3.1.1
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 -19
- package/.mocharc.js +2 -2
- package/api-extractor.json +2 -2
- package/dist/blobAggregationStorage.d.ts +2 -2
- package/dist/blobAggregationStorage.d.ts.map +1 -1
- package/dist/blobAggregationStorage.js +11 -6
- package/dist/blobAggregationStorage.js.map +1 -1
- package/dist/blobCacheStorageService.d.ts.map +1 -1
- package/dist/blobCacheStorageService.js.map +1 -1
- package/dist/buildSnapshotTree.d.ts.map +1 -1
- package/dist/buildSnapshotTree.js.map +1 -1
- package/dist/documentStorageServiceProxy.d.ts.map +1 -1
- package/dist/documentStorageServiceProxy.js.map +1 -1
- package/dist/emptyDocumentDeltaStorageService.d.ts.map +1 -1
- package/dist/emptyDocumentDeltaStorageService.js.map +1 -1
- package/dist/error.d.ts.map +1 -1
- package/dist/error.js.map +1 -1
- package/dist/fluidResolvedUrl.d.ts.map +1 -1
- package/dist/fluidResolvedUrl.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/insecureUrlResolver.d.ts.map +1 -1
- package/dist/insecureUrlResolver.js +2 -1
- package/dist/insecureUrlResolver.js.map +1 -1
- package/dist/mapWithExpiration.d.ts.map +1 -1
- package/dist/mapWithExpiration.js +5 -3
- package/dist/mapWithExpiration.js.map +1 -1
- package/dist/messageRecognition.d.ts.map +1 -1
- package/dist/messageRecognition.js.map +1 -1
- package/dist/multiDocumentServiceFactory.d.ts.map +1 -1
- package/dist/multiDocumentServiceFactory.js.map +1 -1
- package/dist/multiUrlResolver.d.ts.map +1 -1
- package/dist/multiUrlResolver.js.map +1 -1
- package/dist/network.d.ts +1 -1
- package/dist/network.d.ts.map +1 -1
- package/dist/network.js +4 -3
- package/dist/network.js.map +1 -1
- package/dist/networkUtils.d.ts.map +1 -1
- package/dist/networkUtils.js +2 -3
- package/dist/networkUtils.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.d.ts.map +1 -1
- package/dist/parallelRequests.js +19 -9
- package/dist/parallelRequests.js.map +1 -1
- package/dist/prefetchDocumentStorageService.d.ts.map +1 -1
- package/dist/prefetchDocumentStorageService.js.map +1 -1
- package/dist/rateLimiter.d.ts.map +1 -1
- package/dist/rateLimiter.js.map +1 -1
- package/dist/readAndParse.d.ts.map +1 -1
- package/dist/readAndParse.js.map +1 -1
- package/dist/runWithRetry.d.ts.map +1 -1
- package/dist/runWithRetry.js.map +1 -1
- package/dist/summaryForCreateNew.d.ts.map +1 -1
- package/dist/summaryForCreateNew.js.map +1 -1
- package/dist/treeConversions.d.ts.map +1 -1
- package/dist/treeConversions.js +1 -4
- package/dist/treeConversions.js.map +1 -1
- package/dist/treeUtils.d.ts +10 -10
- package/dist/treeUtils.d.ts.map +1 -1
- package/dist/treeUtils.js +10 -10
- package/dist/treeUtils.js.map +1 -1
- package/lib/blobAggregationStorage.d.ts +2 -2
- package/lib/blobAggregationStorage.d.ts.map +1 -1
- package/lib/blobAggregationStorage.js +11 -6
- package/lib/blobAggregationStorage.js.map +1 -1
- package/lib/blobCacheStorageService.d.ts.map +1 -1
- package/lib/blobCacheStorageService.js.map +1 -1
- package/lib/buildSnapshotTree.d.ts.map +1 -1
- package/lib/buildSnapshotTree.js.map +1 -1
- package/lib/documentStorageServiceProxy.d.ts.map +1 -1
- package/lib/documentStorageServiceProxy.js.map +1 -1
- package/lib/emptyDocumentDeltaStorageService.d.ts.map +1 -1
- package/lib/emptyDocumentDeltaStorageService.js.map +1 -1
- package/lib/error.d.ts.map +1 -1
- package/lib/error.js.map +1 -1
- package/lib/fluidResolvedUrl.d.ts.map +1 -1
- package/lib/fluidResolvedUrl.js.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/lib/insecureUrlResolver.d.ts.map +1 -1
- package/lib/insecureUrlResolver.js +2 -1
- package/lib/insecureUrlResolver.js.map +1 -1
- package/lib/mapWithExpiration.d.ts.map +1 -1
- package/lib/mapWithExpiration.js +5 -3
- package/lib/mapWithExpiration.js.map +1 -1
- package/lib/messageRecognition.d.ts.map +1 -1
- package/lib/messageRecognition.js +1 -1
- package/lib/messageRecognition.js.map +1 -1
- package/lib/multiDocumentServiceFactory.d.ts.map +1 -1
- package/lib/multiDocumentServiceFactory.js.map +1 -1
- package/lib/multiUrlResolver.d.ts.map +1 -1
- package/lib/multiUrlResolver.js.map +1 -1
- package/lib/network.d.ts +1 -1
- package/lib/network.d.ts.map +1 -1
- package/lib/network.js +4 -3
- package/lib/network.js.map +1 -1
- package/lib/networkUtils.d.ts.map +1 -1
- package/lib/networkUtils.js +2 -3
- package/lib/networkUtils.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.d.ts.map +1 -1
- package/lib/parallelRequests.js +19 -9
- package/lib/parallelRequests.js.map +1 -1
- package/lib/prefetchDocumentStorageService.d.ts.map +1 -1
- package/lib/prefetchDocumentStorageService.js.map +1 -1
- package/lib/rateLimiter.d.ts.map +1 -1
- package/lib/rateLimiter.js.map +1 -1
- package/lib/readAndParse.d.ts.map +1 -1
- package/lib/readAndParse.js.map +1 -1
- package/lib/runWithRetry.d.ts.map +1 -1
- package/lib/runWithRetry.js.map +1 -1
- package/lib/summaryForCreateNew.d.ts.map +1 -1
- package/lib/summaryForCreateNew.js.map +1 -1
- package/lib/treeConversions.d.ts.map +1 -1
- package/lib/treeConversions.js +4 -7
- package/lib/treeConversions.js.map +1 -1
- package/lib/treeUtils.d.ts +10 -10
- package/lib/treeUtils.d.ts.map +1 -1
- package/lib/treeUtils.js +11 -11
- package/lib/treeUtils.js.map +1 -1
- package/package.json +128 -127
- package/prettier.config.cjs +1 -1
- package/src/blobAggregationStorage.ts +374 -322
- package/src/blobCacheStorageService.ts +20 -17
- package/src/buildSnapshotTree.ts +54 -51
- package/src/documentStorageServiceProxy.ts +49 -43
- package/src/emptyDocumentDeltaStorageService.ts +11 -10
- package/src/error.ts +5 -7
- package/src/fluidResolvedUrl.ts +9 -6
- package/src/index.ts +5 -1
- package/src/insecureUrlResolver.ts +127 -116
- package/src/mapWithExpiration.ts +111 -104
- package/src/messageRecognition.ts +25 -19
- package/src/multiDocumentServiceFactory.ts +73 -62
- package/src/multiUrlResolver.ts +26 -29
- package/src/network.ts +114 -112
- package/src/networkUtils.ts +37 -34
- package/src/packageVersion.ts +1 -1
- package/src/parallelRequests.ts +571 -509
- package/src/prefetchDocumentStorageService.ts +76 -74
- package/src/rateLimiter.ts +29 -29
- package/src/readAndParse.ts +7 -4
- package/src/runWithRetry.ts +105 -94
- package/src/summaryForCreateNew.ts +27 -24
- package/src/treeConversions.ts +48 -70
- package/src/treeUtils.ts +70 -74
- package/tsconfig.esnext.json +6 -6
- package/tsconfig.json +8 -12
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parallelRequests.d.ts","sourceRoot":"","sources":["../src/parallelRequests.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAC;AAE5F,OAAO,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAC;AACjF,OAAO,EAAE,kBAAkB,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAC;AAWhG;;;;;;;;;;;GAWG;AACH,qBAAa,gBAAgB,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"parallelRequests.d.ts","sourceRoot":"","sources":["../src/parallelRequests.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAC;AAE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OAAO,EAAE,CAAC,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,KAAK,IAAI,GACxC,OAAO,CAAC,CAAC,CAAC,CAQZ"}
|
package/lib/parallelRequests.js
CHANGED
|
@@ -36,10 +36,14 @@ export class ParallelRequests {
|
|
|
36
36
|
this.requests = 0;
|
|
37
37
|
this.latestRequested = from;
|
|
38
38
|
this.nextToDeliver = from;
|
|
39
|
-
this.knewTo =
|
|
39
|
+
this.knewTo = to !== undefined;
|
|
40
|
+
}
|
|
41
|
+
get working() {
|
|
42
|
+
return this.workingState === "working";
|
|
43
|
+
}
|
|
44
|
+
get canceled() {
|
|
45
|
+
return this.workingState === "canceled";
|
|
40
46
|
}
|
|
41
|
-
get working() { return this.workingState === "working"; }
|
|
42
|
-
get canceled() { return this.workingState === "canceled"; }
|
|
43
47
|
cancel() {
|
|
44
48
|
if (this.working) {
|
|
45
49
|
this.workingState = "canceled";
|
|
@@ -173,7 +177,7 @@ export class ParallelRequests {
|
|
|
173
177
|
if (this.working) {
|
|
174
178
|
const fromOrig = from;
|
|
175
179
|
const length = payload.length;
|
|
176
|
-
let fullChunk =
|
|
180
|
+
let fullChunk = requestedLength <= length; // we can possible get more than we asked.
|
|
177
181
|
if (length !== 0) {
|
|
178
182
|
// We can get more than we asked for!
|
|
179
183
|
// This can screw up logic in dispatch!
|
|
@@ -402,16 +406,20 @@ export function requestOps(get, concurrency, fromTotal, toTotal, payloadSize, lo
|
|
|
402
406
|
// waits (up to 10 seconds) and fetches (can take infinite amount of time).
|
|
403
407
|
// While every such case should be improved and take into account signal (and thus cancel immediately),
|
|
404
408
|
// it is beneficial to have catch-all
|
|
405
|
-
const listener = (event) => {
|
|
409
|
+
const listener = (event) => {
|
|
410
|
+
manager.cancel();
|
|
411
|
+
};
|
|
406
412
|
if (signal !== undefined) {
|
|
407
413
|
signal.addEventListener("abort", listener);
|
|
408
414
|
}
|
|
409
|
-
manager
|
|
415
|
+
manager
|
|
416
|
+
.run(concurrency)
|
|
410
417
|
.finally(() => {
|
|
411
418
|
if (signal !== undefined) {
|
|
412
419
|
signal.removeEventListener("abort", listener);
|
|
413
420
|
}
|
|
414
|
-
})
|
|
421
|
+
})
|
|
422
|
+
.then(() => {
|
|
415
423
|
const props = {
|
|
416
424
|
lastFetch,
|
|
417
425
|
length,
|
|
@@ -421,7 +429,7 @@ export function requestOps(get, concurrency, fromTotal, toTotal, payloadSize, lo
|
|
|
421
429
|
telemetryEvent.cancel(Object.assign(Object.assign({}, props), { error: "ops request cancelled by client" }));
|
|
422
430
|
}
|
|
423
431
|
else {
|
|
424
|
-
assert(toTotal === undefined || lastFetch !== undefined && lastFetch >= toTotal - 1, 0x270 /* "All requested ops fetched" */);
|
|
432
|
+
assert(toTotal === undefined || (lastFetch !== undefined && lastFetch >= toTotal - 1), 0x270 /* "All requested ops fetched" */);
|
|
425
433
|
telemetryEvent.end(props);
|
|
426
434
|
}
|
|
427
435
|
queue.pushDone();
|
|
@@ -437,7 +445,9 @@ export function requestOps(get, concurrency, fromTotal, toTotal, payloadSize, lo
|
|
|
437
445
|
return queue;
|
|
438
446
|
}
|
|
439
447
|
export const emptyMessageStream = {
|
|
440
|
-
read: async () => {
|
|
448
|
+
read: async () => {
|
|
449
|
+
return { done: true };
|
|
450
|
+
},
|
|
441
451
|
};
|
|
442
452
|
export function streamFromMessages(messagesArg) {
|
|
443
453
|
let messages = messagesArg;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parallelRequests.js","sourceRoot":"","sources":["../src/parallelRequests.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAE7E,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAGnE,OAAO,EAAE,sBAAsB,EAAE,eAAe,EAAE,yBAAyB,EAAE,MAAM,WAAW,CAAC;AAC/F,OAAO,EAAE,qBAAqB,EAAE,iBAAiB,EAAE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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;QACxE,CAAC;KACJ,CAAC;AACN,CAAC;AAED,MAAM,UAAU,cAAc,CAAI,MAAkB,EAAE,OAA0C;IAC5F,OAAO;QACH,IAAI,EAAE,KAAK,IAAI,EAAE;YACb,MAAM,KAAK,GAAG,MAAM,MAAM,CAAC,IAAI,EAAE,CAAC;YAClC,OAAO,CAAC,KAAK,CAAC,CAAC;YACf,OAAO,KAAK,CAAC;QACjB,CAAC;KACJ,CAAC;AACN,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\nimport { assert, Deferred, performance } from \"@fluidframework/common-utils\";\nimport { ITelemetryLogger, ITelemetryProperties } from \"@fluidframework/common-definitions\";\nimport { PerformanceEvent } from \"@fluidframework/telemetry-utils\";\nimport { ISequencedDocumentMessage } from \"@fluidframework/protocol-definitions\";\nimport { IDeltasFetchResult, IStream, IStreamResult } from \"@fluidframework/driver-definitions\";\nimport { getRetryDelayFromError, canRetryOnError, createGenericNetworkError } from \"./network\";\nimport { waitForConnectedState, logNetworkFailure } from \"./networkUtils\";\n// For now, this package is versioned and released in unison with the specific drivers\nimport { pkgVersion as driverVersion } from \"./packageVersion\";\n\nconst MaxFetchDelayInMs = 10000;\nconst MissingFetchDelayInMs = 100;\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 */\nexport class ParallelRequests<T> {\n private latestRequested: number;\n private nextToDeliver: number;\n private readonly results: Map<number, T[]> = new Map();\n private workingState: WorkingState = \"working\";\n private requestsInFlight = 0;\n private readonly endEvent = new Deferred<void>();\n private requests = 0;\n private readonly knewTo: boolean;\n\n private get working() { return this.workingState === \"working\"; }\n public get canceled() { return this.workingState === \"canceled\"; }\n\n constructor(\n from: number,\n private to: number | undefined,\n private readonly payloadSize: number,\n private readonly logger: ITelemetryLogger,\n private readonly requestCallback: (\n request: number,\n from: number,\n to: number,\n strongTo: boolean,\n props: ITelemetryProperties) => Promise<{ partial: boolean; cancel: boolean; payload: T[]; }>,\n private readonly responseCallback: (payload: T[]) => void) {\n this.latestRequested = from;\n this.nextToDeliver = from;\n this.knewTo = (to !== undefined);\n }\n\n public cancel() {\n if (this.working) {\n this.workingState = \"canceled\";\n this.endEvent.resolve();\n }\n }\n\n public async run(concurrency: number) {\n assert(concurrency > 0, 0x102 /* \"invalid level of concurrency\" */);\n assert(this.working, 0x103 /* \"trying to parallel run while not working\" */);\n\n let c = concurrency;\n while (c > 0) {\n c--;\n this.addRequest();\n }\n this.dispatch();// will recalculate and trigger this.endEvent if needed\n return this.endEvent.promise;\n }\n\n private done() {\n // We should satisfy request fully.\n assert(this.to !== undefined, 0x104 /* \"undefined end point for parallel fetch\" */);\n assert(this.nextToDeliver >= this.to, 0x105 /* \"unexpected end point for parallel fetch\" */);\n if (this.working) {\n this.workingState = \"done\";\n this.endEvent.resolve();\n }\n }\n\n private fail(error) {\n if (this.working) {\n this.workingState = \"done\";\n this.endEvent.reject(error);\n }\n }\n\n private dispatch() {\n while (this.working) {\n const value = this.results.get(this.nextToDeliver);\n if (value === undefined) {\n break;\n }\n this.results.delete(this.nextToDeliver);\n assert(value.length <= this.payloadSize, 0x1d9 /* \"addRequestCore() should break into smaller chunks\" */);\n this.nextToDeliver += value.length;\n this.responseCallback(value);\n }\n\n // Account for cancellation - state might be not in consistent state on cancelling operation\n if (this.working) {\n if (this.requestsInFlight === 0) {\n // we should have dispatched everything, no matter whether we knew about the end or not.\n // see comment in addRequestCore() around throwing away chunk if it's above this.to\n assert(this.results.size === 0,\n 0x107 /* \"ending dispatch with remaining results to be sent\" */);\n this.done();\n } else if (this.to !== undefined && this.nextToDeliver >= this.to) {\n // Learned about the end and dispatched all the ops up to it.\n // Ignore all the in-flight requests above boundary - unblock caller sooner.\n assert(!this.knewTo, 0x108 /* \"ending results dispatch but knew in advance about more requests\" */);\n this.done();\n }\n }\n }\n\n private getNextChunk() {\n if (!this.working) {\n return undefined;\n }\n\n const from = this.latestRequested;\n if (this.to !== undefined) {\n if (this.to <= from) {\n return undefined;\n }\n }\n\n // this.latestRequested\n // inclusive on the right side! Exclusive on the left.\n this.latestRequested += this.payloadSize;\n\n if (this.to !== undefined) {\n this.latestRequested = Math.min(this.to, this.latestRequested);\n }\n\n assert(from < this.latestRequested, 0x109 /* \"unexpected next chunk position\" */);\n\n return { from, to: this.latestRequested };\n }\n\n private addRequest() {\n const chunk = this.getNextChunk();\n if (chunk === undefined) {\n return;\n }\n this.addRequestCore(chunk.from, chunk.to).catch(this.fail.bind(this));\n }\n\n private async addRequestCore(fromArg: number, toArg: number) {\n assert(this.working, 0x10a /* \"cannot add parallel request while not working\" */);\n\n let from = fromArg;\n let to = toArg;\n\n // to & from are exclusive\n this.requestsInFlight++;\n while (this.working) {\n const requestedLength = to - from;\n assert(requestedLength > 0, 0x10b /* \"invalid parallel request range\" */);\n\n // We should not be wasting time asking for something useless.\n if (this.to !== undefined) {\n assert(from < this.to, 0x10c /* \"invalid parallel request start point\" */);\n assert(to <= this.to, 0x10d /* \"invalid parallel request end point\" */);\n }\n\n this.requests++;\n\n const promise = this.requestCallback(this.requests, from, to, this.to !== undefined, {});\n\n // dispatch any prior received data\n this.dispatch();\n\n const { payload, cancel, partial } = await promise;\n\n if (cancel) {\n this.cancel();\n }\n\n if (this.to !== undefined && from >= this.to) {\n // while we were waiting for response, we learned on what is the boundary\n // We can get here (with actual result!) if situation changed while this request was in\n // flight, i.e. the end was extended over what we learn in some other request\n // While it's useful not to throw this result, this is very corner cases and makes logic\n // (including consistency checks) much harder to write correctly.\n // So for now, we are throwing this result out the window.\n assert(!this.knewTo, 0x10e /* \"should not throw result if we knew about boundary in advance\" */);\n // Learn how often it happens and if it's too wasteful to throw these chunks.\n // If it pops into our view a lot, we would need to reconsider how we approach it.\n // Note that this is not visible to user other than potentially not hitting 100% of\n // what we can in perf domain.\n if (payload.length !== 0) {\n this.logger.sendErrorEvent({\n eventName: \"ParallelRequests_GotExtra\",\n from,\n to,\n end: this.to,\n length: payload.length,\n });\n }\n\n break;\n }\n\n if (this.working) {\n const fromOrig = from;\n const length = payload.length;\n let fullChunk = (requestedLength <= length); // we can possible get more than we asked.\n\n if (length !== 0) {\n // We can get more than we asked for!\n // This can screw up logic in dispatch!\n // So push only batch size, and keep the rest for later - if conditions are favorable, we\n // will be able to use it. If not (parallel request overlapping these ops), it's easier to\n // discard them and wait for another (overlapping) request to come in later.\n if (requestedLength < length) {\n // This is error in a sense that it's not expected and likely points bug in other layer.\n // This layer copes with this situation just fine.\n this.logger.sendTelemetryEvent({\n eventName: \"ParallelRequests_Over\",\n from,\n to,\n length,\n });\n }\n const data = payload.splice(0, requestedLength);\n this.results.set(from, data);\n from += data.length;\n } else {\n // 1. empty (partial) chunks should not be returned by various caching / adapter layers -\n // they should fall back to next layer. This might be important invariant to hold to ensure\n // that we are less likely have bugs where such layer would keep returning empty partial\n // result on each call.\n // 2. Current invariant is that callback does retries until it gets something,\n // with the goal of failing if zero data is retrieved in given amount of time.\n // This is very specific property of storage / ops, so this logic is not here, but given only\n // one user of this class, we assert that to catch issues earlier.\n // These invariant can be relaxed if needed.\n assert(!partial, 0x10f /* \"empty/partial chunks should not be returned by caching\" */);\n assert(!this.knewTo,\n 0x110 /* \"callback should retry until valid fetch before it learns new boundary\" */);\n }\n\n if (!partial && !fullChunk) {\n if (!this.knewTo) {\n if (this.to === undefined || this.to > from) {\n // The END\n this.to = from;\n }\n break;\n }\n // We know that there are more items to be retrieved\n // Can we get partial chunk? Ideally storage indicates that's not a full chunk\n // Note that it's possible that not all ops hit storage yet.\n // We will come back to request more, and if we can't get any more ops soon, it's\n // catastrophic failure (see comment above on responsibility of callback to return something)\n // This layer will just keep trying until it gets full set.\n this.logger.sendPerformanceEvent({\n eventName: \"ParallelRequests_Partial\",\n from: fromOrig,\n to,\n length,\n });\n }\n\n if (to === this.latestRequested) {\n // we can go after full chunk at the end if we received partial chunk, or more than asked\n // Also if we got more than we asked to, we can actually use those ops!\n if (payload.length !== 0) {\n this.results.set(from, payload);\n from += payload.length;\n }\n\n this.latestRequested = from;\n fullChunk = true;\n }\n\n if (fullChunk) {\n const chunk = this.getNextChunk();\n if (chunk === undefined) { break; }\n from = chunk.from;\n to = chunk.to;\n }\n }\n }\n this.requestsInFlight--;\n this.dispatch();\n }\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 */\nexport class Queue<T> implements IStream<T> {\n private readonly queue: Promise<IStreamResult<T>>[] = [];\n private deferred: Deferred<IStreamResult<T>> | undefined;\n private done = false;\n\n public pushValue(value: T) {\n this.pushCore(Promise.resolve({ done: false, value }));\n }\n\n public pushError(error: any) {\n this.pushCore(Promise.reject(error));\n this.done = true;\n }\n\n public pushDone() {\n this.pushCore(Promise.resolve({ done: true }));\n this.done = true;\n }\n\n protected pushCore(value: Promise<IStreamResult<T>>) {\n assert(!this.done, 0x112 /* \"cannot push onto queue if done\" */);\n if (this.deferred) {\n assert(this.queue.length === 0, 0x113 /* \"deferred queue should be empty\" */);\n this.deferred.resolve(value);\n this.deferred = undefined;\n } else {\n this.queue.push(value);\n }\n }\n\n public async read(): Promise<IStreamResult<T>> {\n assert(this.deferred === undefined, 0x114 /* \"cannot pop if deferred\" */);\n const value = this.queue.shift();\n if (value !== undefined) {\n return value;\n }\n assert(!this.done, 0x115 /* \"queue should not be done during pop\" */);\n this.deferred = new Deferred<IStreamResult<T>>();\n return this.deferred.promise;\n }\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 get: (telemetryProps: ITelemetryProperties) => Promise<IDeltasFetchResult>,\n props: ITelemetryProperties,\n strongTo: boolean,\n logger: ITelemetryLogger,\n signal?: AbortSignal,\n scenarioName?: string):\n Promise<{ partial: boolean; cancel: boolean; payload: ISequencedDocumentMessage[]; }> {\n let lastSuccessTime: number | undefined;\n\n let retry: number = 0;\n const deltas: ISequencedDocumentMessage[] = [];\n const nothing = { partial: false, cancel: true, payload: [] };\n\n while (signal?.aborted !== true) {\n retry++;\n let delay = Math.min(MaxFetchDelayInMs, MissingFetchDelayInMs * Math.pow(2, retry));\n const startTime = performance.now();\n\n try {\n // Issue async request for deltas - limit the number fetched to MaxBatchDeltas\n const deltasP = get({ ...props, retry } /* telemetry props */);\n\n const { messages, partialResult } = await deltasP;\n deltas.push(...messages);\n\n const deltasRetrievedLast = messages.length;\n\n if (deltasRetrievedLast !== 0 || !strongTo) {\n return { payload: deltas, cancel: false, partial: partialResult };\n }\n\n // Storage does not have ops we need.\n // Attempt to fetch more deltas. If we didn't receive any in the previous call we up our retry\n // count since something prevented us from seeing those deltas\n\n if (lastSuccessTime === undefined) {\n lastSuccessTime = performance.now();\n } else if (performance.now() - lastSuccessTime > 30000) {\n // If we are connected and receiving proper responses from server, but can't get any ops back,\n // then give up after some time. This likely indicates the issue with ordering service not flushing\n // ops to storage quick enough, and possibly waiting for summaries, while summarizer can't get\n // current as it can't get ops.\n throw createGenericNetworkError(\n // pre-0.58 error message: failedToRetrieveOpsFromStorage:TooManyRetries\n \"Failed to retrieve ops from storage (Too Many Retries)\",\n { canRetry: false },\n {\n retry,\n driverVersion,\n ...props,\n },\n );\n }\n } catch (error) {\n const canRetry = canRetryOnError(error);\n\n lastSuccessTime = undefined;\n\n const retryAfter = getRetryDelayFromError(error);\n\n // This will log to error table only if the error is non-retryable\n logNetworkFailure(\n logger,\n {\n eventName: \"GetDeltas_Error\",\n ...props,\n retry,\n duration: performance.now() - startTime,\n retryAfter,\n reason: scenarioName,\n },\n error);\n\n if (!canRetry) {\n // It's game over scenario.\n throw error;\n }\n\n if (retryAfter !== undefined && retryAfter >= 0) {\n delay = retryAfter;\n }\n }\n\n await waitForConnectedState(delay);\n }\n\n return 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 */\nexport function requestOps(\n get: (from: number, to: number, telemetryProps: ITelemetryProperties) => Promise<IDeltasFetchResult>,\n concurrency: number,\n fromTotal: number,\n toTotal: number | undefined,\n payloadSize: number,\n logger: ITelemetryLogger,\n signal?: AbortSignal,\n scenarioName?: string,\n): IStream<ISequencedDocumentMessage[]> {\n let requests = 0;\n let lastFetch: number | undefined;\n let length = 0;\n const queue = new Queue<ISequencedDocumentMessage[]>();\n\n const propsTotal: ITelemetryProperties = {\n fromTotal,\n toTotal,\n };\n\n const telemetryEvent = PerformanceEvent.start(logger, {\n eventName: \"GetDeltas\",\n ...propsTotal,\n reason: scenarioName,\n });\n\n const manager = new ParallelRequests<ISequencedDocumentMessage>(\n fromTotal,\n toTotal,\n payloadSize,\n logger,\n async (request: number, from: number, to: number, strongTo: boolean, propsPerRequest: ITelemetryProperties) => {\n requests++;\n return getSingleOpBatch(\n async (propsAll) => get(from, to, propsAll),\n { request, from, to, ...propsTotal, ...propsPerRequest },\n strongTo,\n logger,\n signal,\n scenarioName,\n );\n },\n (deltas: ISequencedDocumentMessage[]) => {\n // Assert continuing and right start.\n if (lastFetch === undefined) {\n assert(deltas[0].sequenceNumber === fromTotal, 0x26d /* \"wrong start\" */);\n } else {\n assert(deltas[0].sequenceNumber === lastFetch + 1, 0x26e /* \"wrong start\" */);\n }\n lastFetch = deltas[deltas.length - 1].sequenceNumber;\n assert(lastFetch - deltas[0].sequenceNumber + 1 === deltas.length,\n 0x26f /* \"continuous and no duplicates\" */);\n length += deltas.length;\n queue.pushValue(deltas);\n });\n\n // Implement faster cancellation. getSingleOpBatch() checks signal, but only in between\n // waits (up to 10 seconds) and fetches (can take infinite amount of time).\n // While every such case should be improved and take into account signal (and thus cancel immediately),\n // it is beneficial to have catch-all\n const listener = (event: Event) => { manager.cancel(); };\n if (signal !== undefined) {\n signal.addEventListener(\"abort\", listener);\n }\n\n manager.run(concurrency)\n .finally(() => {\n if (signal !== undefined) {\n signal.removeEventListener(\"abort\", listener);\n }\n }).then(() => {\n const props = {\n lastFetch,\n length,\n requests,\n };\n if (manager.canceled) {\n telemetryEvent.cancel({ ...props, error: \"ops request cancelled by client\" });\n } else {\n assert(toTotal === undefined || lastFetch !== undefined && lastFetch >= toTotal - 1,\n 0x270 /* \"All requested ops fetched\" */);\n telemetryEvent.end(props);\n }\n queue.pushDone();\n })\n .catch((error) => {\n telemetryEvent.cancel({\n lastFetch,\n length,\n requests,\n }, error);\n queue.pushError(error);\n });\n\n return queue;\n}\n\nexport const emptyMessageStream: IStream<ISequencedDocumentMessage[]> = {\n read: async () => { return { done: true }; },\n};\n\nexport function streamFromMessages(messagesArg: Promise<ISequencedDocumentMessage[]>):\n IStream<ISequencedDocumentMessage[]> {\n let messages: Promise<ISequencedDocumentMessage[]> | undefined = messagesArg;\n return {\n read: async () => {\n if (messages === undefined) {\n return { done: true };\n }\n const value = await messages;\n messages = undefined;\n return value.length === 0 ? { done: true } : { done: false, value };\n },\n };\n}\n\nexport function streamObserver<T>(stream: IStream<T>, handler: (value: IStreamResult<T>) => void): IStream<T> {\n return {\n read: async () => {\n const value = await stream.read();\n handler(value);\n return value;\n },\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"parallelRequests.js","sourceRoot":"","sources":["../src/parallelRequests.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAE7E,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAGnE,OAAO,EAAE,sBAAsB,EAAE,eAAe,EAAE,yBAAyB,EAAE,MAAM,WAAW,CAAC;AAC/F,OAAO,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAC1E,sFAAsF;AACtF,OAAO,EAAE,UAAU,IAAI,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAE/D,MAAM,iBAAiB,GAAG,KAAK,CAAC;AAChC,MAAM,qBAAqB,GAAG,GAAG,CAAC;AAIlC;;;;;;;;;;;GAWG;AACH,MAAM,OAAO,gBAAgB;IAiB5B,YACC,IAAY,EACJ,EAAsB,EACb,WAAmB,EACnB,MAAwB,EACxB,eAMgD,EAChD,gBAAwC;QAVjD,OAAE,GAAF,EAAE,CAAoB;QACb,gBAAW,GAAX,WAAW,CAAQ;QACnB,WAAM,GAAN,MAAM,CAAkB;QACxB,oBAAe,GAAf,eAAe,CAMiC;QAChD,qBAAgB,GAAhB,gBAAgB,CAAwB;QA1BzC,YAAO,GAAqB,IAAI,GAAG,EAAE,CAAC;QAC/C,iBAAY,GAAiB,SAAS,CAAC;QACvC,qBAAgB,GAAG,CAAC,CAAC;QACZ,aAAQ,GAAG,IAAI,QAAQ,EAAQ,CAAC;QACzC,aAAQ,GAAG,CAAC,CAAC;QAwBpB,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC;QAC5B,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC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AAM,kBAAkB,GAAyC;IACvE,IAAI,EAAE,KAAK,IAAI,EAAE;QAChB,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;IACvB,CAAC;CACD,CAAC;AAEF,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;gBAC3B,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;aACtB;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,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 */\nimport { assert, Deferred, performance } from \"@fluidframework/common-utils\";\nimport { ITelemetryLogger, ITelemetryProperties } from \"@fluidframework/common-definitions\";\nimport { PerformanceEvent } from \"@fluidframework/telemetry-utils\";\nimport { ISequencedDocumentMessage } from \"@fluidframework/protocol-definitions\";\nimport { IDeltasFetchResult, IStream, IStreamResult } from \"@fluidframework/driver-definitions\";\nimport { getRetryDelayFromError, canRetryOnError, createGenericNetworkError } from \"./network\";\nimport { waitForConnectedState, logNetworkFailure } from \"./networkUtils\";\n// For now, this package is versioned and released in unison with the specific drivers\nimport { pkgVersion as driverVersion } from \"./packageVersion\";\n\nconst MaxFetchDelayInMs = 10000;\nconst MissingFetchDelayInMs = 100;\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 */\nexport class ParallelRequests<T> {\n\tprivate latestRequested: number;\n\tprivate nextToDeliver: number;\n\tprivate readonly results: Map<number, T[]> = new Map();\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: ITelemetryLogger,\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: ITelemetryProperties,\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(\n\t\t\t\tthis.requests,\n\t\t\t\tfrom,\n\t\t\t\tto,\n\t\t\t\tthis.to !== undefined,\n\t\t\t\t{},\n\t\t\t);\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\tif (payload.length !== 0) {\n\t\t\t\t\t\tthis.results.set(from, payload);\n\t\t\t\t\t\tfrom += payload.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 */\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\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: ITelemetryProperties) => Promise<IDeltasFetchResult>,\n\tprops: ITelemetryProperties,\n\tstrongTo: boolean,\n\tlogger: ITelemetryLogger,\n\tsignal?: AbortSignal,\n\tscenarioName?: string,\n): Promise<{ partial: boolean; cancel: boolean; payload: ISequencedDocumentMessage[] }> {\n\tlet lastSuccessTime: number | undefined;\n\n\tlet retry: number = 0;\n\tconst deltas: ISequencedDocumentMessage[] = [];\n\tconst nothing = { partial: false, cancel: true, payload: [] };\n\n\twhile (signal?.aborted !== true) {\n\t\tretry++;\n\t\tlet delay = Math.min(MaxFetchDelayInMs, MissingFetchDelayInMs * Math.pow(2, retry));\n\t\tconst startTime = performance.now();\n\n\t\ttry {\n\t\t\t// Issue async request for deltas - limit the number fetched to MaxBatchDeltas\n\t\t\tconst deltasP = get({ ...props, retry } /* telemetry props */);\n\n\t\t\tconst { messages, partialResult } = await deltasP;\n\t\t\tdeltas.push(...messages);\n\n\t\t\tconst deltasRetrievedLast = messages.length;\n\n\t\t\tif (deltasRetrievedLast !== 0 || !strongTo) {\n\t\t\t\treturn { payload: deltas, cancel: false, partial: partialResult };\n\t\t\t}\n\n\t\t\t// Storage does not have ops we need.\n\t\t\t// Attempt to fetch more deltas. If we didn't receive any in the previous call we up our retry\n\t\t\t// count since something prevented us from seeing those deltas\n\n\t\t\tif (lastSuccessTime === undefined) {\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\tconst canRetry = canRetryOnError(error);\n\n\t\t\tlastSuccessTime = undefined;\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\n\t\t\tif (retryAfter !== undefined && retryAfter >= 0) {\n\t\t\t\tdelay = retryAfter;\n\t\t\t}\n\t\t}\n\n\t\tawait waitForConnectedState(delay);\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 */\nexport function requestOps(\n\tget: (\n\t\tfrom: number,\n\t\tto: number,\n\t\ttelemetryProps: ITelemetryProperties,\n\t) => Promise<IDeltasFetchResult>,\n\tconcurrency: number,\n\tfromTotal: number,\n\ttoTotal: number | undefined,\n\tpayloadSize: number,\n\tlogger: ITelemetryLogger,\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: ITelemetryProperties = {\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: ITelemetryProperties,\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\nexport const emptyMessageStream: IStream<ISequencedDocumentMessage[]> = {\n\tread: async () => {\n\t\treturn { done: true };\n\t},\n};\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\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;AACH,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AACzE,OAAO,
|
|
1
|
+
{"version":3,"file":"prefetchDocumentStorageService.d.ts","sourceRoot":"","sources":["../src/prefetchDocumentStorageService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AACzE,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,sCAAsC,CAAC;AAC/E,OAAO,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AAG5E,qBAAa,8BAA+B,SAAQ,2BAA2B;IAE9E,OAAO,CAAC,QAAQ,CAAC,aAAa,CAA+C;IAC7E,OAAO,CAAC,eAAe,CAAQ;IAE/B,IAAW,QAAQ;;;;kBAKlB;IAEY,eAAe,CAAC,OAAO,CAAC,EAAE,QAAQ,GAAG,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC;IAclE,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC;IAGxD,YAAY;YAKL,UAAU;IAqBxB,OAAO,CAAC,YAAY;IAUpB,OAAO,CAAC,gBAAgB;CAmBxB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prefetchDocumentStorageService.js","sourceRoot":"","sources":["../src/prefetchDocumentStorageService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;
|
|
1
|
+
{"version":3,"file":"prefetchDocumentStorageService.js","sourceRoot":"","sources":["../src/prefetchDocumentStorageService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AAEzE,OAAO,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AAC5E,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAE5C,MAAM,OAAO,8BAA+B,SAAQ,2BAA2B;IAA/E;;QACC,qCAAqC;QACpB,kBAAa,GAAG,IAAI,GAAG,EAAoC,CAAC;QACrE,oBAAe,G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I,CAAC,KAAK,CAAC,EAAE;YAC9C,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,SAAS,CAAC,CAAC;SACtD;IACF,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\nimport { LoaderCachingPolicy } from \"@fluidframework/driver-definitions\";\nimport { ISnapshotTree, IVersion } from \"@fluidframework/protocol-definitions\";\nimport { DocumentStorageServiceProxy } from \"./documentStorageServiceProxy\";\nimport { canRetryOnError } from \"./network\";\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() {\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 of Object.keys(tree.blobs)) {\n\t\t\tconst blob = tree.blobs[blobKey];\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.keys(tree.trees)) {\n\t\t\tthis.prefetchTreeCore(tree.trees[subTree], secondary);\n\t\t}\n\t}\n}\n"]}
|
package/lib/rateLimiter.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rateLimiter.d.ts","sourceRoot":"","sources":["../src/rateLimiter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,qBAAa,WAAW;
|
|
1
|
+
{"version":3,"file":"rateLimiter.d.ts","sourceRoot":"","sources":["../src/rateLimiter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,qBAAa,WAAW;IAEX,OAAO,CAAC,WAAW;IAD/B,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAsB;gBACxB,WAAW,EAAE,MAAM;IAIvC,IAAW,eAAe,IAAI,MAAM,CAEnC;IAID,SAAS,CAAC,QAAQ,CAAC,OAAO,aAMxB;cAEc,OAAO;IAWV,QAAQ,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC;CAI/C"}
|
package/lib/rateLimiter.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rateLimiter.js","sourceRoot":"","sources":["../src/rateLimiter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AAEtD,MAAM,OAAO,WAAW;
|
|
1
|
+
{"version":3,"file":"rateLimiter.js","sourceRoot":"","sources":["../src/rateLimiter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AAEtD,MAAM,OAAO,WAAW;IAEvB,YAAoB,WAAmB;QAAnB,gBAAW,GAAX,WAAW,CAAQ;QADtB,UAAK,GAAmB,EAAE,CAAC;QAS5C,8CAA8C;QAC9C,0EAA0E;QACvD,YAAO,GAAG,GAAG,EAAE;YACjC,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;YAChC,IAAI,IAAI,KAAK,SAAS,EAAE;gBACvB,OAAO,IAAI,EAAE,CAAC;aACd;YACD,IAAI,CAAC,WAAW,EAAE,CAAC;QACpB,CAAC,CAAC;QAfD,MAAM,CAAC,WAAW,GAAG,CAAC,EAAE,KAAK,CAAC,yDAAyD,CAAC,CAAC;IAC1F,CAAC;IAED,IAAW,eAAe;QACzB,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC;IAC1B,CAAC;IAYS,KAAK,CAAC,OAAO;QACtB,IAAI,IAAI,CAAC,WAAW,GAAG,CAAC,EAAE;YACzB,IAAI,CAAC,WAAW,EAAE,CAAC;YACnB,OAAO;SACP;QAED,OAAO,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,EAAE;YACpC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAC1B,CAAC,CAAC,CAAC;IACJ,CAAC;IAEM,KAAK,CAAC,QAAQ,CAAI,IAAsB;QAC9C,MAAM,IAAI,CAAC,OAAO,EAAE,CAAC;QACrB,OAAO,IAAI,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACrC,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/common-utils\";\n\nexport class RateLimiter {\n\tprivate readonly tasks: (() => void)[] = [];\n\tconstructor(private maxRequests: number) {\n\t\tassert(maxRequests > 0, 0x0ae /* \"Tried to create rate limiter with 0 max requests!\" */);\n\t}\n\n\tpublic get waitQueueLength(): number {\n\t\treturn this.tasks.length;\n\t}\n\n\t// Run when one of the tasks finished running.\n\t// Release next task if we have one, or allow more tasks to run in future.\n\tprotected readonly release = () => {\n\t\tconst task = this.tasks.shift();\n\t\tif (task !== undefined) {\n\t\t\treturn task();\n\t\t}\n\t\tthis.maxRequests++;\n\t};\n\n\tprotected async acquire() {\n\t\tif (this.maxRequests > 0) {\n\t\t\tthis.maxRequests--;\n\t\t\treturn;\n\t\t}\n\n\t\treturn new Promise<void>((resolve) => {\n\t\t\tthis.tasks.push(resolve);\n\t\t});\n\t}\n\n\tpublic async schedule<T>(work: () => Promise<T>) {\n\t\tawait this.acquire();\n\t\treturn work().finally(this.release);\n\t}\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"readAndParse.d.ts","sourceRoot":"","sources":["../src/readAndParse.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,uBAAuB,EAAE,MAAM,oCAAoC,CAAC;AAE7E;;;;;;;;;;;GAWG;AACH,wBAAsB,YAAY,CAAC,CAAC,
|
|
1
|
+
{"version":3,"file":"readAndParse.d.ts","sourceRoot":"","sources":["../src/readAndParse.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,uBAAuB,EAAE,MAAM,oCAAoC,CAAC;AAE7E;;;;;;;;;;;GAWG;AACH,wBAAsB,YAAY,CAAC,CAAC,EACnC,OAAO,EAAE,IAAI,CAAC,uBAAuB,EAAE,UAAU,CAAC,EAClD,EAAE,EAAE,MAAM,GACR,OAAO,CAAC,CAAC,CAAC,CAIZ"}
|
package/lib/readAndParse.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"readAndParse.js","sourceRoot":"","sources":["../src/readAndParse.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAG9D;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,
|
|
1
|
+
{"version":3,"file":"readAndParse.js","sourceRoot":"","sources":["../src/readAndParse.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAG9D;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CACjC,OAAkD,EAClD,EAAU;IAEV,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;IACxC,MAAM,OAAO,GAAG,cAAc,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IAC7C,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAM,CAAC;AACjC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { bufferToString } from \"@fluidframework/common-utils\";\nimport { IDocumentStorageService } from \"@fluidframework/driver-definitions\";\n\n/**\n * Read a blob from {@link @fluidframework/driver-definitions#IDocumentStorageService} and\n * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse | JSON.parse}\n * it into object of type `T`.\n *\n * @param storage - The `DocumentStorageService` to read from.\n * @param id - The ID of the blob to read and parse.\n *\n * @typeParam T - Output type matching JSON format of inpyt blob data.\n *\n * @returns The object that we decoded and parsed via `JSON.parse`.\n */\nexport async function readAndParse<T>(\n\tstorage: Pick<IDocumentStorageService, \"readBlob\">,\n\tid: string,\n): Promise<T> {\n\tconst blob = await storage.readBlob(id);\n\tconst decoded = bufferToString(blob, \"utf8\");\n\treturn JSON.parse(decoded) as T;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runWithRetry.d.ts","sourceRoot":"","sources":["../src/runWithRetry.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAOtE;;;GAGG;AACH,MAAM,WAAW,SAAS;
|
|
1
|
+
{"version":3,"file":"runWithRetry.d.ts","sourceRoot":"","sources":["../src/runWithRetry.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAOtE;;;GAGG;AACH,MAAM,WAAW,SAAS;IACzB;;;;;;;;;;;;;OAaG;IACH,MAAM,CAAC,EAAE,WAAW,CAAC;IAErB;;;;;;;OAOG;IACH,OAAO,CAAC,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,IAAI,CAAC;CAC9C;AAED,wBAAsB,YAAY,CAAC,CAAC,EACnC,GAAG,EAAE,CAAC,MAAM,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,CAAC,CAAC,EACzC,aAAa,EAAE,MAAM,EACrB,MAAM,EAAE,gBAAgB,EACxB,QAAQ,EAAE,SAAS,GACjB,OAAO,CAAC,CAAC,CAAC,CAiFZ"}
|
package/lib/runWithRetry.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runWithRetry.js","sourceRoot":"","sources":["../src/runWithRetry.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAClE,OAAO,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AACrE,OAAO,EAAE,eAAe,EAAE,sBAAsB,EAAE,MAAM,WAAW,CAAC;AACpE,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,iBAAiB,EAAE,MAAM,GAAG,CAAC;AAkCtC,MAAM,CAAC,KAAK,UAAU,YAAY,
|
|
1
|
+
{"version":3,"file":"runWithRetry.js","sourceRoot":"","sources":["../src/runWithRetry.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAClE,OAAO,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AACrE,OAAO,EAAE,eAAe,EAAE,sBAAsB,EAAE,MAAM,WAAW,CAAC;AACpE,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,iBAAiB,EAAE,MAAM,GAAG,CAAC;AAkCtC,MAAM,CAAC,KAAK,UAAU,YAAY,CACjC,GAAyC,EACzC,aAAqB,EACrB,MAAwB,EACxB,QAAmB;;IAEnB,IAAI,MAAqB,CAAC;IAC1B,IAAI,OAAO,GAAG,KAAK,CAAC;IACpB,IAAI,YAAY,GAAG,IAAI,CAAC,CAAC,sBAAsB;IAC/C,IAAI,UAAU,GAAG,CAAC,CAAC;IACnB,MAAM,SAAS,GAAG,WAAW,CAAC,GAAG,EAAE,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CAAC,GAAG,CAAC,mCAAI,IAAI,CAAC,GAAG,CAAC,YAAY,GAAG,CAAC,EAAE,IAAI,CAAC,CAAC;YAC/E,IAAI,QAAQ,CAAC,OAAO,EAAE;gBACrB,QAAQ,CAAC,OAAO,CAAC,YAAY,EAAE,GAAG,CAAC,CAAC;aACpC;YACD,MAAM,KAAK,CAAC,YAAY,CAAC,CAAC;SAC1B;KACD,QAAQ,CAAC,OAAO,EAAE;IACnB,IAAI,UAAU,GAAG,CAAC,EAAE;QACnB,MAAM,CAAC,kBAAkB,CACxB;YACC,SAAS,EAAE,GAAG,aAAa,YAAY;YACvC,KAAK,EAAE,UAAU;YACjB,QAAQ,EAAE,WAAW,CAAC,GAAG,EAAE,GAAG,SAAS;YACvC,aAAa;SACb,EACD,SAAS,CACT,CAAC;KACF;IACD,oEAAoE;IACpE,OAAO,MAAO,CAAC;AAChB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryLogger } from \"@fluidframework/common-definitions\";\nimport { delay, performance } from \"@fluidframework/common-utils\";\nimport { DriverErrorType } from \"@fluidframework/driver-definitions\";\nimport { canRetryOnError, getRetryDelayFromError } from \"./network\";\nimport { pkgVersion } from \"./packageVersion\";\nimport { NonRetryableError } from \".\";\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 */\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\nexport async function runWithRetry<T>(\n\tapi: (cancel?: AbortSignal) => Promise<T>,\n\tfetchCallName: string,\n\tlogger: ITelemetryLogger,\n\tprogress: IProgress,\n): Promise<T> {\n\tlet result: T | undefined;\n\tlet success = false;\n\tlet retryAfterMs = 1000; // has to be positive!\n\tlet numRetries = 0;\n\tconst startTime = performance.now();\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: performance.now() - 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: performance.now() - 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 new NonRetryableError(\n\t\t\t\t\t\"runWithRetry was Aborted\",\n\t\t\t\t\tDriverErrorType.genericError,\n\t\t\t\t\t{ driverVersion: pkgVersion, fetchCallName },\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: performance.now() - 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// If the error is throttling error, then wait for the specified time before retrying.\n\t\t\t// If the waitTime is not specified, then we start with retrying immediately to max of 8s.\n\t\t\tretryAfterMs = getRetryDelayFromError(err) ?? Math.min(retryAfterMs * 2, 8000);\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: performance.now() - 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"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"summaryForCreateNew.d.ts","sourceRoot":"","sources":["../src/summaryForCreateNew.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"summaryForCreateNew.d.ts","sourceRoot":"","sources":["../src/summaryForCreateNew.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,YAAY,EAGZ,kBAAkB,EAClB,mBAAmB,EACnB,MAAM,sCAAsC,CAAC;AAE9C;;;;GAIG;AACH,wBAAgB,4BAA4B,CAC3C,UAAU,EAAE,YAAY,EACxB,eAAe,EAAE,YAAY,GAC3B,YAAY,CASd;AAED;;;GAGG;AACH,wBAAgB,mCAAmC,CAClD,eAAe,EAAE,YAAY,GAC3B,mBAAmB,CAKrB;AAED;;;GAGG;AACH,wBAAgB,kCAAkC,CACjD,eAAe,EAAE,YAAY,GAC3B,CAAC,MAAM,EAAE,kBAAkB,CAAC,EAAE,CAOhC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"summaryForCreateNew.js","sourceRoot":"","sources":["../src/summaryForCreateNew.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"summaryForCreateNew.js","sourceRoot":"","sources":["../src/summaryForCreateNew.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAEN,WAAW,GAIX,MAAM,sCAAsC,CAAC;AAE9C;;;;GAIG;AACH,MAAM,UAAU,4BAA4B,CAC3C,UAAwB,EACxB,eAA6B;IAE7B,MAAM,gBAAgB,GAAiB;QACtC,IAAI,EAAE,WAAW,CAAC,IAAI;QACtB,IAAI,EAAE;YACL,WAAW,EAAE,eAAe;YAC5B,MAAM,EAAE,UAAU;SAClB;KACD,CAAC;IACF,OAAO,gBAAgB,CAAC;AACzB,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,mCAAmC,CAClD,eAA6B;;IAE7B,MAAM,cAAc,GAAG,eAAe,CAAC,IAAI,CAAC,UAA0B,CAAC;IACvE,MAAM,kBAAkB,GAAG,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,OAAiB,CAAwB,CAAC;IAC/F,kBAAkB,CAAC,IAAI,GAAG,MAAA,kBAAkB,CAAC,IAAI,mCAAI,CAAC,CAAC;IACvD,OAAO,kBAAkB,CAAC;AAC3B,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,kCAAkC,CACjD,eAA6B;IAE7B,MAAM,gBAAgB,GAAG,eAAe,CAAC,IAAI,CAAC,YAA4B,CAAC;IAC3E,MAAM,YAAY,GAAG,IAAI,CAAC,KAAK,CAAC,gBAAgB,CAAC,OAAiB,CAG/D,CAAC;IACJ,OAAO,YAAY,CAAC;AACrB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tISummaryTree,\n\tSummaryType,\n\tISummaryBlob,\n\tICommittedProposal,\n\tIDocumentAttributes,\n} from \"@fluidframework/protocol-definitions\";\n\n/**\n * Combine the app summary and protocol summary in 1 tree.\n * @param appSummary - Summary of the app.\n * @param protocolSummary - Summary of the protocol.\n */\nexport function combineAppAndProtocolSummary(\n\tappSummary: ISummaryTree,\n\tprotocolSummary: ISummaryTree,\n): ISummaryTree {\n\tconst createNewSummary: ISummaryTree = {\n\t\ttype: SummaryType.Tree,\n\t\ttree: {\n\t\t\t\".protocol\": protocolSummary,\n\t\t\t\".app\": appSummary,\n\t\t},\n\t};\n\treturn createNewSummary;\n}\n\n/**\n * Extract the attributes from the protocol summary.\n * @param protocolSummary - protocol summary from which the values are to be extracted.\n */\nexport function getDocAttributesFromProtocolSummary(\n\tprotocolSummary: ISummaryTree,\n): IDocumentAttributes {\n\tconst attributesBlob = protocolSummary.tree.attributes as ISummaryBlob;\n\tconst documentAttributes = JSON.parse(attributesBlob.content as string) as IDocumentAttributes;\n\tdocumentAttributes.term = documentAttributes.term ?? 1;\n\treturn documentAttributes;\n}\n\n/**\n * Extract quorum values from the protocol summary.\n * @param protocolSummary - protocol summary from which the values are to be extracted.\n */\nexport function getQuorumValuesFromProtocolSummary(\n\tprotocolSummary: ISummaryTree,\n): [string, ICommittedProposal][] {\n\tconst quorumValuesBlob = protocolSummary.tree.quorumValues as ISummaryBlob;\n\tconst quorumValues = JSON.parse(quorumValuesBlob.content as string) as [\n\t\tstring,\n\t\tICommittedProposal,\n\t][];\n\treturn quorumValues;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"treeConversions.d.ts","sourceRoot":"","sources":["../src/treeConversions.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"treeConversions.d.ts","sourceRoot":"","sources":["../src/treeConversions.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,YAAY,EAAE,KAAK,EAA2B,MAAM,sCAAsC,CAAC;AAEpG;;;GAGG;AACH,wBAAgB,iCAAiC,CAAC,WAAW,EAAE,YAAY,GAAG,KAAK,CAkDlF"}
|
package/lib/treeConversions.js
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
import { Uint8ArrayToString, unreachableCase
|
|
6
|
-
import { AttachmentTreeEntry, BlobTreeEntry, TreeTreeEntry
|
|
7
|
-
import { SummaryType
|
|
5
|
+
import { Uint8ArrayToString, unreachableCase } from "@fluidframework/common-utils";
|
|
6
|
+
import { AttachmentTreeEntry, BlobTreeEntry, TreeTreeEntry } from "@fluidframework/protocol-base";
|
|
7
|
+
import { SummaryType } from "@fluidframework/protocol-definitions";
|
|
8
8
|
/**
|
|
9
9
|
* Converts ISummaryTree to ITree format.
|
|
10
10
|
* @param summaryTree - summary tree in ISummaryTree format
|
|
@@ -17,10 +17,7 @@ export function convertSummaryTreeToSnapshotITree(summaryTree) {
|
|
|
17
17
|
const adaptSumaryTree = protocolSummary && appSummary;
|
|
18
18
|
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
|
|
19
19
|
const allSummaryEntries = adaptSumaryTree
|
|
20
|
-
? [
|
|
21
|
-
...Object.entries(protocolSummary.tree),
|
|
22
|
-
...Object.entries(appSummary.tree),
|
|
23
|
-
]
|
|
20
|
+
? [...Object.entries(protocolSummary.tree), ...Object.entries(appSummary.tree)]
|
|
24
21
|
: Object.entries(summaryTree.tree);
|
|
25
22
|
for (const [key, value] of allSummaryEntries) {
|
|
26
23
|
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"treeConversions.js","sourceRoot":"","sources":["../src/treeConversions.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"treeConversions.js","sourceRoot":"","sources":["../src/treeConversions.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AACnF,OAAO,EAAE,mBAAmB,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAClG,OAAO,EAAmC,WAAW,EAAE,MAAM,sCAAsC,CAAC;AAEpG;;;GAGG;AACH,MAAM,UAAU,iCAAiC,CAAC,WAAyB;IAC1E,MAAM,OAAO,GAAiB,EAAE,CAAC;IACjC,MAAM,eAAe,GAAG,WAAW,CAAC,IAAI,CAAC,WAAW,CAAiB,CAAC;IACtE,MAAM,UAAU,GAAG,WAAW,CAAC,IAAI,CAAC,MAAM,CAAiB,CAAC;IAC5D,yEAAyE;IACzE,MAAM,eAAe,GAAG,eAAe,IAAI,UAAU,CAAC;IACtD,yEAAyE;IACzE,MAAM,iBAAiB,GAAG,eAAe;QACxC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,OAAO,CAAC,eAAe,CAAC,IAAI,CAAC,EAAE,GAAG,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;QAC/E,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;IAEpC,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,iBAAiB,EAAE;QAC7C,yEAAyE;QACzE,MAAM,CAAC,GAAG,eAAe,IAAI,CAAC,YAAY,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,GAAG,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC;QAC5E,QAAQ,KAAK,CAAC,IAAI,EAAE;YACnB,KAAK,WAAW,CAAC,IAAI,CAAC,CAAC;gBACtB,IAAI,aAAqB,CAAC;gBAC1B,IAAI,QAAQ,GAAuB,OAAO,CAAC;gBAC3C,IAAI,OAAO,KAAK,CAAC,OAAO,KAAK,QAAQ,EAAE;oBACtC,aAAa,GAAG,KAAK,CAAC,OAAO,CAAC;iBAC9B;qBAAM;oBACN,aAAa,GAAG,kBAAkB,CAAC,KAAK,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;oBAC5D,QAAQ,GAAG,QAAQ,CAAC;iBACpB;gBACD,OAAO,CAAC,IAAI,CAAC,IAAI,aAAa,CAAC,CAAC,EAAE,aAAa,EAAE,QAAQ,CAAC,CAAC,CAAC;gBAC5D,MAAM;aACN;YAED,KAAK,WAAW,CAAC,IAAI,CAAC,CAAC;gBACtB,OAAO,CAAC,IAAI,CAAC,IAAI,aAAa,CAAC,CAAC,EAAE,iCAAiC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;gBAC7E,MAAM;aACN;YAED,KAAK,WAAW,CAAC,UAAU,CAAC,CAAC;gBAC5B,OAAO,CAAC,IAAI,CAAC,IAAI,mBAAmB,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC;gBACnD,MAAM;aACN;YAED,KAAK,WAAW,CAAC,MAAM,CAAC,CAAC;gBACxB,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAC;aAC/D;YAED;gBACC,eAAe,CAAC,KAAK,EAAE,8BAA8B,CAAC,CAAC;SACxD;KACD;IACD,OAAO;QACN,OAAO;QACP,YAAY,EAAE,WAAW,CAAC,YAAY;KACtC,CAAC;AACH,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { Uint8ArrayToString, unreachableCase } from \"@fluidframework/common-utils\";\nimport { AttachmentTreeEntry, BlobTreeEntry, TreeTreeEntry } from \"@fluidframework/protocol-base\";\nimport { ISummaryTree, ITree, ITreeEntry, SummaryType } from \"@fluidframework/protocol-definitions\";\n\n/**\n * Converts ISummaryTree to ITree format.\n * @param summaryTree - summary tree in ISummaryTree format\n */\nexport function convertSummaryTreeToSnapshotITree(summaryTree: ISummaryTree): ITree {\n\tconst entries: ITreeEntry[] = [];\n\tconst protocolSummary = summaryTree.tree[\".protocol\"] as ISummaryTree;\n\tconst appSummary = summaryTree.tree[\".app\"] as ISummaryTree;\n\t// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions\n\tconst adaptSumaryTree = protocolSummary && appSummary;\n\t// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions\n\tconst allSummaryEntries = adaptSumaryTree\n\t\t? [...Object.entries(protocolSummary.tree), ...Object.entries(appSummary.tree)]\n\t\t: Object.entries(summaryTree.tree);\n\n\tfor (const [key, value] of allSummaryEntries) {\n\t\t// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions\n\t\tconst k = adaptSumaryTree && [\"attributes\"].includes(key) ? `.${key}` : key;\n\t\tswitch (value.type) {\n\t\t\tcase SummaryType.Blob: {\n\t\t\t\tlet parsedContent: string;\n\t\t\t\tlet encoding: \"utf-8\" | \"base64\" = \"utf-8\";\n\t\t\t\tif (typeof value.content === \"string\") {\n\t\t\t\t\tparsedContent = value.content;\n\t\t\t\t} else {\n\t\t\t\t\tparsedContent = Uint8ArrayToString(value.content, \"base64\");\n\t\t\t\t\tencoding = \"base64\";\n\t\t\t\t}\n\t\t\t\tentries.push(new BlobTreeEntry(k, parsedContent, encoding));\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase SummaryType.Tree: {\n\t\t\t\tentries.push(new TreeTreeEntry(k, convertSummaryTreeToSnapshotITree(value)));\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase SummaryType.Attachment: {\n\t\t\t\tentries.push(new AttachmentTreeEntry(k, value.id));\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase SummaryType.Handle: {\n\t\t\t\tthrow new Error(\"Should not have Handle type in summary tree\");\n\t\t\t}\n\n\t\t\tdefault:\n\t\t\t\tunreachableCase(value, \"Unexpected summary tree type\");\n\t\t}\n\t}\n\treturn {\n\t\tentries,\n\t\tunreferenced: summaryTree.unreferenced,\n\t};\n}\n"]}
|
package/lib/treeUtils.d.ts
CHANGED
|
@@ -21,24 +21,24 @@ export declare class SummaryTreeAssembler {
|
|
|
21
21
|
private readonly summaryTree;
|
|
22
22
|
constructor(props?: ISummaryTreeAssemblerProps | undefined);
|
|
23
23
|
/**
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
* Get final summary
|
|
25
|
+
*/
|
|
26
26
|
get summary(): ISummaryTree;
|
|
27
27
|
/**
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
* Add blob to summary
|
|
29
|
+
*/
|
|
30
30
|
addBlob(key: string, content: string | Uint8Array): void;
|
|
31
31
|
/**
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
* Add handle to summary
|
|
33
|
+
*/
|
|
34
34
|
addHandle(key: string, handleType: SummaryType.Tree | SummaryType.Blob | SummaryType.Attachment, handle: string): void;
|
|
35
35
|
/**
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
* Add tree to summary
|
|
37
|
+
*/
|
|
38
38
|
addTree(key: string, summary: ISummaryTree): void;
|
|
39
39
|
/**
|
|
40
|
-
|
|
41
|
-
|
|
40
|
+
* Add attachment to summary
|
|
41
|
+
*/
|
|
42
42
|
addAttachment(id: string): void;
|
|
43
43
|
}
|
|
44
44
|
/**
|
package/lib/treeUtils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"treeUtils.d.ts","sourceRoot":"","sources":["../src/treeUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"treeUtils.d.ts","sourceRoot":"","sources":["../src/treeUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EACN,WAAW,EACX,aAAa,EACb,YAAY,EAEZ,MAAM,sCAAsC,CAAC;AAE9C;;GAEG;AACH,MAAM,WAAW,0BAA0B;IAC1C;;OAEG;IACH,YAAY,CAAC,EAAE,IAAI,CAAC;CACpB;AAED;;GAEG;AACH,qBAAa,oBAAoB;IAIpB,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC;IAHnC,OAAO,CAAC,iBAAiB,CAAa;IACtC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAyC;gBAExC,KAAK,CAAC,wCAA4B;IAE/D;;OAEG;IACH,IAAW,OAAO,IAAI,YAAY,CAMjC;IAED;;OAEG;IACI,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,UAAU,GAAG,IAAI;IAO/D;;OAEG;IACI,SAAS,CACf,GAAG,EAAE,MAAM,EACX,UAAU,EAAE,WAAW,CAAC,IAAI,GAAG,WAAW,CAAC,IAAI,GAAG,WAAW,CAAC,UAAU,EACxE,MAAM,EAAE,MAAM,GACZ,IAAI;IAQP;;OAEG;IACI,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,YAAY,GAAG,IAAI;IAIxD;;OAEG;IACI,aAAa,CAAC,EAAE,EAAE,MAAM;CAG/B;AAED;;;;;GAKG;AACH,wBAAgB,oCAAoC,CACnD,QAAQ,EAAE,aAAa,EACvB,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,GAC7B,YAAY,CAcd"}
|
package/lib/treeUtils.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 { assert, IsoBuffer
|
|
5
|
+
import { assert, IsoBuffer } from "@fluidframework/common-utils";
|
|
6
6
|
import { SummaryType, } from "@fluidframework/protocol-definitions";
|
|
7
7
|
/**
|
|
8
8
|
* Summary tree assembler (without stats collection).
|
|
@@ -14,8 +14,8 @@ export class SummaryTreeAssembler {
|
|
|
14
14
|
this.summaryTree = {};
|
|
15
15
|
}
|
|
16
16
|
/**
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
* Get final summary
|
|
18
|
+
*/
|
|
19
19
|
get summary() {
|
|
20
20
|
var _a;
|
|
21
21
|
return {
|
|
@@ -25,8 +25,8 @@ export class SummaryTreeAssembler {
|
|
|
25
25
|
};
|
|
26
26
|
}
|
|
27
27
|
/**
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
* Add blob to summary
|
|
29
|
+
*/
|
|
30
30
|
addBlob(key, content) {
|
|
31
31
|
this.summaryTree[key] = {
|
|
32
32
|
type: SummaryType.Blob,
|
|
@@ -34,8 +34,8 @@ export class SummaryTreeAssembler {
|
|
|
34
34
|
};
|
|
35
35
|
}
|
|
36
36
|
/**
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
* Add handle to summary
|
|
38
|
+
*/
|
|
39
39
|
addHandle(key, handleType, handle) {
|
|
40
40
|
this.summaryTree[key] = {
|
|
41
41
|
type: SummaryType.Handle,
|
|
@@ -44,14 +44,14 @@ export class SummaryTreeAssembler {
|
|
|
44
44
|
};
|
|
45
45
|
}
|
|
46
46
|
/**
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
* Add tree to summary
|
|
48
|
+
*/
|
|
49
49
|
addTree(key, summary) {
|
|
50
50
|
this.summaryTree[key] = summary;
|
|
51
51
|
}
|
|
52
52
|
/**
|
|
53
|
-
|
|
54
|
-
|
|
53
|
+
* Add attachment to summary
|
|
54
|
+
*/
|
|
55
55
|
addAttachment(id) {
|
|
56
56
|
this.summaryTree[this.attachmentCounter++] = { id, type: SummaryType.Attachment };
|
|
57
57
|
}
|