@fluidframework/container-loader 2.0.0-dev-rc.1.0.0.228517 → 2.0.0-dev-rc.1.0.0.232845
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/README.md +3 -3
- package/dist/attachment.d.ts +116 -0
- package/dist/attachment.d.ts.map +1 -0
- package/dist/attachment.js +82 -0
- package/dist/attachment.js.map +1 -0
- package/dist/connectionManager.d.ts.map +1 -1
- package/dist/connectionManager.js +1 -2
- package/dist/connectionManager.js.map +1 -1
- package/dist/container-loader-alpha.d.ts +1 -1
- package/dist/container-loader-untrimmed.d.ts +1 -1
- package/dist/container.d.ts +21 -8
- package/dist/container.d.ts.map +1 -1
- package/dist/container.js +177 -149
- package/dist/container.js.map +1 -1
- package/dist/containerContext.d.ts +3 -2
- package/dist/containerContext.d.ts.map +1 -1
- package/dist/containerContext.js +2 -1
- package/dist/containerContext.js.map +1 -1
- package/dist/containerStorageAdapter.d.ts +3 -3
- package/dist/containerStorageAdapter.d.ts.map +1 -1
- package/dist/containerStorageAdapter.js +10 -11
- package/dist/containerStorageAdapter.js.map +1 -1
- package/dist/loader.d.ts +1 -1
- package/dist/loader.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/protocolTreeDocumentStorageService.d.ts +1 -0
- package/dist/protocolTreeDocumentStorageService.d.ts.map +1 -1
- package/dist/protocolTreeDocumentStorageService.js +1 -0
- package/dist/protocolTreeDocumentStorageService.js.map +1 -1
- package/dist/retriableDocumentStorageService.d.ts +2 -1
- package/dist/retriableDocumentStorageService.d.ts.map +1 -1
- package/dist/retriableDocumentStorageService.js +8 -0
- package/dist/retriableDocumentStorageService.js.map +1 -1
- package/dist/tsdoc-metadata.json +1 -1
- package/dist/utils.d.ts +13 -7
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +98 -29
- package/dist/utils.js.map +1 -1
- package/lib/attachment.d.mts +112 -0
- package/lib/attachment.d.mts.map +1 -0
- package/lib/attachment.mjs +74 -0
- package/lib/attachment.mjs.map +1 -0
- package/lib/connectionManager.d.mts.map +1 -1
- package/lib/connectionManager.mjs +2 -5
- package/lib/connectionManager.mjs.map +1 -1
- package/lib/container-loader-alpha.d.mts +1 -1
- package/lib/container-loader-untrimmed.d.mts +1 -1
- package/lib/container.d.mts +21 -8
- package/lib/container.d.mts.map +1 -1
- package/lib/container.mjs +176 -151
- package/lib/container.mjs.map +1 -1
- package/lib/containerContext.d.mts +3 -2
- package/lib/containerContext.d.mts.map +1 -1
- package/lib/containerContext.mjs +2 -1
- package/lib/containerContext.mjs.map +1 -1
- package/lib/containerStorageAdapter.d.mts +3 -3
- package/lib/containerStorageAdapter.d.mts.map +1 -1
- package/lib/containerStorageAdapter.mjs +10 -11
- package/lib/containerStorageAdapter.mjs.map +1 -1
- package/lib/loader.d.mts +1 -1
- package/lib/loader.mjs.map +1 -1
- package/lib/packageVersion.d.mts +1 -1
- package/lib/packageVersion.mjs +1 -1
- package/lib/packageVersion.mjs.map +1 -1
- package/lib/protocolTreeDocumentStorageService.d.mts +1 -0
- package/lib/protocolTreeDocumentStorageService.d.mts.map +1 -1
- package/lib/protocolTreeDocumentStorageService.mjs +1 -0
- package/lib/protocolTreeDocumentStorageService.mjs.map +1 -1
- package/lib/retriableDocumentStorageService.d.mts +2 -1
- package/lib/retriableDocumentStorageService.d.mts.map +1 -1
- package/lib/retriableDocumentStorageService.mjs +9 -1
- package/lib/retriableDocumentStorageService.mjs.map +1 -1
- package/lib/utils.d.mts +13 -7
- package/lib/utils.d.mts.map +1 -1
- package/lib/utils.mjs +96 -29
- package/lib/utils.mjs.map +1 -1
- package/package.json +21 -15
- package/src/attachment.ts +219 -0
- package/src/connectionManager.ts +2 -4
- package/src/container.ts +260 -191
- package/src/containerContext.ts +2 -1
- package/src/containerStorageAdapter.ts +15 -12
- package/src/loader.ts +1 -1
- package/src/packageVersion.ts +1 -1
- package/src/protocolTreeDocumentStorageService.ts +1 -0
- package/src/retriableDocumentStorageService.ts +18 -1
- package/src/utils.ts +128 -36
- /package/{.eslintrc.js → .eslintrc.cjs} +0 -0
package/README.md
CHANGED
|
@@ -166,9 +166,9 @@ Errors are of [ICriticalContainerError](../../common/container-definitions/src/e
|
|
|
166
166
|
|
|
167
167
|
There are 4 sources of errors:
|
|
168
168
|
|
|
169
|
-
1. [
|
|
170
|
-
2. [
|
|
171
|
-
3. [
|
|
169
|
+
1. [ContainerErrorTypes](../../common/container-definitions/src/error.ts) - errors & warnings raised at loader level
|
|
170
|
+
2. [DriverErrorTypes](../../common/driver-definitions/src/driverError.ts) - errors that are likely to be raised from the driver level
|
|
171
|
+
3. [OdspErrorTypes](../../drivers/odsp-driver/src/odspError.ts) and [RouterliciousErrorTypes](../../drivers/routerlicious-driver/src/documentDeltaConnection.ts) - errors raised by ODSP and R11S drivers.
|
|
172
172
|
4. Runtime errors, like `"summarizingError"`, `"dataCorruptionError"`. This class of errors is not pre-determined and depends on type of container loaded.
|
|
173
173
|
|
|
174
174
|
`ICriticalContainerError.errorType` is a string, which represents a union of 4 error types described above. Hosting application may package different drivers and open different types of containers, and only hosting application may have enough information to enumerate all possible error codes in such scenarios.
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
import { AttachState } from "@fluidframework/container-definitions";
|
|
6
|
+
import { CombinedAppAndProtocolSummary } from "@fluidframework/driver-utils";
|
|
7
|
+
import { ISnapshotTree, ISummaryTree } from "@fluidframework/protocol-definitions";
|
|
8
|
+
import { IDocumentStorageService } from "@fluidframework/driver-definitions";
|
|
9
|
+
import { ISerializableBlobContents } from "./containerStorageAdapter";
|
|
10
|
+
import { IDetachedBlobStorage } from ".";
|
|
11
|
+
/**
|
|
12
|
+
* The default state a newly created detached container will have.
|
|
13
|
+
* All but the state are optional and undefined, they just exist
|
|
14
|
+
* to make the union easy to deal with for both Detached types
|
|
15
|
+
*/
|
|
16
|
+
export interface DetachedDefaultData {
|
|
17
|
+
readonly state: AttachState.Detached;
|
|
18
|
+
readonly blobs?: undefined;
|
|
19
|
+
readonly summary?: undefined;
|
|
20
|
+
readonly redirectTable?: undefined;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* This always follows DetachedDefaultData when there are
|
|
24
|
+
* outstanding blobs in the detached blob storage.
|
|
25
|
+
* The redirect table will get filled up to include data
|
|
26
|
+
* about the blobs as they are uploaded.
|
|
27
|
+
*/
|
|
28
|
+
export interface DetachedDataWithOutstandingBlobs {
|
|
29
|
+
readonly state: AttachState.Detached;
|
|
30
|
+
readonly blobs: "outstanding";
|
|
31
|
+
readonly summary?: undefined;
|
|
32
|
+
readonly redirectTable: Map<string, string>;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* This state always follows DetachedDataWithOutstandingBlobs.
|
|
36
|
+
* It signals that all outstanding blobs are done being uploaded,
|
|
37
|
+
* so the container can move to the attaching state.
|
|
38
|
+
*/
|
|
39
|
+
export interface AttachingDataWithBlobs {
|
|
40
|
+
readonly state: AttachState.Attaching;
|
|
41
|
+
readonly blobs: "done";
|
|
42
|
+
readonly summary: CombinedAppAndProtocolSummary;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* This always follows DefaultDetachedState when there are
|
|
46
|
+
* no blobs in the detached blob storage. Because there are
|
|
47
|
+
* no blobs we can immediately get the summary and transition
|
|
48
|
+
* to the attaching state.
|
|
49
|
+
*/
|
|
50
|
+
export interface AttachingDataWithoutBlobs {
|
|
51
|
+
readonly state: AttachState.Attaching;
|
|
52
|
+
readonly summary: CombinedAppAndProtocolSummary;
|
|
53
|
+
readonly blobs: "none";
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* The final attachment state which signals the container is fully attached.
|
|
57
|
+
* The baseSnapshotAndBlobs will only be enabled when offline load is enabled.
|
|
58
|
+
*/
|
|
59
|
+
export interface AttachedData {
|
|
60
|
+
readonly state: AttachState.Attached;
|
|
61
|
+
readonly snapshot?: {
|
|
62
|
+
tree: ISnapshotTree;
|
|
63
|
+
blobs: ISerializableBlobContents;
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* A union of all the attachment data types for
|
|
68
|
+
* tracking across all container attachment states
|
|
69
|
+
*/
|
|
70
|
+
export type AttachmentData = DetachedDefaultData | DetachedDataWithOutstandingBlobs | AttachingDataWithoutBlobs | AttachingDataWithBlobs | AttachedData;
|
|
71
|
+
/**
|
|
72
|
+
* The data and services necessary for runRetriableAttachProcess.
|
|
73
|
+
*/
|
|
74
|
+
export interface AttachProcessProps {
|
|
75
|
+
/**
|
|
76
|
+
* The initial attachment data this call should start with
|
|
77
|
+
*/
|
|
78
|
+
readonly initialAttachmentData: Exclude<AttachmentData, AttachedData>;
|
|
79
|
+
/**
|
|
80
|
+
* The caller should use this callback to keep track of the current
|
|
81
|
+
* attachment data, and perform any other operations necessary
|
|
82
|
+
* for dealing with attachment state changes, like emitting events
|
|
83
|
+
*
|
|
84
|
+
* @param attachmentData - the updated attachment data */
|
|
85
|
+
readonly setAttachmentData: (attachmentData: AttachmentData) => void;
|
|
86
|
+
/**
|
|
87
|
+
* The caller should create and or get services based on the data, and its own information.
|
|
88
|
+
* @param data - the data to create services from,
|
|
89
|
+
* the summary property being the most relevant part of the data.
|
|
90
|
+
* @returns A compatible storage service
|
|
91
|
+
*/
|
|
92
|
+
readonly createOrGetStorageService: (data: ISummaryTree | undefined) => Promise<Pick<IDocumentStorageService, "createBlob" | "uploadSummaryWithContext">>;
|
|
93
|
+
/**
|
|
94
|
+
* The detached blob storage if it exists.
|
|
95
|
+
*/
|
|
96
|
+
readonly detachedBlobStorage?: Pick<IDetachedBlobStorage, "getBlobIds" | "readBlob" | "size">;
|
|
97
|
+
/**
|
|
98
|
+
* The caller should create the attachment summary for the container.
|
|
99
|
+
* @param redirectTable - Maps local blob ids to remote blobs ids.
|
|
100
|
+
* @returns The attachment summary for the container.
|
|
101
|
+
*/
|
|
102
|
+
readonly createAttachmentSummary: (redirectTable?: Map<string, string>) => CombinedAppAndProtocolSummary;
|
|
103
|
+
/**
|
|
104
|
+
* Whether offline load is enabled or not.
|
|
105
|
+
*/
|
|
106
|
+
readonly offlineLoadEnabled: boolean;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Executes the attach process state machine based on the provided data and services.
|
|
110
|
+
* This method is retriable on failure. Based on the provided initialAttachmentData
|
|
111
|
+
* this method will resume the attachment process and attempt to complete it.
|
|
112
|
+
*
|
|
113
|
+
* @param props - The data and services necessary to run the attachment process
|
|
114
|
+
*/
|
|
115
|
+
export declare const runRetriableAttachProcess: (props: AttachProcessProps) => Promise<void>;
|
|
116
|
+
//# sourceMappingURL=attachment.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attachment.d.ts","sourceRoot":"","sources":["../src/attachment.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,WAAW,EAAE,MAAM,uCAAuC,CAAC;AACpE,OAAO,EAAE,6BAA6B,EAAE,MAAM,8BAA8B,CAAC;AAC7E,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,sCAAsC,CAAC;AAEnF,OAAO,EAAE,uBAAuB,EAAE,MAAM,oCAAoC,CAAC;AAE7E,OAAO,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,CAAC;AACtE,OAAO,EAAE,oBAAoB,EAAE,MAAM,GAAG,CAAC;AAEzC;;;;GAIG;AACH,MAAM,WAAW,mBAAmB;IACnC,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC,QAAQ,CAAC;IACrC,QAAQ,CAAC,KAAK,CAAC,EAAE,SAAS,CAAC;IAC3B,QAAQ,CAAC,OAAO,CAAC,EAAE,SAAS,CAAC;IAC7B,QAAQ,CAAC,aAAa,CAA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ErE;;;;;OAKG;IACH,QAAQ,CAAC,yBAAyB,EAAE,CACnC,IAAI,EAAE,YAAY,GAAG,SAAS,KAC1B,OAAO,CAAC,IAAI,CAAC,uBAAuB,EAAE,YAAY,GAAG,0BAA0B,CAAC,CAAC,CAAC;IAEvF;;OAEG;IACH,QAAQ,CAAC,mBAAmB,CAAC,EAAE,IAAI,CAAC,oBAAoB,EAAE,YAAY,GAAG,UAAU,GAAG,MAAM,CAAC,CAAC;IAE9F;;;;OAIG;IACH,QAAQ,CAAC,uBAAuB,EAAE,CACjC,aAAa,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,KAC/B,6BAA6B,CAAC;IAEnC;;OAEG;IACH,QAAQ,CAAC,kBAAkB,EAAE,OAAO,CAAC;CACrC;AAED;;;;;;GAMG;AACH,eAAO,MAAM,yBAAyB,UAAiB,kBAAkB,KAAG,QAAQ,IAAI,CAgFvF,CAAC"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.runRetriableAttachProcess = void 0;
|
|
4
|
+
/*!
|
|
5
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
6
|
+
* Licensed under the MIT License.
|
|
7
|
+
*/
|
|
8
|
+
const container_definitions_1 = require("@fluidframework/container-definitions");
|
|
9
|
+
const core_utils_1 = require("@fluidframework/core-utils");
|
|
10
|
+
const utils_1 = require("./utils");
|
|
11
|
+
/**
|
|
12
|
+
* Executes the attach process state machine based on the provided data and services.
|
|
13
|
+
* This method is retriable on failure. Based on the provided initialAttachmentData
|
|
14
|
+
* this method will resume the attachment process and attempt to complete it.
|
|
15
|
+
*
|
|
16
|
+
* @param props - The data and services necessary to run the attachment process
|
|
17
|
+
*/
|
|
18
|
+
const runRetriableAttachProcess = async (props) => {
|
|
19
|
+
const { detachedBlobStorage, createOrGetStorageService, setAttachmentData, createAttachmentSummary, offlineLoadEnabled, } = props;
|
|
20
|
+
let currentData = props.initialAttachmentData;
|
|
21
|
+
if (currentData.blobs === undefined) {
|
|
22
|
+
// If attachment blobs were uploaded in detached state we will go through a different attach flow
|
|
23
|
+
const outstandingAttachmentBlobs = detachedBlobStorage !== undefined && detachedBlobStorage.size > 0;
|
|
24
|
+
// Determine the next phase of attaching which depends on if there are attachment blobs
|
|
25
|
+
// if there are, we will stay detached, so an empty file can be created, and the blobs
|
|
26
|
+
// uploaded, otherwise we will get the summary to create the file with and move to attaching
|
|
27
|
+
currentData = outstandingAttachmentBlobs
|
|
28
|
+
? {
|
|
29
|
+
state: container_definitions_1.AttachState.Detached,
|
|
30
|
+
blobs: "outstanding",
|
|
31
|
+
redirectTable: new Map(),
|
|
32
|
+
}
|
|
33
|
+
: {
|
|
34
|
+
state: container_definitions_1.AttachState.Attaching,
|
|
35
|
+
summary: props.createAttachmentSummary(),
|
|
36
|
+
blobs: "none",
|
|
37
|
+
};
|
|
38
|
+
setAttachmentData(currentData);
|
|
39
|
+
}
|
|
40
|
+
// this has to run here, as it is what creates the file
|
|
41
|
+
// and we need to file for all possible cases after this point
|
|
42
|
+
const storage = await createOrGetStorageService(currentData.summary);
|
|
43
|
+
if (currentData.blobs === "outstanding") {
|
|
44
|
+
const { redirectTable } = currentData;
|
|
45
|
+
// upload blobs to storage
|
|
46
|
+
(0, core_utils_1.assert)(!!detachedBlobStorage, 0x24e /* "assertion for type narrowing" */);
|
|
47
|
+
// build a table mapping IDs assigned locally to IDs assigned by storage and pass it to runtime to
|
|
48
|
+
// support blob handles that only know about the local IDs
|
|
49
|
+
while (redirectTable.size < detachedBlobStorage.size) {
|
|
50
|
+
const newIds = detachedBlobStorage.getBlobIds().filter((id) => !redirectTable.has(id));
|
|
51
|
+
for (const id of newIds) {
|
|
52
|
+
const blob = await detachedBlobStorage.readBlob(id);
|
|
53
|
+
const response = await storage.createBlob(blob);
|
|
54
|
+
redirectTable.set(id, response.id);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
setAttachmentData((currentData = {
|
|
58
|
+
state: container_definitions_1.AttachState.Attaching,
|
|
59
|
+
summary: createAttachmentSummary(redirectTable),
|
|
60
|
+
blobs: "done",
|
|
61
|
+
}));
|
|
62
|
+
}
|
|
63
|
+
(0, core_utils_1.assert)(currentData.state === container_definitions_1.AttachState.Attaching, "must be attaching by this point");
|
|
64
|
+
if (currentData.blobs === "done") {
|
|
65
|
+
// done means outstanding blobs were uploaded.
|
|
66
|
+
// in that case an empty file was created, the blobs were uploaded
|
|
67
|
+
// and now this finally uploads the summary
|
|
68
|
+
await storage.uploadSummaryWithContext(currentData.summary, {
|
|
69
|
+
referenceSequenceNumber: 0,
|
|
70
|
+
ackHandle: undefined,
|
|
71
|
+
proposalHandle: undefined,
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
setAttachmentData((currentData = {
|
|
75
|
+
state: container_definitions_1.AttachState.Attached,
|
|
76
|
+
snapshot: offlineLoadEnabled
|
|
77
|
+
? (0, utils_1.getSnapshotTreeAndBlobsFromSerializedContainer)(currentData.summary)
|
|
78
|
+
: undefined,
|
|
79
|
+
}));
|
|
80
|
+
};
|
|
81
|
+
exports.runRetriableAttachProcess = runRetriableAttachProcess;
|
|
82
|
+
//# sourceMappingURL=attachment.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attachment.js","sourceRoot":"","sources":["../src/attachment.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACH,iFAAoE;AAGpE,2DAAoD;AAEpD,mCAAyE;AA0HzE;;;;;;GAMG;AACI,MAAM,yBAAyB,GAAG,KAAK,EAAE,KAAyB,EAAiB,EAAE;IAC3F,MAAM,EACL,mBAAmB,EACnB,yBAAyB,EACzB,iBAAiB,EACjB,uBAAuB,EACvB,kBAAkB,GAClB,GAAG,KAAK,CAAC;IACV,IAAI,WAAW,GAAmB,KAAK,CAAC,qBAAqB,CAAC;IAE9D,IAAI,WAAW,CAAC,KAAK,KAAK,SAAS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AC;gBAChD,aAAa,CAAC,GAAG,CAAC,EAAE,EAAE,QAAQ,CAAC,EAAE,CAAC,CAAC;aACnC;SACD;QACD,iBAAiB,CAChB,CAAC,WAAW,GAAG;YACd,KAAK,EAAE,mCAAW,CAAC,SAAS;YAC5B,OAAO,EAAE,uBAAuB,CAAC,aAAa,CAAC;YAC/C,KAAK,EAAE,MAAM;SACb,CAAC,CACF,CAAC;KACF;IAED,IAAA,mBAAM,EAAC,WAAW,CAAC,KAAK,KAAK,mCAAW,CAAC,SAAS,EAAE,iCAAiC,CAAC,CAAC;IAEvF,IAAI,WAAW,CAAC,KAAK,KAAK,MAAM,EAAE;QACjC,8CAA8C;QAC9C,kEAAkE;QAClE,2CAA2C;QAC3C,MAAM,OAAO,CAAC,wBAAwB,CAAC,WAAW,CAAC,OAAO,EAAE;YAC3D,uBAAuB,EAAE,CAAC;YAC1B,SAAS,EAAE,SAAS;YACpB,cAAc,EAAE,SAAS;SACzB,CAAC,CAAC;KACH;IAED,iBAAiB,CAChB,CAAC,WAAW,GAAG;QACd,KAAK,EAAE,mCAAW,CAAC,QAAQ;QAC3B,QAAQ,EAAE,kBAAkB;YAC3B,CAAC,CAAC,IAAA,sDAA8C,EAAC,WAAW,CAAC,OAAO,CAAC;YACrE,CAAC,CAAC,SAAS;KACZ,CAAC,CACF,CAAC;AACH,CAAC,CAAC;AAhFW,QAAA,yBAAyB,6BAgFpC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\nimport { AttachState } from \"@fluidframework/container-definitions\";\nimport { CombinedAppAndProtocolSummary } from \"@fluidframework/driver-utils\";\nimport { ISnapshotTree, ISummaryTree } from \"@fluidframework/protocol-definitions\";\nimport { assert } from \"@fluidframework/core-utils\";\nimport { IDocumentStorageService } from \"@fluidframework/driver-definitions\";\nimport { getSnapshotTreeAndBlobsFromSerializedContainer } from \"./utils\";\nimport { ISerializableBlobContents } from \"./containerStorageAdapter\";\nimport { IDetachedBlobStorage } from \".\";\n\n/**\n * The default state a newly created detached container will have.\n * All but the state are optional and undefined, they just exist\n * to make the union easy to deal with for both Detached types\n */\nexport interface DetachedDefaultData {\n\treadonly state: AttachState.Detached;\n\treadonly blobs?: undefined;\n\treadonly summary?: undefined;\n\treadonly redirectTable?: undefined;\n}\n\n/**\n * This always follows DetachedDefaultData when there are\n * outstanding blobs in the detached blob storage.\n * The redirect table will get filled up to include data\n * about the blobs as they are uploaded.\n */\nexport interface DetachedDataWithOutstandingBlobs {\n\treadonly state: AttachState.Detached;\n\treadonly blobs: \"outstanding\";\n\treadonly summary?: undefined;\n\treadonly redirectTable: Map<string, string>;\n}\n\n/**\n * This state always follows DetachedDataWithOutstandingBlobs.\n * It signals that all outstanding blobs are done being uploaded,\n * so the container can move to the attaching state.\n */\nexport interface AttachingDataWithBlobs {\n\treadonly state: AttachState.Attaching;\n\treadonly blobs: \"done\";\n\treadonly summary: CombinedAppAndProtocolSummary;\n}\n\n/**\n * This always follows DefaultDetachedState when there are\n * no blobs in the detached blob storage. Because there are\n * no blobs we can immediately get the summary and transition\n * to the attaching state.\n */\nexport interface AttachingDataWithoutBlobs {\n\treadonly state: AttachState.Attaching;\n\treadonly summary: CombinedAppAndProtocolSummary;\n\treadonly blobs: \"none\";\n}\n\n/**\n * The final attachment state which signals the container is fully attached.\n * The baseSnapshotAndBlobs will only be enabled when offline load is enabled.\n */\nexport interface AttachedData {\n\treadonly state: AttachState.Attached;\n\treadonly snapshot?: {\n\t\ttree: ISnapshotTree;\n\t\tblobs: ISerializableBlobContents;\n\t};\n}\n\n/**\n * A union of all the attachment data types for\n * tracking across all container attachment states\n */\nexport type AttachmentData =\n\t| DetachedDefaultData\n\t| DetachedDataWithOutstandingBlobs\n\t| AttachingDataWithoutBlobs\n\t| AttachingDataWithBlobs\n\t| AttachedData;\n\n/**\n * The data and services necessary for runRetriableAttachProcess.\n */\nexport interface AttachProcessProps {\n\t/**\n\t * The initial attachment data this call should start with\n\t */\n\treadonly initialAttachmentData: Exclude<AttachmentData, AttachedData>;\n\n\t/**\n\t * The caller should use this callback to keep track of the current\n\t * attachment data, and perform any other operations necessary\n\t * for dealing with attachment state changes, like emitting events\n\t *\n\t * @param attachmentData - the updated attachment data\t */\n\treadonly setAttachmentData: (attachmentData: AttachmentData) => void;\n\n\t/**\n\t * The caller should create and or get services based on the data, and its own information.\n\t * @param data - the data to create services from,\n\t * the summary property being the most relevant part of the data.\n\t * @returns A compatible storage service\n\t */\n\treadonly createOrGetStorageService: (\n\t\tdata: ISummaryTree | undefined,\n\t) => Promise<Pick<IDocumentStorageService, \"createBlob\" | \"uploadSummaryWithContext\">>;\n\n\t/**\n\t * The detached blob storage if it exists.\n\t */\n\treadonly detachedBlobStorage?: Pick<IDetachedBlobStorage, \"getBlobIds\" | \"readBlob\" | \"size\">;\n\n\t/**\n\t * The caller should create the attachment summary for the container.\n\t * @param redirectTable - Maps local blob ids to remote blobs ids.\n\t * @returns The attachment summary for the container.\n\t */\n\treadonly createAttachmentSummary: (\n\t\tredirectTable?: Map<string, string>,\n\t) => CombinedAppAndProtocolSummary;\n\n\t/**\n\t * Whether offline load is enabled or not.\n\t */\n\treadonly offlineLoadEnabled: boolean;\n}\n\n/**\n * Executes the attach process state machine based on the provided data and services.\n * This method is retriable on failure. Based on the provided initialAttachmentData\n * this method will resume the attachment process and attempt to complete it.\n *\n * @param props - The data and services necessary to run the attachment process\n */\nexport const runRetriableAttachProcess = async (props: AttachProcessProps): Promise<void> => {\n\tconst {\n\t\tdetachedBlobStorage,\n\t\tcreateOrGetStorageService,\n\t\tsetAttachmentData,\n\t\tcreateAttachmentSummary,\n\t\tofflineLoadEnabled,\n\t} = props;\n\tlet currentData: AttachmentData = props.initialAttachmentData;\n\n\tif (currentData.blobs === undefined) {\n\t\t// If attachment blobs were uploaded in detached state we will go through a different attach flow\n\t\tconst outstandingAttachmentBlobs =\n\t\t\tdetachedBlobStorage !== undefined && detachedBlobStorage.size > 0;\n\t\t// Determine the next phase of attaching which depends on if there are attachment blobs\n\t\t// if there are, we will stay detached, so an empty file can be created, and the blobs\n\t\t// uploaded, otherwise we will get the summary to create the file with and move to attaching\n\t\tcurrentData = outstandingAttachmentBlobs\n\t\t\t? {\n\t\t\t\t\tstate: AttachState.Detached,\n\t\t\t\t\tblobs: \"outstanding\",\n\t\t\t\t\tredirectTable: new Map<string, string>(),\n\t\t\t }\n\t\t\t: {\n\t\t\t\t\tstate: AttachState.Attaching,\n\t\t\t\t\tsummary: props.createAttachmentSummary(),\n\t\t\t\t\tblobs: \"none\",\n\t\t\t };\n\t\tsetAttachmentData(currentData);\n\t}\n\n\t// this has to run here, as it is what creates the file\n\t// and we need to file for all possible cases after this point\n\tconst storage = await createOrGetStorageService(currentData.summary);\n\n\tif (currentData.blobs === \"outstanding\") {\n\t\tconst { redirectTable } = currentData;\n\t\t// upload blobs to storage\n\t\tassert(!!detachedBlobStorage, 0x24e /* \"assertion for type narrowing\" */);\n\n\t\t// build a table mapping IDs assigned locally to IDs assigned by storage and pass it to runtime to\n\t\t// support blob handles that only know about the local IDs\n\t\twhile (redirectTable.size < detachedBlobStorage.size) {\n\t\t\tconst newIds = detachedBlobStorage.getBlobIds().filter((id) => !redirectTable.has(id));\n\t\t\tfor (const id of newIds) {\n\t\t\t\tconst blob = await detachedBlobStorage.readBlob(id);\n\t\t\t\tconst response = await storage.createBlob(blob);\n\t\t\t\tredirectTable.set(id, response.id);\n\t\t\t}\n\t\t}\n\t\tsetAttachmentData(\n\t\t\t(currentData = {\n\t\t\t\tstate: AttachState.Attaching,\n\t\t\t\tsummary: createAttachmentSummary(redirectTable),\n\t\t\t\tblobs: \"done\",\n\t\t\t}),\n\t\t);\n\t}\n\n\tassert(currentData.state === AttachState.Attaching, \"must be attaching by this point\");\n\n\tif (currentData.blobs === \"done\") {\n\t\t// done means outstanding blobs were uploaded.\n\t\t// in that case an empty file was created, the blobs were uploaded\n\t\t// and now this finally uploads the summary\n\t\tawait storage.uploadSummaryWithContext(currentData.summary, {\n\t\t\treferenceSequenceNumber: 0,\n\t\t\tackHandle: undefined,\n\t\t\tproposalHandle: undefined,\n\t\t});\n\t}\n\n\tsetAttachmentData(\n\t\t(currentData = {\n\t\t\tstate: AttachState.Attached,\n\t\t\tsnapshot: offlineLoadEnabled\n\t\t\t\t? getSnapshotTreeAndBlobsFromSerializedContainer(currentData.summary)\n\t\t\t\t: undefined,\n\t\t}),\n\t);\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connectionManager.d.ts","sourceRoot":"","sources":["../src/connectionManager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAe,oBAAoB,EAAY,MAAM,iCAAiC,CAAC;AAG9F,OAAO,EACN,uBAAuB,EACvB,WAAW,EACX,YAAY,EACZ,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAEN,gBAAgB,
|
|
1
|
+
{"version":3,"file":"connectionManager.d.ts","sourceRoot":"","sources":["../src/connectionManager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAe,oBAAoB,EAAY,MAAM,iCAAiC,CAAC;AAG9F,OAAO,EACN,uBAAuB,EACvB,WAAW,EACX,YAAY,EACZ,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAEN,gBAAgB,EAIhB,MAAM,oCAAoC,CAAC;AAU5C,OAAO,EACN,cAAc,EACd,OAAO,EACP,oBAAoB,EACpB,cAAc,EACd,gBAAgB,EAGhB,yBAAyB,EAOzB,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAIN,mBAAmB,EAGnB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EACN,aAAa,EACb,kBAAkB,EAClB,6BAA6B,EAE7B,4BAA4B,EAC5B,MAAM,aAAa,CAAC;AAiIrB;;;;GAIG;AACH,qBAAa,iBAAkB,YAAW,kBAAkB;IAoL1D,OAAO,CAAC,QAAQ,CAAC,eAAe;aAChB,cAAc,EAAE,MAAM,OAAO;IAC7C,OAAO,CAAC,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QAAQ,CAAC,SAAS,CAGxB;IAEF,OAAO,CAAC,QAAQ,CAAC,aAAa,CAG5B;IAGF,OAAO,CAAC,QAAQ,CAAC,WAAW,CAkB1B;IAGF,OAAO,CAAC,QAAQ,CAAC,yBAAyB,CAIxC;IAEF,OAAO,CAAC,QAAQ,CAAC,YAAY,CAE3B;CACF"}
|
|
@@ -457,8 +457,7 @@ class ConnectionManager {
|
|
|
457
457
|
break;
|
|
458
458
|
}
|
|
459
459
|
else if ((0, telemetry_utils_1.isFluidError)(origError) &&
|
|
460
|
-
|
|
461
|
-
origError.errorType === driver_definitions_1.DriverErrorType.outOfStorageError) {
|
|
460
|
+
origError.errorType === driver_definitions_1.DriverErrorTypes.outOfStorageError) {
|
|
462
461
|
// If we get out of storage error from calling joinsession, then use the NoDeltaStream object so
|
|
463
462
|
// that user can at least load the container.
|
|
464
463
|
connection = new NoDeltaStream(undefined, {
|