@fluidframework/container-runtime 2.0.0-dev.1.4.5.105745 → 2.0.0-dev.2.2.0.111723

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 (168) hide show
  1. package/.eslintrc.js +1 -1
  2. package/dist/batchManager.d.ts +11 -6
  3. package/dist/batchManager.d.ts.map +1 -1
  4. package/dist/batchManager.js +23 -13
  5. package/dist/batchManager.js.map +1 -1
  6. package/dist/containerRuntime.d.ts +74 -20
  7. package/dist/containerRuntime.d.ts.map +1 -1
  8. package/dist/containerRuntime.js +190 -137
  9. package/dist/containerRuntime.js.map +1 -1
  10. package/dist/dataStore.d.ts.map +1 -1
  11. package/dist/dataStore.js +6 -0
  12. package/dist/dataStore.js.map +1 -1
  13. package/dist/dataStoreContext.d.ts +14 -21
  14. package/dist/dataStoreContext.d.ts.map +1 -1
  15. package/dist/dataStoreContext.js +71 -57
  16. package/dist/dataStoreContext.js.map +1 -1
  17. package/dist/dataStoreContexts.js +1 -1
  18. package/dist/dataStoreContexts.js.map +1 -1
  19. package/dist/dataStores.d.ts +11 -10
  20. package/dist/dataStores.d.ts.map +1 -1
  21. package/dist/dataStores.js +50 -20
  22. package/dist/dataStores.js.map +1 -1
  23. package/dist/garbageCollection.d.ts +36 -19
  24. package/dist/garbageCollection.d.ts.map +1 -1
  25. package/dist/garbageCollection.js +207 -121
  26. package/dist/garbageCollection.js.map +1 -1
  27. package/dist/gcSweepReadyUsageDetection.d.ts.map +1 -1
  28. package/dist/gcSweepReadyUsageDetection.js +3 -12
  29. package/dist/gcSweepReadyUsageDetection.js.map +1 -1
  30. package/dist/index.d.ts +4 -6
  31. package/dist/index.d.ts.map +1 -1
  32. package/dist/index.js +3 -5
  33. package/dist/index.js.map +1 -1
  34. package/dist/opCompressor.d.ts +18 -0
  35. package/dist/opCompressor.d.ts.map +1 -0
  36. package/dist/opCompressor.js +50 -0
  37. package/dist/opCompressor.js.map +1 -0
  38. package/dist/opDecompressor.d.ts +20 -0
  39. package/dist/opDecompressor.d.ts.map +1 -0
  40. package/dist/opDecompressor.js +72 -0
  41. package/dist/opDecompressor.js.map +1 -0
  42. package/dist/packageVersion.d.ts +1 -1
  43. package/dist/packageVersion.js +1 -1
  44. package/dist/packageVersion.js.map +1 -1
  45. package/dist/pendingStateManager.d.ts +6 -26
  46. package/dist/pendingStateManager.d.ts.map +1 -1
  47. package/dist/pendingStateManager.js +42 -62
  48. package/dist/pendingStateManager.js.map +1 -1
  49. package/dist/runningSummarizer.d.ts +3 -2
  50. package/dist/runningSummarizer.d.ts.map +1 -1
  51. package/dist/runningSummarizer.js +10 -3
  52. package/dist/runningSummarizer.js.map +1 -1
  53. package/dist/scheduleManager.js.map +1 -1
  54. package/dist/summarizer.js +7 -2
  55. package/dist/summarizer.js.map +1 -1
  56. package/dist/summarizerClientElection.js +1 -1
  57. package/dist/summarizerClientElection.js.map +1 -1
  58. package/dist/summarizerHeuristics.d.ts.map +1 -1
  59. package/dist/summarizerHeuristics.js +0 -3
  60. package/dist/summarizerHeuristics.js.map +1 -1
  61. package/dist/summarizerTypes.d.ts +19 -2
  62. package/dist/summarizerTypes.d.ts.map +1 -1
  63. package/dist/summarizerTypes.js.map +1 -1
  64. package/dist/summaryFormat.d.ts +4 -2
  65. package/dist/summaryFormat.d.ts.map +1 -1
  66. package/dist/summaryFormat.js.map +1 -1
  67. package/dist/summaryGenerator.d.ts.map +1 -1
  68. package/dist/summaryGenerator.js +3 -2
  69. package/dist/summaryGenerator.js.map +1 -1
  70. package/dist/summaryManager.d.ts.map +1 -1
  71. package/dist/summaryManager.js +10 -6
  72. package/dist/summaryManager.js.map +1 -1
  73. package/garbageCollection.md +27 -22
  74. package/lib/batchManager.d.ts +11 -6
  75. package/lib/batchManager.d.ts.map +1 -1
  76. package/lib/batchManager.js +23 -13
  77. package/lib/batchManager.js.map +1 -1
  78. package/lib/containerRuntime.d.ts +74 -20
  79. package/lib/containerRuntime.d.ts.map +1 -1
  80. package/lib/containerRuntime.js +189 -136
  81. package/lib/containerRuntime.js.map +1 -1
  82. package/lib/dataStore.d.ts.map +1 -1
  83. package/lib/dataStore.js +6 -0
  84. package/lib/dataStore.js.map +1 -1
  85. package/lib/dataStoreContext.d.ts +14 -21
  86. package/lib/dataStoreContext.d.ts.map +1 -1
  87. package/lib/dataStoreContext.js +75 -61
  88. package/lib/dataStoreContext.js.map +1 -1
  89. package/lib/dataStoreContexts.js +1 -1
  90. package/lib/dataStoreContexts.js.map +1 -1
  91. package/lib/dataStores.d.ts +11 -10
  92. package/lib/dataStores.d.ts.map +1 -1
  93. package/lib/dataStores.js +53 -23
  94. package/lib/dataStores.js.map +1 -1
  95. package/lib/garbageCollection.d.ts +36 -19
  96. package/lib/garbageCollection.d.ts.map +1 -1
  97. package/lib/garbageCollection.js +208 -122
  98. package/lib/garbageCollection.js.map +1 -1
  99. package/lib/gcSweepReadyUsageDetection.d.ts.map +1 -1
  100. package/lib/gcSweepReadyUsageDetection.js +3 -12
  101. package/lib/gcSweepReadyUsageDetection.js.map +1 -1
  102. package/lib/index.d.ts +4 -6
  103. package/lib/index.d.ts.map +1 -1
  104. package/lib/index.js +2 -4
  105. package/lib/index.js.map +1 -1
  106. package/lib/opCompressor.d.ts +18 -0
  107. package/lib/opCompressor.d.ts.map +1 -0
  108. package/lib/opCompressor.js +46 -0
  109. package/lib/opCompressor.js.map +1 -0
  110. package/lib/opDecompressor.d.ts +20 -0
  111. package/lib/opDecompressor.d.ts.map +1 -0
  112. package/lib/opDecompressor.js +68 -0
  113. package/lib/opDecompressor.js.map +1 -0
  114. package/lib/packageVersion.d.ts +1 -1
  115. package/lib/packageVersion.js +1 -1
  116. package/lib/packageVersion.js.map +1 -1
  117. package/lib/pendingStateManager.d.ts +6 -26
  118. package/lib/pendingStateManager.d.ts.map +1 -1
  119. package/lib/pendingStateManager.js +42 -62
  120. package/lib/pendingStateManager.js.map +1 -1
  121. package/lib/runningSummarizer.d.ts +3 -2
  122. package/lib/runningSummarizer.d.ts.map +1 -1
  123. package/lib/runningSummarizer.js +10 -3
  124. package/lib/runningSummarizer.js.map +1 -1
  125. package/lib/scheduleManager.js.map +1 -1
  126. package/lib/summarizer.js +7 -2
  127. package/lib/summarizer.js.map +1 -1
  128. package/lib/summarizerClientElection.js +1 -1
  129. package/lib/summarizerClientElection.js.map +1 -1
  130. package/lib/summarizerHeuristics.d.ts.map +1 -1
  131. package/lib/summarizerHeuristics.js +0 -3
  132. package/lib/summarizerHeuristics.js.map +1 -1
  133. package/lib/summarizerTypes.d.ts +19 -2
  134. package/lib/summarizerTypes.d.ts.map +1 -1
  135. package/lib/summarizerTypes.js.map +1 -1
  136. package/lib/summaryFormat.d.ts +4 -2
  137. package/lib/summaryFormat.d.ts.map +1 -1
  138. package/lib/summaryFormat.js.map +1 -1
  139. package/lib/summaryGenerator.d.ts.map +1 -1
  140. package/lib/summaryGenerator.js +3 -2
  141. package/lib/summaryGenerator.js.map +1 -1
  142. package/lib/summaryManager.d.ts.map +1 -1
  143. package/lib/summaryManager.js +10 -6
  144. package/lib/summaryManager.js.map +1 -1
  145. package/package.json +37 -63
  146. package/prettier.config.cjs +8 -0
  147. package/src/batchManager.ts +32 -15
  148. package/src/containerRuntime.ts +260 -156
  149. package/src/dataStore.ts +13 -1
  150. package/src/dataStoreContext.ts +100 -76
  151. package/src/dataStoreContexts.ts +1 -1
  152. package/src/dataStores.ts +61 -23
  153. package/src/garbageCollection.ts +257 -126
  154. package/src/gcSweepReadyUsageDetection.ts +2 -10
  155. package/src/index.ts +4 -4
  156. package/src/opCompressor.ts +59 -0
  157. package/src/opDecompressor.ts +82 -0
  158. package/src/packageVersion.ts +1 -1
  159. package/src/pendingStateManager.ts +57 -96
  160. package/src/runningSummarizer.ts +11 -3
  161. package/src/scheduleManager.ts +1 -0
  162. package/src/summarizer.ts +6 -6
  163. package/src/summarizerClientElection.ts +1 -1
  164. package/src/summarizerHeuristics.ts +0 -3
  165. package/src/summarizerTypes.ts +20 -7
  166. package/src/summaryFormat.ts +4 -2
  167. package/src/summaryGenerator.ts +3 -2
  168. package/src/summaryManager.ts +18 -7
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluidframework/container-runtime",
3
- "version": "2.0.0-dev.1.4.5.105745",
3
+ "version": "2.0.0-dev.2.2.0.111723",
4
4
  "description": "Fluid container runtime",
