@fluidframework/container-runtime 2.0.0-internal.1.1.2 → 2.0.0-internal.1.2.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 (137) hide show
  1. package/dist/batchManager.d.ts +37 -0
  2. package/dist/batchManager.d.ts.map +1 -0
  3. package/dist/batchManager.js +73 -0
  4. package/dist/batchManager.js.map +1 -0
  5. package/dist/batchTracker.d.ts +1 -2
  6. package/dist/batchTracker.d.ts.map +1 -1
  7. package/dist/batchTracker.js +1 -2
  8. package/dist/batchTracker.js.map +1 -1
  9. package/dist/containerRuntime.d.ts +52 -20
  10. package/dist/containerRuntime.d.ts.map +1 -1
  11. package/dist/containerRuntime.js +252 -126
  12. package/dist/containerRuntime.js.map +1 -1
  13. package/dist/dataStoreContext.d.ts +18 -9
  14. package/dist/dataStoreContext.d.ts.map +1 -1
  15. package/dist/dataStoreContext.js +24 -16
  16. package/dist/dataStoreContext.js.map +1 -1
  17. package/dist/dataStores.d.ts +6 -2
  18. package/dist/dataStores.d.ts.map +1 -1
  19. package/dist/dataStores.js +7 -9
  20. package/dist/dataStores.js.map +1 -1
  21. package/dist/deltaScheduler.d.ts +6 -4
  22. package/dist/deltaScheduler.d.ts.map +1 -1
  23. package/dist/deltaScheduler.js +6 -4
  24. package/dist/deltaScheduler.js.map +1 -1
  25. package/dist/garbageCollection.d.ts +41 -12
  26. package/dist/garbageCollection.d.ts.map +1 -1
  27. package/dist/garbageCollection.js +176 -98
  28. package/dist/garbageCollection.js.map +1 -1
  29. package/dist/gcSweepReadyUsageDetection.d.ts +53 -0
  30. package/dist/gcSweepReadyUsageDetection.d.ts.map +1 -0
  31. package/dist/gcSweepReadyUsageDetection.js +135 -0
  32. package/dist/gcSweepReadyUsageDetection.js.map +1 -0
  33. package/dist/orderedClientElection.d.ts +28 -10
  34. package/dist/orderedClientElection.d.ts.map +1 -1
  35. package/dist/orderedClientElection.js +14 -4
  36. package/dist/orderedClientElection.js.map +1 -1
  37. package/dist/packageVersion.d.ts +1 -1
  38. package/dist/packageVersion.js +1 -1
  39. package/dist/packageVersion.js.map +1 -1
  40. package/dist/pendingStateManager.d.ts +0 -11
  41. package/dist/pendingStateManager.d.ts.map +1 -1
  42. package/dist/pendingStateManager.js +9 -44
  43. package/dist/pendingStateManager.js.map +1 -1
  44. package/dist/runningSummarizer.js +1 -1
  45. package/dist/runningSummarizer.js.map +1 -1
  46. package/dist/scheduleManager.d.ts +6 -3
  47. package/dist/scheduleManager.d.ts.map +1 -1
  48. package/dist/scheduleManager.js +22 -14
  49. package/dist/scheduleManager.js.map +1 -1
  50. package/dist/summarizerTypes.d.ts +16 -9
  51. package/dist/summarizerTypes.d.ts.map +1 -1
  52. package/dist/summarizerTypes.js +1 -1
  53. package/dist/summarizerTypes.js.map +1 -1
  54. package/dist/summaryCollection.d.ts +1 -0
  55. package/dist/summaryCollection.d.ts.map +1 -1
  56. package/dist/summaryCollection.js +29 -13
  57. package/dist/summaryCollection.js.map +1 -1
  58. package/dist/summaryManager.d.ts +2 -2
  59. package/dist/summaryManager.js +2 -2
  60. package/dist/summaryManager.js.map +1 -1
  61. package/lib/batchManager.d.ts +37 -0
  62. package/lib/batchManager.d.ts.map +1 -0
  63. package/lib/batchManager.js +69 -0
  64. package/lib/batchManager.js.map +1 -0
  65. package/lib/batchTracker.d.ts +1 -2
  66. package/lib/batchTracker.d.ts.map +1 -1
  67. package/lib/batchTracker.js +1 -2
  68. package/lib/batchTracker.js.map +1 -1
  69. package/lib/containerRuntime.d.ts +52 -20
  70. package/lib/containerRuntime.d.ts.map +1 -1
  71. package/lib/containerRuntime.js +255 -129
  72. package/lib/containerRuntime.js.map +1 -1
  73. package/lib/dataStoreContext.d.ts +18 -9
  74. package/lib/dataStoreContext.d.ts.map +1 -1
  75. package/lib/dataStoreContext.js +25 -17
  76. package/lib/dataStoreContext.js.map +1 -1
  77. package/lib/dataStores.d.ts +6 -2
  78. package/lib/dataStores.d.ts.map +1 -1
  79. package/lib/dataStores.js +7 -9
  80. package/lib/dataStores.js.map +1 -1
  81. package/lib/deltaScheduler.d.ts +6 -4
  82. package/lib/deltaScheduler.d.ts.map +1 -1
  83. package/lib/deltaScheduler.js +6 -4
  84. package/lib/deltaScheduler.js.map +1 -1
  85. package/lib/garbageCollection.d.ts +41 -12
  86. package/lib/garbageCollection.d.ts.map +1 -1
  87. package/lib/garbageCollection.js +175 -97
  88. package/lib/garbageCollection.js.map +1 -1
  89. package/lib/gcSweepReadyUsageDetection.d.ts +53 -0
  90. package/lib/gcSweepReadyUsageDetection.d.ts.map +1 -0
  91. package/lib/gcSweepReadyUsageDetection.js +130 -0
  92. package/lib/gcSweepReadyUsageDetection.js.map +1 -0
  93. package/lib/orderedClientElection.d.ts +28 -10
  94. package/lib/orderedClientElection.d.ts.map +1 -1
  95. package/lib/orderedClientElection.js +14 -4
  96. package/lib/orderedClientElection.js.map +1 -1
  97. package/lib/packageVersion.d.ts +1 -1
  98. package/lib/packageVersion.js +1 -1
  99. package/lib/packageVersion.js.map +1 -1
  100. package/lib/pendingStateManager.d.ts +0 -11
  101. package/lib/pendingStateManager.d.ts.map +1 -1
  102. package/lib/pendingStateManager.js +9 -44
  103. package/lib/pendingStateManager.js.map +1 -1
  104. package/lib/runningSummarizer.js +1 -1
  105. package/lib/runningSummarizer.js.map +1 -1
  106. package/lib/scheduleManager.d.ts +6 -3
  107. package/lib/scheduleManager.d.ts.map +1 -1
  108. package/lib/scheduleManager.js +24 -16
  109. package/lib/scheduleManager.js.map +1 -1
  110. package/lib/summarizerTypes.d.ts +16 -9
  111. package/lib/summarizerTypes.d.ts.map +1 -1
  112. package/lib/summarizerTypes.js +1 -1
  113. package/lib/summarizerTypes.js.map +1 -1
  114. package/lib/summaryCollection.d.ts +1 -0
  115. package/lib/summaryCollection.d.ts.map +1 -1
  116. package/lib/summaryCollection.js +29 -13
  117. package/lib/summaryCollection.js.map +1 -1
  118. package/lib/summaryManager.d.ts +2 -2
  119. package/lib/summaryManager.js +2 -2
  120. package/lib/summaryManager.js.map +1 -1
  121. package/package.json +21 -18
  122. package/src/batchManager.ts +91 -0
  123. package/src/batchTracker.ts +1 -2
  124. package/src/containerRuntime.ts +331 -176
  125. package/src/dataStoreContext.ts +27 -17
  126. package/src/dataStores.ts +7 -8
  127. package/src/deltaScheduler.ts +6 -4
  128. package/src/garbageCollection.ts +224 -134
  129. package/src/gcSweepReadyUsageDetection.ts +147 -0
  130. package/src/orderedClientElection.ts +31 -10
  131. package/src/packageVersion.ts +1 -1
  132. package/src/pendingStateManager.ts +9 -57
  133. package/src/runningSummarizer.ts +1 -1
  134. package/src/scheduleManager.ts +32 -12
  135. package/src/summarizerTypes.ts +17 -9
  136. package/src/summaryCollection.ts +31 -16
  137. package/src/summaryManager.ts +2 -2
