@fluidframework/driver-utils 2.0.0-internal.3.2.1 → 2.0.0-internal.3.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/blobCacheStorageService.d.ts +11 -0
- package/dist/blobCacheStorageService.d.ts.map +1 -1
- package/dist/blobCacheStorageService.js +11 -0
- package/dist/blobCacheStorageService.js.map +1 -1
- package/dist/emptyDocumentDeltaStorageService.d.ts +5 -0
- package/dist/emptyDocumentDeltaStorageService.d.ts.map +1 -1
- package/dist/emptyDocumentDeltaStorageService.js +5 -0
- package/dist/emptyDocumentDeltaStorageService.js.map +1 -1
- package/dist/mapWithExpiration.d.ts +41 -0
- package/dist/mapWithExpiration.d.ts.map +1 -1
- package/dist/mapWithExpiration.js +41 -0
- package/dist/mapWithExpiration.js.map +1 -1
- package/dist/multiDocumentServiceFactory.d.ts +18 -0
- package/dist/multiDocumentServiceFactory.d.ts.map +1 -1
- package/dist/multiDocumentServiceFactory.js +18 -0
- package/dist/multiDocumentServiceFactory.js.map +1 -1
- package/dist/multiUrlResolver.d.ts +14 -0
- package/dist/multiUrlResolver.d.ts.map +1 -1
- package/dist/multiUrlResolver.js +14 -0
- package/dist/multiUrlResolver.js.map +1 -1
- package/dist/networkUtils.d.ts +2 -0
- package/dist/networkUtils.d.ts.map +1 -1
- package/dist/networkUtils.js +2 -0
- 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 +33 -14
- package/dist/parallelRequests.js.map +1 -1
- package/dist/treeUtils.d.ts +21 -0
- package/dist/treeUtils.d.ts.map +1 -1
- package/dist/treeUtils.js +17 -0
- package/dist/treeUtils.js.map +1 -1
- package/lib/blobCacheStorageService.d.ts +11 -0
- package/lib/blobCacheStorageService.d.ts.map +1 -1
- package/lib/blobCacheStorageService.js +11 -0
- package/lib/blobCacheStorageService.js.map +1 -1
- package/lib/emptyDocumentDeltaStorageService.d.ts +5 -0
- package/lib/emptyDocumentDeltaStorageService.d.ts.map +1 -1
- package/lib/emptyDocumentDeltaStorageService.js +5 -0
- package/lib/emptyDocumentDeltaStorageService.js.map +1 -1
- package/lib/mapWithExpiration.d.ts +41 -0
- package/lib/mapWithExpiration.d.ts.map +1 -1
- package/lib/mapWithExpiration.js +41 -0
- package/lib/mapWithExpiration.js.map +1 -1
- package/lib/multiDocumentServiceFactory.d.ts +18 -0
- package/lib/multiDocumentServiceFactory.d.ts.map +1 -1
- package/lib/multiDocumentServiceFactory.js +18 -0
- package/lib/multiDocumentServiceFactory.js.map +1 -1
- package/lib/multiUrlResolver.d.ts +14 -0
- package/lib/multiUrlResolver.d.ts.map +1 -1
- package/lib/multiUrlResolver.js +14 -0
- package/lib/multiUrlResolver.js.map +1 -1
- package/lib/networkUtils.d.ts +2 -0
- package/lib/networkUtils.d.ts.map +1 -1
- package/lib/networkUtils.js +2 -0
- 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 +34 -15
- package/lib/parallelRequests.js.map +1 -1
- package/lib/treeUtils.d.ts +21 -0
- package/lib/treeUtils.d.ts.map +1 -1
- package/lib/treeUtils.js +17 -0
- package/lib/treeUtils.js.map +1 -1
- package/package.json +12 -16
- package/src/blobCacheStorageService.ts +11 -0
- package/src/emptyDocumentDeltaStorageService.ts +5 -0
- package/src/mapWithExpiration.ts +41 -0
- package/src/multiDocumentServiceFactory.ts +18 -0
- package/src/multiUrlResolver.ts +14 -0
- package/src/networkUtils.ts +2 -0
- package/src/packageVersion.ts +1 -1
- package/src/parallelRequests.ts +37 -18
- package/src/treeUtils.ts +21 -0
package/src/multiUrlResolver.ts
CHANGED
|
@@ -10,6 +10,8 @@ import { IResolvedUrl, IUrlResolver } from "@fluidframework/driver-definitions";
|
|
|
10
10
|
* Resolver that takes a list of url resolvers and then try each of them to resolve the url.
|
|
11
11
|
* @param resolversList - List of url resolvers to be used to resolve the request.
|
|
12
12
|
* @param request - Request to be resolved.
|
|
13
|
+
*
|
|
14
|
+
* @deprecated 2.0.0-internal.3.2.0 Not recommended for general purpose use.
|
|
13
15
|
*/
|
|
14
16
|
export async function configurableUrlResolver(
|
|
15
17
|
resolversList: IUrlResolver[],
|
|
@@ -25,7 +27,13 @@ export async function configurableUrlResolver(
|
|
|
25
27
|
return undefined;
|
|
26
28
|
}
|
|
27
29
|
|
|
30
|
+
/**
|
|
31
|
+
* @deprecated 2.0.0-internal.3.2.0 Not recommended for general purpose use.
|
|
32
|
+
*/
|
|
28
33
|
export class MultiUrlResolver implements IUrlResolver {
|
|
34
|
+
/**
|
|
35
|
+
* @deprecated 2.0.0-internal.3.2.0 Not recommended for general purpose use.
|
|
36
|
+
*/
|
|
29
37
|
public static create(urlResolver: IUrlResolver | IUrlResolver[]) {
|
|
30
38
|
if (Array.isArray(urlResolver)) {
|
|
31
39
|
if (urlResolver.length === 1) {
|
|
@@ -38,10 +46,16 @@ export class MultiUrlResolver implements IUrlResolver {
|
|
|
38
46
|
|
|
39
47
|
private constructor(private readonly urlResolvers: IUrlResolver[]) {}
|
|
40
48
|
|
|
49
|
+
/**
|
|
50
|
+
* @deprecated 2.0.0-internal.3.2.0 Not recommended for general purpose use.
|
|
51
|
+
*/
|
|
41
52
|
async resolve(request: IRequest): Promise<IResolvedUrl | undefined> {
|
|
42
53
|
return configurableUrlResolver(this.urlResolvers, request);
|
|
43
54
|
}
|
|
44
55
|
|
|
56
|
+
/**
|
|
57
|
+
* @deprecated 2.0.0-internal.3.2.0 Not recommended for general purpose use.
|
|
58
|
+
*/
|
|
45
59
|
public async getAbsoluteUrl(resolvedUrl: IResolvedUrl, relativeUrl: string): Promise<string> {
|
|
46
60
|
throw new Error("Not implmented");
|
|
47
61
|
}
|
package/src/networkUtils.ts
CHANGED
|
@@ -38,6 +38,8 @@ export function logNetworkFailure(
|
|
|
38
38
|
* or machine connected to router that is not connected to internet)
|
|
39
39
|
* But there should be no false negatives.
|
|
40
40
|
* The only exception - Opera returns false when user enters "Work Offline" mode, regardless of actual connectivity.
|
|
41
|
+
*
|
|
42
|
+
* @deprecated - 2.0.0-internal.3.2.0 Not recommended for general purpose use.
|
|
41
43
|
*/
|
|
42
44
|
// eslint-disable-next-line @typescript-eslint/promise-function-async
|
|
43
45
|
export function waitForConnectedState(minDelay: number): Promise<void> {
|
package/src/packageVersion.ts
CHANGED
package/src/parallelRequests.ts
CHANGED
|
@@ -8,7 +8,7 @@ import { PerformanceEvent } from "@fluidframework/telemetry-utils";
|
|
|
8
8
|
import { ISequencedDocumentMessage } from "@fluidframework/protocol-definitions";
|
|
9
9
|
import { IDeltasFetchResult, IStream, IStreamResult } from "@fluidframework/driver-definitions";
|
|
10
10
|
import { getRetryDelayFromError, canRetryOnError, createGenericNetworkError } from "./network";
|
|
11
|
-
import {
|
|
11
|
+
import { logNetworkFailure } from "./networkUtils";
|
|
12
12
|
// For now, this package is versioned and released in unison with the specific drivers
|
|
13
13
|
import { pkgVersion as driverVersion } from "./packageVersion";
|
|
14
14
|
|
|
@@ -379,6 +379,19 @@ export class Queue<T> implements IStream<T> {
|
|
|
379
379
|
}
|
|
380
380
|
}
|
|
381
381
|
|
|
382
|
+
const waitForOnline = async (): Promise<void> => {
|
|
383
|
+
// Only wait if we have a strong signal that we're offline - otherwise assume we're online.
|
|
384
|
+
if (globalThis.navigator?.onLine === false && globalThis.addEventListener !== undefined) {
|
|
385
|
+
return new Promise<void>((resolve) => {
|
|
386
|
+
const resolveAndRemoveListener = () => {
|
|
387
|
+
resolve();
|
|
388
|
+
globalThis.removeEventListener("online", resolveAndRemoveListener);
|
|
389
|
+
};
|
|
390
|
+
globalThis.addEventListener("online", resolveAndRemoveListener);
|
|
391
|
+
});
|
|
392
|
+
}
|
|
393
|
+
};
|
|
394
|
+
|
|
382
395
|
/**
|
|
383
396
|
* Retrieve single batch of ops
|
|
384
397
|
* @param request - request index
|
|
@@ -403,7 +416,6 @@ async function getSingleOpBatch(
|
|
|
403
416
|
let lastSuccessTime: number | undefined;
|
|
404
417
|
|
|
405
418
|
let retry: number = 0;
|
|
406
|
-
const deltas: ISequencedDocumentMessage[] = [];
|
|
407
419
|
const nothing = { partial: false, cancel: true, payload: [] };
|
|
408
420
|
|
|
409
421
|
while (signal?.aborted !== true) {
|
|
@@ -412,23 +424,22 @@ async function getSingleOpBatch(
|
|
|
412
424
|
const startTime = performance.now();
|
|
413
425
|
|
|
414
426
|
try {
|
|
415
|
-
// Issue async request for deltas
|
|
416
|
-
const
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
deltas.push(...messages);
|
|
420
|
-
|
|
421
|
-
const deltasRetrievedLast = messages.length;
|
|
427
|
+
// Issue async request for deltas
|
|
428
|
+
const { messages, partialResult } = await get(
|
|
429
|
+
{ ...props, retry } /* telemetry props */,
|
|
430
|
+
);
|
|
422
431
|
|
|
423
|
-
|
|
424
|
-
|
|
432
|
+
// If we got messages back, return them. Return regardless of whether we got messages back if we didn't
|
|
433
|
+
// specify a "to", since we don't have an expectation of how many to receive.
|
|
434
|
+
if (messages.length !== 0 || !strongTo) {
|
|
435
|
+
return { payload: messages, cancel: false, partial: partialResult };
|
|
425
436
|
}
|
|
426
437
|
|
|
427
|
-
//
|
|
428
|
-
// Attempt to fetch more deltas. If we didn't receive any in the previous call we up our retry
|
|
429
|
-
// count since something prevented us from seeing those deltas
|
|
438
|
+
// Otherwise, the storage gave us back an empty set of ops but we were expecting a non-empty set.
|
|
430
439
|
|
|
431
440
|
if (lastSuccessTime === undefined) {
|
|
441
|
+
// Take timestamp of the first time server responded successfully, even though it wasn't with the ops we asked for.
|
|
442
|
+
// If we keep getting empty responses we'll eventually fail out below.
|
|
432
443
|
lastSuccessTime = performance.now();
|
|
433
444
|
} else if (performance.now() - lastSuccessTime > 30000) {
|
|
434
445
|
// If we are connected and receiving proper responses from server, but can't get any ops back,
|
|
@@ -449,8 +460,6 @@ async function getSingleOpBatch(
|
|
|
449
460
|
} catch (error) {
|
|
450
461
|
const canRetry = canRetryOnError(error);
|
|
451
462
|
|
|
452
|
-
lastSuccessTime = undefined;
|
|
453
|
-
|
|
454
463
|
const retryAfter = getRetryDelayFromError(error);
|
|
455
464
|
|
|
456
465
|
// This will log to error table only if the error is non-retryable
|
|
@@ -472,12 +481,22 @@ async function getSingleOpBatch(
|
|
|
472
481
|
throw error;
|
|
473
482
|
}
|
|
474
483
|
|
|
475
|
-
if (retryAfter !== undefined
|
|
484
|
+
if (retryAfter !== undefined) {
|
|
485
|
+
// If the error told us to wait, then we will wait for that specific amount rather than the default.
|
|
476
486
|
delay = retryAfter;
|
|
477
487
|
}
|
|
478
488
|
}
|
|
479
489
|
|
|
480
|
-
|
|
490
|
+
// If we get here something has gone wrong - either got an unexpected empty set of messages back or a real error.
|
|
491
|
+
// Either way we will wait a little bit before retrying.
|
|
492
|
+
await new Promise<void>((resolve) => {
|
|
493
|
+
setTimeout(resolve, delay);
|
|
494
|
+
});
|
|
495
|
+
|
|
496
|
+
// If we believe we're offline, we assume there's no point in trying until we at least think we're online.
|
|
497
|
+
// NOTE: This isn't strictly true for drivers that don't require network (e.g. local driver). Really this logic
|
|
498
|
+
// should probably live in the driver.
|
|
499
|
+
await waitForOnline();
|
|
481
500
|
}
|
|
482
501
|
|
|
483
502
|
return nothing;
|
package/src/treeUtils.ts
CHANGED
|
@@ -13,25 +13,36 @@ import {
|
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
15
|
* Summary tree assembler props
|
|
16
|
+
*
|
|
17
|
+
* @deprecated 2.0.0-internal.3.2.0 Not recommended for general purpose use.
|
|
16
18
|
*/
|
|
17
19
|
export interface ISummaryTreeAssemblerProps {
|
|
18
20
|
/**
|
|
19
21
|
* Indicates that this tree is unreferenced. If this is not present, the tree is considered referenced.
|
|
22
|
+
*
|
|
23
|
+
* @deprecated 2.0.0-internal.3.2.0 Not recommended for general purpose use.
|
|
20
24
|
*/
|
|
21
25
|
unreferenced?: true;
|
|
22
26
|
}
|
|
23
27
|
|
|
24
28
|
/**
|
|
25
29
|
* Summary tree assembler (without stats collection).
|
|
30
|
+
*
|
|
31
|
+
* @deprecated 2.0.0-internal.3.2.0 Not recommended for general purpose use.
|
|
26
32
|
*/
|
|
27
33
|
export class SummaryTreeAssembler {
|
|
28
34
|
private attachmentCounter: number = 0;
|
|
29
35
|
private readonly summaryTree: { [path: string]: SummaryObject } = {};
|
|
30
36
|
|
|
37
|
+
/**
|
|
38
|
+
* @deprecated 2.0.0-internal.3.2.0 Not recommended for general purpose use.
|
|
39
|
+
*/
|
|
31
40
|
constructor(private readonly props?: ISummaryTreeAssemblerProps) {}
|
|
32
41
|
|
|
33
42
|
/**
|
|
34
43
|
* Get final summary
|
|
44
|
+
*
|
|
45
|
+
* @deprecated 2.0.0-internal.3.2.0 Not recommended for general purpose use.
|
|
35
46
|
*/
|
|
36
47
|
public get summary(): ISummaryTree {
|
|
37
48
|
return {
|
|
@@ -43,6 +54,8 @@ export class SummaryTreeAssembler {
|
|
|
43
54
|
|
|
44
55
|
/**
|
|
45
56
|
* Add blob to summary
|
|
57
|
+
*
|
|
58
|
+
* @deprecated 2.0.0-internal.3.2.0 Not recommended for general purpose use.
|
|
46
59
|
*/
|
|
47
60
|
public addBlob(key: string, content: string | Uint8Array): void {
|
|
48
61
|
this.summaryTree[key] = {
|
|
@@ -53,6 +66,8 @@ export class SummaryTreeAssembler {
|
|
|
53
66
|
|
|
54
67
|
/**
|
|
55
68
|
* Add handle to summary
|
|
69
|
+
*
|
|
70
|
+
* @deprecated 2.0.0-internal.3.2.0 Not recommended for general purpose use.
|
|
56
71
|
*/
|
|
57
72
|
public addHandle(
|
|
58
73
|
key: string,
|
|
@@ -68,6 +83,8 @@ export class SummaryTreeAssembler {
|
|
|
68
83
|
|
|
69
84
|
/**
|
|
70
85
|
* Add tree to summary
|
|
86
|
+
*
|
|
87
|
+
* @deprecated 2.0.0-internal.3.2.0 Not recommended for general purpose use.
|
|
71
88
|
*/
|
|
72
89
|
public addTree(key: string, summary: ISummaryTree): void {
|
|
73
90
|
this.summaryTree[key] = summary;
|
|
@@ -75,6 +92,8 @@ export class SummaryTreeAssembler {
|
|
|
75
92
|
|
|
76
93
|
/**
|
|
77
94
|
* Add attachment to summary
|
|
95
|
+
*
|
|
96
|
+
* @deprecated 2.0.0-internal.3.2.0 Not recommended for general purpose use.
|
|
78
97
|
*/
|
|
79
98
|
public addAttachment(id: string) {
|
|
80
99
|
this.summaryTree[this.attachmentCounter++] = { id, type: SummaryType.Attachment };
|
|
@@ -86,6 +105,8 @@ export class SummaryTreeAssembler {
|
|
|
86
105
|
* @param snapshot - Source snapshot tree
|
|
87
106
|
* @param blobs - Blobs cache
|
|
88
107
|
* @returns Converted snapshot in ISummaryTree format
|
|
108
|
+
*
|
|
109
|
+
* @deprecated 2.0.0-internal.3.2.0 Not recommended for general purpose use.
|
|
89
110
|
*/
|
|
90
111
|
export function convertSnapshotAndBlobsToSummaryTree(
|
|
91
112
|
snapshot: ISnapshotTree,
|