5
5
  "homepage": "https://fluidframework.com",
6
6
  "repository": {
@@ -28,17 +28,19 @@
28
28
  "clean": "rimraf dist lib *.tsbuildinfo *.build.log",
29
29
  "eslint": "eslint --format stylish src",
30
30
  "eslint:fix": "eslint --format stylish src --fix --fix-type problem,suggestion,layout",
31
+ "format": "npm run prettier:fix",
31
32
  "lint": "npm run eslint",
32
33
  "lint:fix": "npm run eslint:fix",
34
+ "prettier": "prettier --check . --ignore-path ../../../.prettierignore",
35
+ "prettier:fix": "prettier --write . --ignore-path ../../../.prettierignore",
33
36
  "test": "npm run test:mocha",
34
37
  "test:coverage": "nyc npm test -- --reporter xunit --reporter-option output=nyc/junit-report.xml",
35
38
  "test:mocha": "mocha --ignore 'dist/test/types/*' --recursive dist/test -r node_modules/@fluidframework/mocha-test-setup --unhandled-rejections=strict",
36
39
  "test:mocha:verbose": "cross-env FLUID_TEST_VERBOSE=1 npm run test:mocha",
37
40
  "tsc": "tsc",
38
41
  "tsc:watch": "tsc --watch",
39
- "tsfmt": "tsfmt --verify",
40
- "tsfmt:fix": "tsfmt --replace",
41
- "typetests:gen": "fluid-type-validator -g -d ."
42
+ "typetests:gen": "flub generate typetests --generate --dir .",
43
+ "typetests:prepare": "flub generate typetests --prepare --dir . --pin"
42
44
  },
