apache-iggy 0.5.0-edge.1

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 (265) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +81 -0
  3. package/dist/src/bdd/auth.d.ts +20 -0
  4. package/dist/src/bdd/auth.js +38 -0
  5. package/dist/src/bdd/message.d.ts +20 -0
  6. package/dist/src/bdd/message.js +70 -0
  7. package/dist/src/bdd/stream.d.ts +20 -0
  8. package/dist/src/bdd/stream.js +39 -0
  9. package/dist/src/bdd/topic.d.ts +20 -0
  10. package/dist/src/bdd/topic.js +36 -0
  11. package/dist/src/bdd/world.d.ts +30 -0
  12. package/dist/src/bdd/world.js +21 -0
  13. package/dist/src/client/client.connection.d.ts +40 -0
  14. package/dist/src/client/client.connection.js +171 -0
  15. package/dist/src/client/client.d.ts +38 -0
  16. package/dist/src/client/client.debug.d.ts +21 -0
  17. package/dist/src/client/client.debug.js +21 -0
  18. package/dist/src/client/client.js +97 -0
  19. package/dist/src/client/client.socket.d.ts +48 -0
  20. package/dist/src/client/client.socket.js +156 -0
  21. package/dist/src/client/client.type.d.ts +69 -0
  22. package/dist/src/client/client.type.js +20 -0
  23. package/dist/src/client/client.utils.d.ts +29 -0
  24. package/dist/src/client/client.utils.js +54 -0
  25. package/dist/src/client/index.d.ts +23 -0
  26. package/dist/src/client/index.js +23 -0
  27. package/dist/src/client.e2e.d.ts +20 -0
  28. package/dist/src/client.e2e.js +54 -0
  29. package/dist/src/debug-send.d.ts +20 -0
  30. package/dist/src/debug-send.js +117 -0
  31. package/dist/src/debug.d.ts +20 -0
  32. package/dist/src/debug.js +107 -0
  33. package/dist/src/e2e/tcp.client.e2e.d.ts +20 -0
  34. package/dist/src/e2e/tcp.client.e2e.js +45 -0
  35. package/dist/src/e2e/tcp.consumer-group.e2e.d.ts +20 -0
  36. package/dist/src/e2e/tcp.consumer-group.e2e.js +111 -0
  37. package/dist/src/e2e/tcp.consumer-stream.e2e.d.ts +20 -0
  38. package/dist/src/e2e/tcp.consumer-stream.e2e.js +92 -0
  39. package/dist/src/e2e/tcp.parallel.e2e.d.ts +20 -0
  40. package/dist/src/e2e/tcp.parallel.e2e.js +59 -0
  41. package/dist/src/e2e/tcp.send-message.e2e.d.ts +20 -0
  42. package/dist/src/e2e/tcp.send-message.e2e.js +118 -0
  43. package/dist/src/e2e/tcp.stream.e2e.d.ts +20 -0
  44. package/dist/src/e2e/tcp.stream.e2e.js +59 -0
  45. package/dist/src/e2e/tcp.system.e2e.d.ts +20 -0
  46. package/dist/src/e2e/tcp.system.e2e.js +46 -0
  47. package/dist/src/e2e/tcp.token.e2e.d.ts +20 -0
  48. package/dist/src/e2e/tcp.token.e2e.js +43 -0
  49. package/dist/src/e2e/tcp.topic.e2e.d.ts +20 -0
  50. package/dist/src/e2e/tcp.topic.e2e.js +83 -0
  51. package/dist/src/e2e/tcp.user.e2e.d.ts +20 -0
  52. package/dist/src/e2e/tcp.user.e2e.js +95 -0
  53. package/dist/src/e2e/test-client.utils.d.ts +21 -0
  54. package/dist/src/e2e/test-client.utils.js +28 -0
  55. package/dist/src/index.d.ts +22 -0
  56. package/dist/src/index.js +22 -0
  57. package/dist/src/stream/consumer-stream.d.ts +40 -0
  58. package/dist/src/stream/consumer-stream.js +79 -0
  59. package/dist/src/stream/index.d.ts +20 -0
  60. package/dist/src/stream/index.js +20 -0
  61. package/dist/src/tcp.e2e.d.ts +20 -0
  62. package/dist/src/tcp.e2e.js +106 -0
  63. package/dist/src/tcp.sm.utils.d.ts +97 -0
  64. package/dist/src/tcp.sm.utils.js +66 -0
  65. package/dist/src/tls.system.e2e.d.ts +20 -0
  66. package/dist/src/tls.system.e2e.js +49 -0
  67. package/dist/src/type.utils.d.ts +21 -0
  68. package/dist/src/type.utils.js +25 -0
  69. package/dist/src/wire/client/client.utils.d.ts +32 -0
  70. package/dist/src/wire/client/client.utils.js +48 -0
  71. package/dist/src/wire/client/get-client.command.d.ts +30 -0
  72. package/dist/src/wire/client/get-client.command.js +33 -0
  73. package/dist/src/wire/client/get-clients.command.d.ts +27 -0
  74. package/dist/src/wire/client/get-clients.command.js +38 -0
  75. package/dist/src/wire/client/get-me.command.d.ts +27 -0
  76. package/dist/src/wire/client/get-me.command.js +28 -0
  77. package/dist/src/wire/client/index.d.ts +22 -0
  78. package/dist/src/wire/client/index.js +22 -0
  79. package/dist/src/wire/command-set.d.ts +128 -0
  80. package/dist/src/wire/command-set.js +157 -0
  81. package/dist/src/wire/command.code.d.ts +68 -0
  82. package/dist/src/wire/command.code.js +72 -0
  83. package/dist/src/wire/command.utils.d.ts +26 -0
  84. package/dist/src/wire/command.utils.js +29 -0
  85. package/dist/src/wire/consumer-group/create-group.command.d.ts +34 -0
  86. package/dist/src/wire/consumer-group/create-group.command.js +44 -0
  87. package/dist/src/wire/consumer-group/create-group.command.test.d.ts +20 -0
  88. package/dist/src/wire/consumer-group/create-group.command.test.js +47 -0
  89. package/dist/src/wire/consumer-group/delete-group.command.d.ts +31 -0
  90. package/dist/src/wire/consumer-group/delete-group.command.js +31 -0
  91. package/dist/src/wire/consumer-group/get-group.command.d.ts +33 -0
  92. package/dist/src/wire/consumer-group/get-group.command.js +32 -0
  93. package/dist/src/wire/consumer-group/get-groups.command.d.ts +32 -0
  94. package/dist/src/wire/consumer-group/get-groups.command.js +36 -0
  95. package/dist/src/wire/consumer-group/group.command.test.d.ts +20 -0
  96. package/dist/src/wire/consumer-group/group.command.test.js +50 -0
  97. package/dist/src/wire/consumer-group/group.utils.d.ts +34 -0
  98. package/dist/src/wire/consumer-group/group.utils.js +53 -0
  99. package/dist/src/wire/consumer-group/index.d.ts +25 -0
  100. package/dist/src/wire/consumer-group/index.js +25 -0
  101. package/dist/src/wire/consumer-group/join-group.command.d.ts +31 -0
  102. package/dist/src/wire/consumer-group/join-group.command.js +31 -0
  103. package/dist/src/wire/consumer-group/leave-group.command.d.ts +31 -0
  104. package/dist/src/wire/consumer-group/leave-group.command.js +31 -0
  105. package/dist/src/wire/error.code.d.ts +20 -0
  106. package/dist/src/wire/error.code.js +202 -0
  107. package/dist/src/wire/error.utils.d.ts +20 -0
  108. package/dist/src/wire/error.utils.js +23 -0
  109. package/dist/src/wire/identifier.utils.d.ts +21 -0
  110. package/dist/src/wire/identifier.utils.js +49 -0
  111. package/dist/src/wire/identifier.utils.test.d.ts +20 -0
  112. package/dist/src/wire/identifier.utils.test.js +40 -0
  113. package/dist/src/wire/index.d.ts +32 -0
  114. package/dist/src/wire/index.js +31 -0
  115. package/dist/src/wire/message/flush-unsaved-buffers.command.d.ts +31 -0
  116. package/dist/src/wire/message/flush-unsaved-buffers.command.js +31 -0
  117. package/dist/src/wire/message/header.type.d.ts +101 -0
  118. package/dist/src/wire/message/header.type.js +55 -0
  119. package/dist/src/wire/message/header.utils.d.ts +67 -0
  120. package/dist/src/wire/message/header.utils.js +248 -0
  121. package/dist/src/wire/message/header.utils.test.d.ts +20 -0
  122. package/dist/src/wire/message/header.utils.test.js +39 -0
  123. package/dist/src/wire/message/iggy-header.utils.d.ts +32 -0
  124. package/dist/src/wire/message/iggy-header.utils.js +50 -0
  125. package/dist/src/wire/message/index.d.ts +25 -0
  126. package/dist/src/wire/message/index.js +25 -0
  127. package/dist/src/wire/message/message.utils.d.ts +35 -0
  128. package/dist/src/wire/message/message.utils.js +112 -0
  129. package/dist/src/wire/message/partitioning.utils.d.ts +51 -0
  130. package/dist/src/wire/message/partitioning.utils.js +77 -0
  131. package/dist/src/wire/message/poll-messages.command.d.ts +43 -0
  132. package/dist/src/wire/message/poll-messages.command.js +32 -0
  133. package/dist/src/wire/message/poll.utils.d.ts +93 -0
  134. package/dist/src/wire/message/poll.utils.js +135 -0
  135. package/dist/src/wire/message/send-messages.command.d.ts +34 -0
  136. package/dist/src/wire/message/send-messages.command.js +31 -0
  137. package/dist/src/wire/message/send-messages.command.test.d.ts +20 -0
  138. package/dist/src/wire/message/send-messages.command.test.js +88 -0
  139. package/dist/src/wire/number.utils.d.ts +32 -0
  140. package/dist/src/wire/number.utils.js +85 -0
  141. package/dist/src/wire/offset/delete-offset.command.d.ts +28 -0
  142. package/dist/src/wire/offset/delete-offset.command.js +31 -0
  143. package/dist/src/wire/offset/get-offset.command.d.ts +34 -0
  144. package/dist/src/wire/offset/get-offset.command.js +41 -0
  145. package/dist/src/wire/offset/index.d.ts +22 -0
  146. package/dist/src/wire/offset/index.js +22 -0
  147. package/dist/src/wire/offset/offset.utils.d.ts +54 -0
  148. package/dist/src/wire/offset/offset.utils.js +60 -0
  149. package/dist/src/wire/offset/store-offset.command.d.ts +34 -0
  150. package/dist/src/wire/offset/store-offset.command.js +29 -0
  151. package/dist/src/wire/partition/create-partition.command.d.ts +31 -0
  152. package/dist/src/wire/partition/create-partition.command.js +31 -0
  153. package/dist/src/wire/partition/delete-partition.command.d.ts +31 -0
  154. package/dist/src/wire/partition/delete-partition.command.js +31 -0
  155. package/dist/src/wire/partition/index.d.ts +21 -0
  156. package/dist/src/wire/partition/index.js +21 -0
  157. package/dist/src/wire/partition/partition.utils.d.ts +21 -0
  158. package/dist/src/wire/partition/partition.utils.js +33 -0
  159. package/dist/src/wire/partition/partition.utils.test.d.ts +20 -0
  160. package/dist/src/wire/partition/partition.utils.test.js +33 -0
  161. package/dist/src/wire/segment/delete-segments.command.d.ts +32 -0
  162. package/dist/src/wire/segment/delete-segments.command.js +31 -0
  163. package/dist/src/wire/segment/index.d.ts +20 -0
  164. package/dist/src/wire/segment/index.js +20 -0
  165. package/dist/src/wire/segment/segment.utils.d.ts +21 -0
  166. package/dist/src/wire/segment/segment.utils.js +35 -0
  167. package/dist/src/wire/serialize.utils.d.ts +22 -0
  168. package/dist/src/wire/serialize.utils.js +27 -0
  169. package/dist/src/wire/session/index.d.ts +23 -0
  170. package/dist/src/wire/session/index.js +22 -0
  171. package/dist/src/wire/session/login-with-token.command.d.ts +32 -0
  172. package/dist/src/wire/session/login-with-token.command.js +30 -0
  173. package/dist/src/wire/session/login-with-token.command.test.d.ts +20 -0
  174. package/dist/src/wire/session/login-with-token.command.test.js +38 -0
  175. package/dist/src/wire/session/login.command.d.ts +29 -0
  176. package/dist/src/wire/session/login.command.js +30 -0
  177. package/dist/src/wire/session/login.command.test.d.ts +20 -0
  178. package/dist/src/wire/session/login.command.test.js +52 -0
  179. package/dist/src/wire/session/login.utils.d.ts +30 -0
  180. package/dist/src/wire/session/login.utils.js +54 -0
  181. package/dist/src/wire/session/logout.command.d.ts +25 -0
  182. package/dist/src/wire/session/logout.command.js +30 -0
  183. package/dist/src/wire/stream/create-stream.command.d.ts +31 -0
  184. package/dist/src/wire/stream/create-stream.command.js +41 -0
  185. package/dist/src/wire/stream/create-stream.command.test.d.ts +20 -0
  186. package/dist/src/wire/stream/create-stream.command.test.js +45 -0
  187. package/dist/src/wire/stream/delete-stream.command.d.ts +29 -0
  188. package/dist/src/wire/stream/delete-stream.command.js +31 -0
  189. package/dist/src/wire/stream/get-stream.command.d.ts +31 -0
  190. package/dist/src/wire/stream/get-stream.command.js +33 -0
  191. package/dist/src/wire/stream/get-streams.command.d.ts +27 -0
  192. package/dist/src/wire/stream/get-streams.command.js +38 -0
  193. package/dist/src/wire/stream/index.d.ts +25 -0
  194. package/dist/src/wire/stream/index.js +25 -0
  195. package/dist/src/wire/stream/purge-stream.command.d.ts +29 -0
  196. package/dist/src/wire/stream/purge-stream.command.js +31 -0
  197. package/dist/src/wire/stream/stream.utils.d.ts +33 -0
  198. package/dist/src/wire/stream/stream.utils.js +35 -0
  199. package/dist/src/wire/stream/update-stream.command.d.ts +30 -0
  200. package/dist/src/wire/stream/update-stream.command.js +40 -0
  201. package/dist/src/wire/system/get-stats.command.d.ts +50 -0
  202. package/dist/src/wire/system/get-stats.command.js +83 -0
  203. package/dist/src/wire/system/index.d.ts +21 -0
  204. package/dist/src/wire/system/index.js +21 -0
  205. package/dist/src/wire/system/ping.command.d.ts +25 -0
  206. package/dist/src/wire/system/ping.command.js +30 -0
  207. package/dist/src/wire/token/create-token.command.d.ts +31 -0
  208. package/dist/src/wire/token/create-token.command.js +37 -0
  209. package/dist/src/wire/token/create-token.command.test.d.ts +20 -0
  210. package/dist/src/wire/token/create-token.command.test.js +45 -0
  211. package/dist/src/wire/token/delete-token.command.d.ts +28 -0
  212. package/dist/src/wire/token/delete-token.command.js +38 -0
  213. package/dist/src/wire/token/delete-token.command.test.d.ts +20 -0
  214. package/dist/src/wire/token/delete-token.command.test.js +42 -0
  215. package/dist/src/wire/token/get-tokens.command.d.ts +27 -0
  216. package/dist/src/wire/token/get-tokens.command.js +28 -0
  217. package/dist/src/wire/token/index.d.ts +22 -0
  218. package/dist/src/wire/token/index.js +22 -0
  219. package/dist/src/wire/token/token.utils.d.ts +38 -0
  220. package/dist/src/wire/token/token.utils.js +53 -0
  221. package/dist/src/wire/topic/create-topic.command.d.ts +38 -0
  222. package/dist/src/wire/topic/create-topic.command.js +53 -0
  223. package/dist/src/wire/topic/create-topic.command.test.d.ts +20 -0
  224. package/dist/src/wire/topic/create-topic.command.test.js +67 -0
  225. package/dist/src/wire/topic/delete-topic.command.d.ts +32 -0
  226. package/dist/src/wire/topic/delete-topic.command.js +36 -0
  227. package/dist/src/wire/topic/get-topic.command.d.ts +33 -0
  228. package/dist/src/wire/topic/get-topic.command.js +36 -0
  229. package/dist/src/wire/topic/get-topics.command.d.ts +31 -0
  230. package/dist/src/wire/topic/get-topics.command.js +33 -0
  231. package/dist/src/wire/topic/index.d.ts +25 -0
  232. package/dist/src/wire/topic/index.js +25 -0
  233. package/dist/src/wire/topic/purge-topic.command.d.ts +30 -0
  234. package/dist/src/wire/topic/purge-topic.command.js +34 -0
  235. package/dist/src/wire/topic/topic.utils.d.ts +71 -0
  236. package/dist/src/wire/topic/topic.utils.js +91 -0
  237. package/dist/src/wire/topic/update-topic.command.d.ts +36 -0
  238. package/dist/src/wire/topic/update-topic.command.js +50 -0
  239. package/dist/src/wire/user/change-password.command.d.ts +30 -0
  240. package/dist/src/wire/user/change-password.command.js +45 -0
  241. package/dist/src/wire/user/create-user.command.d.ts +34 -0
  242. package/dist/src/wire/user/create-user.command.js +48 -0
  243. package/dist/src/wire/user/create-user.command.test.d.ts +20 -0
  244. package/dist/src/wire/user/create-user.command.test.js +60 -0
  245. package/dist/src/wire/user/delete-user.command.d.ts +29 -0
  246. package/dist/src/wire/user/delete-user.command.js +31 -0
  247. package/dist/src/wire/user/get-user.command.d.ts +31 -0
  248. package/dist/src/wire/user/get-user.command.js +31 -0
  249. package/dist/src/wire/user/get-users.command.d.ts +27 -0
  250. package/dist/src/wire/user/get-users.command.js +28 -0
  251. package/dist/src/wire/user/index.d.ts +26 -0
  252. package/dist/src/wire/user/index.js +26 -0
  253. package/dist/src/wire/user/permissions.utils.d.ts +77 -0
  254. package/dist/src/wire/user/permissions.utils.js +161 -0
  255. package/dist/src/wire/user/permissions.utils.test.d.ts +20 -0
  256. package/dist/src/wire/user/permissions.utils.test.js +44 -0
  257. package/dist/src/wire/user/update-permissions.command.d.ts +31 -0
  258. package/dist/src/wire/user/update-permissions.command.js +39 -0
  259. package/dist/src/wire/user/update-user.command.d.ts +32 -0
  260. package/dist/src/wire/user/update-user.command.js +54 -0
  261. package/dist/src/wire/user/user.utils.d.ts +41 -0
  262. package/dist/src/wire/user/user.utils.js +74 -0
  263. package/dist/src/wire/uuid.utils.d.ts +22 -0
  264. package/dist/src/wire/uuid.utils.js +23 -0
  265. package/package.json +70 -0
