@fluidframework/container-runtime 2.0.0-dev.1.4.6.106135 → 2.0.0-dev.2.3.0.115467

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 (239) hide show
  1. package/.eslintrc.js +1 -1
  2. package/dist/blobManager.d.ts +20 -5
  3. package/dist/blobManager.d.ts.map +1 -1
  4. package/dist/blobManager.js +57 -15
  5. package/dist/blobManager.js.map +1 -1
  6. package/dist/containerRuntime.d.ts +88 -51
  7. package/dist/containerRuntime.d.ts.map +1 -1
  8. package/dist/containerRuntime.js +205 -300
  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 +51 -20
  22. package/dist/dataStores.js.map +1 -1
  23. package/dist/garbageCollection.d.ts +40 -32
  24. package/dist/garbageCollection.d.ts.map +1 -1
  25. package/dist/garbageCollection.js +227 -161
  26. package/dist/garbageCollection.js.map +1 -1
  27. package/dist/garbageCollectionConstants.d.ts +19 -0
  28. package/dist/garbageCollectionConstants.d.ts.map +1 -0
  29. package/dist/garbageCollectionConstants.js +34 -0
  30. package/dist/garbageCollectionConstants.js.map +1 -0
  31. package/dist/gcSweepReadyUsageDetection.d.ts.map +1 -1
  32. package/dist/gcSweepReadyUsageDetection.js +5 -14
  33. package/dist/gcSweepReadyUsageDetection.js.map +1 -1
  34. package/dist/index.d.ts +6 -6
  35. package/dist/index.d.ts.map +1 -1
  36. package/dist/index.js +8 -9
  37. package/dist/index.js.map +1 -1
  38. package/dist/opLifecycle/batchManager.d.ts +30 -0
  39. package/dist/opLifecycle/batchManager.d.ts.map +1 -0
  40. package/dist/{batchManager.js → opLifecycle/batchManager.js} +25 -15
  41. package/dist/opLifecycle/batchManager.js.map +1 -0
  42. package/dist/opLifecycle/definitions.d.ts +40 -0
  43. package/dist/opLifecycle/definitions.d.ts.map +1 -0
  44. package/dist/opLifecycle/definitions.js +7 -0
  45. package/dist/opLifecycle/definitions.js.map +1 -0
  46. package/dist/opLifecycle/index.d.ts +12 -0
  47. package/dist/opLifecycle/index.d.ts.map +1 -0
  48. package/dist/opLifecycle/index.js +21 -0
  49. package/dist/opLifecycle/index.js.map +1 -0
  50. package/dist/opLifecycle/opCompressor.d.ts +18 -0
  51. package/dist/opLifecycle/opCompressor.d.ts.map +1 -0
  52. package/dist/opLifecycle/opCompressor.js +53 -0
  53. package/dist/opLifecycle/opCompressor.js.map +1 -0
  54. package/dist/opLifecycle/opDecompressor.d.ts +20 -0
  55. package/dist/opLifecycle/opDecompressor.d.ts.map +1 -0
  56. package/dist/opLifecycle/opDecompressor.js +72 -0
  57. package/dist/opLifecycle/opDecompressor.js.map +1 -0
  58. package/dist/opLifecycle/opSplitter.d.ts +17 -0
  59. package/dist/opLifecycle/opSplitter.d.ts.map +1 -0
  60. package/dist/opLifecycle/opSplitter.js +61 -0
  61. package/dist/opLifecycle/opSplitter.js.map +1 -0
  62. package/dist/opLifecycle/outbox.d.ts +47 -0
  63. package/dist/opLifecycle/outbox.d.ts.map +1 -0
  64. package/dist/opLifecycle/outbox.js +153 -0
  65. package/dist/opLifecycle/outbox.js.map +1 -0
  66. package/dist/opLifecycle/remoteMessageProcessor.d.ts +26 -0
  67. package/dist/opLifecycle/remoteMessageProcessor.d.ts.map +1 -0
  68. package/dist/opLifecycle/remoteMessageProcessor.js +81 -0
  69. package/dist/opLifecycle/remoteMessageProcessor.js.map +1 -0
  70. package/dist/packageVersion.d.ts +1 -1
  71. package/dist/packageVersion.js +1 -1
  72. package/dist/packageVersion.js.map +1 -1
  73. package/dist/pendingStateManager.d.ts +6 -26
  74. package/dist/pendingStateManager.d.ts.map +1 -1
  75. package/dist/pendingStateManager.js +42 -62
  76. package/dist/pendingStateManager.js.map +1 -1
  77. package/dist/runningSummarizer.d.ts +3 -2
  78. package/dist/runningSummarizer.d.ts.map +1 -1
  79. package/dist/runningSummarizer.js +10 -3
  80. package/dist/runningSummarizer.js.map +1 -1
  81. package/dist/scheduleManager.js.map +1 -1
  82. package/dist/summarizer.js +7 -2
  83. package/dist/summarizer.js.map +1 -1
  84. package/dist/summarizerClientElection.js +1 -1
  85. package/dist/summarizerClientElection.js.map +1 -1
  86. package/dist/summarizerHeuristics.d.ts.map +1 -1
  87. package/dist/summarizerHeuristics.js +0 -3
  88. package/dist/summarizerHeuristics.js.map +1 -1
  89. package/dist/summarizerTypes.d.ts +19 -2
  90. package/dist/summarizerTypes.d.ts.map +1 -1
  91. package/dist/summarizerTypes.js.map +1 -1
  92. package/dist/summaryFormat.d.ts +4 -2
  93. package/dist/summaryFormat.d.ts.map +1 -1
  94. package/dist/summaryFormat.js +2 -2
  95. package/dist/summaryFormat.js.map +1 -1
  96. package/dist/summaryGenerator.d.ts.map +1 -1
  97. package/dist/summaryGenerator.js +3 -2
  98. package/dist/summaryGenerator.js.map +1 -1
  99. package/dist/summaryManager.d.ts.map +1 -1
  100. package/dist/summaryManager.js +10 -6
  101. package/dist/summaryManager.js.map +1 -1
  102. package/garbageCollection.md +27 -22
  103. package/lib/blobManager.d.ts +20 -5
  104. package/lib/blobManager.d.ts.map +1 -1
  105. package/lib/blobManager.js +59 -17
  106. package/lib/blobManager.js.map +1 -1
  107. package/lib/containerRuntime.d.ts +88 -51
  108. package/lib/containerRuntime.d.ts.map +1 -1
  109. package/lib/containerRuntime.js +203 -297
  110. package/lib/containerRuntime.js.map +1 -1
  111. package/lib/dataStore.d.ts.map +1 -1
  112. package/lib/dataStore.js +6 -0
  113. package/lib/dataStore.js.map +1 -1
  114. package/lib/dataStoreContext.d.ts +14 -21
  115. package/lib/dataStoreContext.d.ts.map +1 -1
  116. package/lib/dataStoreContext.js +75 -61
  117. package/lib/dataStoreContext.js.map +1 -1
  118. package/lib/dataStoreContexts.js +1 -1
  119. package/lib/dataStoreContexts.js.map +1 -1
  120. package/lib/dataStores.d.ts +11 -10
  121. package/lib/dataStores.d.ts.map +1 -1
  122. package/lib/dataStores.js +53 -22
  123. package/lib/dataStores.js.map +1 -1
  124. package/lib/garbageCollection.d.ts +40 -32
  125. package/lib/garbageCollection.d.ts.map +1 -1
  126. package/lib/garbageCollection.js +220 -154
  127. package/lib/garbageCollection.js.map +1 -1
  128. package/lib/garbageCollectionConstants.d.ts +19 -0
  129. package/lib/garbageCollectionConstants.d.ts.map +1 -0
  130. package/lib/garbageCollectionConstants.js +31 -0
  131. package/lib/garbageCollectionConstants.js.map +1 -0
  132. package/lib/gcSweepReadyUsageDetection.d.ts.map +1 -1
  133. package/lib/gcSweepReadyUsageDetection.js +4 -13
  134. package/lib/gcSweepReadyUsageDetection.js.map +1 -1
  135. package/lib/index.d.ts +6 -6
  136. package/lib/index.d.ts.map +1 -1
  137. package/lib/index.js +3 -4
  138. package/lib/index.js.map +1 -1
  139. package/lib/opLifecycle/batchManager.d.ts +30 -0
  140. package/lib/opLifecycle/batchManager.d.ts.map +1 -0
  141. package/lib/{batchManager.js → opLifecycle/batchManager.js} +25 -15
  142. package/lib/opLifecycle/batchManager.js.map +1 -0
  143. package/lib/opLifecycle/definitions.d.ts +40 -0
  144. package/lib/opLifecycle/definitions.d.ts.map +1 -0
  145. package/lib/opLifecycle/definitions.js +6 -0
  146. package/lib/opLifecycle/definitions.js.map +1 -0
  147. package/lib/opLifecycle/index.d.ts +12 -0
  148. package/lib/opLifecycle/index.d.ts.map +1 -0
  149. package/lib/opLifecycle/index.js +11 -0
  150. package/lib/opLifecycle/index.js.map +1 -0
  151. package/lib/opLifecycle/opCompressor.d.ts +18 -0
  152. package/lib/opLifecycle/opCompressor.d.ts.map +1 -0
  153. package/lib/opLifecycle/opCompressor.js +49 -0
  154. package/lib/opLifecycle/opCompressor.js.map +1 -0
  155. package/lib/opLifecycle/opDecompressor.d.ts +20 -0
  156. package/lib/opLifecycle/opDecompressor.d.ts.map +1 -0
  157. package/lib/opLifecycle/opDecompressor.js +68 -0
  158. package/lib/opLifecycle/opDecompressor.js.map +1 -0
  159. package/lib/opLifecycle/opSplitter.d.ts +17 -0
  160. package/lib/opLifecycle/opSplitter.d.ts.map +1 -0
  161. package/lib/opLifecycle/opSplitter.js +57 -0
  162. package/lib/opLifecycle/opSplitter.js.map +1 -0
  163. package/lib/opLifecycle/outbox.d.ts +47 -0
  164. package/lib/opLifecycle/outbox.d.ts.map +1 -0
  165. package/lib/opLifecycle/outbox.js +149 -0
  166. package/lib/opLifecycle/outbox.js.map +1 -0
  167. package/lib/opLifecycle/remoteMessageProcessor.d.ts +26 -0
  168. package/lib/opLifecycle/remoteMessageProcessor.d.ts.map +1 -0
  169. package/lib/opLifecycle/remoteMessageProcessor.js +76 -0
  170. package/lib/opLifecycle/remoteMessageProcessor.js.map +1 -0
  171. package/lib/packageVersion.d.ts +1 -1
  172. package/lib/packageVersion.js +1 -1
  173. package/lib/packageVersion.js.map +1 -1
  174. package/lib/pendingStateManager.d.ts +6 -26
  175. package/lib/pendingStateManager.d.ts.map +1 -1
  176. package/lib/pendingStateManager.js +42 -62
  177. package/lib/pendingStateManager.js.map +1 -1
  178. package/lib/runningSummarizer.d.ts +3 -2
  179. package/lib/runningSummarizer.d.ts.map +1 -1
  180. package/lib/runningSummarizer.js +10 -3
  181. package/lib/runningSummarizer.js.map +1 -1
  182. package/lib/scheduleManager.js.map +1 -1
  183. package/lib/summarizer.js +7 -2
  184. package/lib/summarizer.js.map +1 -1
  185. package/lib/summarizerClientElection.js +1 -1
  186. package/lib/summarizerClientElection.js.map +1 -1
  187. package/lib/summarizerHeuristics.d.ts.map +1 -1
  188. package/lib/summarizerHeuristics.js +0 -3
  189. package/lib/summarizerHeuristics.js.map +1 -1
  190. package/lib/summarizerTypes.d.ts +19 -2
  191. package/lib/summarizerTypes.d.ts.map +1 -1
  192. package/lib/summarizerTypes.js.map +1 -1
  193. package/lib/summaryFormat.d.ts +4 -2
  194. package/lib/summaryFormat.d.ts.map +1 -1
  195. package/lib/summaryFormat.js +1 -1
  196. package/lib/summaryFormat.js.map +1 -1
  197. package/lib/summaryGenerator.d.ts.map +1 -1
  198. package/lib/summaryGenerator.js +3 -2
  199. package/lib/summaryGenerator.js.map +1 -1
  200. package/lib/summaryManager.d.ts.map +1 -1
  201. package/lib/summaryManager.js +10 -6
  202. package/lib/summaryManager.js.map +1 -1
  203. package/package.json +32 -71
  204. package/prettier.config.cjs +8 -0
  205. package/src/blobManager.ts +74 -19
  206. package/src/containerRuntime.ts +286 -369
  207. package/src/dataStore.ts +13 -1
  208. package/src/dataStoreContext.ts +100 -76
  209. package/src/dataStoreContexts.ts +1 -1
  210. package/src/dataStores.ts +61 -22
  211. package/src/garbageCollection.ts +282 -163
  212. package/src/garbageCollectionConstants.ts +35 -0
  213. package/src/gcSweepReadyUsageDetection.ts +3 -11
  214. package/src/index.ts +9 -8
  215. package/src/{batchManager.ts → opLifecycle/batchManager.ts} +42 -28
  216. package/src/opLifecycle/definitions.ts +44 -0
  217. package/src/opLifecycle/index.ts +17 -0
  218. package/src/opLifecycle/opCompressor.ts +64 -0
  219. package/src/opLifecycle/opDecompressor.ts +84 -0
  220. package/src/opLifecycle/opSplitter.ts +78 -0
  221. package/src/opLifecycle/outbox.ts +204 -0
  222. package/src/opLifecycle/remoteMessageProcessor.ts +90 -0
  223. package/src/packageVersion.ts +1 -1
  224. package/src/pendingStateManager.ts +57 -96
  225. package/src/runningSummarizer.ts +11 -3
  226. package/src/scheduleManager.ts +1 -0
  227. package/src/summarizer.ts +6 -6
  228. package/src/summarizerClientElection.ts +1 -1
  229. package/src/summarizerHeuristics.ts +0 -3
  230. package/src/summarizerTypes.ts +20 -7
  231. package/src/summaryFormat.ts +5 -3
  232. package/src/summaryGenerator.ts +3 -2
  233. package/src/summaryManager.ts +18 -7
  234. package/dist/batchManager.d.ts +0 -37
  235. package/dist/batchManager.d.ts.map +0 -1
  236. package/dist/batchManager.js.map +0 -1
  237. package/lib/batchManager.d.ts +0 -37
  238. package/lib/batchManager.d.ts.map +0 -1
  239. package/lib/batchManager.js.map +0 -1
