@fluidframework/routerlicious-driver 0.51.3 → 0.53.0-46105

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.
Files changed (55) hide show
  1. package/dist/createNewUtils.js +4 -3
  2. package/dist/createNewUtils.js.map +1 -1
  3. package/dist/deltaStorageService.d.ts +1 -1
  4. package/dist/deltaStorageService.d.ts.map +1 -1
  5. package/dist/deltaStorageService.js +2 -2
  6. package/dist/deltaStorageService.js.map +1 -1
  7. package/dist/documentService.d.ts.map +1 -1
  8. package/dist/documentService.js +4 -0
  9. package/dist/documentService.js.map +1 -1
  10. package/dist/documentStorageService.d.ts.map +1 -1
  11. package/dist/documentStorageService.js +4 -261
  12. package/dist/documentStorageService.js.map +1 -1
  13. package/dist/packageVersion.d.ts +1 -1
  14. package/dist/packageVersion.d.ts.map +1 -1
  15. package/dist/packageVersion.js +1 -1
  16. package/dist/packageVersion.js.map +1 -1
  17. package/dist/shreddedSummaryDocumentStorageService.d.ts +36 -0
  18. package/dist/shreddedSummaryDocumentStorageService.d.ts.map +1 -0
  19. package/dist/shreddedSummaryDocumentStorageService.js +143 -0
  20. package/dist/shreddedSummaryDocumentStorageService.js.map +1 -0
  21. package/dist/wholeSummaryDocumentStorageService.d.ts +31 -0
  22. package/dist/wholeSummaryDocumentStorageService.d.ts.map +1 -0
  23. package/dist/wholeSummaryDocumentStorageService.js +154 -0
  24. package/dist/wholeSummaryDocumentStorageService.js.map +1 -0
  25. package/lib/createNewUtils.js +4 -3
  26. package/lib/createNewUtils.js.map +1 -1
  27. package/lib/deltaStorageService.d.ts +1 -1
  28. package/lib/deltaStorageService.d.ts.map +1 -1
  29. package/lib/deltaStorageService.js +2 -2
  30. package/lib/deltaStorageService.js.map +1 -1
  31. package/lib/documentService.d.ts.map +1 -1
  32. package/lib/documentService.js +4 -0
  33. package/lib/documentService.js.map +1 -1
  34. package/lib/documentStorageService.d.ts.map +1 -1
  35. package/lib/documentStorageService.js +3 -260
  36. package/lib/documentStorageService.js.map +1 -1
  37. package/lib/packageVersion.d.ts +1 -1
  38. package/lib/packageVersion.d.ts.map +1 -1
  39. package/lib/packageVersion.js +1 -1
  40. package/lib/packageVersion.js.map +1 -1
  41. package/lib/shreddedSummaryDocumentStorageService.d.ts +36 -0
  42. package/lib/shreddedSummaryDocumentStorageService.d.ts.map +1 -0
  43. package/lib/shreddedSummaryDocumentStorageService.js +139 -0
  44. package/lib/shreddedSummaryDocumentStorageService.js.map +1 -0
  45. package/lib/wholeSummaryDocumentStorageService.d.ts +31 -0
  46. package/lib/wholeSummaryDocumentStorageService.d.ts.map +1 -0
  47. package/lib/wholeSummaryDocumentStorageService.js +150 -0
  48. package/lib/wholeSummaryDocumentStorageService.js.map +1 -0
  49. package/package.json +11 -11
  50. package/src/deltaStorageService.ts +2 -0
  51. package/src/documentService.ts +5 -0
  52. package/src/documentStorageService.ts +20 -374
  53. package/src/packageVersion.ts +1 -1
  54. package/src/shreddedSummaryDocumentStorageService.ts +213 -0
  55. package/src/wholeSummaryDocumentStorageService.ts +225 -0