@@ -0,0 +1,248 @@
1
+ /**
2
+ * Licensed to the Apache Software Foundation (ASF) under one
3
+ * or more contributor license agreements. See the NOTICE file
4
+ * distributed with this work for additional information
5
+ * regarding copyright ownership. The ASF licenses this file
6
+ * to you under the Apache License, Version 2.0 (the
7
+ * "License"); you may not use this file except in compliance
8
+ * with the License. You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing,
13
+ * software distributed under the License is distributed on an
14
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
+ * KIND, either express or implied. See the License for the
16
+ * specific language governing permissions and limitations
17
+ * under the License.
18
+ */
19
+ import { boolToBuf, int8ToBuf, int16ToBuf, int32ToBuf, int64ToBuf, uint8ToBuf, uint16ToBuf, uint32ToBuf, uint64ToBuf, floatToBuf, doubleToBuf } from '../number.utils.js';
20
+ import { HeaderKind, ReverseHeaderKind } from './header.type.js';
21
+ export const serializeHeaderValue = (header) => {
22
+ const { kind, value } = header;
23
+ switch (kind) {
24
+ case HeaderKind.Raw: return value;
25
+ case HeaderKind.String: return Buffer.from(value);
26
+ case HeaderKind.Bool: return boolToBuf(value);
27
+ case HeaderKind.Int8: return int8ToBuf(value);
28
+ case HeaderKind.Int16: return int16ToBuf(value);
29
+ case HeaderKind.Int32: return int32ToBuf(value);
30
+ case HeaderKind.Int64: return int64ToBuf(value);
31
+ case HeaderKind.Int128: return value;
32
+ case HeaderKind.Uint8: return uint8ToBuf(value);
33
+ case HeaderKind.Uint16: return uint16ToBuf(value);
34
+ case HeaderKind.Uint32: return uint32ToBuf(value);
35
+ case HeaderKind.Uint64: return uint64ToBuf(value);
36
+ case HeaderKind.Uint128: return value;
37
+ case HeaderKind.Float: return floatToBuf(value);
38
+ case HeaderKind.Double: return doubleToBuf(value);
39
+ }
40
+ };
41
+ export const serializeHeader = (key, v) => {
42
+ const bKey = Buffer.from(key);
43
+ const b1 = uint32ToBuf(bKey.length);
44
+ const b2 = Buffer.alloc(5);
45
+ b2.writeUInt8(v.kind);
46
+ b2.writeUInt32LE(v.value.length, 1);
47
+ // @TODO debug
48
+ // console.log(
49
+ // 'SERIALIZE\n',
50
+ // 'KEY-LEN', b1.length, b1.toString('hex'), '=', b1.readUInt32LE(0), '\n',
51
+ // 'KEY', bKey.length, bKey.toString('hex'), '\n',
52
+ // 'KIND', b2.readUInt8(0), b2.subarray(0, 1).toString('hex'), '\n',
53
+ // 'V-LEN', b2.readUInt32LE(1), b2.subarray(1, 5).toString('hex'), '\n',
54
+ // 'V', v.value.length, v.value.toString('hex')
55
+ // );
56
+ return Buffer.concat([
57
+ b1,
58
+ bKey,
59
+ b2,
60
+ v.value
61
+ ]);
62
+ };
63
+ export const EMPTY_HEADERS = Buffer.alloc(0);
64
+ const createHeaderValue = (header) => ({
65
+ kind: header.kind,
66
+ value: serializeHeaderValue(header)
67
+ });
68
+ export const serializeHeaders = (headers) => {
69
+ if (!headers)
70
+ return EMPTY_HEADERS;
71
+ return Buffer.concat(Object.keys(headers).map((c) => serializeHeader(c, createHeaderValue(headers[c]))));
72
+ };
73
+ export const mapHeaderKind = (k) => {
74
+ if (!ReverseHeaderKind[k])
75
+ throw new Error(`unknow header kind: ${k}`);
76
+ return ReverseHeaderKind[k];
77
+ };
78
+ export const deserializeHeaderValue = (kind, value) => {
79
+ switch (kind) {
80
+ case HeaderKind.Int128:
81
+ case HeaderKind.Uint128:
82
+ case HeaderKind.Raw: return value;
83
+ case HeaderKind.String: return value.toString();
84
+ case HeaderKind.Int8: return value.readInt8();
85
+ case HeaderKind.Int16: return value.readInt16LE();
86
+ case HeaderKind.Int32: return value.readInt32LE();
87
+ case HeaderKind.Int64: return value.readBigInt64LE();
88
+ case HeaderKind.Uint8: return value.readUint8();
89
+ case HeaderKind.Uint16: return value.readUint16LE();
90
+ case HeaderKind.Uint32: return value.readUInt32LE();
91
+ case HeaderKind.Uint64: return value.readBigUInt64LE();
92
+ case HeaderKind.Bool: return value.readUInt8() === 1;
93
+ case HeaderKind.Float: return value.readFloatLE();
94
+ case HeaderKind.Double: return value.readDoubleLE();
95
+ default: throw new Error(`deserializeHeaderValue: invalid HeaderKind ${kind}`);
96
+ }
97
+ };
98
+ export const deserializeHeader = (p, pos = 0) => {
99
+ const keyLength = p.readUInt32LE(pos);
100
+ const key = p.subarray(pos + 4, pos + 4 + keyLength).toString();
101
+ pos += keyLength + 4;
102
+ const rawKind = p.readUInt8(pos);
103
+ // @TODO ?
104
+ // const kind = mapHeaderKind(rawKind);
105
+ const valueLength = p.readUInt32LE(pos + 1);
106
+ const value = deserializeHeaderValue(rawKind, p.subarray(pos + 5, pos + 5 + valueLength));
107
+ return {
108
+ bytesRead: 4 + 4 + 1 + keyLength + valueLength,
109
+ data: {
110
+ key,
111
+ kind: rawKind,
112
+ value
113
+ }
114
+ };
115
+ };
116
+ export const deserializeHeaders = (p, pos = 0) => {
117
+ const headers = {};
118
+ const len = p.length;
119
+ while (pos < len) {
120
+ const { bytesRead, data: { kind, key, value } } = deserializeHeader(p, pos);
121
+ headers[key] = { kind, value };
122
+ pos += bytesRead;
123
+ }
124
+ return headers;
125
+ };
126
+ /** HeaderValue Helper */
127
+ const Raw = (value) => ({
128
+ kind: HeaderKind.Raw,
129
+ value
130
+ });
131
+ const String = (value) => ({
132
+ kind: HeaderKind.String,
133
+ value
134
+ });
135
+ const Bool = (value) => ({
136
+ kind: HeaderKind.Bool,
137
+ value
138
+ });
139
+ const Int8 = (value) => ({
140
+ kind: HeaderKind.Int8,
141
+ value
142
+ });
143
+ const Int16 = (value) => ({
144
+ kind: HeaderKind.Int16,
145
+ value
146
+ });
147
+ const Int32 = (value) => ({
148
+ kind: HeaderKind.Int32,
149
+ value
150
+ });
151
+ const Int64 = (value) => ({
152
+ kind: HeaderKind.Int64,
153
+ value
154
+ });
155
+ const Int128 = (value) => ({
156
+ kind: HeaderKind.Int128,
157
+ value
158
+ });
159
+ const Uint8 = (value) => ({
160
+ kind: HeaderKind.Uint8,
161
+ value
162
+ });
163
+ const Uint16 = (value) => ({
164
+ kind: HeaderKind.Uint16,
165
+ value
166
+ });
167
+ const Uint32 = (value) => ({
168
+ kind: HeaderKind.Uint32,
169
+ value
170
+ });
171
+ const Uint64 = (value) => ({
172
+ kind: HeaderKind.Uint64,
173
+ value
174
+ });
175
+ const Uint128 = (value) => ({
176
+ kind: HeaderKind.Uint128,
177
+ value
178
+ });
179
+ const Float = (value) => ({
180
+ kind: HeaderKind.Float,
181
+ value
182
+ });
183
+ const Double = (value) => ({
184
+ kind: HeaderKind.Double,
185
+ value
186
+ });
187
+ const getKind = (h) => mapHeaderKind(h.kind);
188
+ const getValue = (h) => h.value;
189
+ export const HeaderValue = {
190
+ Raw,
191
+ String,
192
+ Bool,
193
+ Int8,
194
+ Int16,
195
+ Int32,
196
+ Int64,
197
+ Int128,
198
+ Uint8,
199
+ Uint16,
200
+ Uint32,
201
+ Uint64,
202
+ Uint128,
203
+ Float,
204
+ Double,
205
+ getKind,
206
+ getValue
207
+ };
208
+ // export type InputHeaderValue = boolean | number | string | bigint | Buffer;
209
+ // export type InputHeaders = Record<string, InputHeaderValue>;
210
+ // const isFloat = (n: number) => n % 1 !== 0;
211
+ // export const createHeaderValueFloat = (v: number): HeaderValue =>
212
+ // ({ kind: HeaderKind.Float, value: floatToBuf(v) });
213
+ // export const createHeaderValueDouble = (v: number): HeaderValue =>
214
+ // ({ kind: HeaderKind.Double, value: doubleToBuf(v) });
215
+ // export const createHeaderValueInt32 = (v: number): HeaderValue =>
216
+ // ({ kind: HeaderKind.Int32, value: int32ToBuf(v) });
217
+ // export const createHeaderValueInt64 = (v: bigint): HeaderValue =>
218
+ // ({ kind: HeaderKind.Int64, value: int64ToBuf(v) });
219
+ // export const createHeaderValueUInt32 = (v: number): HeaderValue =>
220
+ // ({ kind: HeaderKind.Uint32, value: uint32ToBuf(v) });
221
+ // export const createHeaderValueUInt64 = (v: bigint): HeaderValue =>
222
+ // ({ kind: HeaderKind.Uint64, value: uint64ToBuf(v) });
223
+ // export const createHeaderValueBool = (v: boolean): HeaderValue =>
224
+ // ({ kind: HeaderKind.Bool, value: boolToBuf(v) });
225
+ // export const createHeaderValueBuffer = (v: Buffer): HeaderValue =>
226
+ // ({ kind: HeaderKind.Raw, value: v });
227
+ // export const createHeaderValueString = (v: string): HeaderValue =>
228
+ // ({ kind: HeaderKind.String, value: Buffer.from(v) });
229
+ // // guess wire type from js type ?
230
+ // const guessHeaderValue = (v: InputHeaderValue): HeaderValue => {
231
+ // if (typeof v === 'number') {
232
+ // if (isFloat(v))
233
+ // return createHeaderValueFloat(v);
234
+ // else
235
+ // return createHeaderValueInt32(v); // BAD KARMA
236
+ // }
237
+ // if (typeof v === 'bigint') {
238
+ // return createHeaderValueInt64(v); // BAD KARMA
239
+ // }
240
+ // if (typeof v === 'boolean')
241
+ // return createHeaderValueBool(v);
242
+ // if (typeof v === 'string')
243
+ // return createHeaderValueString(v);
244
+ // if (v instanceof Buffer)
245
+ // return createHeaderValueBuffer(v);
246
+ // throw new Error(`unable to serialize headers param ${v} - ${typeof v}`)
247
+ // }
248
+ //# sourceMappingURL=header.utils.js.map
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Licensed to the Apache Software Foundation (ASF) under one
3
+ * or more contributor license agreements. See the NOTICE file
4
+ * distributed with this work for additional information
5
+ * regarding copyright ownership. The ASF licenses this file
6
+ * to you under the Apache License, Version 2.0 (the
7
+ * "License"); you may not use this file except in compliance
8
+ * with the License. You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing,
13
+ * software distributed under the License is distributed on an
14
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
+ * KIND, either express or implied. See the License for the
16
+ * specific language governing permissions and limitations
17
+ * under the License.
18
+ */
19
+ export {};
20
+ //# sourceMappingURL=header.utils.test.d.ts.map
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Licensed to the Apache Software Foundation (ASF) under one
3
+ * or more contributor license agreements. See the NOTICE file
4
+ * distributed with this work for additional information
5
+ * regarding copyright ownership. The ASF licenses this file
6
+ * to you under the Apache License, Version 2.0 (the
7
+ * "License"); you may not use this file except in compliance
8
+ * with the License. You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing,
13
+ * software distributed under the License is distributed on an
14
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
+ * KIND, either express or implied. See the License for the
16
+ * specific language governing permissions and limitations
17
+ * under the License.
18
+ */
19
+ import { describe, it } from 'node:test';
20
+ import assert from 'node:assert/strict';
21
+ import { uuidv7, uuidv4 } from 'uuidv7';
22
+ import { serializeHeaders, deserializeHeaders, HeaderValue } from './header.utils.js';
23
+ describe('Headers', () => {
24
+ const headers = {
25
+ 'p': HeaderValue.Bool(true),
26
+ 'x': HeaderValue.Uint32(123),
27
+ 'y': HeaderValue.Uint64(42n),
28
+ 'z': HeaderValue.Float(42.20000076293945),
29
+ 'a': HeaderValue.Double(1 / 3),
30
+ 'ID': HeaderValue.String(uuidv7()),
31
+ 'val': HeaderValue.Raw(Buffer.from(uuidv4()))
32
+ };
33
+ it('serialize/deserialize', () => {
34
+ const s = serializeHeaders(headers);
35
+ const d = deserializeHeaders(s);
36
+ assert.deepEqual(headers, d);
37
+ });
38
+ });
39
+ //# sourceMappingURL=header.utils.test.js.map
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Licensed to the Apache Software Foundation (ASF) under one
3
+ * or more contributor license agreements. See the NOTICE file
4
+ * distributed with this work for additional information
5
+ * regarding copyright ownership. The ASF licenses this file
6
+ * to you under the Apache License, Version 2.0 (the
7
+ * "License"); you may not use this file except in compliance
8
+ * with the License. You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing,
13
+ * software distributed under the License is distributed on an
14
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
+ * KIND, either express or implied. See the License for the
16
+ * specific language governing permissions and limitations
17
+ * under the License.
18
+ */
19
+ export type IggyMessageHeader = {
20
+ checksum: bigint;
21
+ id: string | BigInt;
22
+ offset: bigint;
23
+ timestamp: Date;
24
+ originTimestamp: Date;
25
+ userHeadersLength: number;
26
+ payloadLength: number;
27
+ };
28
+ export declare const IGGY_MESSAGE_HEADER_SIZE: number;
29
+ export declare const serializeIggyMessageHeader: (id: Buffer, payload: Buffer, userHeaders: Buffer) => Buffer<ArrayBuffer>;
30
+ export declare const deserialiseMessageId: (b: Buffer) => bigint;
31
+ export declare const deserializeIggyMessageHeaders: (b: Buffer) => IggyMessageHeader;
32
+ //# sourceMappingURL=iggy-header.utils.d.ts.map
@@ -0,0 +1,50 @@
1
+ /**
2
+ * Licensed to the Apache Software Foundation (ASF) under one
3
+ * or more contributor license agreements. See the NOTICE file
4
+ * distributed with this work for additional information
5
+ * regarding copyright ownership. The ASF licenses this file
6
+ * to you under the Apache License, Version 2.0 (the
7
+ * "License"); you may not use this file except in compliance
8
+ * with the License. You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing,
13
+ * software distributed under the License is distributed on an
14
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
+ * KIND, either express or implied. See the License for the
16
+ * specific language governing permissions and limitations
17
+ * under the License.
18
+ */
19
+ import { toDate } from "../serialize.utils.js";
20
+ import { u128LEBufToBigint } from "../number.utils.js";
21
+ // u64 + u128 + u64 + u64 + u64 + u32 + u32
22
+ export const IGGY_MESSAGE_HEADER_SIZE = 8 + 16 + 8 + 8 + 8 + 4 + 4;
23
+ export const serializeIggyMessageHeader = (id, payload, userHeaders) => {
24
+ const b = Buffer.allocUnsafe(IGGY_MESSAGE_HEADER_SIZE);
25
+ b.writeBigUInt64LE(0n, 0); // checksum u64
26
+ b.fill(id, 8, 24); // id u128
27
+ b.writeBigUInt64LE(0n, 24); // offset u64
28
+ b.writeBigUInt64LE(0n, 32); // timestamp u64
29
+ b.writeBigUint64LE(BigInt(new Date().getTime()), 40); // originTimestamp u64
30
+ b.writeUInt32LE(userHeaders.length, 48); // userHeaders len u32
31
+ b.writeUInt32LE(payload.length, 52); // payload len u32
32
+ return b;
33
+ };
34
+ export const deserialiseMessageId = (b) => u128LEBufToBigint(b);
35
+ export const deserializeIggyMessageHeaders = (b) => {
36
+ if (b.length !== IGGY_MESSAGE_HEADER_SIZE)
37
+ throw new Error(`deserialize message headers error, length = ${b.length} ` +
38
+ `expected ${IGGY_MESSAGE_HEADER_SIZE}`);
39
+ const headers = {
40
+ checksum: b.readBigUInt64LE(0),
41
+ id: deserialiseMessageId(b.subarray(8, 24)),
42
+ offset: b.readBigUInt64LE(24),
43
+ timestamp: toDate(b.readBigUInt64LE(32)),
44
+ originTimestamp: toDate(b.readBigUInt64LE(40)),
45
+ userHeadersLength: b.readUInt32LE(48),
46
+ payloadLength: b.readUInt32LE(52)
47
+ };
48
+ return headers;
49
+ };
50
+ //# sourceMappingURL=iggy-header.utils.js.map
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Licensed to the Apache Software Foundation (ASF) under one
3
+ * or more contributor license agreements. See the NOTICE file
4
+ * distributed with this work for additional information
5
+ * regarding copyright ownership. The ASF licenses this file
6
+ * to you under the Apache License, Version 2.0 (the
7
+ * "License"); you may not use this file except in compliance
8
+ * with the License. You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing,
13
+ * software distributed under the License is distributed on an
14
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
+ * KIND, either express or implied. See the License for the
16
+ * specific language governing permissions and limitations
17
+ * under the License.
18
+ */
19
+ export * from './poll-messages.command.js';
20
+ export * from './send-messages.command.js';
21
+ export * from './message.utils.js';
22
+ export * from "./poll.utils.js";
23
+ export { Partitioning } from './partitioning.utils.js';
24
+ export { HeaderValue } from './header.utils.js';
25
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Licensed to the Apache Software Foundation (ASF) under one
3
+ * or more contributor license agreements. See the NOTICE file
4
+ * distributed with this work for additional information
5
+ * regarding copyright ownership. The ASF licenses this file
6
+ * to you under the Apache License, Version 2.0 (the
7
+ * "License"); you may not use this file except in compliance
8
+ * with the License. You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing,
13
+ * software distributed under the License is distributed on an
14
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
+ * KIND, either express or implied. See the License for the
16
+ * specific language governing permissions and limitations
17
+ * under the License.
18
+ */
19
+ export * from './poll-messages.command.js';
20
+ export * from './send-messages.command.js';
21
+ export * from './message.utils.js';
22
+ export * from "./poll.utils.js";
23
+ export { Partitioning } from './partitioning.utils.js';
24
+ export { HeaderValue } from './header.utils.js';
25
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Licensed to the Apache Software Foundation (ASF) under one
3
+ * or more contributor license agreements. See the NOTICE file
4
+ * distributed with this work for additional information
5
+ * regarding copyright ownership. The ASF licenses this file
6
+ * to you under the Apache License, Version 2.0 (the
7
+ * "License"); you may not use this file except in compliance
8
+ * with the License. You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing,
13
+ * software distributed under the License is distributed on an
14
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
+ * KIND, either express or implied. See the License for the
16
+ * specific language governing permissions and limitations
17
+ * under the License.
18
+ */
19
+ import { type Headers } from './header.utils.js';
20
+ import { type Id } from '../identifier.utils.js';
21
+ import { type Partitioning } from './partitioning.utils.js';
22
+ export type MessageIdKind = number | bigint | string;
23
+ export type CreateMessage = {
24
+ id?: MessageIdKind;
25
+ headers?: Headers;
26
+ payload: string | Buffer;
27
+ };
28
+ export declare const isValidMessageId: (x?: unknown) => x is MessageIdKind;
29
+ export declare const serializeMessageId: (id?: unknown) => Buffer<ArrayBufferLike>;
30
+ export declare const serializeMessage: (msg: CreateMessage) => Buffer<ArrayBuffer>;
31
+ export declare const serializeMessages: (messages: CreateMessage[]) => Buffer<ArrayBuffer>[];
32
+ export declare const createMessagesIndex: (messages: Buffer[]) => Buffer<ArrayBuffer>;
33
+ export declare const serializeSendMessages: (streamId: Id, topicId: Id, messages: CreateMessage[], partitioning?: Partitioning) => Buffer<ArrayBuffer>;
34
+ export declare const serializeFlushUnsavedBuffers: (streamId: Id, topicId: Id, partitionId: number, fsync?: boolean) => Buffer<ArrayBuffer>;
35
+ //# sourceMappingURL=message.utils.d.ts.map
@@ -0,0 +1,112 @@
1
+ /**
2
+ * Licensed to the Apache Software Foundation (ASF) under one
3
+ * or more contributor license agreements. See the NOTICE file
4
+ * distributed with this work for additional information
5
+ * regarding copyright ownership. The ASF licenses this file
6
+ * to you under the Apache License, Version 2.0 (the
7
+ * "License"); you may not use this file except in compliance
8
+ * with the License. You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing,
13
+ * software distributed under the License is distributed on an
14
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
+ * KIND, either express or implied. See the License for the
16
+ * specific language governing permissions and limitations
17
+ * under the License.
18
+ */
19
+ import Debug from 'debug';
20
+ import { uint32ToBuf, u128ToBuf, uint8ToBuf } from '../number.utils.js';
21
+ import { serializeHeaders } from './header.utils.js';
22
+ import { serializeIdentifier } from '../identifier.utils.js';
23
+ import { serializePartitioning } from './partitioning.utils.js';
24
+ import { parse as parseUUID } from '../uuid.utils.js';
25
+ import { serializeIggyMessageHeader } from './iggy-header.utils.js';
26
+ const debug = Debug('iggy:client');
27
+ /** index size per messages in bit */
28
+ const INDEX_SIZE = 16;
29
+ export const isValidMessageId = (x) => x === undefined ||
30
+ 'string' === typeof x ||
31
+ 'bigint' === typeof x ||
32
+ 'number' === typeof x;
33
+ export const serializeMessageId = (id) => {
34
+ if (!isValidMessageId(id))
35
+ throw new Error(`invalid message id: '${id}' (use uuid string | number | bigint >= 0)`);
36
+ if (id === undefined)
37
+ return Buffer.alloc(16, 0); // 0u128
38
+ if ('bigint' === typeof id || 'number' === typeof id) {
39
+ if (id < 0)
40
+ throw new Error(`invalid message id: '${id}' (numeric id must be >= 0)`);
41
+ const idValue = 'number' === typeof id ? BigInt(id) : id;
42
+ return u128ToBuf(idValue);
43
+ }
44
+ try {
45
+ const uuid = parseUUID(id);
46
+ return Buffer.from(uuid.toHex(), 'hex');
47
+ }
48
+ catch (err) {
49
+ throw new Error(`invalid message id: '${id}' (use uuid string | number | bigint >= 0)`, { cause: err });
50
+ }
51
+ };
52
+ export const serializeMessage = (msg) => {
53
+ const { id, headers, payload } = msg;
54
+ const bId = serializeMessageId(id);
55
+ const bUserHeaders = serializeHeaders(headers);
56
+ const bPayload = 'string' === typeof payload ? Buffer.from(payload) : payload;
57
+ const bIggyMessageHeader = serializeIggyMessageHeader(bId, bPayload, bUserHeaders);
58
+ const r = Buffer.concat([
59
+ bIggyMessageHeader,
60
+ bPayload,
61
+ bUserHeaders
62
+ ]);
63
+ debug('id', bId.length, bId.toString('hex'), 'iggyHeaders', bIggyMessageHeader.length, bIggyMessageHeader.toString('hex'), 'userHeaders', bUserHeaders.length, bUserHeaders.toString('hex'), 'payload', bPayload.length, bPayload.toString('hex'), 'full len', r.length //, r.toString('hex')
64
+ );
65
+ return r;
66
+ };
67
+ export const serializeMessages = (messages) => messages.map(c => serializeMessage(c));
68
+ export const createMessagesIndex = (messages) => {
69
+ const bIndex = Buffer.allocUnsafe(messages.length * INDEX_SIZE);
70
+ let currentIndex = 0;
71
+ let msgsSize = 0;
72
+ messages.forEach(msg => {
73
+ msgsSize += msg.length;
74
+ bIndex.writeBigUInt64LE(0n, currentIndex);
75
+ bIndex.writeUInt32LE(msgsSize, currentIndex + 4);
76
+ bIndex.writeBigUInt64LE(0n, currentIndex + 8);
77
+ currentIndex += INDEX_SIZE;
78
+ });
79
+ return bIndex;
80
+ };
81
+ export const serializeSendMessages = (streamId, topicId, messages, partitioning) => {
82
+ const streamIdentifier = serializeIdentifier(streamId);
83
+ const topicIdentifier = serializeIdentifier(topicId);
84
+ const bPartitioning = serializePartitioning(partitioning);
85
+ const bMessagesCount = uint32ToBuf(messages.length);
86
+ const bMetadataLen = uint32ToBuf(streamIdentifier.length + topicIdentifier.length +
87
+ bPartitioning.length + bMessagesCount.length);
88
+ const bMessagesArray = serializeMessages(messages);
89
+ const bMessageIndex = createMessagesIndex(bMessagesArray);
90
+ return Buffer.concat([
91
+ bMetadataLen,
92
+ streamIdentifier,
93
+ topicIdentifier,
94
+ bPartitioning,
95
+ bMessagesCount,
96
+ bMessageIndex,
97
+ ...bMessagesArray
98
+ ]);
99
+ };
100
+ export const serializeFlushUnsavedBuffers = (streamId, topicId, partitionId, fsync = false) => {
101
+ const streamIdentifier = serializeIdentifier(streamId);
102
+ const topicIdentifier = serializeIdentifier(topicId);
103
+ const bPartitionId = uint32ToBuf(partitionId);
104
+ const bFSync = uint8ToBuf(fsync ? 1 : 0);
105
+ return Buffer.concat([
106
+ streamIdentifier,
107
+ topicIdentifier,
108
+ bPartitionId,
109
+ bFSync
110
+ ]);
111
+ };
112
+ //# sourceMappingURL=message.utils.js.map
@@ -0,0 +1,51 @@
1
+ /**
2
+ * Licensed to the Apache Software Foundation (ASF) under one
3
+ * or more contributor license agreements. See the NOTICE file
4
+ * distributed with this work for additional information
5
+ * regarding copyright ownership. The ASF licenses this file
6
+ * to you under the Apache License, Version 2.0 (the
7
+ * "License"); you may not use this file except in compliance
8
+ * with the License. You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing,
13
+ * software distributed under the License is distributed on an
14
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
+ * KIND, either express or implied. See the License for the
16
+ * specific language governing permissions and limitations
17
+ * under the License.
18
+ */
19
+ import type { ValueOf } from '../../type.utils.js';
20
+ export declare const PartitionKind: {
21
+ readonly Balanced: 1;
22
+ readonly PartitionId: 2;
23
+ readonly MessageKey: 3;
24
+ };
25
+ export type PartitionKind = typeof PartitionKind;
26
+ export type PartitionKindId = keyof PartitionKind;
27
+ export type PartitionKindValue = ValueOf<PartitionKind>;
28
+ export type Balanced = {
29
+ kind: PartitionKind['Balanced'];
30
+ value: null;
31
+ };
32
+ export type PartitionId = {
33
+ kind: PartitionKind['PartitionId'];
34
+ value: number;
35
+ };
36
+ export type MessageKeyValue = string | number | bigint | Buffer;
37
+ export type MessageKey = {
38
+ kind: PartitionKind['MessageKey'];
39
+ value: MessageKeyValue;
40
+ };
41
+ export type Partitioning = Balanced | PartitionId | MessageKey;
42
+ export declare const Partitioning: {
43
+ Balanced: Balanced;
44
+ PartitionId: (id: number) => PartitionId;
45
+ MessageKey: (key: MessageKeyValue) => MessageKey;
46
+ };
47
+ export declare const serializeMessageKey: (v: MessageKeyValue) => Buffer<ArrayBuffer>;
48
+ export declare const serializePartitioningValue: (part: Partitioning) => Buffer;
49
+ export declare const default_partionning: Balanced;
50
+ export declare const serializePartitioning: (p?: Partitioning) => Buffer<ArrayBuffer>;
51
+ //# sourceMappingURL=partitioning.utils.d.ts.map