@fluidframework/routerlicious-driver 2.0.0-internal.3.0.0 → 2.0.0-internal.3.1.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/.eslintrc.js +10 -12
- package/.mocharc.js +2 -2
- package/README.md +1 -1
- package/api-extractor.json +2 -2
- package/dist/cache.d.ts.map +1 -1
- package/dist/cache.js +2 -5
- package/dist/cache.js.map +1 -1
- package/dist/createNewUtils.d.ts.map +1 -1
- package/dist/createNewUtils.js +4 -2
- package/dist/createNewUtils.js.map +1 -1
- package/dist/defaultTokenProvider.d.ts.map +1 -1
- package/dist/defaultTokenProvider.js.map +1 -1
- package/dist/definitions.d.ts.map +1 -1
- package/dist/definitions.js.map +1 -1
- package/dist/deltaStorageService.d.ts.map +1 -1
- package/dist/deltaStorageService.js +4 -1
- package/dist/deltaStorageService.js.map +1 -1
- package/dist/documentDeltaConnection.d.ts.map +1 -1
- package/dist/documentDeltaConnection.js.map +1 -1
- package/dist/documentService.d.ts.map +1 -1
- package/dist/documentService.js +13 -5
- package/dist/documentService.js.map +1 -1
- package/dist/documentServiceFactory.d.ts.map +1 -1
- package/dist/documentServiceFactory.js +7 -4
- package/dist/documentServiceFactory.js.map +1 -1
- package/dist/documentStorageService.d.ts.map +1 -1
- package/dist/documentStorageService.js +7 -5
- package/dist/documentStorageService.js.map +1 -1
- package/dist/errorUtils.d.ts +9 -2
- package/dist/errorUtils.d.ts.map +1 -1
- package/dist/errorUtils.js +15 -8
- package/dist/errorUtils.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/dist/nullBlobStorageService.d.ts.map +1 -1
- package/dist/nullBlobStorageService.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/policies.d.ts.map +1 -1
- package/dist/policies.js.map +1 -1
- package/dist/restWrapper.d.ts.map +1 -1
- package/dist/restWrapper.js +5 -6
- package/dist/restWrapper.js.map +1 -1
- package/dist/retriableGitManager.d.ts.map +1 -1
- package/dist/retriableGitManager.js.map +1 -1
- package/dist/shreddedSummaryDocumentStorageService.d.ts.map +1 -1
- package/dist/shreddedSummaryDocumentStorageService.js +8 -4
- package/dist/shreddedSummaryDocumentStorageService.js.map +1 -1
- package/dist/tokens.d.ts +24 -7
- package/dist/tokens.d.ts.map +1 -1
- package/dist/tokens.js.map +1 -1
- package/dist/urlUtils.d.ts.map +1 -1
- package/dist/urlUtils.js.map +1 -1
- package/dist/wholeSummaryDocumentStorageService.d.ts.map +1 -1
- package/dist/wholeSummaryDocumentStorageService.js +25 -11
- package/dist/wholeSummaryDocumentStorageService.js.map +1 -1
- package/lib/cache.d.ts.map +1 -1
- package/lib/cache.js +2 -5
- package/lib/cache.js.map +1 -1
- package/lib/createNewUtils.d.ts.map +1 -1
- package/lib/createNewUtils.js +4 -2
- package/lib/createNewUtils.js.map +1 -1
- package/lib/defaultTokenProvider.d.ts.map +1 -1
- package/lib/defaultTokenProvider.js.map +1 -1
- package/lib/definitions.d.ts.map +1 -1
- package/lib/definitions.js.map +1 -1
- package/lib/deltaStorageService.d.ts.map +1 -1
- package/lib/deltaStorageService.js +4 -1
- package/lib/deltaStorageService.js.map +1 -1
- package/lib/documentDeltaConnection.d.ts.map +1 -1
- package/lib/documentDeltaConnection.js.map +1 -1
- package/lib/documentService.d.ts.map +1 -1
- package/lib/documentService.js +15 -7
- package/lib/documentService.js.map +1 -1
- package/lib/documentServiceFactory.d.ts.map +1 -1
- package/lib/documentServiceFactory.js +7 -4
- package/lib/documentServiceFactory.js.map +1 -1
- package/lib/documentStorageService.d.ts.map +1 -1
- package/lib/documentStorageService.js +8 -6
- package/lib/documentStorageService.js.map +1 -1
- package/lib/errorUtils.d.ts +9 -2
- package/lib/errorUtils.d.ts.map +1 -1
- package/lib/errorUtils.js +14 -7
- package/lib/errorUtils.js.map +1 -1
- package/lib/index.d.ts +2 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +3 -1
- package/lib/index.js.map +1 -1
- package/lib/nullBlobStorageService.d.ts.map +1 -1
- package/lib/nullBlobStorageService.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/policies.d.ts.map +1 -1
- package/lib/policies.js.map +1 -1
- package/lib/restWrapper.d.ts.map +1 -1
- package/lib/restWrapper.js +5 -6
- package/lib/restWrapper.js.map +1 -1
- package/lib/retriableGitManager.d.ts.map +1 -1
- package/lib/retriableGitManager.js.map +1 -1
- package/lib/shreddedSummaryDocumentStorageService.d.ts.map +1 -1
- package/lib/shreddedSummaryDocumentStorageService.js +9 -5
- package/lib/shreddedSummaryDocumentStorageService.js.map +1 -1
- package/lib/tokens.d.ts +24 -7
- package/lib/tokens.d.ts.map +1 -1
- package/lib/tokens.js.map +1 -1
- package/lib/urlUtils.d.ts.map +1 -1
- package/lib/urlUtils.js.map +1 -1
- package/lib/wholeSummaryDocumentStorageService.d.ts.map +1 -1
- package/lib/wholeSummaryDocumentStorageService.js +27 -13
- package/lib/wholeSummaryDocumentStorageService.js.map +1 -1
- package/package.json +115 -114
- package/prettier.config.cjs +1 -1
- package/src/cache.ts +16 -19
- package/src/createNewUtils.ts +24 -22
- package/src/defaultTokenProvider.ts +13 -15
- package/src/definitions.ts +2 -2
- package/src/deltaStorageService.ts +99 -95
- package/src/documentDeltaConnection.ts +53 -47
- package/src/documentService.ts +260 -239
- package/src/documentServiceFactory.ts +263 -250
- package/src/documentStorageService.ts +87 -83
- package/src/errorUtils.ts +91 -81
- package/src/index.ts +7 -1
- package/src/nullBlobStorageService.ts +24 -21
- package/src/packageVersion.ts +1 -1
- package/src/policies.ts +44 -44
- package/src/restWrapper.ts +266 -216
- package/src/retriableGitManager.ts +152 -151
- package/src/shreddedSummaryDocumentStorageService.ts +202 -194
- package/src/tokens.ts +69 -44
- package/src/urlUtils.ts +26 -23
- package/src/wholeSummaryDocumentStorageService.ts +246 -228
- package/tsconfig.esnext.json +6 -6
- package/tsconfig.json +9 -13
|
@@ -5,21 +5,21 @@
|
|
|
5
5
|
|
|
6
6
|
import { assert } from "@fluidframework/common-utils";
|
|
7
7
|
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
8
|
+
FiveDaysMs,
|
|
9
|
+
IDocumentService,
|
|
10
|
+
IDocumentServiceFactory,
|
|
11
|
+
IDocumentStorageServicePolicies,
|
|
12
|
+
IFluidResolvedUrl,
|
|
13
|
+
IResolvedUrl,
|
|
14
|
+
LoaderCachingPolicy,
|
|
15
15
|
} from "@fluidframework/driver-definitions";
|
|
16
16
|
import { ITelemetryBaseLogger } from "@fluidframework/common-definitions";
|
|
17
17
|
import { ISummaryTree } from "@fluidframework/protocol-definitions";
|
|
18
18
|
import {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
19
|
+
ensureFluidResolvedUrl,
|
|
20
|
+
getDocAttributesFromProtocolSummary,
|
|
21
|
+
getQuorumValuesFromProtocolSummary,
|
|
22
|
+
RateLimiter,
|
|
23
23
|
} from "@fluidframework/driver-utils";
|
|
24
24
|
import { ChildLogger, PerformanceEvent } from "@fluidframework/telemetry-utils";
|
|
25
25
|
import { ISession } from "@fluidframework/server-services-client";
|
|
@@ -36,14 +36,14 @@ import { ISnapshotTreeVersion } from "./definitions";
|
|
|
36
36
|
const maximumSnapshotCacheDurationMs: FiveDaysMs = 432_000_000; // 5 days in ms
|
|
37
37
|
|
|
38
38
|
const defaultRouterliciousDriverPolicies: IRouterliciousDriverPolicies = {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
39
|
+
enablePrefetch: true,
|
|
40
|
+
maxConcurrentStorageRequests: 100,
|
|
41
|
+
maxConcurrentOrdererRequests: 100,
|
|
42
|
+
aggregateBlobsSmallerThanBytes: undefined,
|
|
43
|
+
enableDiscovery: false,
|
|
44
|
+
enableWholeSummaryUpload: false,
|
|
45
|
+
enableRestLess: true,
|
|
46
|
+
enableInternalSummaryCaching: true,
|
|
47
47
|
};
|
|
48
48
|
|
|
49
49
|
/**
|
|
@@ -51,246 +51,257 @@ const defaultRouterliciousDriverPolicies: IRouterliciousDriverPolicies = {
|
|
|
51
51
|
* use the routerlicious implementation.
|
|
52
52
|
*/
|
|
53
53
|
export class RouterliciousDocumentServiceFactory implements IDocumentServiceFactory {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
54
|
+
public readonly protocolName = "fluid:";
|
|
55
|
+
private readonly driverPolicies: IRouterliciousDriverPolicies;
|
|
56
|
+
private readonly blobCache: ICache<ArrayBufferLike>;
|
|
57
|
+
private readonly snapshotTreeCache: ICache<ISnapshotTreeVersion>;
|
|
58
58
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
59
|
+
constructor(
|
|
60
|
+
private readonly tokenProvider: ITokenProvider,
|
|
61
|
+
driverPolicies: Partial<IRouterliciousDriverPolicies> = {},
|
|
62
|
+
) {
|
|
63
|
+
// Use the maximum allowed by the policy (IDocumentStorageServicePolicies.maximumCacheDurationMs set below)
|
|
64
|
+
const snapshotCacheExpiryMs: FiveDaysMs = maximumSnapshotCacheDurationMs;
|
|
65
65
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
66
|
+
this.driverPolicies = {
|
|
67
|
+
...defaultRouterliciousDriverPolicies,
|
|
68
|
+
...driverPolicies,
|
|
69
|
+
};
|
|
70
|
+
this.blobCache = new InMemoryCache<ArrayBufferLike>();
|
|
71
|
+
this.snapshotTreeCache = this.driverPolicies.enableInternalSummaryCaching
|
|
72
|
+
? new InMemoryCache<ISnapshotTreeVersion>(snapshotCacheExpiryMs)
|
|
73
|
+
: new NullCache<ISnapshotTreeVersion>();
|
|
74
|
+
}
|
|
75
75
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
76
|
+
/**
|
|
77
|
+
* {@inheritDoc @fluidframework/driver-definitions#IDocumentServiceFactory.createContainer}
|
|
78
|
+
*
|
|
79
|
+
* @throws {@link DocumentPostCreateError}
|
|
80
|
+
* If an exception is thrown while invoking the provided {@link ITokenProvider.documentPostCreateCallback}.
|
|
81
|
+
*/
|
|
82
|
+
public async createContainer(
|
|
83
|
+
createNewSummary: ISummaryTree | undefined,
|
|
84
|
+
resolvedUrl: IResolvedUrl,
|
|
85
|
+
logger?: ITelemetryBaseLogger,
|
|
86
|
+
clientIsSummarizer?: boolean,
|
|
87
|
+
): Promise<IDocumentService> {
|
|
88
|
+
ensureFluidResolvedUrl(resolvedUrl);
|
|
89
|
+
if (createNewSummary === undefined) {
|
|
90
|
+
throw new Error("Empty file summary creation isn't supported in this driver.");
|
|
91
|
+
}
|
|
92
|
+
assert(!!resolvedUrl.endpoints.ordererUrl, 0x0b2 /* "Missing orderer URL!" */);
|
|
93
|
+
let parsedUrl = parseFluidUrl(resolvedUrl.url);
|
|
94
|
+
if (!parsedUrl.pathname) {
|
|
95
|
+
throw new Error("Parsed url should contain tenant and doc Id!!");
|
|
96
|
+
}
|
|
97
|
+
const [, tenantId] = parsedUrl.pathname.split("/");
|
|
98
98
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
99
|
+
const protocolSummary = createNewSummary.tree[".protocol"] as ISummaryTree;
|
|
100
|
+
const appSummary = createNewSummary.tree[".app"] as ISummaryTree;
|
|
101
|
+
if (!(protocolSummary && appSummary)) {
|
|
102
|
+
throw new Error("Protocol and App Summary required in the full summary");
|
|
103
|
+
}
|
|
104
|
+
const documentAttributes = getDocAttributesFromProtocolSummary(protocolSummary);
|
|
105
|
+
const quorumValues = getQuorumValuesFromProtocolSummary(protocolSummary);
|
|
106
106
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
107
|
+
const logger2 = ChildLogger.create(logger, "RouterliciousDriver");
|
|
108
|
+
const rateLimiter = new RateLimiter(this.driverPolicies.maxConcurrentOrdererRequests);
|
|
109
|
+
const ordererRestWrapper = await RouterliciousOrdererRestWrapper.load(
|
|
110
|
+
tenantId,
|
|
111
|
+
undefined,
|
|
112
|
+
this.tokenProvider,
|
|
113
|
+
logger2,
|
|
114
|
+
rateLimiter,
|
|
115
|
+
this.driverPolicies.enableRestLess,
|
|
116
|
+
resolvedUrl.endpoints.ordererUrl,
|
|
117
|
+
);
|
|
118
118
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
undefined,
|
|
140
|
-
});
|
|
119
|
+
const res = await PerformanceEvent.timedExecAsync(
|
|
120
|
+
logger2,
|
|
121
|
+
{
|
|
122
|
+
eventName: "CreateNew",
|
|
123
|
+
details: JSON.stringify({
|
|
124
|
+
enableDiscovery: this.driverPolicies.enableDiscovery,
|
|
125
|
+
sequenceNumber: documentAttributes.sequenceNumber,
|
|
126
|
+
}),
|
|
127
|
+
},
|
|
128
|
+
async (event) => {
|
|
129
|
+
// @TODO: Remove returned "string" type when removing back-compat code
|
|
130
|
+
const postRes = await ordererRestWrapper.post<
|
|
131
|
+
{ id: string; token?: string; session?: ISession } | string
|
|
132
|
+
>(`/documents/${tenantId}`, {
|
|
133
|
+
summary: convertSummaryToCreateNewSummary(appSummary),
|
|
134
|
+
sequenceNumber: documentAttributes.sequenceNumber,
|
|
135
|
+
values: quorumValues,
|
|
136
|
+
enableDiscovery: this.driverPolicies.enableDiscovery,
|
|
137
|
+
generateToken: this.tokenProvider.documentPostCreateCallback !== undefined,
|
|
138
|
+
});
|
|
141
139
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
140
|
+
event.end({
|
|
141
|
+
docId: typeof postRes === "string" ? postRes : postRes.id,
|
|
142
|
+
});
|
|
143
|
+
return postRes;
|
|
144
|
+
},
|
|
145
|
+
);
|
|
148
146
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
147
|
+
// For supporting backward compatibility, when the request has generateToken === true, it will return
|
|
148
|
+
// an object instead of string
|
|
149
|
+
// @TODO: Remove the logic when no need to support back-compat
|
|
152
150
|
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
151
|
+
let documentId: string;
|
|
152
|
+
let token: string | undefined;
|
|
153
|
+
let session: ISession | undefined;
|
|
154
|
+
if (typeof res === "string") {
|
|
155
|
+
documentId = res;
|
|
156
|
+
} else {
|
|
157
|
+
documentId = res.id;
|
|
158
|
+
token = res.token;
|
|
159
|
+
session = this.driverPolicies.enableDiscovery ? res.session : undefined;
|
|
160
|
+
}
|
|
161
|
+
parsedUrl = parseFluidUrl(resolvedUrl.url);
|
|
164
162
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
163
|
+
// @TODO: Remove token from the condition, checking the documentPostCreateCallback !== undefined
|
|
164
|
+
// is sufficient to determine if the token will be undefined or not.
|
|
165
|
+
try {
|
|
166
|
+
await PerformanceEvent.timedExecAsync(
|
|
167
|
+
logger2,
|
|
168
|
+
{
|
|
169
|
+
eventName: "DocPostCreateCallback",
|
|
170
|
+
docId: documentId,
|
|
171
|
+
},
|
|
172
|
+
async () => {
|
|
173
|
+
if (token && this.tokenProvider.documentPostCreateCallback !== undefined) {
|
|
174
|
+
return this.tokenProvider.documentPostCreateCallback(documentId, token);
|
|
175
|
+
}
|
|
176
|
+
},
|
|
177
|
+
);
|
|
178
|
+
} catch (error: any) {
|
|
179
|
+
throw new DocumentPostCreateError(error);
|
|
180
|
+
}
|
|
182
181
|
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
182
|
+
parsedUrl.set("pathname", replaceDocumentIdInPath(parsedUrl.pathname, documentId));
|
|
183
|
+
const deltaStorageUrl = resolvedUrl.endpoints.deltaStorageUrl;
|
|
184
|
+
if (!deltaStorageUrl) {
|
|
185
|
+
throw new Error(
|
|
186
|
+
`All endpoints urls must be provided. [deltaStorageUrl:${deltaStorageUrl}]`,
|
|
187
|
+
);
|
|
188
|
+
}
|
|
189
|
+
const parsedDeltaStorageUrl = new URL(deltaStorageUrl);
|
|
190
|
+
parsedDeltaStorageUrl.pathname = replaceDocumentIdInPath(
|
|
191
|
+
parsedDeltaStorageUrl.pathname,
|
|
192
|
+
documentId,
|
|
193
|
+
);
|
|
191
194
|
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
195
|
+
return this.createDocumentService(
|
|
196
|
+
{
|
|
197
|
+
...resolvedUrl,
|
|
198
|
+
url: parsedUrl.toString(),
|
|
199
|
+
id: documentId,
|
|
200
|
+
endpoints: {
|
|
201
|
+
...resolvedUrl.endpoints,
|
|
202
|
+
deltaStorageUrl: parsedDeltaStorageUrl.toString(),
|
|
203
|
+
},
|
|
204
|
+
},
|
|
205
|
+
logger,
|
|
206
|
+
clientIsSummarizer,
|
|
207
|
+
session,
|
|
208
|
+
);
|
|
209
|
+
}
|
|
207
210
|
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
211
|
+
/**
|
|
212
|
+
* {@inheritDoc @fluidframework/driver-definitions#IDocumentServiceFactory.createDocumentService}
|
|
213
|
+
*
|
|
214
|
+
* @returns Routerlicious document service.
|
|
215
|
+
*/
|
|
216
|
+
public async createDocumentService(
|
|
217
|
+
resolvedUrl: IResolvedUrl,
|
|
218
|
+
logger?: ITelemetryBaseLogger,
|
|
219
|
+
clientIsSummarizer?: boolean,
|
|
220
|
+
session?: ISession,
|
|
221
|
+
): Promise<IDocumentService> {
|
|
222
|
+
ensureFluidResolvedUrl(resolvedUrl);
|
|
223
|
+
const parsedUrl = parseFluidUrl(resolvedUrl.url);
|
|
224
|
+
const [, tenantId, documentId] = parsedUrl.pathname.split("/");
|
|
225
|
+
if (!documentId || !tenantId) {
|
|
226
|
+
throw new Error(
|
|
227
|
+
`Couldn't parse documentId and/or tenantId. [documentId:${documentId}][tenantId:${tenantId}]`,
|
|
228
|
+
);
|
|
229
|
+
}
|
|
230
|
+
const logger2 = ChildLogger.create(logger, "RouterliciousDriver", {
|
|
231
|
+
all: { driverVersion },
|
|
232
|
+
});
|
|
227
233
|
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
234
|
+
const rateLimiter = new RateLimiter(this.driverPolicies.maxConcurrentOrdererRequests);
|
|
235
|
+
const ordererRestWrapper = await RouterliciousOrdererRestWrapper.load(
|
|
236
|
+
tenantId,
|
|
237
|
+
documentId,
|
|
238
|
+
this.tokenProvider,
|
|
239
|
+
logger2,
|
|
240
|
+
rateLimiter,
|
|
241
|
+
this.driverPolicies.enableRestLess,
|
|
242
|
+
);
|
|
237
243
|
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
244
|
+
const discoverFluidResolvedUrl = async (): Promise<IFluidResolvedUrl> => {
|
|
245
|
+
if (!this.driverPolicies.enableDiscovery) {
|
|
246
|
+
return resolvedUrl;
|
|
247
|
+
}
|
|
242
248
|
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
249
|
+
const discoveredSession = await PerformanceEvent.timedExecAsync(
|
|
250
|
+
logger2,
|
|
251
|
+
{
|
|
252
|
+
eventName: "DiscoverSession",
|
|
253
|
+
docId: documentId,
|
|
254
|
+
},
|
|
255
|
+
async () => {
|
|
256
|
+
// The service responds with the current document session associated with the container.
|
|
257
|
+
return ordererRestWrapper.get<ISession>(
|
|
258
|
+
`${resolvedUrl.endpoints.ordererUrl}/documents/${tenantId}/session/${documentId}`,
|
|
259
|
+
);
|
|
260
|
+
},
|
|
261
|
+
);
|
|
262
|
+
return getDiscoveredFluidResolvedUrl(resolvedUrl, discoveredSession);
|
|
263
|
+
};
|
|
264
|
+
const fluidResolvedUrl: IFluidResolvedUrl =
|
|
265
|
+
session !== undefined
|
|
266
|
+
? getDiscoveredFluidResolvedUrl(resolvedUrl, session)
|
|
267
|
+
: await discoverFluidResolvedUrl();
|
|
259
268
|
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
269
|
+
const storageUrl = fluidResolvedUrl.endpoints.storageUrl;
|
|
270
|
+
const ordererUrl = fluidResolvedUrl.endpoints.ordererUrl;
|
|
271
|
+
const deltaStorageUrl = fluidResolvedUrl.endpoints.deltaStorageUrl;
|
|
272
|
+
const deltaStreamUrl = fluidResolvedUrl.endpoints.deltaStreamUrl || ordererUrl; // backward compatibility
|
|
273
|
+
if (!ordererUrl || !deltaStorageUrl) {
|
|
274
|
+
throw new Error(
|
|
275
|
+
`All endpoints urls must be provided. [ordererUrl:${ordererUrl}][deltaStorageUrl:${deltaStorageUrl}]`,
|
|
276
|
+
);
|
|
277
|
+
}
|
|
268
278
|
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
279
|
+
const documentStorageServicePolicies: IDocumentStorageServicePolicies = {
|
|
280
|
+
caching: this.driverPolicies.enablePrefetch
|
|
281
|
+
? LoaderCachingPolicy.Prefetch
|
|
282
|
+
: LoaderCachingPolicy.NoCaching,
|
|
283
|
+
minBlobSize: this.driverPolicies.aggregateBlobsSmallerThanBytes,
|
|
284
|
+
maximumCacheDurationMs: maximumSnapshotCacheDurationMs,
|
|
285
|
+
};
|
|
276
286
|
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
287
|
+
return new DocumentService(
|
|
288
|
+
fluidResolvedUrl,
|
|
289
|
+
ordererUrl,
|
|
290
|
+
deltaStorageUrl,
|
|
291
|
+
deltaStreamUrl,
|
|
292
|
+
storageUrl,
|
|
293
|
+
logger2,
|
|
294
|
+
this.tokenProvider,
|
|
295
|
+
tenantId,
|
|
296
|
+
documentId,
|
|
297
|
+
ordererRestWrapper,
|
|
298
|
+
documentStorageServicePolicies,
|
|
299
|
+
this.driverPolicies,
|
|
300
|
+
this.blobCache,
|
|
301
|
+
this.snapshotTreeCache,
|
|
302
|
+
discoverFluidResolvedUrl,
|
|
303
|
+
);
|
|
304
|
+
}
|
|
294
305
|
}
|
|
295
306
|
|
|
296
307
|
/**
|
|
@@ -305,16 +316,18 @@ export class RouterliciousDocumentServiceFactory implements IDocumentServiceFact
|
|
|
305
316
|
* - What would a retry pattern look like here?
|
|
306
317
|
*/
|
|
307
318
|
export class DocumentPostCreateError extends Error {
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
319
|
+
public constructor(
|
|
320
|
+
/**
|
|
321
|
+
* Inner error being wrapped.
|
|
322
|
+
*/
|
|
323
|
+
private readonly innerError: Error,
|
|
324
|
+
) {
|
|
325
|
+
super(innerError.message);
|
|
326
|
+
}
|
|
316
327
|
|
|
317
|
-
|
|
328
|
+
public readonly name = "DocumentPostCreateError";
|
|
318
329
|
|
|
319
|
-
|
|
330
|
+
public get stack() {
|
|
331
|
+
return this.innerError.stack;
|
|
332
|
+
}
|
|
320
333
|
}
|