@@ -37,6 +37,7 @@ import {
37
37
  IContainerRuntime,
38
38
  } from "@fluidframework/container-runtime-definitions";
39
39
  import {
40
+ BindState,
40
41
  channelsTreeName,
41
42
  CreateChildSummarizerNodeFn,
42
43
  CreateChildSummarizerNodeParam,
@@ -224,9 +225,8 @@ export abstract class FluidDataStoreContext extends TypedEventEmitter<IFluidData
224
225
  protected registry: IFluidDataStoreRegistry | undefined;
225
226
 
226
227
  protected detachedRuntimeCreation = false;
227
- // back-compat (for tests) - can be removed in 2.0.0-alpha.2.0.0, or earlier if compat tests drop n/n-2 coverage
228
- // @ts-expect-error - This shouldn't be referenced in the current version, but needs to be here for back-compat
229
- private readonly bindToContext: () => void;
228
+ /** @deprecated - To be replaced by calling makeLocallyVisible directly */
229
+ public readonly bindToContext: () => void;
230
230
  protected channel: IFluidDataStoreChannel | undefined;
231
231
  private loaded = false;
232
232
  protected pending: ISequencedDocumentMessage[] | undefined = [];
@@ -253,6 +253,7 @@ export abstract class FluidDataStoreContext extends TypedEventEmitter<IFluidData
253
253
  constructor(
254
254
  props: IFluidDataStoreContextProps,
255
255
  private readonly existing: boolean,
256
+ private bindState: BindState, // Used to assert for state tracking purposes
256
257
  public readonly isLocalDataStore: boolean,
257
258
  private readonly makeLocallyVisibleFn: () => void,
258
259
  ) {
@@ -273,8 +274,11 @@ export abstract class FluidDataStoreContext extends TypedEventEmitter<IFluidData
273
274
  this.containerRuntime.attachState : AttachState.Detached;
274
275
 
275
276
  this.bindToContext = () => {
277
+ assert(this.bindState === BindState.NotBound, 0x13b /* "datastore context is already in bound state" */);
278
+ this.bindState = BindState.Binding;
276
279
  assert(this.channel !== undefined, 0x13c /* "undefined channel on datastore context" */);
277
280
  this.makeLocallyVisible();
281
+ this.bindState = BindState.Bound;
278
282
  };
279
283
 
280
284
  const thisSummarizeInternal =
@@ -515,12 +519,18 @@ export abstract class FluidDataStoreContext extends TypedEventEmitter<IFluidData
515
519
 
516
520
  /**
517
521
  * After GC has run, called to notify the data store of routes used in it. These are used for the following:
522
+ *
518
523
  * 1. To identify if this data store is being referenced in the document or not.
524
+ *
519
525
  * 2. To determine if it needs to re-summarize in case used routes changed since last summary.
526
+ *
520
527
  * 3. These are added to the summary generated by the data store.
521
- * 4. To notify child contexts of their used routes. This is done immediately if the data store is loaded. Else,
522
- * it is done when realizing the data store.
528
+ *
529
+ * 4. To notify child contexts of their used routes. This is done immediately if the data store is loaded.
530
+ * Else, it is done when realizing the data store.
531
+ *
523
532
  * 5. To update the timestamp when this data store or any children are marked as unreferenced.
533
+ *
524
534
  * @param usedRoutes - The routes that are used in this data store.
525
535
  * @param gcTimestamp - The time when GC was run that generated these used routes. If any node becomes unreferenced
526
536
  * as part of this GC run, this should be used to update the time when it happens.
@@ -700,7 +710,7 @@ export abstract class FluidDataStoreContext extends TypedEventEmitter<IFluidData
700
710
  public abstract getInitialSnapshotDetails(): Promise<ISnapshotDetails>;
701
711
 
702
712
  /**
703
- * @deprecated - Sets the datastore as root, for aliasing purposes: #7948
713
+ * @deprecated Sets the datastore as root, for aliasing purposes: #7948
704
714
  * This method should not be used outside of the aliasing context.
705
715
  * It will be removed, as the source of truth for this flag will be the aliasing blob.
706
716
  */
@@ -709,7 +719,7 @@ export abstract class FluidDataStoreContext extends TypedEventEmitter<IFluidData
709
719
  }
710
720
 
711
721
  /**
712
- * @deprecated - Renamed to getBaseGCDetails().
722
+ * @deprecated Renamed to `{@link FluidDataStoreContext.getBaseGCDetails}()`.
713
723
  */
714
724
  public abstract getInitialGCSummaryDetails(): Promise<IGarbageCollectionSummaryDetails>;
715
725
 
@@ -776,6 +786,7 @@ export class RemoteFluidDataStoreContext extends FluidDataStoreContext {
776
786
  super(
777
787
  props,
778
788
  true /* existing */,
789
+ BindState.Bound,
779
790
  false /* isLocalDataStore */,
780
791
  () => {
781
792
  throw new Error("Already attached");
@@ -814,11 +825,9 @@ export class RemoteFluidDataStoreContext extends FluidDataStoreContext {
814
825
  // For snapshotFormatVersion = "0.1" (1) or above, pkg is jsonified, otherwise it is just a string.
815
826
  const formatVersion = getAttributesFormatVersion(attributes);
816
827
  if (formatVersion < 1) {
817
- if (attributes.pkg.startsWith("[\"") && attributes.pkg.endsWith("\"]")) {
818
- pkgFromSnapshot = JSON.parse(attributes.pkg) as string[];
819
- } else {
820
- pkgFromSnapshot = [attributes.pkg];
821
- }
828
+ pkgFromSnapshot = attributes.pkg.startsWith("[\"") && attributes.pkg.endsWith("\"]")
829
+ ? JSON.parse(attributes.pkg) as string[]
830
+ : [attributes.pkg];
822
831
  } else {
823
832
  pkgFromSnapshot = JSON.parse(attributes.pkg) as string[];
824
833
  }
@@ -851,7 +860,7 @@ export class RemoteFluidDataStoreContext extends FluidDataStoreContext {
851
860
  }
852
861
 
853
862
  /**
854
- * @deprecated - Renamed to getBaseGCDetails.
863
+ * @deprecated Renamed to {@link RemoteFluidDataStoreContext.getBaseGCDetails}.
855
864
  */
856
865
  public async getInitialGCSummaryDetails(): Promise<IGarbageCollectionSummaryDetails> {
857
866
  return this.getBaseGCDetails();
@@ -880,6 +889,7 @@ export class LocalFluidDataStoreContextBase extends FluidDataStoreContext {
880
889
  super(
881
890
  props,
882
891
  props.snapshotTree !== undefined ? true : false /* existing */,
892
+ props.snapshotTree ? BindState.Bound : BindState.NotBound,
883
893
  true /* isLocalDataStore */,
884
894
  props.makeLocallyVisibleFn,
885
895
  );
@@ -965,7 +975,7 @@ export class LocalFluidDataStoreContextBase extends FluidDataStoreContext {
965
975
  }
966
976
 
967
977
  /**
968
- * @deprecated - Renamed to getBaseGCDetails.
978
+ * @deprecated Renamed to {@link LocalFluidDataStoreContextBase.getBaseGCDetails}.
969
979
  */
970
980
  public async getInitialGCSummaryDetails(): Promise<IGarbageCollectionSummaryDetails> {
971
981
  // Local data store does not have initial summary.
@@ -1008,7 +1018,10 @@ export class LocalDetachedFluidDataStoreContext
1008
1018
  registry: IProvideFluidDataStoreFactory,
1009
1019
  dataStoreChannel: IFluidDataStoreChannel) {
1010
1020
  assert(this.detachedRuntimeCreation, 0x154 /* "runtime creation is already attached" */);
1021
+ this.detachedRuntimeCreation = false;
1022
+
1011
1023
  assert(this.channelDeferred === undefined, 0x155 /* "channel deferral is already set" */);
1024
+ this.channelDeferred = new Deferred<IFluidDataStoreChannel>();
1012
1025
 
1013
1026
  const factory = registry.IFluidDataStoreFactory;
1014
1027
 
@@ -1018,9 +1031,6 @@ export class LocalDetachedFluidDataStoreContext
1018
1031
  assert(this.registry === undefined, 0x157 /* "datastore registry already attached" */);
1019
1032
  this.registry = entry.registry;
1020
1033
 
1021
- this.detachedRuntimeCreation = false;
1022
- this.channelDeferred = new Deferred<IFluidDataStoreChannel>();
1023
-
1024
1034
  super.bindRuntime(dataStoreChannel);
1025
1035
 
1026
1036
  if (await this.isRoot()) {
package/src/dataStores.ts CHANGED
@@ -469,12 +469,7 @@ export class DataStores implements IDisposable {
469
469
  }
470
470
 
471
471
  public setAttachState(attachState: AttachState.Attaching | AttachState.Attached): void {
472
- let eventName: "attaching" | "attached";
473
- if (attachState === AttachState.Attaching) {
474
- eventName = "attaching";
475
- } else {
476
- eventName = "attached";
477
- }
472
+ const eventName = attachState === AttachState.Attaching ? "attaching" : "attached";
478
473
  for (const [, context] of this.contexts) {
479
474
  // Fire only for bounded stores.
480
475
  if (!this.contexts.isNotBound(context.id)) {
@@ -566,11 +561,15 @@ export class DataStores implements IDisposable {
566
561
 
567
562
  /**
568
563
  * Generates data used for garbage collection. It does the following:
564
+ *
569
565
  * 1. Calls into each child data store context to get its GC data.
566
+ *
570
567
  * 2. Prefixes the child context's id to the GC nodes in the child's GC data. This makes sure that the node can be
571
- * identified as belonging to the child.
568
+ * identified as belonging to the child.
569
+ *
572
570
  * 3. Adds a GC node for this channel to the nodes received from the children. All these nodes together represent
573
- * the GC data of this channel.
571
+ * the GC data of this channel.
572
+ *
574
573
  * @param fullGC - true to bypass optimizations and force full generation of GC data.
575
574
  */
576
575
  public async getGCData(fullGC: boolean = false): Promise<IGarbageCollectionData> {
@@ -18,12 +18,14 @@ import {
18
18
  * DeltaScheduler is responsible for the scheduling of inbound delta queue in cases where there
19
19
  * is more than one op a particular run of the queue. It does not schedule if there is just one
20
20
  * op or just one batch in the run. It does the following two things:
21
+ *
21
22
  * 1. If the ops have been processed for more than a specific amount of time, it pauses the queue
22
- * and calls setTimeout to schedule a resume of the queue. This ensures that we don't block
23
- * the JS thread for a long time processing ops synchronously (for example, when catching up
24
- * ops right after boot or catching up ops / delayed realizing data stores by summarizer).
23
+ * and calls setTimeout to schedule a resume of the queue. This ensures that we don't block
24
+ * the JS thread for a long time processing ops synchronously (for example, when catching up
25
+ * ops right after boot or catching up ops / delayed realizing data stores by summarizer).
26
+ *
25
27
  * 2. If we scheduled a particular run of the queue, it logs telemetry for the number of ops
26
- * processed, the time and number of turns it took to process the ops.
28
+ * processed, the time and number of turns it took to process the ops.
27
29
  */
28
30
  export class DeltaScheduler {
29
31
  private readonly deltaManager: IDeltaManager<ISequencedDocumentMessage, IDocumentMessage>;