@@ -0,0 +1,150 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ import { assert, stringToBuffer, Uint8ArrayToString, } from "@fluidframework/common-utils";
6
+ import { convertWholeFlatSummaryToSnapshotTreeAndBlobs, WholeSummaryUploadManager, } from "@fluidframework/server-services-client";
7
+ import { PerformanceEvent } from "@fluidframework/telemetry-utils";
8
+ import { InMemoryCache } from "./cache";
9
+ const latestSnapshotId = "latest";
10
+ export class WholeSummaryDocumentStorageService {
11
+ constructor(id, manager, logger, policies = {}, blobCache = new InMemoryCache(), snapshotTreeCache = new InMemoryCache()) {
12
+ this.id = id;
13
+ this.manager = manager;
14
+ this.logger = logger;
15
+ this.policies = policies;
16
+ this.blobCache = blobCache;
17
+ this.snapshotTreeCache = snapshotTreeCache;
18
+ this.firstVersionsCall = true;
19
+ this.summaryUploadManager = new WholeSummaryUploadManager(manager);
20
+ }
21
+ get repositoryUrl() {
22
+ return "";
23
+ }
24
+ async getVersions(versionId, count) {
25
+ if (versionId !== this.id && versionId !== null) {
26
+ // Blobs in this scenario will never have multiple versions, so return blobId as is
27
+ return [{
28
+ id: versionId,
29
+ treeId: undefined,
30
+ }];
31
+ }
32
+ // If this is the first versions call for the document, we know we will want the latest summary.
33
+ // Fetch latest summary, cache it, and return its id.
34
+ if (this.firstVersionsCall && count === 1) {
35
+ this.firstVersionsCall = false;
36
+ return [{
37
+ id: (await this.fetchAndCacheSnapshotTree(latestSnapshotId)).id,
38
+ treeId: undefined,
39
+ }];
40
+ }
41
+ // Otherwise, get the latest version of the document as normal.
42
+ const id = versionId ? versionId : this.id;
43
+ const commits = await PerformanceEvent.timedExecAsync(this.logger, {
44
+ eventName: "getVersions",
45
+ versionId: id,
46
+ count,
47
+ }, async () => this.manager.getCommits(id, count));
48
+ return commits.map((commit) => ({
49
+ date: commit.commit.author.date,
50
+ id: commit.sha,
51
+ treeId: undefined,
52
+ }));
53
+ }
54
+ async getSnapshotTree(version) {
55
+ let requestVersion = version;
56
+ if (!requestVersion) {
57
+ const versions = await this.getVersions(this.id, 1);
58
+ if (versions.length === 0) {
59
+ return null;
60
+ }
61
+ requestVersion = versions[0];
62
+ }
63
+ return (await this.fetchAndCacheSnapshotTree(requestVersion.id)).snapshotTree;
64
+ }
65
+ async readBlob(blobId) {
66
+ const cachedBlob = await this.blobCache.get(blobId);
67
+ if (cachedBlob !== undefined) {
68
+ return cachedBlob;
69
+ }
70
+ const blob = await PerformanceEvent.timedExecAsync(this.logger, {
71
+ eventName: "readBlob",
72
+ blobId,
73
+ }, async (event) => {
74
+ const response = await this.manager.getBlob(blobId);
75
+ event.end({
76
+ size: response.size,
77
+ });
78
+ return response;
79
+ });
80
+ const bufferValue = stringToBuffer(blob.content, blob.encoding);
81
+ await this.blobCache.put(blob.sha, bufferValue);
82
+ return bufferValue;
83
+ }
84
+ async uploadSummaryWithContext(summary, context) {
85
+ const summaryHandle = await PerformanceEvent.timedExecAsync(this.logger, {
86
+ eventName: "uploadSummaryWithContext",
87
+ }, async () => { var _a; return this.summaryUploadManager.writeSummaryTree(summary, (_a = context.ackHandle) !== null && _a !== void 0 ? _a : "", "channel"); });
88
+ return summaryHandle;
89
+ }
90
+ async downloadSummary(handle) {
91
+ throw new Error("NOT IMPLEMENTED!");
92
+ }
93
+ async write(tree, parents, message, ref) {
94
+ throw new Error("NOT IMPLEMENTED!");
95
+ }
96
+ async createBlob(file) {
97
+ const uint8ArrayFile = new Uint8Array(file);
98
+ return PerformanceEvent.timedExecAsync(this.logger, {
99
+ eventName: "createBlob",
100
+ size: uint8ArrayFile.length,
101
+ }, async (event) => {
102
+ const response = await this.manager.createBlob(Uint8ArrayToString(uint8ArrayFile, "base64"), "base64").then((r) => ({ id: r.sha, url: r.url }));
103
+ event.end({
104
+ blobId: response.id,
105
+ });
106
+ return response;
107
+ });
108
+ }
109
+ async fetchAndCacheSnapshotTree(versionId) {
110
+ const cachedSnapshotTree = await this.snapshotTreeCache.get(versionId);
111
+ if (cachedSnapshotTree !== undefined) {
112
+ return { id: cachedSnapshotTree.id, snapshotTree: cachedSnapshotTree };
113
+ }
114
+ const wholeFlatSummary = await PerformanceEvent.timedExecAsync(this.logger, {
115
+ eventName: "getWholeFlatSummary",
116
+ treeId: versionId,
117
+ }, async (event) => {
118
+ var _a;
119
+ const response = await this.manager.getSummary(versionId);
120
+ event.end({
121
+ size: (_a = response.trees[0]) === null || _a === void 0 ? void 0 : _a.entries.length,
122
+ });
123
+ return response;
124
+ });
125
+ const normalizedWholeSummary = convertWholeFlatSummaryToSnapshotTreeAndBlobs(wholeFlatSummary);
126
+ const snapshotId = normalizedWholeSummary.snapshotTree.id;
127
+ assert(snapshotId !== undefined, 0x275 /* "Root tree should contain the id" */);
128
+ const cachePs = [
129
+ this.snapshotTreeCache.put(snapshotId, normalizedWholeSummary.snapshotTree),
130
+ this.initBlobCache(normalizedWholeSummary.blobs),
131
+ ];
132
+ if (snapshotId !== versionId) {
133
+ // versionId could be "latest". When summarizer checks cache for "latest", we want it to be available.
134
+ // TODO: For in-memory cache, <latest,snapshotTree> will be a shared pointer with <snapshotId,snapshotTree>,
135
+ // However, for something like Redis, this will cache the same value twice. Alternatively, could we simply
136
+ // cache with versionId?
137
+ cachePs.push(this.snapshotTreeCache.put(versionId, normalizedWholeSummary.snapshotTree));
138
+ }
139
+ await Promise.all(cachePs);
140
+ return { id: snapshotId, snapshotTree: normalizedWholeSummary.snapshotTree };
141
+ }
142
+ async initBlobCache(blobs) {
143
+ const blobCachePutPs = [];
144
+ blobs.forEach((value, id) => {
145
+ blobCachePutPs.push(this.blobCache.put(id, value));
146
+ });
147
+ await Promise.all(blobCachePutPs);
148
+ }
149
+ }
150
+ //# sourceMappingURL=wholeSummaryDocumentStorageService.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wholeSummaryDocumentStorageService.js","sourceRoot":"","sources":["../src/wholeSummaryDocumentStorageService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EACH,MAAM,EACN,cAAc,EACd,kBAAkB,GACrB,MAAM,8BAA8B,CAAC;AActC,OAAO,EACH,6CAA6C,EAG7C,yBAAyB,GAC5B,MAAM,wCAAwC,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,EAAU,aAAa,EAAE,MAAM,SAAS,CAAC;AAEhD,MAAM,gBAAgB,GAAW,QAAQ,CAAC;AAE1C,MAAM,OAAO,kCAAkC;IAQ3C,YACuB,EAAU,EACV,OAAmB,EACnB,MAAwB,EAC3B,WAA4C,EAAE,EAC7C,YAAqC,IAAI,aAAa,EAAE,EACxD,oBAA2C,IAAI,aAAa,EAAE;QAL5D,OAAE,GAAF,EAAE,CAAQ;QACV,YAAO,GAAP,OAAO,CAAY;QACnB,WAAM,GAAN,MAAM,CAAkB;QAC3B,aAAQ,GAAR,QAAQ,CAAsC;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CAAC;QACF,IAAI,UAAU,KAAK,SAAS,EAAE;YAC1B,sGAAsG;YACtG,4GAA4G;YAC5G,0GAA0G;YAC1G,wBAAwB;YACxB,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,iBAAiB,CAAC,GAAG,CACnC,SAAS,EACT,sBAAsB,CAAC,YAAY,CACtC,CAAC,CAAC;SACN;QAED,MAAM,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QAE3B,OAAO,EAAE,EAAE,EAAE,UAAU,EAAE,YAAY,EAAE,sBAAsB,CAAC,YAAY,EAAC,CAAC;IAChF,CAAC;IAEO,KAAK,CAAC,aAAa,CAAC,KAA+B;QACvD,MAAM,cAAc,GAAoB,EAAE,CAAC;QAC3C,KAAK,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE,EAAE,EAAE;YACxB,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC,CAAC;QACvD,CAAC,CAAC,CAAC;QACH,MAAM,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;IACtC,CAAC;CACJ","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { ITelemetryLogger } from \"@fluidframework/common-definitions\";\nimport {\n assert,\n stringToBuffer,\n Uint8ArrayToString,\n} from \"@fluidframework/common-utils\";\nimport {\n IDocumentStorageService,\n ISummaryContext,\n IDocumentStorageServicePolicies,\n } from \"@fluidframework/driver-definitions\";\nimport {\n ICreateBlobResponse,\n ISnapshotTree,\n ISummaryHandle,\n ISummaryTree,\n ITree,\n IVersion,\n} from \"@fluidframework/protocol-definitions\";\nimport {\n convertWholeFlatSummaryToSnapshotTreeAndBlobs,\n GitManager,\n ISummaryUploadManager,\n WholeSummaryUploadManager,\n} from \"@fluidframework/server-services-client\";\nimport { PerformanceEvent } from \"@fluidframework/telemetry-utils\";\nimport { ICache, InMemoryCache } from \"./cache\";\n\nconst latestSnapshotId: string = \"latest\";\n\nexport class WholeSummaryDocumentStorageService implements IDocumentStorageService {\n private readonly summaryUploadManager: ISummaryUploadManager;\n private firstVersionsCall: boolean = true;\n\n public get repositoryUrl(): string {\n return \"\";\n }\n\n constructor(\n protected readonly id: string,\n protected readonly manager: GitManager,\n protected readonly logger: ITelemetryLogger,\n public readonly policies: IDocumentStorageServicePolicies = {},\n private readonly blobCache: ICache<ArrayBufferLike> = new InMemoryCache(),\n private readonly snapshotTreeCache: ICache<ISnapshotTree> = new InMemoryCache()) {\n this.summaryUploadManager = new WholeSummaryUploadManager(manager);\n }\n\n public async getVersions(versionId: string | null, count: number): Promise<IVersion[]> {\n if (versionId !== this.id && versionId !== null) {\n // Blobs in this scenario will never have multiple versions, so return blobId as is\n return [{\n id: versionId,\n treeId: undefined!,\n }];\n }\n // If this is the first versions call for the document, we know we will want the latest summary.\n // Fetch latest summary, cache it, and return its id.\n if (this.firstVersionsCall && count === 1) {\n this.firstVersionsCall = false;\n return [{\n id: (await this.fetchAndCacheSnapshotTree(latestSnapshotId)).id,\n treeId: undefined!,\n }];\n }\n\n // Otherwise, get the latest version of the document as normal.\n const id = versionId ? versionId : this.id;\n const commits = await PerformanceEvent.timedExecAsync(\n this.logger,\n {\n eventName: \"getVersions\",\n versionId: id,\n count,\n },\n async () => this.manager.getCommits(id, count),\n );\n return commits.map((commit) => ({\n date: commit.commit.author.date,\n id: commit.sha,\n treeId: undefined!,\n }));\n }\n\n public async getSnapshotTree(version?: IVersion): Promise<ISnapshotTree | null> {\n let requestVersion = version;\n if (!requestVersion) {\n const versions = await this.getVersions(this.id, 1);\n if (versions.length === 0) {\n return null;\n }\n\n requestVersion = versions[0];\n }\n\n return (await this.fetchAndCacheSnapshotTree(requestVersion.id)).snapshotTree;\n }\n\n public async readBlob(blobId: string): Promise<ArrayBufferLike> {\n const cachedBlob = await this.blobCache.get(blobId);\n if (cachedBlob !== undefined) {\n return cachedBlob;\n }\n\n const blob = await PerformanceEvent.timedExecAsync(\n this.logger,\n {\n eventName: \"readBlob\",\n blobId,\n },\n async (event) => {\n const response = await this.manager.getBlob(blobId);\n event.end({\n size: response.size,\n });\n return response;\n },\n );\n const bufferValue = stringToBuffer(blob.content, blob.encoding);\n\n await this.blobCache.put(blob.sha, bufferValue);\n\n return bufferValue;\n }\n\n public async uploadSummaryWithContext(summary: ISummaryTree, context: ISummaryContext): Promise<string> {\n const summaryHandle = await PerformanceEvent.timedExecAsync(\n this.logger,\n {\n eventName: \"uploadSummaryWithContext\",\n },\n async () => this.summaryUploadManager.writeSummaryTree(summary, context.ackHandle ?? \"\", \"channel\"),\n );\n return summaryHandle;\n }\n\n public async downloadSummary(handle: ISummaryHandle): Promise<ISummaryTree> {\n throw new Error(\"NOT IMPLEMENTED!\");\n }\n\n public async write(tree: ITree, parents: string[], message: string, ref: string): Promise<IVersion> {\n throw new Error(\"NOT IMPLEMENTED!\");\n }\n\n public async createBlob(file: ArrayBufferLike): Promise<ICreateBlobResponse> {\n const uint8ArrayFile = new Uint8Array(file);\n return PerformanceEvent.timedExecAsync(\n this.logger,\n {\n eventName: \"createBlob\",\n size: uint8ArrayFile.length,\n },\n async (event) => {\n const response = await this.manager.createBlob(\n Uint8ArrayToString(\n uint8ArrayFile, \"base64\"),\n \"base64\").then((r) => ({ id: r.sha, url: r.url }));\n event.end({\n blobId: response.id,\n });\n return response;\n },\n );\n }\n\n private async fetchAndCacheSnapshotTree(versionId: string): Promise<{ id: string, snapshotTree: ISnapshotTree }> {\n const cachedSnapshotTree = await this.snapshotTreeCache.get(versionId);\n if (cachedSnapshotTree !== undefined) {\n return { id: cachedSnapshotTree.id!, snapshotTree: cachedSnapshotTree };\n }\n\n const wholeFlatSummary = await PerformanceEvent.timedExecAsync(\n this.logger,\n {\n eventName: \"getWholeFlatSummary\",\n treeId: versionId,\n },\n async (event) => {\n const response = await this.manager.getSummary(versionId);\n event.end({\n size: response.trees[0]?.entries.length,\n });\n return response;\n },\n );\n const normalizedWholeSummary = convertWholeFlatSummaryToSnapshotTreeAndBlobs(wholeFlatSummary);\n const snapshotId = normalizedWholeSummary.snapshotTree.id;\n assert(snapshotId !== undefined, 0x275 /* \"Root tree should contain the id\" */);\n\n const cachePs: Promise<any>[] = [\n this.snapshotTreeCache.put(\n snapshotId,\n normalizedWholeSummary.snapshotTree,\n ),\n this.initBlobCache(normalizedWholeSummary.blobs),\n ];\n if (snapshotId !== versionId) {\n // versionId could be \"latest\". When summarizer checks cache for \"latest\", we want it to be available.\n // TODO: For in-memory cache, <latest,snapshotTree> will be a shared pointer with <snapshotId,snapshotTree>,\n // However, for something like Redis, this will cache the same value twice. Alternatively, could we simply\n // cache with versionId?\n cachePs.push(this.snapshotTreeCache.put(\n versionId,\n normalizedWholeSummary.snapshotTree,\n ));\n }\n\n await Promise.all(cachePs);\n\n return { id: snapshotId, snapshotTree: normalizedWholeSummary.snapshotTree};\n }\n\n private async initBlobCache(blobs: Map<string, ArrayBuffer>): Promise<void> {\n const blobCachePutPs: Promise<void>[] = [];\n blobs.forEach((value, id) => {\n blobCachePutPs.push(this.blobCache.put(id, value));\n });\n await Promise.all(blobCachePutPs);\n }\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluidframework/routerlicious-driver",
3
- "version": "0.51.3",
3
+ "version": "0.53.0-46105",
4
4
  "description": "Socket.IO + Git implementation of Fluid service API",
