@fluidframework/datastore 2.0.0-internal.4.2.1 → 2.0.0-internal.4.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/dist/channelContext.d.ts +12 -5
  2. package/dist/channelContext.d.ts.map +1 -1
  3. package/dist/channelContext.js +74 -5
  4. package/dist/channelContext.js.map +1 -1
  5. package/dist/channelDeltaConnection.d.ts +4 -5
  6. package/dist/channelDeltaConnection.d.ts.map +1 -1
  7. package/dist/channelDeltaConnection.js +3 -4
  8. package/dist/channelDeltaConnection.js.map +1 -1
  9. package/dist/dataStoreRuntime.d.ts.map +1 -1
  10. package/dist/dataStoreRuntime.js +1 -2
  11. package/dist/dataStoreRuntime.js.map +1 -1
  12. package/dist/localChannelContext.d.ts +7 -16
  13. package/dist/localChannelContext.d.ts.map +1 -1
  14. package/dist/localChannelContext.js +52 -65
  15. package/dist/localChannelContext.js.map +1 -1
  16. package/dist/remoteChannelContext.d.ts +3 -8
  17. package/dist/remoteChannelContext.d.ts.map +1 -1
  18. package/dist/remoteChannelContext.js +22 -89
  19. package/dist/remoteChannelContext.js.map +1 -1
  20. package/lib/channelContext.d.ts +12 -5
  21. package/lib/channelContext.d.ts.map +1 -1
  22. package/lib/channelContext.js +70 -3
  23. package/lib/channelContext.js.map +1 -1
  24. package/lib/channelDeltaConnection.d.ts +4 -5
  25. package/lib/channelDeltaConnection.d.ts.map +1 -1
  26. package/lib/channelDeltaConnection.js +3 -4
  27. package/lib/channelDeltaConnection.js.map +1 -1
  28. package/lib/dataStoreRuntime.d.ts.map +1 -1
  29. package/lib/dataStoreRuntime.js +1 -2
  30. package/lib/dataStoreRuntime.js.map +1 -1
  31. package/lib/localChannelContext.d.ts +7 -16
  32. package/lib/localChannelContext.d.ts.map +1 -1
  33. package/lib/localChannelContext.js +54 -67
  34. package/lib/localChannelContext.js.map +1 -1
  35. package/lib/remoteChannelContext.d.ts +3 -8
  36. package/lib/remoteChannelContext.d.ts.map +1 -1
  37. package/lib/remoteChannelContext.js +25 -92
  38. package/lib/remoteChannelContext.js.map +1 -1
  39. package/package.json +14 -15
  40. package/src/channelContext.ts +105 -6
  41. package/src/channelDeltaConnection.ts +4 -5
  42. package/src/dataStoreRuntime.ts +4 -8
  43. package/src/localChannelContext.ts +105 -140
  44. package/src/remoteChannelContext.ts +58 -125
  45. package/dist/packageVersion.d.ts +0 -9
  46. package/dist/packageVersion.d.ts.map +0 -1
  47. package/dist/packageVersion.js +0 -12
  48. package/dist/packageVersion.js.map +0 -1
  49. package/lib/packageVersion.d.ts +0 -9
  50. package/lib/packageVersion.d.ts.map +0 -1
  51. package/lib/packageVersion.js +0 -9
  52. package/lib/packageVersion.js.map +0 -1
  53. package/src/packageVersion.ts +0 -9
@@ -4,16 +4,10 @@
4
4
  */
5
5
 
6
6
  import { ITelemetryLogger } from "@fluidframework/common-definitions";
7
- import { assert } from "@fluidframework/common-utils";
8
- import { DataCorruptionError } from "@fluidframework/container-utils";
7
+ import { LazyPromise, assert } from "@fluidframework/common-utils";
9
8
  import { IFluidHandle } from "@fluidframework/core-interfaces";
10
- import {
11
- IChannel,
12
- IChannelAttributes,
13
- IFluidDataStoreRuntime,
14
- } from "@fluidframework/datastore-definitions";
9
+ import { IChannel, IFluidDataStoreRuntime } from "@fluidframework/datastore-definitions";
15
10
  import { IDocumentStorageService } from "@fluidframework/driver-definitions";
16
- import { readAndParse } from "@fluidframework/driver-utils";
17
11
  import { ISequencedDocumentMessage, ISnapshotTree } from "@fluidframework/protocol-definitions";
