@fluidframework/container-runtime 0.54.2 → 0.56.0-49831

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 (94) hide show
  1. package/.eslintrc.js +1 -1
  2. package/dist/blobManager.js +1 -1
  3. package/dist/blobManager.js.map +1 -1
  4. package/dist/containerRuntime.d.ts +20 -14
  5. package/dist/containerRuntime.d.ts.map +1 -1
  6. package/dist/containerRuntime.js +51 -58
  7. package/dist/containerRuntime.js.map +1 -1
  8. package/dist/dataStoreContext.d.ts +57 -33
  9. package/dist/dataStoreContext.d.ts.map +1 -1
  10. package/dist/dataStoreContext.js +44 -54
  11. package/dist/dataStoreContext.js.map +1 -1
  12. package/dist/dataStores.d.ts +12 -2
  13. package/dist/dataStores.d.ts.map +1 -1
  14. package/dist/dataStores.js +106 -32
  15. package/dist/dataStores.js.map +1 -1
  16. package/dist/garbageCollection.d.ts +49 -14
  17. package/dist/garbageCollection.d.ts.map +1 -1
  18. package/dist/garbageCollection.js +122 -26
  19. package/dist/garbageCollection.js.map +1 -1
  20. package/dist/index.d.ts +7 -7
  21. package/dist/index.d.ts.map +1 -1
  22. package/dist/index.js +12 -17
  23. package/dist/index.js.map +1 -1
  24. package/dist/packageVersion.d.ts +1 -1
  25. package/dist/packageVersion.d.ts.map +1 -1
  26. package/dist/packageVersion.js +1 -1
  27. package/dist/packageVersion.js.map +1 -1
  28. package/dist/runningSummarizer.d.ts.map +1 -1
  29. package/dist/runningSummarizer.js +2 -9
  30. package/dist/runningSummarizer.js.map +1 -1
  31. package/dist/summaryFormat.d.ts +2 -0
  32. package/dist/summaryFormat.d.ts.map +1 -1
  33. package/dist/summaryFormat.js +2 -4
  34. package/dist/summaryFormat.js.map +1 -1
  35. package/dist/summaryGenerator.d.ts +0 -5
  36. package/dist/summaryGenerator.d.ts.map +1 -1
  37. package/dist/summaryGenerator.js.map +1 -1
  38. package/dist/summaryManager.d.ts +1 -0
  39. package/dist/summaryManager.d.ts.map +1 -1
  40. package/dist/summaryManager.js +7 -2
  41. package/dist/summaryManager.js.map +1 -1
  42. package/garbageCollection.md +33 -0
  43. package/lib/blobManager.js +1 -1
  44. package/lib/blobManager.js.map +1 -1
  45. package/lib/containerRuntime.d.ts +20 -14
  46. package/lib/containerRuntime.d.ts.map +1 -1
  47. package/lib/containerRuntime.js +51 -58
  48. package/lib/containerRuntime.js.map +1 -1
  49. package/lib/dataStoreContext.d.ts +57 -33
  50. package/lib/dataStoreContext.d.ts.map +1 -1
  51. package/lib/dataStoreContext.js +42 -52
  52. package/lib/dataStoreContext.js.map +1 -1
  53. package/lib/dataStores.d.ts +12 -2
  54. package/lib/dataStores.d.ts.map +1 -1
  55. package/lib/dataStores.js +107 -33
  56. package/lib/dataStores.js.map +1 -1
  57. package/lib/garbageCollection.d.ts +49 -14
  58. package/lib/garbageCollection.d.ts.map +1 -1
  59. package/lib/garbageCollection.js +122 -26
  60. package/lib/garbageCollection.js.map +1 -1
  61. package/lib/index.d.ts +7 -7
  62. package/lib/index.d.ts.map +1 -1
  63. package/lib/index.js +6 -7
  64. package/lib/index.js.map +1 -1
  65. package/lib/packageVersion.d.ts +1 -1
  66. package/lib/packageVersion.d.ts.map +1 -1
  67. package/lib/packageVersion.js +1 -1
  68. package/lib/packageVersion.js.map +1 -1
  69. package/lib/runningSummarizer.d.ts.map +1 -1
  70. package/lib/runningSummarizer.js +2 -9
  71. package/lib/runningSummarizer.js.map +1 -1
  72. package/lib/summaryFormat.d.ts +2 -0
  73. package/lib/summaryFormat.d.ts.map +1 -1
  74. package/lib/summaryFormat.js +2 -4
  75. package/lib/summaryFormat.js.map +1 -1
  76. package/lib/summaryGenerator.d.ts +0 -5
  77. package/lib/summaryGenerator.d.ts.map +1 -1
  78. package/lib/summaryGenerator.js.map +1 -1
  79. package/lib/summaryManager.d.ts +1 -0
  80. package/lib/summaryManager.d.ts.map +1 -1
  81. package/lib/summaryManager.js +7 -2
  82. package/lib/summaryManager.js.map +1 -1
  83. package/package.json +24 -23
  84. package/src/blobManager.ts +1 -1
  85. package/src/containerRuntime.ts +69 -65
  86. package/src/dataStoreContext.ts +105 -129
  87. package/src/dataStores.ts +118 -68
  88. package/src/garbageCollection.ts +156 -31
  89. package/src/index.ts +52 -6
  90. package/src/packageVersion.ts +1 -1
  91. package/src/runningSummarizer.ts +2 -7
  92. package/src/summaryFormat.ts +4 -4
  93. package/src/summaryGenerator.ts +0 -5
  94. package/src/summaryManager.ts +9 -3