5
5
  "homepage": "https://fluidframework.com",
6
6
  "repository": "https://github.com/microsoft/FluidFramework",
@@ -57,15 +57,15 @@
57
57
  "dependencies": {
58
58
  "@fluidframework/common-definitions": "^0.20.1",
59
59
  "@fluidframework/common-utils": "^0.32.1",
60
- "@fluidframework/driver-base": "^0.51.3",
61
- "@fluidframework/driver-definitions": "^0.41.0",
62
- "@fluidframework/driver-utils": "^0.51.3",
63
- "@fluidframework/gitresources": "^0.1033.0",
64
- "@fluidframework/protocol-base": "^0.1033.0",
65
- "@fluidframework/protocol-definitions": "^0.1025.0",
66
- "@fluidframework/server-services-client": "^0.1033.0",
67
- "@fluidframework/telemetry-utils": "^0.51.3",
68
- "axios": "^0.21.1",
60
+ "@fluidframework/driver-base": "0.53.0-46105",
61
+ "@fluidframework/driver-definitions": "^0.43.0-0",
62
+ "@fluidframework/driver-utils": "0.53.0-46105",
63
+ "@fluidframework/gitresources": "^0.1034.0",
64
+ "@fluidframework/protocol-base": "^0.1034.0",
65
+ "@fluidframework/protocol-definitions": "^0.1026.0",
66
+ "@fluidframework/server-services-client": "^0.1034.0",
67
+ "@fluidframework/telemetry-utils": "0.53.0-46105",
68
+ "axios": "^0.21.2",
69
69
  "json-stringify-safe": "5.0.1",
70
70
  "socket.io-client": "^2.4.0",
71
71
  "url-parse": "^1.5.3",
@@ -74,7 +74,7 @@
74
74
  "devDependencies": {
75
75
  "@fluidframework/build-common": "^0.23.0",
76
76
  "@fluidframework/eslint-config-fluid": "^0.24.0",
77
- "@fluidframework/mocha-test-setup": "^0.51.3",
77
+ "@fluidframework/mocha-test-setup": "0.53.0-46105",
78
78
  "@microsoft/api-extractor": "^7.16.1",
79
79
  "@types/mocha": "^8.2.2",
80
80
  "@types/nock": "^9.3.0",
@@ -36,6 +36,7 @@ export class DocumentDeltaStorageService implements IDocumentDeltaStorageService
36
36
  to: number | undefined,
37
37
  abortSignal?: AbortSignal,
38
38
  cachedOnly?: boolean,
39
+ fetchReason?: string,
39
40
  ): IStream<ISequencedDocumentMessage[]>
40
41
  {
41
42
  if (cachedOnly) {
@@ -51,6 +52,7 @@ export class DocumentDeltaStorageService implements IDocumentDeltaStorageService
51
52
  MaxBatchDeltas,
52
53
  new TelemetryNullLogger(),
53
54
  abortSignal,
55
+ fetchReason,
54
56
  );
55
57
  }
56
58
 
@@ -49,6 +49,10 @@ export class DocumentService implements api.IDocumentService {
49
49
  * @returns returns the document storage service for routerlicious driver.
50
50
  */
51
51
  public async connectToStorage(): Promise<api.IDocumentStorageService> {
52
+ if (this.documentStorageService !== undefined) {
53
+ return this.documentStorageService;
54
+ }
55
+
52
56
  if (this.gitUrl === undefined) {
53
57
  return new NullBlobStorageService();
54
58
  }
@@ -93,6 +97,7 @@ export class DocumentService implements api.IDocumentService {
93
97
  * @returns returns the document delta storage service for routerlicious driver.
94
98
  */
95
99
  public async connectToDeltaStorage(): Promise<api.IDocumentDeltaStorageService> {
100
+ await this.connectToStorage();
96
101
  assert(!!this.documentStorageService, 0x0b1 /* "Storage service not initialized" */);
97
102
 
98
103
  const rateLimiter = new RateLimiter(this.driverPolicies.maxConcurrentOrdererRequests);
@@ -4,392 +4,23 @@
4
4
  */
5
5
 
6
6
  import type { ITelemetryLogger } from "@fluidframework/common-definitions";
7
- import {
8
- assert,
9
- stringToBuffer,
10
- Uint8ArrayToString,
11
- } from "@fluidframework/common-utils";
12
7
  import {
13
8
  IDocumentStorageService,
14
- ISummaryContext,
15
9
  IDocumentStorageServicePolicies,
16
10
  LoaderCachingPolicy,
17
11
  } from "@fluidframework/driver-definitions";
18
- import { buildHierarchy } from "@fluidframework/protocol-base";
19
12
  import {
20
- ICreateBlobResponse,
21
13
  ISnapshotTree,
22
- ISnapshotTreeEx,
23
- ISummaryHandle,
24
- ISummaryTree,
25
- ITree,
26
14
  IVersion,
27
15
  } from "@fluidframework/protocol-definitions";
28
16
  import {
29
- convertWholeFlatSummaryToSnapshotTreeAndBlobs,
30
17
  GitManager,
31
- ISummaryUploadManager,
32
- SummaryTreeUploadManager,
33
- WholeSummaryUploadManager,
34
18
  } from "@fluidframework/server-services-client";
35
- import { PerformanceEvent } from "@fluidframework/telemetry-utils";
36
19
  import { DocumentStorageServiceProxy, PrefetchDocumentStorageService } from "@fluidframework/driver-utils";
37
- import { RetriableGitManager } from "./retriableGitManager";
38
20
  import { IRouterliciousDriverPolicies } from "./policies";
39
- import { ICache, InMemoryCache } from "./cache";
40
-
41
- /**
42
- * Document access to underlying storage for routerlicious driver.
43
- * Uploads summaries piece-by-piece traversing the tree recursively.
44
- * Downloads summaries
45
- */
46
- class ShreddedSummaryDocumentStorageService implements IDocumentStorageService {
47
- // The values of this cache is useless. We only need the keys. So we are always putting
48
- // empty strings as values.
49
- protected readonly blobsShaCache = new Map<string, string>();
50
- private readonly summaryUploadManager: ISummaryUploadManager;
51
-
52
- public get repositoryUrl(): string {
53
- return "";
54
- }
55
-
56
- constructor(
57
- protected readonly id: string,
58
- protected readonly manager: GitManager,
59
- protected readonly logger: ITelemetryLogger,
60
- public readonly policies: IDocumentStorageServicePolicies = {}) {
61
- this.summaryUploadManager = new SummaryTreeUploadManager(
62
- new RetriableGitManager(manager, logger),
63
- this.blobsShaCache,
64
- this.getPreviousFullSnapshot.bind(this),
65
- );
66
- }
67
-
68
- public async getVersions(versionId: string, count: number): Promise<IVersion[]> {
69
- const id = versionId ? versionId : this.id;
70
- const commits = await PerformanceEvent.timedExecAsync(
71
- this.logger,
72
- {
73
- eventName: "getVersions",
74
- versionId: id,
75
- count,
76
- },
77
- async () => this.manager.getCommits(id, count),
78
- );
79
- return commits.map((commit) => ({
80
- date: commit.commit.author.date,
81
- id: commit.sha,
82
- treeId: commit.commit.tree.sha,
83
- }));
84
- }
85
-
86
- public async getSnapshotTree(version?: IVersion): Promise<ISnapshotTreeEx | null> {
87
- let requestVersion = version;
88
- if (!requestVersion) {
89
- const versions = await this.getVersions(this.id, 1);
90
- if (versions.length === 0) {
91
- return null;
92
- }
93
-
94
- requestVersion = versions[0];
95
- }
96
-
97
- const rawTree = await PerformanceEvent.timedExecAsync(
98
- this.logger,
99
- {
100
- eventName: "getSnapshotTree",
101
- treeId: requestVersion.treeId,
102
- },
103
- async (event) => {
104
- const response = await this.manager.getTree(requestVersion!.treeId);
105
- event.end({
106
- size: response.tree.length,
107
- });
108
- return response;
109
- },
110
- );
111
- const tree = buildHierarchy(rawTree, this.blobsShaCache, true);
112
- return tree;
113
- }
114
-
115
- public async readBlob(blobId: string): Promise<ArrayBufferLike> {
116
- const value = await PerformanceEvent.timedExecAsync(
117
- this.logger,
118
- {
119
- eventName: "readBlob",
120
- blobId,
121
- },
122
- async (event) => {
123
- const response = await this.manager.getBlob(blobId);
124
- event.end({
125
- size: response.size,
126
- });
127
- return response;
128
- },
129
- );
130
- this.blobsShaCache.set(value.sha, "");
131
- return stringToBuffer(value.content, value.encoding);
132
- }
133
-
134
- public async write(tree: ITree, parents: string[], message: string, ref: string): Promise<IVersion> {
135
- const branch = ref ? `datastores/${this.id}/${ref}` : this.id;
136
- const commit = await PerformanceEvent.timedExecAsync(
137
- this.logger,
138
- {
139
- eventName: "write",
140
- id: branch,
141
- },
142
- async () => this.manager.write(branch, tree, parents, message),
143
- );
144
- return { date: commit.committer.date, id: commit.sha, treeId: commit.tree.sha };
145
- }
146
-
147
- public async uploadSummaryWithContext(summary: ISummaryTree, context: ISummaryContext): Promise<string> {
148
- const summaryHandle = await PerformanceEvent.timedExecAsync(
149
- this.logger,
150
- {
151
- eventName: "uploadSummaryWithContext",
152
- },
153
- async () => this.summaryUploadManager.writeSummaryTree(summary, context.ackHandle ?? "", "channel"),
154
- );
155
- return summaryHandle;
156
- }
157
-
158
- public async downloadSummary(handle: ISummaryHandle): Promise<ISummaryTree> {
159
- throw new Error("NOT IMPLEMENTED!");
160
- }
161
-
162
- public async createBlob(file: ArrayBufferLike): Promise<ICreateBlobResponse> {
163
- const uint8ArrayFile = new Uint8Array(file);
164
- return PerformanceEvent.timedExecAsync(
165
- this.logger,
166
- {
167
- eventName: "createBlob",
168
- size: uint8ArrayFile.length,
169
- },
170
- async (event) => {
171
- const response = await this.manager.createBlob(
172
- Uint8ArrayToString(
173
- uint8ArrayFile, "base64"),
174
- "base64").then((r) => ({ id: r.sha, url: r.url }));
175
- event.end({
176
- blobId: response.id,
177
- });
178
- return response;
179
- },
180
- );
181
- }
182
-
183
- private async getPreviousFullSnapshot(parentHandle: string): Promise<ISnapshotTreeEx | null | undefined> {
184
- return parentHandle
185
- ? this.getVersions(parentHandle, 1)
186
- .then(async (versions) => {
187
- // Clear the cache as the getSnapshotTree call will fill the cache.
188
- this.blobsShaCache.clear();
189
- return this.getSnapshotTree(versions[0]);
190
- })
191
- : undefined;
192
- }
193
- }
194
-
195
- const latestSnapshotId: string = "latest";
196
-
197
- class WholeSummaryDocumentStorageService implements IDocumentStorageService {
198
- private readonly summaryUploadManager: ISummaryUploadManager;
199
- private firstVersionsCall: boolean = true;
200
-
201
- public get repositoryUrl(): string {
202
- return "";
203
- }
204
-
205
- constructor(
206
- protected readonly id: string,
207
- protected readonly manager: GitManager,
208
- protected readonly logger: ITelemetryLogger,
209
- public readonly policies: IDocumentStorageServicePolicies = {},
210
- private readonly blobCache: ICache<ArrayBufferLike> = new InMemoryCache(),
211
- private readonly snapshotTreeCache: ICache<ISnapshotTree> = new InMemoryCache()) {
212
- this.summaryUploadManager = new WholeSummaryUploadManager(manager);
213
- }
214
-
215
- public async getVersions(versionId: string | null, count: number): Promise<IVersion[]> {
216
- if (versionId !== this.id && versionId !== null) {
217
- // Blobs in this scenario will never have multiple versions, so return blobId as is
218
- return [{
219
- id: versionId,
220
- treeId: undefined!,
221
- }];
222
- }
223
- // If this is the first versions call for the document, we know we will want the latest summary.
224
- // Fetch latest summary, cache it, and return its id.
225
- if (this.firstVersionsCall && count === 1) {
226
- this.firstVersionsCall = false;
227
- return [{
228
- id: (await this.fetchAndCacheSnapshotTree(latestSnapshotId)).id,
229
- treeId: undefined!,
230
- }];
231
- }
232
-
233
- // Otherwise, get the latest version of the document as normal.
234
- const id = versionId ? versionId : this.id;
235
- const commits = await PerformanceEvent.timedExecAsync(
236
- this.logger,
237
- {
238
- eventName: "getVersions",
239
- versionId: id,
240
- count,
241
- },
242
- async () => this.manager.getCommits(id, count),
243
- );
244
- return commits.map((commit) => ({
245
- date: commit.commit.author.date,
246
- id: commit.sha,
247
- treeId: undefined!,
248
- }));
249
- }
250
-
251
- public async getSnapshotTree(version?: IVersion): Promise<ISnapshotTree | null> {
252
- let requestVersion = version;
253
- if (!requestVersion) {
254
- const versions = await this.getVersions(this.id, 1);
255
- if (versions.length === 0) {
256
- return null;
257
- }
258
-
259
- requestVersion = versions[0];
260
- }
261
-
262
- return (await this.fetchAndCacheSnapshotTree(requestVersion.id)).snapshotTree;
263
- }
264
-
265
- public async readBlob(blobId: string): Promise<ArrayBufferLike> {
266
- const cachedBlob = await this.blobCache.get(blobId);
267
- if (cachedBlob !== undefined) {
268
- return cachedBlob;
269
- }
270
-
271
- const blob = await PerformanceEvent.timedExecAsync(
272
- this.logger,
273
- {
274
- eventName: "readBlob",
275
- blobId,
276
- },
277
- async (event) => {
278
- const response = await this.manager.getBlob(blobId);
279
- event.end({
280
- size: response.size,
281
- });
282
- return response;
283
- },
284
- );
285
- const bufferValue = stringToBuffer(blob.content, blob.encoding);
286
-
287
- await this.blobCache.put(blob.sha, bufferValue);
288
-
289
- return bufferValue;
290
- }
291
-
292
- public async uploadSummaryWithContext(summary: ISummaryTree, context: ISummaryContext): Promise<string> {
293
- const summaryHandle = await PerformanceEvent.timedExecAsync(
294
- this.logger,
295
- {
296
- eventName: "uploadSummaryWithContext",
297
- },
298
- async () => this.summaryUploadManager.writeSummaryTree(summary, context.ackHandle ?? "", "channel"),
299
- );
300
- return summaryHandle;
301
- }
302
-
303
- public async downloadSummary(handle: ISummaryHandle): Promise<ISummaryTree> {
304
- throw new Error("NOT IMPLEMENTED!");
305
- }
306
-
307
- public async write(tree: ITree, parents: string[], message: string, ref: string): Promise<IVersion> {
308
- throw new Error("NOT IMPLEMENTED!");
309
- }
310
-
311
- public async createBlob(file: ArrayBufferLike): Promise<ICreateBlobResponse> {
312
- const uint8ArrayFile = new Uint8Array(file);
313
- return PerformanceEvent.timedExecAsync(
314
- this.logger,
315
- {
316
- eventName: "createBlob",
317
- size: uint8ArrayFile.length,
318
- },
319
- async (event) => {
320
- const response = await this.manager.createBlob(
321
- Uint8ArrayToString(
322
- uint8ArrayFile, "base64"),
323
- "base64").then((r) => ({ id: r.sha, url: r.url }));
324
- event.end({
325
- blobId: response.id,
326
- });
327
- return response;
328
- },
329
- );
330
- }
331
-
332
- private async fetchAndCacheSnapshotTree(versionId: string): Promise<{ id: string, snapshotTree: ISnapshotTree }> {
333
- const cachedSnapshotTree = await this.snapshotTreeCache.get(versionId);
334
- if (cachedSnapshotTree !== undefined) {
335
- return { id: cachedSnapshotTree.id!, snapshotTree: cachedSnapshotTree };
336
- }
337
-
338
- const wholeFlatSummary = await PerformanceEvent.timedExecAsync(
339
- this.logger,
340
- {
341
- eventName: "getWholeFlatSummary",
342
- treeId: versionId,
343
- },
344
- async (event) => {
345
- const response = await this.manager.getSummary(versionId);
346
- event.end({
347
- size: response.trees[0]?.entries.length,
348
- });
349
- return response;
350
- },
351
- );
352
- const normalizedWholeSummary = convertWholeFlatSummaryToSnapshotTreeAndBlobs(wholeFlatSummary);
353
- const snapshotId = normalizedWholeSummary.snapshotTree.id;
354
- assert(snapshotId !== undefined, 0x275 /* "Root tree should contain the id" */);
355
-
356
- const cachePs: Promise<any>[] = [
357
- this.snapshotTreeCache.put(
358
- snapshotId,
359
- normalizedWholeSummary.snapshotTree,
360
- ),
361
- this.initBlobCache(normalizedWholeSummary.blobs),
362
- ];
363
- if (snapshotId !== versionId) {
364
- // versionId could be "latest". When summarizer checks cache for "latest", we want it to be available.
365
- // TODO: For in-memory cache, <latest,snapshotTree> will be a shared pointer with <snapshotId,snapshotTree>,
366
- // However, for something like Redis, this will cache the same value twice. Alternatively, could we simply
367
- // cache with versionId?
368
- cachePs.push(this.snapshotTreeCache.put(
369
- versionId,
370
- normalizedWholeSummary.snapshotTree,
371
- ));
372
- }
373
-
374
- await Promise.all([
375
- this.snapshotTreeCache.put(
376
- snapshotId,
377
- normalizedWholeSummary.snapshotTree,
378
- ),
379
- this.initBlobCache(normalizedWholeSummary.blobs),
380
- ]);
381
-
382
- return { id: snapshotId, snapshotTree: normalizedWholeSummary.snapshotTree};
383
- }
384
-
385
- private async initBlobCache(blobs: Map<string, ArrayBuffer>): Promise<void> {
386
- const blobCachePutPs: Promise<void>[] = [];
387
- blobs.forEach((value, id) => {
388
- blobCachePutPs.push(this.blobCache.put(id, value));
389
- });
390
- await Promise.all(blobCachePutPs);
391
- }
392
- }
21
+ import { ICache } from "./cache";
22
+ import { WholeSummaryDocumentStorageService } from "./wholeSummaryDocumentStorageService";
23
+ import { ShreddedSummaryDocumentStorageService } from "./shreddedSummaryDocumentStorageService";
393
24
 
394
25
  export class DocumentStorageService extends DocumentStorageServiceProxy {
395
26
  private _logTailSha: string | undefined = undefined;
@@ -407,8 +38,23 @@ export class DocumentStorageService extends DocumentStorageServiceProxy {
407
38
  blobCache?: ICache<ArrayBufferLike>,
408
39
  snapshotTreeCache?: ICache<ISnapshotTree>): IDocumentStorageService {
409
40
  const storageService = driverPolicies?.enableWholeSummaryUpload ?
410
- new WholeSummaryDocumentStorageService(id, manager, logger, policies, blobCache, snapshotTreeCache) :
411
- new ShreddedSummaryDocumentStorageService(id, manager, logger, policies);
41
+ new WholeSummaryDocumentStorageService(
42
+ id,
43
+ manager,
44
+ logger,
45
+ policies,
46
+ blobCache,
47
+ snapshotTreeCache,
48
+ ) :
49
+ new ShreddedSummaryDocumentStorageService(
50
+ id,
51
+ manager,
52
+ logger,
53
+ policies,
54
+ driverPolicies,
55
+ blobCache,
56
+ snapshotTreeCache,
57
+ );
412
58
  // TODO: worth prefetching latest summary making version + snapshot call with WholeSummary storage?
413
59
  if (!driverPolicies?.enableWholeSummaryUpload && policies.caching === LoaderCachingPolicy.Prefetch) {
414
60
  return new PrefetchDocumentStorageService(storageService);