18
12
  import {
19
13
  CreateChildSummarizerNodeFn,
@@ -25,52 +19,48 @@ import {
25
19
  ISummarizerNodeWithGC,
26
20
  ITelemetryContext,
27
21
  } from "@fluidframework/runtime-definitions";
28
- import { ChildLogger, TelemetryDataTag, ThresholdCounter } from "@fluidframework/telemetry-utils";
22
+ import { ChildLogger, ThresholdCounter } from "@fluidframework/telemetry-utils";
29
23
  import {
30
- attributesBlobKey,
31
- createServiceEndpoints,
24
+ ChannelServiceEndpoints,
25
+ createChannelServiceEndpoints,
32
26
  IChannelContext,
27
+ loadChannel,
28
+ loadChannelFactoryAndAttributes,
33
29
  summarizeChannelAsync,
34
30
  } from "./channelContext";
35
- import { ChannelDeltaConnection } from "./channelDeltaConnection";
36
- import { ChannelStorageService } from "./channelStorageService";
37
31
  import { ISharedObjectRegistry } from "./dataStoreRuntime";
38
32
 
39
33
  export class RemoteChannelContext implements IChannelContext {
40
34
  private isLoaded = false;
41
35
  private pending: ISequencedDocumentMessage[] | undefined = [];
42
- private channelP: Promise<IChannel> | undefined;
36
+ private readonly channelP: Promise<IChannel>;
43
37
  private channel: IChannel | undefined;
44
- private readonly services: {
45
- readonly deltaConnection: ChannelDeltaConnection;
46
- readonly objectStorage: ChannelStorageService;
47
- };
38
+ private readonly services: ChannelServiceEndpoints;
48
39
  private readonly summarizerNode: ISummarizerNodeWithGC;
49
40
  private readonly subLogger: ITelemetryLogger;
50
41
  private readonly thresholdOpsCounter: ThresholdCounter;
51
42
  private static readonly pendingOpsCountThreshold = 1000;
52
43
 
53
44
  constructor(
54
- private readonly runtime: IFluidDataStoreRuntime,
55
- private readonly dataStoreContext: IFluidDataStoreContext,
45
+ runtime: IFluidDataStoreRuntime,
46
+ dataStoreContext: IFluidDataStoreContext,
56
47
  storageService: IDocumentStorageService,
57
48
  submitFn: (content: any, localOpMetadata: unknown) => void,
58
49
  dirtyFn: (address: string) => void,
59
50
  addedGCOutboundReferenceFn: (srcHandle: IFluidHandle, outboundHandle: IFluidHandle) => void,
60
51
  private readonly id: string,
61
52
  baseSnapshot: ISnapshotTree,
62
- private readonly registry: ISharedObjectRegistry,
53
+ registry: ISharedObjectRegistry,
63
54
  extraBlobs: Map<string, ArrayBufferLike> | undefined,
64
55
  createSummarizerNode: CreateChildSummarizerNodeFn,
65
- private readonly attachMessageType?: string,
56
+ attachMessageType?: string,
66
57
  ) {
67
58
  assert(!this.id.includes("/"), 0x310 /* Channel context ID cannot contain slashes */);
68
59
 
69
- this.subLogger = ChildLogger.create(this.runtime.logger, "RemoteChannelContext");
60
+ this.subLogger = ChildLogger.create(runtime.logger, "RemoteChannelContext");
70
61
 
71
- this.services = createServiceEndpoints(
72
- this.id,
73
- this.dataStoreContext.connected,
62
+ this.services = createChannelServiceEndpoints(
63
+ dataStoreContext.connected,
74
64
  submitFn,
75
65
  () => dirtyFn(this.id),
76
66
  addedGCOutboundReferenceFn,
@@ -80,6 +70,46 @@ export class RemoteChannelContext implements IChannelContext {
80
70
  extraBlobs,
81
71
  );
82
72
 
73
+ this.channelP = new LazyPromise<IChannel>(async () => {
74
+ const { attributes, factory } = await loadChannelFactoryAndAttributes(
75
+ dataStoreContext,
76
+ this.services,
77
+ this.id,
78
+ registry,
79
+ attachMessageType,
80
+ );
81
+
82
+ const channel = await loadChannel(
83
+ runtime,
84
+ attributes,
85
+ factory,
86
+ this.services,
87
+ this.subLogger,
88
+ this.id,
89
+ );
90
+
91
+ // Send all pending messages to the channel
92
+ assert(this.pending !== undefined, 0x23f /* "pending undefined" */);
93
+ for (const message of this.pending) {
94
+ this.services.deltaConnection.process(
95
+ message,
96
+ false,
97
+ undefined /* localOpMetadata */,
98
+ );
99
+ }
100
+ this.thresholdOpsCounter.send("ProcessPendingOps", this.pending.length);
101
+
102
+ // Commit changes.
103
+ this.channel = channel;
104
+ this.pending = undefined;
105
+ this.isLoaded = true;
106
+
107
+ // Because have some await between we created the service and here, the connection state might have changed
108
+ // and we don't propagate the connection state when we are not loaded. So we have to set it again here.
109
+ this.services.deltaConnection.setConnectionState(dataStoreContext.connected);
110
+ return this.channel;
111
+ });
112
+
83
113
  const thisSummarizeInternal = async (
84
114
  fullTree: boolean,
85
115
  trackState: boolean,
@@ -106,10 +136,6 @@ export class RemoteChannelContext implements IChannelContext {
106
136
 
107
137
  // eslint-disable-next-line @typescript-eslint/promise-function-async
108
138
  public getChannel(): Promise<IChannel> {
109
- if (this.channelP === undefined) {
110
- this.channelP = this.loadChannel();
111
- }
112
-
113
139
  return this.channelP;
114
140
  }
115
141
 
@@ -122,9 +148,9 @@ export class RemoteChannelContext implements IChannelContext {
122
148
  this.services.deltaConnection.setConnectionState(connected);
123
149
  }
124
150
 
125
- public applyStashedOp(message: ISequencedDocumentMessage): unknown {
151
+ public applyStashedOp(content: any): unknown {
126
152
  assert(this.isLoaded, 0x194 /* "Remote channel must be loaded when rebasing op" */);
127
- return this.services.deltaConnection.applyStashedOp(message);
153
+ return this.services.deltaConnection.applyStashedOp(content);
128
154
  }
129
155
 
130
156
  public processOp(
@@ -187,99 +213,6 @@ export class RemoteChannelContext implements IChannelContext {
187
213
  return { ...summarizeResult, id: this.id };
188
214
  }
189
215
 
190
- private async loadChannel(): Promise<IChannel> {
191
- assert(
192
- !this.isLoaded,
193
- 0x197 /* "Remote channel must not already be loaded when loading" */,
194
- );
195
-
196
- let attributes: IChannelAttributes | undefined;
197
- if (await this.services.objectStorage.contains(attributesBlobKey)) {
198
- attributes = await readAndParse<IChannelAttributes | undefined>(
199
- this.services.objectStorage,
200
- attributesBlobKey,
201
- );
202
- }
203
-
204
- // This is a backward compatibility case where the attach message doesn't include attributes. They must
205
- // include attach message type.
206
- // Since old attach messages will not have attributes, we need to keep this as long as we support old attach
207
- // messages.
208
- const channelFactoryType = attributes ? attributes.type : this.attachMessageType;
209
- if (channelFactoryType === undefined) {
210
- throw new DataCorruptionError("channelTypeNotAvailable", {
211
- channelId: {
212
- value: this.id,
213
- tag: TelemetryDataTag.CodeArtifact,
214
- },
215
- dataStoreId: {
216
- value: this.dataStoreContext.id,
217
- tag: TelemetryDataTag.CodeArtifact,
218
- },
219
- dataStorePackagePath: this.dataStoreContext.packagePath.join("/"),
220
- channelFactoryType: this.attachMessageType,
221
- });
222
- }
223
- const factory = this.registry.get(channelFactoryType);
224
- if (factory === undefined) {
225
- // TODO: dataStoreId may require a different tag from PackageData #7488
226
- throw new DataCorruptionError("channelFactoryNotRegisteredForGivenType", {
227
- channelId: {
228
- value: this.id,
229
- tag: TelemetryDataTag.CodeArtifact,
230
- },
231
- dataStoreId: {
232
- value: this.dataStoreContext.id,
233
- tag: TelemetryDataTag.CodeArtifact,
234
- },
235
- dataStorePackagePath: this.dataStoreContext.packagePath.join("/"),
236
- channelFactoryType,
237
- });
238
- }
239
-
240
- // This is a backward compatibility case where the attach message doesn't include attributes. Get the attributes
241
- // from the factory.
242
- attributes = attributes ?? factory.attributes;
243
-
244
- // Compare snapshot version to collaborative object version
245
- if (
246
- attributes.snapshotFormatVersion !== undefined &&
247
- attributes.snapshotFormatVersion !== factory.attributes.snapshotFormatVersion
248
- ) {
249
- this.subLogger.sendTelemetryEvent({
250
- eventName: "ChannelAttributesVersionMismatch",
251
- channelType: { value: attributes.type, tag: TelemetryDataTag.CodeArtifact },
252
- channelSnapshotVersion: {
253
- value: `${attributes.snapshotFormatVersion}@${attributes.packageVersion}`,
254
- tag: TelemetryDataTag.CodeArtifact,
255
- },
256
- channelCodeVersion: {
257
- value: `${factory.attributes.snapshotFormatVersion}@${factory.attributes.packageVersion}`,
258
- tag: TelemetryDataTag.CodeArtifact,
259
- },
260
- });
261
- }
262
-
263
- const channel = await factory.load(this.runtime, this.id, this.services, attributes);
264
-
265
- // Send all pending messages to the channel
266
- assert(this.pending !== undefined, 0x23f /* "pending undefined" */);
267
- for (const message of this.pending) {
268
- this.services.deltaConnection.process(message, false, undefined /* localOpMetadata */);
269
- }
270
- this.thresholdOpsCounter.send("ProcessPendingOps", this.pending.length);
271
-
272
- // Commit changes.
273
- this.channel = channel;
274
- this.pending = undefined;
275
- this.isLoaded = true;
276
-
277
- // Because have some await between we created the service and here, the connection state might have changed
278
- // and we don't propagate the connection state when we are not loaded. So we have to set it again here.
279
- this.services.deltaConnection.setConnectionState(this.dataStoreContext.connected);
280
- return this.channel;
281
- }
282
-
283
216
  /**
284
217
  * Returns the data used for garbage collection. This includes a list of GC nodes that represent this context.
285
218
  * Each node has a set of outbound routes to other GC nodes in the document.
@@ -1,9 +0,0 @@
1
- /*!
2
- * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
- * Licensed under the MIT License.
4
- *
5
- * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
6
- */
7
- export declare const pkgName = "@fluidframework/datastore";
8
- export declare const pkgVersion = "2.0.0-internal.4.2.1";
9
- //# sourceMappingURL=packageVersion.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"packageVersion.d.ts","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,OAAO,8BAA8B,CAAC;AACnD,eAAO,MAAM,UAAU,yBAAyB,CAAC"}
@@ -1,12 +0,0 @@
1
- "use strict";
2
- /*!
3
- * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
4
- * Licensed under the MIT License.
5
- *
6
- * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
7
- */
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.pkgVersion = exports.pkgName = void 0;
10
- exports.pkgName = "@fluidframework/datastore";
11
- exports.pkgVersion = "2.0.0-internal.4.2.1";
12
- //# sourceMappingURL=packageVersion.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEU,QAAA,OAAO,GAAG,2BAA2B,CAAC;AACtC,QAAA,UAAU,GAAG,sBAAsB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/datastore\";\nexport const pkgVersion = \"2.0.0-internal.4.2.1\";\n"]}
@@ -1,9 +0,0 @@
1
- /*!
2
- * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
- * Licensed under the MIT License.
4
- *
5
- * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
6
- */
7
- export declare const pkgName = "@fluidframework/datastore";
8
- export declare const pkgVersion = "2.0.0-internal.4.2.1";
9
- //# sourceMappingURL=packageVersion.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"packageVersion.d.ts","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,OAAO,8BAA8B,CAAC;AACnD,eAAO,MAAM,UAAU,yBAAyB,CAAC"}
@@ -1,9 +0,0 @@
1
- /*!
2
- * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
- * Licensed under the MIT License.
4
- *
5
- * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
6
- */
7
- export const pkgName = "@fluidframework/datastore";
8
- export const pkgVersion = "2.0.0-internal.4.2.1";
9
- //# sourceMappingURL=packageVersion.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,OAAO,GAAG,2BAA2B,CAAC;AACnD,MAAM,CAAC,MAAM,UAAU,GAAG,sBAAsB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/datastore\";\nexport const pkgVersion = \"2.0.0-internal.4.2.1\";\n"]}
@@ -1,9 +0,0 @@
1
- /*!
2
- * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
- * Licensed under the MIT License.
4
- *
5
- * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
6
- */
7
-
8
- export const pkgName = "@fluidframework/datastore";
9
- export const pkgVersion = "2.0.0-internal.4.2.1";