43
45
  "nyc": {
44
46
  "all": true,
@@ -63,29 +65,31 @@
63
65
  "dependencies": {
64
66
  "@fluidframework/common-definitions": "^0.20.1",
65
67
  "@fluidframework/common-utils": "^1.0.0",
66
- "@fluidframework/container-definitions": "2.0.0-dev.1.4.5.105745",
67
- "@fluidframework/container-runtime-definitions": "2.0.0-dev.1.4.5.105745",
68
- "@fluidframework/container-utils": "2.0.0-dev.1.4.5.105745",
69
- "@fluidframework/core-interfaces": "2.0.0-dev.1.4.5.105745",
70
- "@fluidframework/datastore": "2.0.0-dev.1.4.5.105745",
71
- "@fluidframework/driver-definitions": "2.0.0-dev.1.4.5.105745",
72
- "@fluidframework/driver-utils": "2.0.0-dev.1.4.5.105745",
73
- "@fluidframework/garbage-collector": "2.0.0-dev.1.4.5.105745",
74
- "@fluidframework/protocol-base": "^0.1037.2001",
75
- "@fluidframework/protocol-definitions": "^1.0.0",
76
- "@fluidframework/runtime-definitions": "2.0.0-dev.1.4.5.105745",
77
- "@fluidframework/runtime-utils": "2.0.0-dev.1.4.5.105745",
78
- "@fluidframework/telemetry-utils": "2.0.0-dev.1.4.5.105745",
68
+ "@fluidframework/container-definitions": ">=2.0.0-dev.2.2.0.111723 <2.0.0-dev.3.0.0",
69
+ "@fluidframework/container-runtime-definitions": ">=2.0.0-dev.2.2.0.111723 <2.0.0-dev.3.0.0",
70
+ "@fluidframework/container-utils": ">=2.0.0-dev.2.2.0.111723 <2.0.0-dev.3.0.0",
71
+ "@fluidframework/core-interfaces": ">=2.0.0-dev.2.2.0.111723 <2.0.0-dev.3.0.0",
72
+ "@fluidframework/datastore": ">=2.0.0-dev.2.2.0.111723 <2.0.0-dev.3.0.0",
73
+ "@fluidframework/driver-definitions": ">=2.0.0-dev.2.2.0.111723 <2.0.0-dev.3.0.0",
74
+ "@fluidframework/driver-utils": ">=2.0.0-dev.2.2.0.111723 <2.0.0-dev.3.0.0",
75
+ "@fluidframework/garbage-collector": ">=2.0.0-dev.2.2.0.111723 <2.0.0-dev.3.0.0",
76
+ "@fluidframework/protocol-base": "^0.1038.2000",
77
+ "@fluidframework/protocol-definitions": "^1.1.0",
78
+ "@fluidframework/runtime-definitions": ">=2.0.0-dev.2.2.0.111723 <2.0.0-dev.3.0.0",
79
+ "@fluidframework/runtime-utils": ">=2.0.0-dev.2.2.0.111723 <2.0.0-dev.3.0.0",
80
+ "@fluidframework/telemetry-utils": ">=2.0.0-dev.2.2.0.111723 <2.0.0-dev.3.0.0",
79
81
  "double-ended-queue": "^2.1.0-0",
82
+ "lz4js": "^0.2.0",
80
83
  "uuid": "^8.3.1"
81
84
  },
82
85
  "devDependencies": {
83
- "@fluidframework/build-common": "^1.0.0",
84
- "@fluidframework/build-tools": "^0.4.4000",
85
- "@fluidframework/container-runtime-previous": "npm:@fluidframework/container-runtime@^1.0.0",
86
- "@fluidframework/eslint-config-fluid": "^1.0.0",
87
- "@fluidframework/mocha-test-setup": "2.0.0-dev.1.4.5.105745",
88
- "@fluidframework/test-runtime-utils": "2.0.0-dev.1.4.5.105745",
86
+ "@fluid-tools/build-cli": "^0.6.0-109663",
87
+ "@fluidframework/build-common": "^1.1.0",
88
+ "@fluidframework/build-tools": "^0.6.0-109663",
89
+ "@fluidframework/container-runtime-previous": "npm:@fluidframework/container-runtime@2.0.0-internal.2.1.0",
90
+ "@fluidframework/eslint-config-fluid": "^1.2.0",
91
+ "@fluidframework/mocha-test-setup": ">=2.0.0-dev.2.2.0.111723 <2.0.0-dev.3.0.0",
92
+ "@fluidframework/test-runtime-utils": ">=2.0.0-dev.2.2.0.111723 <2.0.0-dev.3.0.0",
89
93
  "@microsoft/api-extractor": "^7.22.2",
90
94
  "@rushstack/eslint-config": "^2.5.1",
91
95
  "@types/double-ended-queue": "^2.1.0",
@@ -101,54 +105,24 @@
101
105
  "nyc": "^15.0.0",
102
106
  "rimraf": "^2.6.2",
103
107
  "sinon": "^7.4.2",
104
- "typescript": "~4.5.5",
105
- "typescript-formatter": "7.1.0"
108
+ "typescript": "~4.5.5"
106
109
  },
107
110
  "typeValidation": {
108
- "version": "2.0.0",
111
+ "version": "2.0.0-internal.2.2.0",
112
+ "baselineRange": ">=2.0.0-internal.2.1.0 <2.0.0-internal.2.2.0",
113
+ "baselineVersion": "2.0.0-internal.2.1.0",
109
114
  "broken": {
110
- "VariableDeclaration_DefaultSummaryConfiguration": {
111
- "forwardCompat": false,
112
- "backCompat": false
113
- },
114
- "TypeAliasDeclaration_ISummaryConfiguration": {
115
- "forwardCompat": false,
116
- "backCompat": false
117
- },
118
- "InterfaceDeclaration_ISummaryConfigurationHeuristics": {
119
- "forwardCompat": false,
120
- "backCompat": false
121
- },
122
- "InterfaceDeclaration_IGeneratedSummaryStats": {
123
- "backCompat": false
124
- },
125
- "InterfaceDeclaration_IGenerateSummaryTreeResult": {
126
- "backCompat": false
127
- },
128
- "InterfaceDeclaration_ISubmitSummaryOpResult": {
129
- "backCompat": false
130
- },
131
- "InterfaceDeclaration_IUploadSummaryResult": {
132
- "backCompat": false
115
+ "InterfaceDeclaration_ICompressionRuntimeOptions": {
116
+ "backCompat": false,
117
+ "forwardCompat": false
133
118
  },
134
- "TypeAliasDeclaration_SubmitSummaryResult": {
135
- "backCompat": false
119
+ "InterfaceDeclaration_IContainerRuntimeOptions": {
120
+ "backCompat": false,
121
+ "forwardCompat": false
136
122
  },
137
123
  "ClassDeclaration_ContainerRuntime": {
138
- "backCompat": false
139
- },
140
- "InterfaceDeclaration_IConnectableRuntime": {
141
- "backCompat": false
142
- },
143
- "InterfaceDeclaration_ISummarizerRuntime": {
144
- "backCompat": false
145
- },
146
- "RemovedInterfaceDeclaration_IPendingRuntimeState": {
147
124
  "forwardCompat": false,
148
125
  "backCompat": false
149
- },
150
- "ClassDeclaration_ScheduleManager": {
151
- "forwardCompat": false
152
126
  }
153
127
  }
154
128
  }
@@ -0,0 +1,8 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+
6
+ module.exports = {
7
+ ...require("@fluidframework/build-common/prettier.config.cjs"),
8
+ };
@@ -3,8 +3,10 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
 
6
+ import { ITelemetryLogger } from "@fluidframework/common-definitions";
6
7
  import { IBatchMessage } from "@fluidframework/container-definitions";
7
- import { ContainerRuntimeMessage } from "./containerRuntime";
8
+ import { ContainerRuntimeMessage, ICompressionRuntimeOptions } from "./containerRuntime";
9
+ import { OpCompressor } from "./opCompressor";
8
10
 
9
11
  /**
10
12
  * Message type used by BatchManager
@@ -15,27 +17,28 @@ export type BatchMessage = IBatchMessage & {
15
17
  referenceSequenceNumber: number;
16
18
  };
17
19
 
20
+ export interface IBatchManagerOptions {
21
+ readonly hardLimit: number;
22
+ readonly softLimit?: number;
23
+ readonly compressionOptions?: ICompressionRuntimeOptions;
24
+ }
25
+
18
26
  /**
19
27
  * Helper class that manages partial batch & rollback.
20
28
  */
21
29
  export class BatchManager {
30
+ private readonly opCompressor: OpCompressor;
22
31
  private pendingBatch: BatchMessage [] = [];
23
32
  private batchContentSize = 0;
24
33
 
25
- // The actual limit is 1Mb (socket.io and Kafka limits)
26
- // We can't estimate it fully, as we
27
- // - do not know what properties relay service will add
28
- // - we do not stringify final op, thus we do not know how much escaping will be added.
29
- private static readonly hardLimit = 950 * 1024;
30
-
31
34
  public get length() { return this.pendingBatch.length; }
32
- public get limit() { return BatchManager.hardLimit; }
33
- public static get limit() { return BatchManager.hardLimit; }
34
35
 
35
- constructor(public readonly softLimit?: number) {}
36
+ constructor(public readonly logger: ITelemetryLogger, public readonly options: IBatchManagerOptions) {
37
+ this.opCompressor = new OpCompressor(logger);
38
+ }
36
39
 
37
40
  public push(message: BatchMessage): boolean {
38
- const contentSize = this.batchContentSize + message.contents.length;
41
+ const contentSize = this.batchContentSize + (message.contents?.length ?? 0);
39
42
  const opCount = this.pendingBatch.length;
40
43
 
41
44
  // Attempt to estimate batch size, aka socket message size.
@@ -48,11 +51,17 @@ export class BatchManager {
48
51
  // If we were provided soft limit, check for exceeding it.
49
52
  // But only if we have any ops, as the intention here is to flush existing ops (on exceeding this limit)
50
53
  // and start over. That's not an option if we have no ops.
51
- if (this.softLimit !== undefined && this.length > 0 && socketMessageSize >= this.softLimit) {
54
+ // If compression is enabled, the soft and hard limit are ignored and the message will be pushed anyways.
55
+ // Cases where the message is still too large will be handled by the maxConsecutiveReconnects path.
56
+ if (this.options.softLimit !== undefined
57
+ && this.length > 0
58
+ && socketMessageSize >= this.options.softLimit
59
+ && Infinity === (this.options.compressionOptions?.minimumBatchSizeInBytes ?? Infinity)) {
52
60
  return false;
53
61
  }
54
62
 
55
- if (socketMessageSize >= this.limit) {
63
+ if (socketMessageSize >= this.options.hardLimit
64
+ && Infinity === (this.options.compressionOptions?.minimumBatchSizeInBytes ?? Infinity)) {
56
65
  return false;
57
66
  }
58
67
 
@@ -65,22 +74,30 @@ export class BatchManager {
65
74
 
66
75
  public popBatch() {
67
76
  const batch = this.pendingBatch;
77
+ const size = this.batchContentSize;
68
78
  this.pendingBatch = [];
69
79
  this.batchContentSize = 0;
80
+
81
+ if (batch.length > 0
82
+ && this.options.compressionOptions !== undefined
83
+ && this.options.compressionOptions.minimumBatchSizeInBytes < size) {
84
+ return this.opCompressor.compressBatch(batch, size);
85
+ }
86
+
70
87
  return batch;
71
88
  }
72
89
 
73
90
  /**
74
91
  * Capture the pending state at this point
75
92
  */
76
- public checkpoint() {
93
+ public checkpoint() {
77
94
  const startPoint = this.pendingBatch.length;
78
95
  return {
79
96
  rollback: (process: (message: BatchMessage) => void) => {
80
97
  for (let i = this.pendingBatch.length; i > startPoint;) {
81
98
  i--;
82
99
  const message = this.pendingBatch[i];
83
- this.batchContentSize -= message.contents.length;
100
+ this.batchContentSize -= message.contents?.length ?? 0;
84
101
  process(message);
85
102
  }
86
103