@fluidframework/routerlicious-driver 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 +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
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
IDeltaStorageService,
|
|
8
|
+
IDocumentDeltaStorageService,
|
|
9
|
+
IDeltasFetchResult,
|
|
10
|
+
IStream,
|
|
11
11
|
} from "@fluidframework/driver-definitions";
|
|
12
12
|
import { ISequencedDocumentMessage } from "@fluidframework/protocol-definitions";
|
|
13
13
|
import { readAndParse, requestOps, emptyMessageStream } from "@fluidframework/driver-utils";
|
|
@@ -22,108 +22,112 @@ const MaxBatchDeltas = 2000; // Maximum number of ops we can fetch at a time
|
|
|
22
22
|
* Storage service limited to only being able to fetch documents for a specific document
|
|
23
23
|
*/
|
|
24
24
|
export class DocumentDeltaStorageService implements IDocumentDeltaStorageService {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
25
|
+
constructor(
|
|
26
|
+
private readonly tenantId: string,
|
|
27
|
+
private readonly id: string,
|
|
28
|
+
private readonly deltaStorageService: IDeltaStorageService,
|
|
29
|
+
private readonly documentStorageService: DocumentStorageService,
|
|
30
|
+
private readonly logger: ITelemetryLogger,
|
|
31
|
+
) {}
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+
private logtailSha: string | undefined = this.documentStorageService.logTailSha;
|
|
34
34
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
35
|
+
fetchMessages(
|
|
36
|
+
from: number,
|
|
37
|
+
to: number | undefined,
|
|
38
|
+
abortSignal?: AbortSignal,
|
|
39
|
+
cachedOnly?: boolean,
|
|
40
|
+
fetchReason?: string,
|
|
41
|
+
): IStream<ISequencedDocumentMessage[]> {
|
|
42
|
+
if (cachedOnly) {
|
|
43
|
+
return emptyMessageStream;
|
|
44
|
+
}
|
|
45
|
+
return requestOps(
|
|
46
|
+
this.getCore.bind(this),
|
|
47
|
+
// Staging: starting with no concurrency, listening for feedback first.
|
|
48
|
+
// In future releases we will switch to actual concurrency
|
|
49
|
+
1, // concurrency
|
|
50
|
+
from, // inclusive
|
|
51
|
+
to, // exclusive
|
|
52
|
+
MaxBatchDeltas,
|
|
53
|
+
new TelemetryNullLogger(),
|
|
54
|
+
abortSignal,
|
|
55
|
+
fetchReason,
|
|
56
|
+
);
|
|
57
|
+
}
|
|
57
58
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
59
|
+
private async getCore(from: number, to: number): Promise<IDeltasFetchResult> {
|
|
60
|
+
const opsFromLogTail = this.logtailSha
|
|
61
|
+
? await readAndParse<ISequencedDocumentMessage[]>(
|
|
62
|
+
this.documentStorageService,
|
|
63
|
+
this.logtailSha,
|
|
64
|
+
)
|
|
65
|
+
: [];
|
|
62
66
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
if (messages.length > 0 && messages[0].sequenceNumber === from) {
|
|
75
|
-
return { messages, partialResult: true };
|
|
76
|
-
}
|
|
77
|
-
} catch (error) {
|
|
78
|
-
this.logger.sendErrorEvent({ eventName: "LogTailReadError" }, error);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
67
|
+
this.logtailSha = undefined;
|
|
68
|
+
if (opsFromLogTail.length > 0) {
|
|
69
|
+
try {
|
|
70
|
+
const messages = opsFromLogTail.filter((op, i) => {
|
|
71
|
+
// throw if the sequence numbers in logtail are not contiguous
|
|
72
|
+
if (i > 0 && op.sequenceNumber !== opsFromLogTail[i - 1].sequenceNumber + 1) {
|
|
73
|
+
throw new Error("Log tail ops are not contiguous");
|
|
74
|
+
}
|
|
75
|
+
return op.sequenceNumber >= from;
|
|
76
|
+
});
|
|
81
77
|
|
|
82
|
-
|
|
83
|
-
|
|
78
|
+
if (messages.length > 0 && messages[0].sequenceNumber === from) {
|
|
79
|
+
return { messages, partialResult: true };
|
|
80
|
+
}
|
|
81
|
+
} catch (error) {
|
|
82
|
+
this.logger.sendErrorEvent({ eventName: "LogTailReadError" }, error);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
return this.deltaStorageService.get(this.tenantId, this.id, from, to);
|
|
87
|
+
}
|
|
84
88
|
}
|
|
85
89
|
|
|
86
90
|
/**
|
|
87
91
|
* Provides access to the underlying delta storage on the server for routerlicious driver.
|
|
88
92
|
*/
|
|
89
93
|
export class DeltaStorageService implements IDeltaStorageService {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
}
|
|
94
|
+
constructor(
|
|
95
|
+
private readonly url: string,
|
|
96
|
+
private readonly restWrapper: RestWrapper,
|
|
97
|
+
private readonly logger: ITelemetryLogger,
|
|
98
|
+
private readonly getRestWrapper: () => Promise<RestWrapper> = async () => this.restWrapper,
|
|
99
|
+
private readonly getDeltaStorageUrl: () => string = () => this.url,
|
|
100
|
+
) {}
|
|
98
101
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
102
|
+
public async get(
|
|
103
|
+
tenantId: string,
|
|
104
|
+
id: string,
|
|
105
|
+
from: number, // inclusive
|
|
106
|
+
to: number, // exclusive
|
|
107
|
+
): Promise<IDeltasFetchResult> {
|
|
108
|
+
const ops = await PerformanceEvent.timedExecAsync(
|
|
109
|
+
this.logger,
|
|
110
|
+
{
|
|
111
|
+
eventName: "getDeltas",
|
|
112
|
+
from,
|
|
113
|
+
to,
|
|
114
|
+
},
|
|
115
|
+
async (event) => {
|
|
116
|
+
const restWrapper = await this.getRestWrapper();
|
|
117
|
+
const url = this.getDeltaStorageUrl();
|
|
118
|
+
const response = await restWrapper.get<ISequencedDocumentMessage[]>(url, {
|
|
119
|
+
from: from - 1,
|
|
120
|
+
to,
|
|
121
|
+
});
|
|
122
|
+
event.end({
|
|
123
|
+
count: response.length,
|
|
124
|
+
});
|
|
125
|
+
return response;
|
|
126
|
+
},
|
|
127
|
+
);
|
|
124
128
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
+
// It is assumed that server always returns all the ops that it has in the range that was requested.
|
|
130
|
+
// This may change in the future, if so, we need to adjust and receive "end" value from server in such case.
|
|
131
|
+
return { messages: ops, partialResult: false };
|
|
132
|
+
}
|
|
129
133
|
}
|
|
@@ -17,55 +17,61 @@ const protocolVersions = ["^0.4.0", "^0.3.0", "^0.2.0", "^0.1.0"];
|
|
|
17
17
|
* Wrapper over the shared one for driver specific translation.
|
|
18
18
|
*/
|
|
19
19
|
export class R11sDocumentDeltaConnection extends DocumentDeltaConnection {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
});
|
|
20
|
+
public static async create(
|
|
21
|
+
tenantId: string,
|
|
22
|
+
id: string,
|
|
23
|
+
token: string | null,
|
|
24
|
+
io: typeof SocketIOClientStatic,
|
|
25
|
+
client: IClient,
|
|
26
|
+
url: string,
|
|
27
|
+
logger: ITelemetryLogger,
|
|
28
|
+
timeoutMs = 20000,
|
|
29
|
+
): Promise<IDocumentDeltaConnection> {
|
|
30
|
+
const socket = io(url, {
|
|
31
|
+
query: {
|
|
32
|
+
documentId: id,
|
|
33
|
+
tenantId,
|
|
34
|
+
},
|
|
35
|
+
reconnection: false,
|
|
36
|
+
// Default to websocket connection, with long-polling disabled
|
|
37
|
+
transports: ["websocket"],
|
|
38
|
+
timeout: timeoutMs,
|
|
39
|
+
});
|
|
41
40
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
41
|
+
const connectMessage: IConnect = {
|
|
42
|
+
client,
|
|
43
|
+
id,
|
|
44
|
+
mode: client.mode,
|
|
45
|
+
tenantId,
|
|
46
|
+
token, // Token is going to indicate tenant level information, etc...
|
|
47
|
+
versions: protocolVersions,
|
|
48
|
+
relayUserAgent: [client.details.environment, ` driverVersion:${driverVersion}`].join(
|
|
49
|
+
";",
|
|
50
|
+
),
|
|
51
|
+
};
|
|
51
52
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
53
|
+
// TODO: expose to host at factory level
|
|
54
|
+
const enableLongPollingDowngrades = true;
|
|
55
|
+
const deltaConnection = new R11sDocumentDeltaConnection(
|
|
56
|
+
socket,
|
|
57
|
+
id,
|
|
58
|
+
logger,
|
|
59
|
+
enableLongPollingDowngrades,
|
|
60
|
+
);
|
|
55
61
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
62
|
+
await deltaConnection.initialize(connectMessage, timeoutMs);
|
|
63
|
+
return deltaConnection;
|
|
64
|
+
}
|
|
59
65
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
66
|
+
/**
|
|
67
|
+
* Error raising for socket.io issues
|
|
68
|
+
*/
|
|
69
|
+
protected createErrorObject(handler: string, error?: any, canRetry = true): IAnyDriverError {
|
|
70
|
+
// Note: we suspect the incoming error object is either:
|
|
71
|
+
// - a socketError: add it to the R11sError object for driver to be able to parse it and reason over it.
|
|
72
|
+
// - anything else: let base class handle it
|
|
73
|
+
return canRetry && Number.isInteger(error?.code) && typeof error?.message === "string"
|
|
74
|
+
? errorObjectFromSocketError(error as IR11sSocketError, handler)
|
|
75
|
+
: super.createErrorObject(handler, error, canRetry);
|
|
76
|
+
}
|
|
71
77
|
}
|