@@ -0,0 +1,57 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ import { DataCorruptionError, extractSafePropertiesFromMessage } from "@fluidframework/container-utils";
6
+ import { ContainerMessageType } from "../containerRuntime";
7
+ /**
8
+ * Responsible for creating and reconstructing chunked messages.
9
+ */
10
+ export class OpSplitter {
11
+ constructor(chunks) {
12
+ this.chunkMap = new Map(chunks);
13
+ }
14
+ get chunks() {
15
+ return this.chunkMap;
16
+ }
17
+ processRemoteMessage(message) {
18
+ if (message.type !== ContainerMessageType.ChunkedOp) {
19
+ return message;
20
+ }
21
+ const clientId = message.clientId;
22
+ const chunkedContent = message.contents;
23
+ this.addChunk(clientId, chunkedContent, message);
24
+ if (chunkedContent.chunkId < chunkedContent.totalChunks) {
25
+ // We are processing the op in chunks but haven't reached
26
+ // the last chunk yet in order to reconstruct the original op
27
+ return message;
28
+ }
29
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
30
+ const serializedContent = this.chunkMap.get(clientId).join("");
31
+ this.clearPartialChunks(clientId);
32
+ const newMessage = Object.assign({}, message);
33
+ newMessage.contents = serializedContent === "" ? undefined : JSON.parse(serializedContent);
34
+ newMessage.type = chunkedContent.originalType;
35
+ return newMessage;
36
+ }
37
+ clearPartialChunks(clientId) {
38
+ if (this.chunkMap.has(clientId)) {
39
+ this.chunkMap.delete(clientId);
40
+ }
41
+ }
42
+ addChunk(clientId, chunkedContent, originalMessage) {
43
+ let map = this.chunkMap.get(clientId);
44
+ if (map === undefined) {
45
+ map = [];
46
+ this.chunkMap.set(clientId, map);
47
+ }
48
+ if (chunkedContent.chunkId !== map.length + 1) {
49
+ // We are expecting the chunks to be processed sequentially, in the same order as they are sent.
50
+ // Therefore, the chunkId of the incoming op needs to match the length of the array (1-based indexing)
51
+ // holding the existing chunks for that particular clientId.
52
+ throw new DataCorruptionError("Chunk Id mismatch", Object.assign(Object.assign({}, extractSafePropertiesFromMessage(originalMessage)), { chunkMapLength: map.length, chunkId: chunkedContent.chunkId, totalChunks: chunkedContent.totalChunks }));
53
+ }
54
+ map.push(chunkedContent.contents);
55
+ }
56
+ }
57
+ //# sourceMappingURL=opSplitter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"opSplitter.js","sourceRoot":"","sources":["../../src/opLifecycle/opSplitter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,mBAAmB,EAAE,gCAAgC,EAAE,MAAM,iCAAiC,CAAC;AAExG,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAG3D;;GAEG;AACH,MAAM,OAAO,UAAU;IAInB,YAAY,MAA4B;QACpC,IAAI,CAAC,QAAQ,GAAG,IAAI,GAAG,CAAmB,MAAM,CAAC,CAAC;IACtD,CAAC;IAED,IAAW,MAAM;QACb,OAAO,IAAI,CAAC,QAAQ,CAAC;IACzB,CAAC;IAEM,oBAAoB,CAAC,OAAkC;QAC1D,IAAI,OAAO,CAAC,IAAI,KAAK,oBAAoB,CAAC,SAAS,EAAE;YACjD,OAAO,OAAO,CAAC;SAClB;QAED,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;QAClC,MAAM,cAAc,GAAG,OAAO,CAAC,QAAsB,CAAC;QACtD,IAAI,CAAC,QAAQ,CAAC,QAAQ,EAAE,cAAc,EAAE,OAAO,CAAC,CAAC;QAEjD,IAAI,cAAc,CAAC,OAAO,GAAG,cAAc,CAAC,WAAW,EAAE;YACrD,yDAAyD;YACzD,6DAA6D;YAC7D,OAAO,OAAO,CAAC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SACN;QAED,GAAG,CAAC,IAAI,CAAC,cAAc,CAAC,QAAQ,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 { DataCorruptionError, extractSafePropertiesFromMessage } from \"@fluidframework/container-utils\";\nimport { ISequencedDocumentMessage } from \"@fluidframework/protocol-definitions\";\nimport { ContainerMessageType } from \"../containerRuntime\";\nimport { IChunkedOp } from \"./definitions\";\n\n/**\n * Responsible for creating and reconstructing chunked messages.\n */\nexport class OpSplitter {\n // Local copy of incomplete received chunks.\n private readonly chunkMap: Map<string, string[]>;\n\n constructor(chunks: [string, string[]][]) {\n this.chunkMap = new Map<string, string[]>(chunks);\n }\n\n public get chunks(): ReadonlyMap<string, string[]> {\n return this.chunkMap;\n }\n\n public processRemoteMessage(message: ISequencedDocumentMessage): ISequencedDocumentMessage {\n if (message.type !== ContainerMessageType.ChunkedOp) {\n return message;\n }\n\n const clientId = message.clientId;\n const chunkedContent = message.contents as IChunkedOp;\n this.addChunk(clientId, chunkedContent, message);\n\n if (chunkedContent.chunkId < chunkedContent.totalChunks) {\n // We are processing the op in chunks but haven't reached\n // the last chunk yet in order to reconstruct the original op\n return message;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const serializedContent = this.chunkMap.get(clientId)!.join(\"\");\n this.clearPartialChunks(clientId);\n\n const newMessage = { ...message };\n newMessage.contents = serializedContent === \"\" ? undefined : JSON.parse(serializedContent);\n newMessage.type = chunkedContent.originalType;\n return newMessage;\n }\n\n public clearPartialChunks(clientId: string) {\n if (this.chunkMap.has(clientId)) {\n this.chunkMap.delete(clientId);\n }\n }\n\n private addChunk(clientId: string, chunkedContent: IChunkedOp, originalMessage: ISequencedDocumentMessage) {\n let map = this.chunkMap.get(clientId);\n if (map === undefined) {\n map = [];\n this.chunkMap.set(clientId, map);\n }\n\n if (chunkedContent.chunkId !== map.length + 1) {\n // We are expecting the chunks to be processed sequentially, in the same order as they are sent.\n // Therefore, the chunkId of the incoming op needs to match the length of the array (1-based indexing)\n // holding the existing chunks for that particular clientId.\n throw new DataCorruptionError(\"Chunk Id mismatch\", {\n ...extractSafePropertiesFromMessage(originalMessage),\n chunkMapLength: map.length,\n chunkId: chunkedContent.chunkId,\n totalChunks: chunkedContent.totalChunks,\n });\n }\n\n map.push(chunkedContent.contents);\n }\n}\n"]}
@@ -0,0 +1,47 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ import { IContainerContext } from "@fluidframework/container-definitions";
6
+ import { ICompressionRuntimeOptions } from "../containerRuntime";
7
+ import { PendingStateManager } from "../pendingStateManager";
8
+ import { BatchMessage } from "./definitions";
9
+ import { OpCompressor } from "./opCompressor";
10
+ export interface IOutboxConfig {
11
+ readonly compressionOptions: ICompressionRuntimeOptions;
12
+ readonly maxBatchSizeInBytes: number;
13
+ }
14
+ export interface IOutboxParameters {
15
+ readonly shouldSend: () => boolean;
16
+ readonly pendingStateManager: PendingStateManager;
17
+ readonly containerContext: IContainerContext;
18
+ readonly config: IOutboxConfig;
19
+ readonly compressor: OpCompressor;
20
+ }
21
+ export declare class Outbox {
22
+ private readonly params;
23
+ private readonly attachFlowBatch;
24
+ private readonly mainBatch;
25
+ private readonly defaultAttachFlowSoftLimitInBytes;
26
+ constructor(params: IOutboxParameters);
27
+ get isEmpty(): boolean;
28
+ submit(message: BatchMessage): void;
29
+ submitAttach(message: BatchMessage): void;
30
+ flush(): void;
31
+ private flushInternal;
32
+ private compressBatch;
33
+ /**
34
+ * Sends the batch object to the container context to be sent over the wire.
35
+ *
36
+ * @param batch - batch to be sent
37
+ * @returns the client sequence number of the last batched op which was sent and
38
+ * -1 if there are no ops or the container cannot send ops.
39
+ */
40
+ private sendBatch;
41
+ private persistBatch;
42
+ checkpoint(): {
43
+ mainBatch: import("./definitions").IBatchCheckpoint;
44
+ attachFlowBatch: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B;;;;;;OAMG;IACH,OAAO,CAAC,SAAS;IAuCjB,OAAO,CAAC,YAAY;IAoBb,UAAU;;;;CAMpB"}
@@ -0,0 +1,149 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ import { assert } from "@fluidframework/common-utils";
6
+ import { GenericError } from "@fluidframework/container-utils";
7
+ import { MessageType } from "@fluidframework/protocol-definitions";
8
+ import { BatchManager } from "./batchManager";
9
+ ;
10
+ export class Outbox {
11
+ constructor(params) {
12
+ this.params = params;
13
+ this.defaultAttachFlowSoftLimitInBytes = 64 * 1024;
14
+ const isCompressionEnabled = this.params.config.compressionOptions.minimumBatchSizeInBytes !== Number.POSITIVE_INFINITY;
15
+ // We need to allow infinite size batches if we enable compression
16
+ const hardLimit = isCompressionEnabled ? Infinity : this.params.config.maxBatchSizeInBytes;
17
+ const softLimit = isCompressionEnabled ? Infinity : this.defaultAttachFlowSoftLimitInBytes;
18
+ this.attachFlowBatch = new BatchManager({
19
+ hardLimit,
20
+ softLimit,
21
+ });
22
+ this.mainBatch = new BatchManager({
23
+ hardLimit
24
+ });
25
+ }
26
+ get isEmpty() {
27
+ return this.attachFlowBatch.length === 0 && this.mainBatch.length === 0;
28
+ }
29
+ submit(message) {
30
+ var _a, _b;
31
+ if (!this.mainBatch.push(message)) {
32
+ throw new GenericError("BatchTooLarge",
33
+ /* error */ undefined, {
34
+ opSize: (_b = ((_a = message.contents) === null || _a === void 0 ? void 0 : _a.length)) !== null && _b !== void 0 ? _b : 0,
35
+ count: this.mainBatch.length,
36
+ limit: this.mainBatch.options.hardLimit,
37
+ });
38
+ }
39
+ }
40
+ submitAttach(message) {
41
+ var _a, _b;
42
+ if (!this.attachFlowBatch.push(message)) {
43
+ // BatchManager has two limits - soft limit & hard limit. Soft limit is only engaged
44
+ // when queue is not empty.
45
+ // Flush queue & retry. Failure on retry would mean - single message is bigger than hard limit
46
+ this.flushInternal(this.attachFlowBatch.popBatch());
47
+ if (!this.attachFlowBatch.push(message)) {
48
+ throw new GenericError("BatchTooLarge",
49
+ /* error */ undefined, {
50
+ opSize: (_b = ((_a = message.contents) === null || _a === void 0 ? void 0 : _a.length)) !== null && _b !== void 0 ? _b : 0,
51
+ count: this.attachFlowBatch.length,
52
+ limit: this.attachFlowBatch.options.hardLimit,
53
+ });
54
+ }
55
+ }
56
+ // If compression is enabled, we will always successfully receive
57
+ // attach ops and compress then send them at the next JS turn, regardless
58
+ // of the overall size of the accumulated ops in the batch.
59
+ // However, it is more efficient to flush these ops faster, preferably
60
+ // after they reach a size which would benefit from compression.
61
+ if (this.attachFlowBatch.contentSizeInBytes >= this.params.config.compressionOptions.minimumBatchSizeInBytes) {
62
+ this.flushInternal(this.attachFlowBatch.popBatch());
63
+ }
64
+ }
65
+ flush() {
66
+ this.flushInternal(this.attachFlowBatch.popBatch());
67
+ this.flushInternal(this.mainBatch.popBatch());
68
+ }
69
+ flushInternal(rawBatch) {
70
+ const processedBatch = this.compressBatch(rawBatch);
71
+ const clientSequenceNumber = this.sendBatch(processedBatch);
72
+ this.persistBatch(clientSequenceNumber, rawBatch.content);
73
+ }
74
+ compressBatch(batch) {
75
+ if (batch.content.length === 0
76
+ || this.params.config.compressionOptions === undefined
77
+ || this.params.config.compressionOptions.minimumBatchSizeInBytes > batch.contentSizeInBytes) {
78
+ // Nothing to do if the batch is empty or if compression is disabled or if we don't need to compress
79
+ return batch;
80
+ }
81
+ const compressedBatch = this.params.compressor.compressBatch(batch);
82
+ if (compressedBatch.contentSizeInBytes > this.params.config.maxBatchSizeInBytes) {
83
+ throw new GenericError("BatchTooLarge",
84
+ /* error */ undefined, {
85
+ opSize: batch.contentSizeInBytes,
86
+ count: batch.content.length,
87
+ limit: this.params.config.maxBatchSizeInBytes,
88
+ compressed: true,
89
+ });
90
+ }
91
+ // If we don't reach the maximum supported size of a batch, it safe to be sent as is
92
+ return compressedBatch;
93
+ }
94
+ /**
95
+ * Sends the batch object to the container context to be sent over the wire.
96
+ *
97
+ * @param batch - batch to be sent
98
+ * @returns the client sequence number of the last batched op which was sent and
99
+ * -1 if there are no ops or the container cannot send ops.
100
+ */
101
+ sendBatch(batch) {
102
+ var _a;
103
+ let clientSequenceNumber = -1;
104
+ const length = batch.content.length;
105
+ // Did we disconnect in the middle of turn-based batch?
106
+ // If so, do nothing, as pending state manager will resubmit it correctly on reconnect.
107
+ if (length === 0 || !this.params.shouldSend()) {
108
+ return clientSequenceNumber;
109
+ }
110
+ if (this.params.containerContext.submitBatchFn === undefined) {
111
+ // Legacy path - supporting old loader versions. Can be removed only when LTS moves above
112
+ // version that has support for batches (submitBatchFn)
113
+ for (const message of batch.content) {
114
+ // Legacy path doesn't support compressed payloads and will submit uncompressed payload anyways
115
+ if ((_a = message.metadata) === null || _a === void 0 ? void 0 : _a.compressed) {
116
+ delete message.metadata.compressed;
117
+ }
118
+ clientSequenceNumber = this.params.containerContext.submitFn(MessageType.Operation, message.deserializedContent, true, // batch
119
+ message.metadata);
120
+ }
121
+ this.params.containerContext.deltaManager.flush();
122
+ }
123
+ else {
124
+ // returns clientSequenceNumber of last message in a batch
125
+ clientSequenceNumber = this.params.containerContext.submitBatchFn(batch.content.map((message) => ({ contents: message.contents, metadata: message.metadata })));
126
+ }
127
+ // Convert from clientSequenceNumber of last message in the batch to clientSequenceNumber of first message.
128
+ clientSequenceNumber -= length - 1;
129
+ assert(clientSequenceNumber >= 0, 0x3d0 /* clientSequenceNumber can't be negative */);
130
+ return clientSequenceNumber;
131
+ }
132
+ persistBatch(initialClientSequenceNumber, batch) {
133
+ let clientSequenceNumber = initialClientSequenceNumber;
134
+ // Let the PendingStateManager know that a message was submitted.
135
+ // In future, need to shift toward keeping batch as a whole!
136
+ for (const message of batch) {
137
+ this.params.pendingStateManager.onSubmitMessage(message.deserializedContent.type, clientSequenceNumber, message.referenceSequenceNumber, message.deserializedContent.contents, message.localOpMetadata, message.metadata);
138
+ clientSequenceNumber++;
139
+ }
140
+ this.params.pendingStateManager.onFlush();
141
+ }
142
+ checkpoint() {
143
+ return {
144
+ mainBatch: this.mainBatch.checkpoint(),
145
+ attachFlowBatch: this.attachFlowBatch.checkpoint(),
146
+ };
147
+ }
148
+ }
149
+ //# sourceMappingURL=outbox.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"outbox.js","sourceRoot":"","sources":["../../src/opLifecycle/outbox.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AAEtD,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,MAAM,sCAAsC,CAAC;AAGnE,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAQ7C,CAAC;AAUF,MAAM,OAAO,MAAM;IAKf,YAA6B,MAAyB;QAAzB,WAAM,GAAN,MAAM,CAAmB;QAFrC,sCAAiC,GAAG,EAAE,GAAG,IAAI,CAAC;QAG3D,MAAM,oBAAoB,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,kBAAkB,CAAC,uBAAuB,KAAK,MAAM,CAAC,iBAAiB,CAAC;QACxH,kEAAkE;QAClE,MAAM,SAAS,GAAG,oBAAoB,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,mBAAmB,CAAC;QAC3F,MAAM,SAAS,GAAG,oBAAoB,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,iCAAiC,CAAC;QAE3F,IAAI,CAAC,eAAe,GAAG,IAAI,YAAY,CAAC;YACpC,SAAS;YACT,SAAS;SACZ,CAAC,CAAC;QACH,IAAI,CAAC,SAAS,GAAG,IAAI,YAAY,CAAC;YAC9B,SAAS;SACZ,CAAC,CAAC;IACP,CAAC;IAED,IAAW,OAAO;QACd,OAAO,IAAI,CAAC,eAAe,CAAC,MAAM,KAAK,CAAC,IAAI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2G;QAC3G,oBAAoB,IAAI,MAAM,GAAG,CAAC,CAAC;QACnC,MAAM,CAAC,oBAAoB,IAAI,CAAC,EAAE,KAAK,CAAC,4CAA4C,CAAC,CAAC;QACtF,OAAO,oBAAoB,CAAC;IAChC,CAAC;IAEO,YAAY,CAAC,2BAAmC,EAAE,KAAqB;QAC3E,IAAI,oBAAoB,GAAG,2BAA2B,CAAC;QACvD,iEAAiE;QACjE,4DAA4D;QAC5D,KAAK,MAAM,OAAO,IAAI,KAAK,EAAE;YACzB,IAAI,CAAC,MAAM,CAAC,mBAAmB,CAAC,eAAe,CAC3C,OAAO,CAAC,mBAAmB,CAAC,IAAI,EAChC,oBAAoB,EACpB,OAAO,CAAC,uBAAuB,EAC/B,OAAO,CAAC,mBAAmB,CAAC,QAAQ,EACpC,OAAO,CAAC,eAAe,EACvB,OAAO,CAAC,QAAQ,CACnB,CAAC;YAEF,oBAAoB,EAAE,CAAC;SAC1B;QAED,IAAI,CAAC,MAAM,CAAC,mBAAmB,CAAC,OAAO,EAAE,CAAC;IAC9C,CAAC;IAEM,UAAU;QACb,OAAO;YACH,SAAS,EAAE,IAAI,CAAC,SAAS,CAAC,UAAU,EAAE;YACtC,eAAe,EAAE,IAAI,CAAC,eAAe,CAAC,UAAU,EAAE;SACrD,CAAC;IACN,CAAC;CACJ","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/common-utils\";\nimport { IContainerContext } from \"@fluidframework/container-definitions\";\nimport { GenericError } from \"@fluidframework/container-utils\";\nimport { MessageType } from \"@fluidframework/protocol-definitions\";\nimport { ICompressionRuntimeOptions } from \"../containerRuntime\";\nimport { PendingStateManager } from \"../pendingStateManager\";\nimport { BatchManager } from \"./batchManager\";\nimport { BatchMessage, IBatch } from \"./definitions\";\nimport { OpCompressor } from \"./opCompressor\";\n\nexport interface IOutboxConfig {\n readonly compressionOptions: ICompressionRuntimeOptions;\n // The maximum size of a batch that we can send over the wire.\n readonly maxBatchSizeInBytes: number;\n};\n\nexport interface IOutboxParameters {\n readonly shouldSend: () => boolean,\n readonly pendingStateManager: PendingStateManager,\n readonly containerContext: IContainerContext,\n readonly config: IOutboxConfig,\n readonly compressor: OpCompressor;\n}\n\nexport class Outbox {\n private readonly attachFlowBatch: BatchManager;\n private readonly mainBatch: BatchManager;\n private readonly defaultAttachFlowSoftLimitInBytes = 64 * 1024;\n\n constructor(private readonly params: IOutboxParameters) {\n const isCompressionEnabled = this.params.config.compressionOptions.minimumBatchSizeInBytes !== Number.POSITIVE_INFINITY;\n // We need to allow infinite size batches if we enable compression\n const hardLimit = isCompressionEnabled ? Infinity : this.params.config.maxBatchSizeInBytes;\n const softLimit = isCompressionEnabled ? Infinity : this.defaultAttachFlowSoftLimitInBytes;\n\n this.attachFlowBatch = new BatchManager({\n hardLimit,\n softLimit,\n });\n this.mainBatch = new BatchManager({\n hardLimit\n });\n }\n\n public get isEmpty(): boolean {\n return this.attachFlowBatch.length === 0 && this.mainBatch.length === 0;\n }\n\n public submit(message: BatchMessage) {\n if (!this.mainBatch.push(message)) {\n throw new GenericError(\n \"BatchTooLarge\",\n /* error */ undefined,\n {\n opSize: (message.contents?.length) ?? 0,\n count: this.mainBatch.length,\n limit: this.mainBatch.options.hardLimit,\n });\n }\n }\n\n public submitAttach(message: BatchMessage) {\n if (!this.attachFlowBatch.push(message)) {\n // BatchManager has two limits - soft limit & hard limit. Soft limit is only engaged\n // when queue is not empty.\n // Flush queue & retry. Failure on retry would mean - single message is bigger than hard limit\n this.flushInternal(this.attachFlowBatch.popBatch());\n if (!this.attachFlowBatch.push(message)) {\n throw new GenericError(\n \"BatchTooLarge\",\n /* error */ undefined,\n {\n opSize: (message.contents?.length) ?? 0,\n count: this.attachFlowBatch.length,\n limit: this.attachFlowBatch.options.hardLimit,\n });\n }\n }\n\n // If compression is enabled, we will always successfully receive\n // attach ops and compress then send them at the next JS turn, regardless\n // of the overall size of the accumulated ops in the batch.\n // However, it is more efficient to flush these ops faster, preferably\n // after they reach a size which would benefit from compression.\n if (this.attachFlowBatch.contentSizeInBytes >= this.params.config.compressionOptions.minimumBatchSizeInBytes) {\n this.flushInternal(this.attachFlowBatch.popBatch());\n }\n }\n\n public flush() {\n this.flushInternal(this.attachFlowBatch.popBatch());\n this.flushInternal(this.mainBatch.popBatch());\n }\n\n private flushInternal(rawBatch: IBatch) {\n const processedBatch = this.compressBatch(rawBatch);\n const clientSequenceNumber = this.sendBatch(processedBatch);\n\n this.persistBatch(clientSequenceNumber, rawBatch.content);\n }\n\n private compressBatch(batch: IBatch): IBatch {\n if (batch.content.length === 0\n || this.params.config.compressionOptions === undefined\n || this.params.config.compressionOptions.minimumBatchSizeInBytes > batch.contentSizeInBytes) {\n // Nothing to do if the batch is empty or if compression is disabled or if we don't need to compress\n return batch;\n }\n\n const compressedBatch = this.params.compressor.compressBatch(batch);\n if (compressedBatch.contentSizeInBytes > this.params.config.maxBatchSizeInBytes) {\n throw new GenericError(\n \"BatchTooLarge\",\n /* error */ undefined,\n {\n opSize: batch.contentSizeInBytes,\n count: batch.content.length,\n limit: this.params.config.maxBatchSizeInBytes,\n compressed: true,\n });\n }\n\n // If we don't reach the maximum supported size of a batch, it safe to be sent as is\n return compressedBatch;\n }\n\n /**\n * Sends the batch object to the container context to be sent over the wire.\n *\n * @param batch - batch to be sent\n * @returns the client sequence number of the last batched op which was sent and\n * -1 if there are no ops or the container cannot send ops.\n */\n private sendBatch(batch: IBatch): number {\n let clientSequenceNumber: number = -1;\n const length = batch.content.length;\n\n // Did we disconnect in the middle of turn-based batch?\n // If so, do nothing, as pending state manager will resubmit it correctly on reconnect.\n if (length === 0 || !this.params.shouldSend()) {\n return clientSequenceNumber;\n }\n\n if (this.params.containerContext.submitBatchFn === undefined) {\n // Legacy path - supporting old loader versions. Can be removed only when LTS moves above\n // version that has support for batches (submitBatchFn)\n for (const message of batch.content) {\n // Legacy path doesn't support compressed payloads and will submit uncompressed payload anyways\n if (message.metadata?.compressed) {\n delete message.metadata.compressed;\n }\n\n clientSequenceNumber = this.params.containerContext.submitFn(\n MessageType.Operation,\n message.deserializedContent,\n true, // batch\n message.metadata);\n }\n\n this.params.containerContext.deltaManager.flush();\n } else {\n // returns clientSequenceNumber of last message in a batch\n clientSequenceNumber = this.params.containerContext.submitBatchFn(\n batch.content.map((message) => ({ contents: message.contents, metadata: message.metadata })));\n }\n\n // Convert from clientSequenceNumber of last message in the batch to clientSequenceNumber of first message.\n clientSequenceNumber -= length - 1;\n assert(clientSequenceNumber >= 0, 0x3d0 /* clientSequenceNumber can't be negative */);\n return clientSequenceNumber;\n }\n\n private persistBatch(initialClientSequenceNumber: number, batch: BatchMessage[]) {\n let clientSequenceNumber = initialClientSequenceNumber;\n // Let the PendingStateManager know that a message was submitted.\n // In future, need to shift toward keeping batch as a whole!\n for (const message of batch) {\n this.params.pendingStateManager.onSubmitMessage(\n message.deserializedContent.type,\n clientSequenceNumber,\n message.referenceSequenceNumber,\n message.deserializedContent.contents,\n message.localOpMetadata,\n message.metadata,\n );\n\n clientSequenceNumber++;\n }\n\n this.params.pendingStateManager.onFlush();\n }\n\n public checkpoint() {\n return {\n mainBatch: this.mainBatch.checkpoint(),\n attachFlowBatch: this.attachFlowBatch.checkpoint(),\n };\n }\n}\n"]}
@@ -0,0 +1,26 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ import { ISequencedDocumentMessage } from "@fluidframework/protocol-definitions";
6
+ import { OpDecompressor } from "./opDecompressor";
7
+ import { OpSplitter } from "./opSplitter";
8
+ export declare class RemoteMessageProcessor {
9
+ private readonly opSplitter;
10
+ private readonly opDecompressor;
11
+ constructor(opSplitter: OpSplitter, opDecompressor: OpDecompressor);
12
+ get partialMessages(): ReadonlyMap<string, string[]>;
13
+ clearPartialMessagesFor(clientId: string): void;
14
+ process(remoteMessage: ISequencedDocumentMessage): ISequencedDocumentMessage;
15
+ }
16
+ /**
17
+ * Unpacks runtime messages.
18
+ *
19
+ * @remarks This API makes no promises regarding backward-compatibility. This is internal API.
20
+ * @param message - message (as it observed in storage / service)
21
+ * @returns unpacked runtime message
22
+ *
23
+ * @internal
24
+ */
25
+ export declare function unpackRuntimeMessage(message: ISequencedDocumentMessage): boolean;
26
+ //# sourceMappingURL=remoteMessageProcessor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"remoteMessageProcessor.d.ts","sourceRoot":"","sources":["../../src/opLifecycle/remoteMessageProcessor.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,yBAAyB,EAAe,MAAM,sCAAsC,CAAC;AAE9F,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,qBAAa,sBAAsB;IAE3B,OAAO,CAAC,QAAQ,CAAC,UAAU;IAC3B,OAAO,CAAC,QAAQ,CAAC,cAAc;gBADd,UAAU,EAAE,UAAU,EACtB,cAAc,EAAE,cAAc;IAGnD,IAAW,eAAe,IAAI,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAE1D;IAEM,uBAAuB,CAAC,QAAQ,EAAE,MAAM;IAIxC,OAAO,CAAC,aAAa,EAAE,yBAAyB,GAAG,yBAAyB;CAStF;AA6BD;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,yBAAyB,GAAG,OAAO,CAkBhF"}
@@ -0,0 +1,76 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ import { MessageType } from "@fluidframework/protocol-definitions";
6
+ import { ContainerMessageType } from "../containerRuntime";
7
+ export class RemoteMessageProcessor {
8
+ constructor(opSplitter, opDecompressor) {
9
+ this.opSplitter = opSplitter;
10
+ this.opDecompressor = opDecompressor;
11
+ }
12
+ get partialMessages() {
13
+ return this.opSplitter.chunks;
14
+ }
15
+ clearPartialMessagesFor(clientId) {
16
+ this.opSplitter.clearPartialChunks(clientId);
17
+ }
18
+ process(remoteMessage) {
19
+ let message = copy(remoteMessage);
20
+ message = this.opDecompressor.processMessage(message);
21
+ unpackRuntimeMessage(message);
22
+ message = this.opSplitter.processRemoteMessage(message);
23
+ return message;
24
+ }
25
+ }
26
+ const copy = (remoteMessage) => {
27
+ // Do shallow copy of message, as the processing flow will modify it.
28
+ // There might be multiple container instances receiving same message
29
+ // We do not need to make deep copy, as each layer will just replace message.content itself,
30
+ // but would not modify contents details
31
+ const message = Object.assign({}, remoteMessage);
32
+ // back-compat: ADO #1385: eventually should become unconditional, but only for runtime messages!
33
+ // System message may have no contents, or in some cases (mostly for back-compat) they may have actual objects.
34
+ // Old ops may contain empty string (I assume noops).
35
+ if (typeof message.contents === "string" && message.contents !== "") {
36
+ message.contents = JSON.parse(message.contents);
37
+ }
38
+ return message;
39
+ };
40
+ /**
41
+ * For a given message, it moves the nested contents and type on level up.
42
+ *
43
+ */
44
+ const unpack = (message) => {
45
+ const innerContents = message.contents;
46
+ message.type = innerContents.type;
47
+ message.contents = innerContents.contents;
48
+ };
49
+ /**
50
+ * Unpacks runtime messages.
51
+ *
52
+ * @remarks This API makes no promises regarding backward-compatibility. This is internal API.
53
+ * @param message - message (as it observed in storage / service)
54
+ * @returns unpacked runtime message
55
+ *
56
+ * @internal
57
+ */
58
+ export function unpackRuntimeMessage(message) {
59
+ if (message.type !== MessageType.Operation) {
60
+ // Legacy format, but it's already "unpacked",
61
+ // i.e. message.type is actually ContainerMessageType.
62
+ // Or it's non-runtime message.
63
+ // Nothing to do in such case.
64
+ return false;
65
+ }
66
+ // legacy op format?
67
+ if (message.contents.address !== undefined && message.contents.type === undefined) {
68
+ message.type = ContainerMessageType.FluidDataStoreOp;
69
+ }
70
+ else {
71
+ // new format
72
+ unpack(message);
73
+ }
74
+ return true;
75
+ }
76
+ //# sourceMappingURL=remoteMessageProcessor.js.map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,CAAC;KACnD;IAED,OAAO,OAAO,CAAC;AACnB,CAAC,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,GAAG,CAAC,OAAkC,EAAE,EAAE;IAClD,MAAM,aAAa,GAAG,OAAO,CAAC,QAAmC,CAAC;IAClE,OAAO,CAAC,IAAI,GAAG,aAAa,CAAC,IAAI,CAAC;IAClC,OAAO,CAAC,QAAQ,GAAG,aAAa,CAAC,QAAQ,CAAC;AAC9C,CAAC,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,UAAU,oBAAoB,CAAC,OAAkC;IACnE,IAAI,OAAO,CAAC,IAAI,KAAK,WAAW,CAAC,SAAS,EAAE;QACxC,8CAA8C;QAC9C,sDAAsD;QACtD,+BAA+B;QAC/B,8BAA8B;QAC9B,OAAO,KAAK,CAAC;KAChB;IAED,oBAAoB;IACpB,IAAI,OAAO,CAAC,QAAQ,CAAC,OAAO,KAAK,SAAS,IAAI,OAAO,CAAC,QAAQ,CAAC,IAAI,KAAK,SAAS,EAAE;QAC/E,OAAO,CAAC,IAAI,GAAG,oBAAoB,CAAC,gBAAgB,CAAC;KACxD;SAAM;QACH,aAAa;QACb,MAAM,CAAC,OAAO,CAAC,CAAC;KACnB;IAED,OAAO,IAAI,CAAC;AAChB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ISequencedDocumentMessage, MessageType } from \"@fluidframework/protocol-definitions\";\nimport { ContainerMessageType, ContainerRuntimeMessage } from \"../containerRuntime\";\nimport { OpDecompressor } from \"./opDecompressor\";\nimport { OpSplitter } from \"./opSplitter\";\n\nexport class RemoteMessageProcessor {\n constructor(\n private readonly opSplitter: OpSplitter,\n private readonly opDecompressor: OpDecompressor,\n ) { }\n\n public get partialMessages(): ReadonlyMap<string, string[]> {\n return this.opSplitter.chunks;\n }\n\n public clearPartialMessagesFor(clientId: string) {\n this.opSplitter.clearPartialChunks(clientId);\n }\n\n public process(remoteMessage: ISequencedDocumentMessage): ISequencedDocumentMessage {\n let message = copy(remoteMessage);\n\n message = this.opDecompressor.processMessage(message);\n unpackRuntimeMessage(message);\n message = this.opSplitter.processRemoteMessage(message);\n\n return message;\n }\n}\n\nconst copy = (remoteMessage: ISequencedDocumentMessage): ISequencedDocumentMessage => {\n // Do shallow copy of message, as the processing flow will modify it.\n // There might be multiple container instances receiving same message\n // We do not need to make deep copy, as each layer will just replace message.content itself,\n // but would not modify contents details\n const message = { ...remoteMessage };\n\n // back-compat: ADO #1385: eventually should become unconditional, but only for runtime messages!\n // System message may have no contents, or in some cases (mostly for back-compat) they may have actual objects.\n // Old ops may contain empty string (I assume noops).\n if (typeof message.contents === \"string\" && message.contents !== \"\") {\n message.contents = JSON.parse(message.contents);\n }\n\n return message;\n};\n\n/**\n * For a given message, it moves the nested contents and type on level up.\n *\n */\nconst unpack = (message: ISequencedDocumentMessage) => {\n const innerContents = message.contents as ContainerRuntimeMessage;\n message.type = innerContents.type;\n message.contents = innerContents.contents;\n};\n\n/**\n * Unpacks runtime messages.\n *\n * @remarks This API makes no promises regarding backward-compatibility. This is internal API.\n * @param message - message (as it observed in storage / service)\n * @returns unpacked runtime message\n *\n * @internal\n */\nexport function unpackRuntimeMessage(message: ISequencedDocumentMessage): boolean {\n if (message.type !== MessageType.Operation) {\n // Legacy format, but it's already \"unpacked\",\n // i.e. message.type is actually ContainerMessageType.\n // Or it's non-runtime message.\n // Nothing to do in such case.\n return false;\n }\n\n // legacy op format?\n if (message.contents.address !== undefined && message.contents.type === undefined) {\n message.type = ContainerMessageType.FluidDataStoreOp;\n } else {\n // new format\n unpack(message);\n }\n\n return true;\n}\n"]}
@@ -5,5 +5,5 @@
5
5
  * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
6
6
  */
7
7
  export declare const pkgName = "@fluidframework/container-runtime";
8
- export declare const pkgVersion = "2.0.0-dev.1.4.6.106135";
8
+ export declare const pkgVersion = "2.0.0-dev.2.3.0.115467";
9
9
  //# sourceMappingURL=packageVersion.d.ts.map
@@ -5,5 +5,5 @@
5
5
  * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
6
6
  */
7
7
  export const pkgName = "@fluidframework/container-runtime";
8
- export const pkgVersion = "2.0.0-dev.1.4.6.106135";
8
+ export const pkgVersion = "2.0.0-dev.2.3.0.115467";
9
9
  //# sourceMappingURL=packageVersion.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,OAAO,GAAG,mCAAmC,CAAC;AAC3D,MAAM,CAAC,MAAM,UAAU,GAAG,wBAAwB,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/container-runtime\";\nexport const pkgVersion = \"2.0.0-dev.1.4.6.106135\";\n"]}
1
+ {"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,OAAO,GAAG,mCAAmC,CAAC;AAC3D,MAAM,CAAC,MAAM,UAAU,GAAG,wBAAwB,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/container-runtime\";\nexport const pkgVersion = \"2.0.0-dev.2.3.0.115467\";\n"]}
@@ -5,7 +5,6 @@
5
5
  import { IDisposable } from "@fluidframework/common-definitions";
6
6
  import { ICriticalContainerError } from "@fluidframework/container-definitions";
7
7
  import { ISequencedDocumentMessage } from "@fluidframework/protocol-definitions";
8
- import { FlushMode } from "@fluidframework/runtime-definitions";
9
8
  import { ContainerMessageType } from "./containerRuntime";
10
9
  /**
11
10
  * This represents a message that has been submitted and is added to the pending queue when `submit` is called on the
@@ -20,14 +19,6 @@ export interface IPendingMessage {
20
19
  localOpMetadata: unknown;
21
20
  opMetadata: Record<string, unknown> | undefined;
22
21
  }
23
- /**
24
- * This represents a FlushMode update and is added to the pending queue when `setFlushMode` is called on the
25
- * ContainerRuntime and the FlushMode changes.
26
- */
27
- export interface IPendingFlushMode {
28
- type: "flushMode";
29
- flushMode: FlushMode;
30
- }
31
22
  /**
32
23
  * This represents an explicit flush call and is added to the pending queue when flush is called on the ContainerRuntime
33
24
  * to flush pending messages.
@@ -35,7 +26,7 @@ export interface IPendingFlushMode {
35
26
  export interface IPendingFlush {
36
27
  type: "flush";
37
28
  }
38
- export declare type IPendingState = IPendingMessage | IPendingFlushMode | IPendingFlush;
29
+ export declare type IPendingState = IPendingMessage | IPendingFlush;
39
30
  export interface IPendingLocalState {
40
31
  /**
41
32
  * list of pending states, including ops and batch information
@@ -45,18 +36,18 @@ export interface IPendingLocalState {
45
36
  export interface IRuntimeStateHandler {
46
37
  connected(): boolean;
47
38
  clientId(): string | undefined;
48
- flushMode(): FlushMode;
49
- setFlushMode(mode: FlushMode): void;
50
39
  close(error?: ICriticalContainerError): void;
51
40
  applyStashedOp: (type: ContainerMessageType, content: ISequencedDocumentMessage) => Promise<unknown>;
52
41
  flush(): void;
53
42
  reSubmit(type: ContainerMessageType, content: any, localOpMetadata: unknown, opMetadata: Record<string, unknown> | undefined): void;
43
+ rollback(type: ContainerMessageType, content: any, localOpMetadata: unknown): void;
44
+ orderSequentially(callback: () => void): void;
54
45
  }
55
46
  /**
56
47
  * PendingStateManager is responsible for maintaining the messages that have not been sent or have not yet been
57
48
  * acknowledged by the server. It also maintains the batch information for both automatically and manually flushed
58
49
  * batches along with the messages.
59
- * When the Container reconnects, it replays the pending states, which includes setting the FlushMode, manual flushing
50
+ * When the Container reconnects, it replays the pending states, which includes manual flushing
60
51
  * of messages and triggering resubmission of unacked ops.
61
52
  *
62
53
  * It verifies that all the ops are acked, are received in the right order and batch information is correct.
@@ -70,12 +61,6 @@ export declare class PendingStateManager implements IDisposable {
70
61
  get pendingMessagesCount(): number;
71
62
  private isProcessingBatch;
72
63
  private pendingBatchBeginMessage;
73
- /**
74
- * This tracks the flush mode for the next message in the pending state queue. When replaying messages, we need to
75
- * first set the flush mode to this value and then send ops. It is important to do this info because the flush
76
- * mode could have been updated.
77
- */
78
- private flushModeForNextMessage;
79
64
  private clientId;
80
65
  /**
81
66
  * Called to check if there are any pending messages in the pending state queue.
@@ -83,7 +68,7 @@ export declare class PendingStateManager implements IDisposable {
83
68
  */
84
69
  hasPendingMessages(): boolean;
85
70
  getLocalState(): IPendingLocalState | undefined;
86
- constructor(stateHandler: IRuntimeStateHandler, initialFlushMode: FlushMode, initialLocalState: IPendingLocalState | undefined);
71
+ constructor(stateHandler: IRuntimeStateHandler, initialLocalState: IPendingLocalState | undefined);
87
72
  get disposed(): boolean;
88
73
  readonly dispose: () => void;
89
74
  /**
@@ -95,11 +80,6 @@ export declare class PendingStateManager implements IDisposable {
95
80
  * @param localOpMetadata - The local metadata associated with the message.
96
81
  */
97
82
  onSubmitMessage(type: ContainerMessageType, clientSequenceNumber: number, referenceSequenceNumber: number, content: any, localOpMetadata: unknown, opMetadata: Record<string, unknown> | undefined): void;
98
- /**
99
- * Called when the FlushMode is updated. Adds the FlushMode to the pending state queue.
100
- * @param flushMode - The flushMode that was updated.
101
- */
102
- onFlushModeUpdated(flushMode: FlushMode): void;
103
83
  /**
104
84
  * Called when flush() is called on the ContainerRuntime to manually flush messages.
105
85
  */
@@ -131,7 +111,7 @@ export declare class PendingStateManager implements IDisposable {
131
111
  private peekNextPendingState;
132
112
  /**
133
113
  * Called when the Container's connection state changes. If the Container gets connected, it replays all the pending
134
- * states in its queue. This includes setting the FlushMode and triggering resubmission of unacked ops.
114
+ * states in its queue. This includes triggering resubmission of unacked ops.
135
115
  */
136
116
  replayPendingStates(): void;
137
117
  }
@@ -1 +1 @@
1
- {"version":3,"file":"pendingStateManager.d.ts","sourceRoot":"","sources":["../src/pendingStateManager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAC;AAEjE,OAAO,EAAE,uBAAuB,EAAE,MAAM,uCAAuC,CAAC;AAEhF,OAAO,EACH,yBAAyB,EAC5B,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,qCAAqC,CAAC;AAEhE,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAG1D;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC5B,IAAI,EAAE,SAAS,CAAC;IAChB,WAAW,EAAE,oBAAoB,CAAC;IAClC,oBAAoB,EAAE,MAAM,CAAC;IAC7B,uBAAuB,EAAE,MAAM,CAAC;IAChC,OAAO,EAAE,GAAG,CAAC;IACb,eAAe,EAAE,OAAO,CAAC;IACzB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAAC;CACnD;AAED;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IAC9B,IAAI,EAAE,WAAW,CAAC;IAClB,SAAS,EAAE,SAAS,CAAC;CACxB;AAED;;;GAGG;AACH,MAAM,WAAW,aAAa;IAC1B,IAAI,EAAE,OAAO,CAAC;CACjB;AAED,oBAAY,aAAa,GAAG,eAAe,GAAG,iBAAiB,GAAG,aAAa,CAAC;AAEhF,MAAM,WAAW,kBAAkB;IAC/B;;OAEG;IACH,aAAa,EAAE,aAAa,EAAE,CAAC;CAClC;AAED,MAAM,WAAW,oBAAoB;IACjC,SAAS,IAAI,OAAO,CAAC;IACrB,QAAQ,IAAI,MAAM,GAAG,SAAS,CAAC;IAC/B,SAAS,IAAI,SAAS,CAAC;IACvB,YAAY,CAAC,IAAI,EAAE,SAAS,GAAG,IAAI,CAAC;IACp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