@@ -13,7 +13,6 @@ import {
13
13
  import {
14
14
  IAudience,
15
15
  IDeltaManager,
16
- ContainerWarning,
17
16
  BindState,
18
17
  AttachState,
19
18
  ILoaderOptions,
@@ -51,6 +50,7 @@ import {
51
50
  IFluidDataStoreContextEvents,
52
51
  IFluidDataStoreRegistry,
53
52
  IGarbageCollectionData,
53
+ IGarbageCollectionDetailsBase,
54
54
  IGarbageCollectionSummaryDetails,
55
55
  IInboundSignalMessage,
56
56
  IProvideFluidDataStoreFactory,
@@ -119,6 +119,36 @@ interface FluidDataStoreMessage {
119
119
  type: string;
120
120
  }
121
121
 
122
+ /** Properties necessary for creating a FluidDataStoreContext */
123
+ export interface IFluidDataStoreContextProps {
124
+ readonly id: string;
125
+ readonly runtime: ContainerRuntime;
126
+ readonly storage: IDocumentStorageService;
127
+ readonly scope: FluidObject;
128
+ readonly createSummarizerNodeFn: CreateChildSummarizerNodeFn;
129
+ readonly writeGCDataAtRoot: boolean;
130
+ readonly disableIsolatedChannels: boolean;
131
+ readonly pkg?: Readonly<string[]>;
132
+ }
133
+
134
+ /** Properties necessary for creating a local FluidDataStoreContext */
135
+ export interface ILocalFluidDataStoreContextProps extends IFluidDataStoreContextProps {
136
+ readonly pkg: Readonly<string[]> | undefined;
137
+ readonly snapshotTree: ISnapshotTree | undefined;
138
+ readonly isRootDataStore: boolean | undefined;
139
+ readonly bindChannelFn: (channel: IFluidDataStoreChannel) => void;
140
+ /**
141
+ * @deprecated 0.16 Issue #1635, #3631
142
+ */
143
+ readonly createProps?: any;
144
+ }
145
+
146
+ /** Properties necessary for creating a remote FluidDataStoreContext */
147
+ export interface IRemoteFluidDataStoreContextProps extends IFluidDataStoreContextProps {
148
+ readonly snapshotTree: ISnapshotTree | string | undefined;
149
+ readonly getBaseGCDetails: () => Promise<IGarbageCollectionDetailsBase | undefined>;
150
+ }
151
+
122
152
  /**
123
153
  * Represents the context for the store. This context is passed to the store runtime.
124
154
  */
@@ -185,15 +215,6 @@ export abstract class FluidDataStoreContext extends TypedEventEmitter<IFluidData
185
215
  return (await this.getInitialSnapshotDetails()).isRootDataStore;
186
216
  }
187
217
 
188
- protected get disableIsolatedChannels(): boolean {
189
- return this._containerRuntime.disableIsolatedChannels;
190
- }
191
-
192
- /** Tells whether GC data will be written at the root of the summary tree. If so, data store should not write it. */
193
- protected get writeGCDataAtRoot(): boolean {
194
- return this._containerRuntime.writeGCDataAtRoot;
195
- }
196
-
197
218
  protected registry: IFluidDataStoreRegistry | undefined;
198
219
 
199
220
  protected detachedRuntimeCreation = false;
@@ -213,23 +234,34 @@ export abstract class FluidDataStoreContext extends TypedEventEmitter<IFluidData
213
234
  // if it realizes after GC is run.
214
235
  private lastUsedState: { usedRoutes: string[], gcTimestamp?: number } | undefined;
215
236
 
237
+ public readonly id: string;
238
+ private readonly _containerRuntime: ContainerRuntime;
239
+ public readonly storage: IDocumentStorageService;
240
+ public readonly scope: FluidObject;
241
+ private readonly writeGCDataAtRoot: boolean;
242
+ protected readonly disableIsolatedChannels: boolean;
243
+ protected pkg?: readonly string[];
244
+
216
245
  constructor(
217
- private readonly _containerRuntime: ContainerRuntime,
218
- public readonly id: string,
246
+ props: IFluidDataStoreContextProps,
219
247
  private readonly existing: boolean,
220
- public readonly storage: IDocumentStorageService,
221
- public readonly scope: FluidObject | FluidObject,
222
- createSummarizerNode: CreateChildSummarizerNodeFn,
223
248
  private bindState: BindState,
224
249
  public readonly isLocalDataStore: boolean,
225
- bindChannel: (channel: IFluidDataStoreChannel) => void,
226
- protected pkg?: readonly string[],
250
+ bindChannelFn: (channel: IFluidDataStoreChannel) => void,
227
251
  ) {
228
252
  super();
229
253
 
254
+ this._containerRuntime = props.runtime;
255
+ this.id = props.id;
256
+ this.storage = props.storage;
257
+ this.scope = props.scope;
258
+ this.writeGCDataAtRoot = props.writeGCDataAtRoot;
259
+ this.disableIsolatedChannels = props.disableIsolatedChannels;
260
+ this.pkg = props.pkg;
261
+
230
262
  // URIs use slashes as delimiters. Handles use URIs.
231
263
  // Thus having slashes in types almost guarantees trouble down the road!
232
- assert(id.indexOf("/") === -1, 0x13a /* `Data store ID contains slash: ${id}` */);
264
+ assert(this.id.indexOf("/") === -1, 0x13a /* `Data store ID contains slash: ${id}` */);
233
265
 
234
266
  this._attachState = this.containerRuntime.attachState !== AttachState.Detached && this.existing ?
235
267
  this.containerRuntime.attachState : AttachState.Detached;
@@ -238,17 +270,17 @@ export abstract class FluidDataStoreContext extends TypedEventEmitter<IFluidData
238
270
  assert(this.bindState === BindState.NotBound, 0x13b /* "datastore context is already in bound state" */);
239
271
  this.bindState = BindState.Binding;
240
272
  assert(this.channel !== undefined, 0x13c /* "undefined channel on datastore context" */);
241
- bindChannel(this.channel);
273
+ bindChannelFn(this.channel);
242
274
  this.bindState = BindState.Bound;
243
275
  };
244
276
 
245
277
  const thisSummarizeInternal =
246
278
  async (fullTree: boolean, trackState: boolean) => this.summarizeInternal(fullTree, trackState);
247
279
 
248
- this.summarizerNode = createSummarizerNode(
280
+ this.summarizerNode = props.createSummarizerNodeFn(
249
281
  thisSummarizeInternal,
250
282
  async (fullGC?: boolean) => this.getGCDataInternal(fullGC),
251
- async () => this.getInitialGCSummaryDetails(),
283
+ async () => this.getBaseGCDetails(),
252
284
  );
253
285
 
254
286
  this.subLogger = ChildLogger.create(this.logger, "FluidDataStoreContext");
@@ -580,11 +612,6 @@ export abstract class FluidDataStoreContext extends TypedEventEmitter<IFluidData
580
612
  return this._containerRuntime.submitDataStoreSignal(this.id, type, content);
581
613
  }
582
614
 
583
- // @deprecated Warnings are being deprecated
584
- public raiseContainerWarning(warning: ContainerWarning): void {
585
- this.containerRuntime.raiseContainerWarning(warning);
586
- }
587
-
588
615
  protected bindRuntime(channel: IFluidDataStoreChannel) {
589
616
  if (this.channel) {
590
617
  throw new Error("Runtime already bound");
@@ -652,8 +679,13 @@ export abstract class FluidDataStoreContext extends TypedEventEmitter<IFluidData
652
679
  */
653
680
  public abstract setRoot(): void;
654
681
 
682
+ /**
683
+ * @deprecated - Renamed to getBaseGCDetails().
684
+ */
655
685
  public abstract getInitialGCSummaryDetails(): Promise<IGarbageCollectionSummaryDetails>;
656
686
 
687
+ public abstract getBaseGCDetails(): Promise<IGarbageCollectionDetailsBase>;
688
+
657
689
  public reSubmit(contents: any, localOpMetadata: unknown) {
658
690
  assert(!!this.channel, 0x14b /* "Channel must exist when resubmitting ops" */);
659
691
  const innerContents = contents as FluidDataStoreMessage;
@@ -679,7 +711,7 @@ export abstract class FluidDataStoreContext extends TypedEventEmitter<IFluidData
679
711
  return (
680
712
  summarizeInternal: SummarizeInternalFn,
681
713
  getGCDataFn: (fullGC?: boolean) => Promise<IGarbageCollectionData>,
682
- getInitialGCSummaryDetailsFn: () => Promise<IGarbageCollectionSummaryDetails>,
714
+ getBaseGCDetailsFn: () => Promise<IGarbageCollectionDetailsBase>,
683
715
  ) => this.summarizerNode.createChild(
684
716
  summarizeInternal,
685
717
  id,
@@ -687,7 +719,7 @@ export abstract class FluidDataStoreContext extends TypedEventEmitter<IFluidData
687
719
  // DDS will not create failure summaries
688
720
  { throwOnFailure: true },
689
721
  getGCDataFn,
690
- getInitialGCSummaryDetailsFn,
722
+ getBaseGCDetailsFn,
691
723
  );
692
724
  }
693
725
 
@@ -696,33 +728,26 @@ export abstract class FluidDataStoreContext extends TypedEventEmitter<IFluidData
696
728
  }
697
729
  }
698
730
 
699
- export class RemotedFluidDataStoreContext extends FluidDataStoreContext {
731
+ export class RemoteFluidDataStoreContext extends FluidDataStoreContext {
700
732
  private isRootDataStore: boolean | undefined;
733
+ private readonly initSnapshotValue: ISnapshotTree | string | undefined;
734
+ private readonly baseGCDetailsP: Promise<IGarbageCollectionDetailsBase>;
701
735
 
702
- constructor(
703
- id: string,
704
- private readonly initSnapshotValue: ISnapshotTree | string | undefined,
705
- private readonly getBaseSummaryGCDetails: () => Promise<IGarbageCollectionSummaryDetails | undefined>,
706
- runtime: ContainerRuntime,
707
- storage: IDocumentStorageService,
708
- scope: FluidObject,
709
- createSummarizerNode: CreateChildSummarizerNodeFn,
710
- pkg?: string[],
711
- ) {
736
+ constructor(props: IRemoteFluidDataStoreContextProps) {
712
737
  super(
713
- runtime,
714
- id,
715
- true,
716
- storage,
717
- scope,
718
- createSummarizerNode,
738
+ props,
739
+ true /* existing */,
719
740
  BindState.Bound,
720
- false,
741
+ false /* isLocalDataStore */,
721
742
  () => {
722
743
  throw new Error("Already attached");
723
744
  },
724
- pkg,
725
745
  );
746
+
747
+ this.initSnapshotValue = props.snapshotTree;
748
+ this.baseGCDetailsP = new LazyPromise<IGarbageCollectionDetailsBase>(async () => {
749
+ return (await props.getBaseGCDetails()) ?? {};
750
+ });
726
751
  }
727
752
 
728
753
  private readonly initialSnapshotDetailsP = new LazyPromise<ISnapshotDetails>(async () => {
@@ -787,16 +812,19 @@ export class RemotedFluidDataStoreContext extends FluidDataStoreContext {
787
812
  };
788
813
  });
789
814
 
790
- private readonly gcDetailsInInitialSummaryP = new LazyPromise<IGarbageCollectionSummaryDetails>(async () => {
791
- return (await this.getBaseSummaryGCDetails()) ?? {};
792
- });
793
-
794
815
  protected async getInitialSnapshotDetails(): Promise<ISnapshotDetails> {
795
816
  return this.initialSnapshotDetailsP;
796
817
  }
797
818
 
819
+ /**
820
+ * @deprecated - Renamed to getBaseGCDetails.
821
+ */
798
822
  public async getInitialGCSummaryDetails(): Promise<IGarbageCollectionSummaryDetails> {
799
- return this.gcDetailsInInitialSummaryP;
823
+ return this.getBaseGCDetails();
824
+ }
825
+
826
+ public async getBaseGCDetails(): Promise<IGarbageCollectionDetailsBase> {
827
+ return this.baseGCDetailsP;
800
828
  }
801
829
 
802
830
  public generateAttachMessage(): IAttachMessage {
@@ -817,32 +845,20 @@ export class RemotedFluidDataStoreContext extends FluidDataStoreContext {
817
845
  * Base class for detached & attached context classes
818
846
  */
819
847
  export class LocalFluidDataStoreContextBase extends FluidDataStoreContext {
820
- constructor(
821
- id: string,
822
- pkg: Readonly<string[]> | undefined,
823
- runtime: ContainerRuntime,
824
- storage: IDocumentStorageService,
825
- scope: FluidObject,
826
- createSummarizerNode: CreateChildSummarizerNodeFn,
827
- bindChannel: (channel: IFluidDataStoreChannel) => void,
828
- private readonly snapshotTree: ISnapshotTree | undefined,
829
- protected isRootDataStore: boolean | undefined,
830
- /**
831
- * @deprecated 0.16 Issue #1635, #3631
832
- */
833
- public readonly createProps?: any,
834
- ) {
848
+ private readonly snapshotTree: ISnapshotTree | undefined;
849
+ protected isRootDataStore: boolean | undefined;
850
+
851
+ constructor(props: ILocalFluidDataStoreContextProps) {
835
852
  super(
836
- runtime,
837
- id,
838
- snapshotTree !== undefined ? true : false,
839
- storage,
840
- scope,
841
- createSummarizerNode,
842
- snapshotTree ? BindState.Bound : BindState.NotBound,
843
- true,
844
- bindChannel,
845
- pkg);
853
+ props,
854
+ props.snapshotTree !== undefined ? true : false /* existing */,
855
+ props.snapshotTree ? BindState.Bound : BindState.NotBound,
856
+ true /* isLocalDataStore */,
857
+ props.bindChannelFn,
858
+ );
859
+
860
+ this.snapshotTree = props.snapshotTree;
861
+ this.isRootDataStore = props.isRootDataStore;
846
862
  this.attachListeners();
847
863
  }
848
864
 
@@ -878,11 +894,6 @@ export class LocalFluidDataStoreContextBase extends FluidDataStoreContext {
878
894
  );
879
895
  addBlobToSummary(summarizeResult, dataStoreAttributesBlobName, JSON.stringify(attributes));
880
896
 
881
- // Add GC data to the summary if it's not written at the root.
882
- if (!this.writeGCDataAtRoot) {
883
- addBlobToSummary(summarizeResult, gcBlobKey, JSON.stringify(this.summarizerNode.getGCSummaryDetails()));
884
- }
885
-
886
897
  // Attach message needs the summary in ITree format. Convert the ISummaryTree into an ITree.
887
898
  const snapshot = convertSummaryTreeToITree(summarizeResult.summary);
888
899
 
@@ -926,11 +937,19 @@ export class LocalFluidDataStoreContextBase extends FluidDataStoreContext {
926
937
  };
927
938
  }
928
939
 
940
+ /**
941
+ * @deprecated - Renamed to getBaseGCDetails.
942
+ */
929
943
  public async getInitialGCSummaryDetails(): Promise<IGarbageCollectionSummaryDetails> {
930
944
  // Local data store does not have initial summary.
931
945
  return {};
932
946
  }
933
947
 
948
+ public async getBaseGCDetails(): Promise<IGarbageCollectionDetailsBase> {
949
+ // Local data store does not have initial summary.
950
+ return {};
951
+ }
952
+
934
953
  /**
935
954
  * @deprecated - Sets the datastore as root, for aliasing purposes: #7948
936
955
  * This method should not be used outside of the aliasing context.
@@ -948,32 +967,8 @@ export class LocalFluidDataStoreContextBase extends FluidDataStoreContext {
948
967
  * Runtime is created using data store factory that is associated with this context.
949
968
  */
950
969
  export class LocalFluidDataStoreContext extends LocalFluidDataStoreContextBase {
951
- constructor(
952
- id: string,
953
- pkg: string[] | undefined,
954
- runtime: ContainerRuntime,
955
- storage: IDocumentStorageService,
956
- scope: FluidObject & FluidObject,
957
- createSummarizerNode: CreateChildSummarizerNodeFn,
958
- bindChannel: (channel: IFluidDataStoreChannel) => void,
959
- snapshotTree: ISnapshotTree | undefined,
960
- isRootDataStore: boolean | undefined,
961
- /**
962
- * @deprecated 0.16 Issue #1635, #3631
963
- */
964
- createProps?: any,
965
- ) {
966
- super(
967
- id,
968
- pkg,
969
- runtime,
970
- storage,
971
- scope,
972
- createSummarizerNode,
973
- bindChannel,
974
- snapshotTree,
975
- isRootDataStore,
976
- createProps);
970
+ constructor(props: ILocalFluidDataStoreContextProps) {
971
+ super(props);
977
972
  }
978
973
  }
979
974
 
@@ -987,27 +982,8 @@ export class LocalDetachedFluidDataStoreContext
987
982
  extends LocalFluidDataStoreContextBase
988
983
  implements IFluidDataStoreContextDetached
989
984
  {
990
- constructor(
991
- id: string,
992
- pkg: Readonly<string[]>,
993
- runtime: ContainerRuntime,
994
- storage: IDocumentStorageService,
995
- scope: FluidObject & FluidObject,
996
- createSummarizerNode: CreateChildSummarizerNodeFn,
997
- bindChannel: (channel: IFluidDataStoreChannel) => void,
998
- isRootDataStore: boolean,
999
- ) {
1000
- super(
1001
- id,
1002
- pkg,
1003
- runtime,
1004
- storage,
1005
- scope,
1006
- createSummarizerNode,
1007
- bindChannel,
1008
- undefined,
1009
- isRootDataStore,
1010
- );
985
+ constructor(props: ILocalFluidDataStoreContextProps) {
986
+ super(props);
1011
987
  this.detachedRuntimeCreation = true;
1012
988
  }
1013
989