apache-iggy 0.8.1-edge.1 → 0.8.1-edge.3

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 (331) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +62 -1
  3. package/dist/client/client.config.d.ts +6 -0
  4. package/dist/client/client.config.js +40 -0
  5. package/dist/client/client.config.test.d.ts +2 -0
  6. package/dist/client/client.config.test.js +68 -0
  7. package/dist/client/client.connection.d.ts +29 -26
  8. package/dist/client/client.connection.js +249 -97
  9. package/dist/client/client.connection.test.d.ts +2 -0
  10. package/dist/client/client.connection.test.js +385 -0
  11. package/dist/client/client.d.ts +4 -22
  12. package/dist/client/client.debug.d.ts +0 -18
  13. package/dist/client/client.debug.js +17 -18
  14. package/dist/client/client.frame.d.ts +31 -0
  15. package/dist/client/client.frame.js +168 -0
  16. package/dist/client/client.frame.test.d.ts +2 -0
  17. package/dist/client/client.frame.test.js +110 -0
  18. package/dist/client/client.js +52 -52
  19. package/dist/client/client.socket.d.ts +28 -25
  20. package/dist/client/client.socket.js +313 -62
  21. package/dist/client/client.socket.test.d.ts +2 -0
  22. package/dist/client/client.socket.test.js +509 -0
  23. package/dist/client/client.type.d.ts +17 -19
  24. package/dist/client/client.type.js +17 -18
  25. package/dist/client/client.utils.d.ts +0 -18
  26. package/dist/client/client.utils.js +17 -18
  27. package/dist/client/client.utils.test.d.ts +0 -18
  28. package/dist/client/client.utils.test.js +17 -18
  29. package/dist/client/index.d.ts +1 -18
  30. package/dist/client/index.js +18 -18
  31. package/dist/client.e2e.d.ts +0 -18
  32. package/dist/client.e2e.js +17 -18
  33. package/dist/debug-send.d.ts +0 -18
  34. package/dist/debug-send.js +17 -18
  35. package/dist/debug.d.ts +0 -18
  36. package/dist/debug.js +17 -18
  37. package/dist/e2e/tcp.client.e2e.d.ts +0 -18
  38. package/dist/e2e/tcp.client.e2e.js +17 -18
  39. package/dist/e2e/tcp.cluster.e2e.d.ts +0 -18
  40. package/dist/e2e/tcp.cluster.e2e.js +17 -18
  41. package/dist/e2e/tcp.consumer-group.e2e.d.ts +0 -18
  42. package/dist/e2e/tcp.consumer-group.e2e.js +23 -20
  43. package/dist/e2e/tcp.consumer-stream.e2e.d.ts +0 -18
  44. package/dist/e2e/tcp.consumer-stream.e2e.js +22 -19
  45. package/dist/e2e/tcp.parallel.e2e.d.ts +0 -18
  46. package/dist/e2e/tcp.parallel.e2e.js +17 -18
  47. package/dist/e2e/tcp.raw.e2e.d.ts +2 -0
  48. package/dist/e2e/tcp.raw.e2e.js +54 -0
  49. package/dist/e2e/tcp.send-message.e2e.d.ts +0 -18
  50. package/dist/e2e/tcp.send-message.e2e.js +17 -18
  51. package/dist/e2e/tcp.stream.e2e.d.ts +0 -18
  52. package/dist/e2e/tcp.stream.e2e.js +17 -18
  53. package/dist/e2e/tcp.system.e2e.d.ts +0 -18
  54. package/dist/e2e/tcp.system.e2e.js +17 -18
  55. package/dist/e2e/tcp.token.e2e.d.ts +0 -18
  56. package/dist/e2e/tcp.token.e2e.js +17 -18
  57. package/dist/e2e/tcp.topic.e2e.d.ts +0 -18
  58. package/dist/e2e/tcp.topic.e2e.js +17 -18
  59. package/dist/e2e/tcp.user.e2e.d.ts +0 -18
  60. package/dist/e2e/tcp.user.e2e.js +51 -21
  61. package/dist/e2e/test-client.utils.d.ts +0 -18
  62. package/dist/e2e/test-client.utils.js +19 -18
  63. package/dist/e2e/tls.system.e2e.d.ts +0 -18
  64. package/dist/e2e/tls.system.e2e.js +17 -18
  65. package/dist/index.d.ts +3 -18
  66. package/dist/index.js +20 -18
  67. package/dist/stream/consumer-stream.d.ts +0 -18
  68. package/dist/stream/consumer-stream.js +22 -18
  69. package/dist/stream/index.d.ts +0 -18
  70. package/dist/stream/index.js +17 -18
  71. package/dist/tcp.e2e.d.ts +0 -18
  72. package/dist/tcp.e2e.js +17 -18
  73. package/dist/tcp.sm.utils.d.ts +0 -18
  74. package/dist/tcp.sm.utils.js +17 -18
  75. package/dist/tls.system.e2e.d.ts +0 -18
  76. package/dist/tls.system.e2e.js +17 -18
  77. package/dist/type.utils.d.ts +0 -18
  78. package/dist/type.utils.js +17 -18
  79. package/dist/wire/client/client.utils.d.ts +0 -18
  80. package/dist/wire/client/client.utils.js +17 -18
  81. package/dist/wire/client/get-client.command.d.ts +0 -18
  82. package/dist/wire/client/get-client.command.js +17 -18
  83. package/dist/wire/client/get-clients.command.d.ts +0 -18
  84. package/dist/wire/client/get-clients.command.js +17 -18
  85. package/dist/wire/client/get-me.command.d.ts +0 -18
  86. package/dist/wire/client/get-me.command.js +17 -18
  87. package/dist/wire/client/index.d.ts +0 -18
  88. package/dist/wire/client/index.js +17 -18
  89. package/dist/wire/cluster/cluster.type.d.ts +2 -20
  90. package/dist/wire/cluster/cluster.type.js +17 -18
  91. package/dist/wire/cluster/cluster.utils.d.ts +0 -18
  92. package/dist/wire/cluster/cluster.utils.js +17 -18
  93. package/dist/wire/cluster/get-cluster-metadata.command.d.ts +0 -18
  94. package/dist/wire/cluster/get-cluster-metadata.command.js +17 -18
  95. package/dist/wire/cluster/index.d.ts +0 -18
  96. package/dist/wire/cluster/index.js +17 -18
  97. package/dist/wire/command-set.d.ts +14 -23
  98. package/dist/wire/command-set.js +42 -19
  99. package/dist/wire/command-set.test.d.ts +2 -0
  100. package/dist/wire/command-set.test.js +95 -0
  101. package/dist/wire/command.code.d.ts +5 -18
  102. package/dist/wire/command.code.js +23 -19
  103. package/dist/wire/command.utils.d.ts +0 -18
  104. package/dist/wire/command.utils.js +22 -19
  105. package/dist/wire/command.utils.test.d.ts +2 -0
  106. package/dist/wire/command.utils.test.js +35 -0
  107. package/dist/wire/consumer-group/create-group.command.d.ts +0 -18
  108. package/dist/wire/consumer-group/create-group.command.js +17 -18
  109. package/dist/wire/consumer-group/create-group.command.test.d.ts +0 -18
  110. package/dist/wire/consumer-group/create-group.command.test.js +17 -18
  111. package/dist/wire/consumer-group/delete-group.command.d.ts +4 -31
  112. package/dist/wire/consumer-group/delete-group.command.js +18 -19
  113. package/dist/wire/consumer-group/ensure-group.virtual.command.d.ts +0 -18
  114. package/dist/wire/consumer-group/ensure-group.virtual.command.js +17 -18
  115. package/dist/wire/consumer-group/get-group.command.d.ts +4 -32
  116. package/dist/wire/consumer-group/get-group.command.js +17 -18
  117. package/dist/wire/consumer-group/get-groups.command.d.ts +0 -18
  118. package/dist/wire/consumer-group/get-groups.command.js +17 -18
  119. package/dist/wire/consumer-group/group.command.test.d.ts +0 -18
  120. package/dist/wire/consumer-group/group.command.test.js +17 -18
  121. package/dist/wire/consumer-group/group.utils.d.ts +6 -18
  122. package/dist/wire/consumer-group/group.utils.js +17 -18
  123. package/dist/wire/consumer-group/index.d.ts +1 -18
  124. package/dist/wire/consumer-group/index.js +18 -18
  125. package/dist/wire/consumer-group/join-group.command.d.ts +4 -31
  126. package/dist/wire/consumer-group/join-group.command.js +18 -19
  127. package/dist/wire/consumer-group/leave-group.command.d.ts +4 -31
  128. package/dist/wire/consumer-group/leave-group.command.js +18 -19
  129. package/dist/wire/consumer-group/sync-group.command.d.ts +17 -0
  130. package/dist/wire/consumer-group/sync-group.command.js +45 -0
  131. package/dist/wire/consumer-group/sync-group.command.test.d.ts +2 -0
  132. package/dist/wire/consumer-group/sync-group.command.test.js +71 -0
  133. package/dist/wire/error.code.d.ts +0 -18
  134. package/dist/wire/error.code.js +27 -40
  135. package/dist/wire/error.code.test.d.ts +2 -0
  136. package/dist/wire/error.code.test.js +33 -0
  137. package/dist/wire/error.utils.d.ts +6 -19
  138. package/dist/wire/error.utils.js +30 -20
  139. package/dist/wire/identifier.utils.d.ts +0 -18
  140. package/dist/wire/identifier.utils.js +17 -18
  141. package/dist/wire/identifier.utils.test.d.ts +0 -18
  142. package/dist/wire/identifier.utils.test.js +17 -18
  143. package/dist/wire/index.d.ts +0 -18
  144. package/dist/wire/index.js +17 -18
  145. package/dist/wire/message/flush-unsaved-buffers.command.d.ts +0 -18
  146. package/dist/wire/message/flush-unsaved-buffers.command.js +17 -18
  147. package/dist/wire/message/header.type.d.ts +1 -19
  148. package/dist/wire/message/header.type.js +17 -18
  149. package/dist/wire/message/header.utils.d.ts +0 -18
  150. package/dist/wire/message/header.utils.js +17 -18
  151. package/dist/wire/message/header.utils.test.d.ts +0 -18
  152. package/dist/wire/message/header.utils.test.js +17 -18
  153. package/dist/wire/message/iggy-header.utils.d.ts +0 -18
  154. package/dist/wire/message/iggy-header.utils.js +17 -18
  155. package/dist/wire/message/index.d.ts +0 -18
  156. package/dist/wire/message/index.js +17 -18
  157. package/dist/wire/message/message.utils.d.ts +0 -18
  158. package/dist/wire/message/message.utils.js +17 -18
  159. package/dist/wire/message/partitioning.utils.d.ts +0 -18
  160. package/dist/wire/message/partitioning.utils.js +17 -18
  161. package/dist/wire/message/poll-messages.command.d.ts +5 -21
  162. package/dist/wire/message/poll-messages.command.js +168 -20
  163. package/dist/wire/message/poll-messages.command.test.d.ts +2 -0
  164. package/dist/wire/message/poll-messages.command.test.js +301 -0
  165. package/dist/wire/message/poll.utils.d.ts +0 -18
  166. package/dist/wire/message/poll.utils.js +17 -18
  167. package/dist/wire/message/send-messages.command.d.ts +0 -18
  168. package/dist/wire/message/send-messages.command.js +17 -18
  169. package/dist/wire/message/send-messages.command.test.d.ts +0 -18
  170. package/dist/wire/message/send-messages.command.test.js +17 -18
  171. package/dist/wire/number.utils.d.ts +0 -18
  172. package/dist/wire/number.utils.js +17 -18
  173. package/dist/wire/offset/delete-offset.command.d.ts +0 -18
  174. package/dist/wire/offset/delete-offset.command.js +17 -18
  175. package/dist/wire/offset/get-offset.command.d.ts +1 -19
  176. package/dist/wire/offset/get-offset.command.js +17 -18
  177. package/dist/wire/offset/index.d.ts +0 -18
  178. package/dist/wire/offset/index.js +17 -18
  179. package/dist/wire/offset/offset.utils.d.ts +2 -20
  180. package/dist/wire/offset/offset.utils.js +19 -20
  181. package/dist/wire/offset/store-offset.command.d.ts +1 -19
  182. package/dist/wire/offset/store-offset.command.js +17 -18
  183. package/dist/wire/partition/create-partition.command.d.ts +0 -18
  184. package/dist/wire/partition/create-partition.command.js +17 -18
  185. package/dist/wire/partition/delete-partition.command.d.ts +0 -18
  186. package/dist/wire/partition/delete-partition.command.js +17 -18
  187. package/dist/wire/partition/index.d.ts +0 -18
  188. package/dist/wire/partition/index.js +17 -18
  189. package/dist/wire/partition/partition.utils.d.ts +0 -18
  190. package/dist/wire/partition/partition.utils.js +17 -18
  191. package/dist/wire/partition/partition.utils.test.d.ts +0 -18
  192. package/dist/wire/partition/partition.utils.test.js +17 -18
  193. package/dist/wire/segment/delete-segments.command.d.ts +0 -18
  194. package/dist/wire/segment/delete-segments.command.js +17 -18
  195. package/dist/wire/segment/index.d.ts +0 -18
  196. package/dist/wire/segment/index.js +17 -18
  197. package/dist/wire/segment/segment.utils.d.ts +0 -18
  198. package/dist/wire/segment/segment.utils.js +17 -18
  199. package/dist/wire/serialize.utils.d.ts +0 -18
  200. package/dist/wire/serialize.utils.js +17 -18
  201. package/dist/wire/session/index.d.ts +0 -18
  202. package/dist/wire/session/index.js +17 -18
  203. package/dist/wire/session/login-with-token.command.d.ts +0 -18
  204. package/dist/wire/session/login-with-token.command.js +17 -18
  205. package/dist/wire/session/login-with-token.command.test.d.ts +0 -18
  206. package/dist/wire/session/login-with-token.command.test.js +17 -18
  207. package/dist/wire/session/login.command.d.ts +0 -18
  208. package/dist/wire/session/login.command.js +17 -18
  209. package/dist/wire/session/login.command.test.d.ts +0 -18
  210. package/dist/wire/session/login.command.test.js +17 -18
  211. package/dist/wire/session/login.utils.d.ts +0 -18
  212. package/dist/wire/session/login.utils.js +17 -18
  213. package/dist/wire/session/logout.command.d.ts +0 -18
  214. package/dist/wire/session/logout.command.js +17 -18
  215. package/dist/wire/stream/create-stream.command.d.ts +0 -18
  216. package/dist/wire/stream/create-stream.command.js +17 -18
  217. package/dist/wire/stream/create-stream.command.test.d.ts +0 -18
  218. package/dist/wire/stream/create-stream.command.test.js +17 -18
  219. package/dist/wire/stream/delete-stream.command.d.ts +0 -18
  220. package/dist/wire/stream/delete-stream.command.js +17 -18
  221. package/dist/wire/stream/ensure-stream.virtual.command.d.ts +0 -18
  222. package/dist/wire/stream/ensure-stream.virtual.command.js +17 -18
  223. package/dist/wire/stream/get-stream.command.d.ts +0 -18
  224. package/dist/wire/stream/get-stream.command.js +17 -18
  225. package/dist/wire/stream/get-streams.command.d.ts +0 -18
  226. package/dist/wire/stream/get-streams.command.js +17 -18
  227. package/dist/wire/stream/index.d.ts +0 -18
  228. package/dist/wire/stream/index.js +17 -18
  229. package/dist/wire/stream/purge-stream.command.d.ts +0 -18
  230. package/dist/wire/stream/purge-stream.command.js +17 -18
  231. package/dist/wire/stream/stream.utils.d.ts +0 -18
  232. package/dist/wire/stream/stream.utils.js +17 -18
  233. package/dist/wire/stream/update-stream.command.d.ts +0 -18
  234. package/dist/wire/stream/update-stream.command.js +17 -18
  235. package/dist/wire/system/get-stats.command.d.ts +0 -18
  236. package/dist/wire/system/get-stats.command.js +17 -18
  237. package/dist/wire/system/index.d.ts +0 -18
  238. package/dist/wire/system/index.js +17 -18
  239. package/dist/wire/system/ping.command.d.ts +0 -18
  240. package/dist/wire/system/ping.command.js +17 -18
  241. package/dist/wire/token/create-token.command.d.ts +0 -18
  242. package/dist/wire/token/create-token.command.js +17 -18
  243. package/dist/wire/token/create-token.command.test.d.ts +0 -18
  244. package/dist/wire/token/create-token.command.test.js +17 -18
  245. package/dist/wire/token/delete-token.command.d.ts +0 -18
  246. package/dist/wire/token/delete-token.command.js +17 -18
  247. package/dist/wire/token/delete-token.command.test.d.ts +0 -18
  248. package/dist/wire/token/delete-token.command.test.js +17 -18
  249. package/dist/wire/token/get-tokens.command.d.ts +0 -18
  250. package/dist/wire/token/get-tokens.command.js +17 -18
  251. package/dist/wire/token/index.d.ts +0 -18
  252. package/dist/wire/token/index.js +17 -18
  253. package/dist/wire/token/token.utils.d.ts +0 -18
  254. package/dist/wire/token/token.utils.js +17 -18
  255. package/dist/wire/topic/create-topic.command.d.ts +0 -18
  256. package/dist/wire/topic/create-topic.command.js +17 -18
  257. package/dist/wire/topic/create-topic.command.test.d.ts +0 -18
  258. package/dist/wire/topic/create-topic.command.test.js +17 -18
  259. package/dist/wire/topic/delete-topic.command.d.ts +0 -18
  260. package/dist/wire/topic/delete-topic.command.js +17 -18
  261. package/dist/wire/topic/ensure-topic.virtual.command.d.ts +0 -18
  262. package/dist/wire/topic/ensure-topic.virtual.command.js +17 -18
  263. package/dist/wire/topic/get-topic.command.d.ts +0 -18
  264. package/dist/wire/topic/get-topic.command.js +17 -18
  265. package/dist/wire/topic/get-topics.command.d.ts +0 -18
  266. package/dist/wire/topic/get-topics.command.js +17 -18
  267. package/dist/wire/topic/index.d.ts +0 -18
  268. package/dist/wire/topic/index.js +17 -18
  269. package/dist/wire/topic/purge-topic.command.d.ts +0 -18
  270. package/dist/wire/topic/purge-topic.command.js +17 -18
  271. package/dist/wire/topic/topic.utils.d.ts +0 -18
  272. package/dist/wire/topic/topic.utils.js +19 -20
  273. package/dist/wire/topic/topic.utils.test.d.ts +2 -0
  274. package/dist/wire/topic/topic.utils.test.js +42 -0
  275. package/dist/wire/topic/update-topic.command.d.ts +0 -18
  276. package/dist/wire/topic/update-topic.command.js +17 -18
  277. package/dist/wire/user/change-password.command.d.ts +0 -18
  278. package/dist/wire/user/change-password.command.js +17 -18
  279. package/dist/wire/user/create-user.command.d.ts +0 -18
  280. package/dist/wire/user/create-user.command.js +25 -21
  281. package/dist/wire/user/create-user.command.test.d.ts +0 -18
  282. package/dist/wire/user/create-user.command.test.js +45 -22
  283. package/dist/wire/user/delete-user.command.d.ts +0 -18
  284. package/dist/wire/user/delete-user.command.js +17 -18
  285. package/dist/wire/user/get-user.command.d.ts +0 -18
  286. package/dist/wire/user/get-user.command.js +17 -18
  287. package/dist/wire/user/get-users.command.d.ts +0 -18
  288. package/dist/wire/user/get-users.command.js +17 -18
  289. package/dist/wire/user/index.d.ts +0 -18
  290. package/dist/wire/user/index.js +17 -18
  291. package/dist/wire/user/permissions.utils.d.ts +2 -21
  292. package/dist/wire/user/permissions.utils.js +48 -48
  293. package/dist/wire/user/permissions.utils.test.d.ts +0 -18
  294. package/dist/wire/user/permissions.utils.test.js +106 -36
  295. package/dist/wire/user/update-permissions.command.d.ts +0 -18
  296. package/dist/wire/user/update-permissions.command.js +17 -18
  297. package/dist/wire/user/update-user.command.d.ts +0 -18
  298. package/dist/wire/user/update-user.command.js +17 -18
  299. package/dist/wire/user/user.utils.d.ts +0 -18
  300. package/dist/wire/user/user.utils.js +17 -18
  301. package/dist/wire/uuid.utils.d.ts +0 -18
  302. package/dist/wire/uuid.utils.js +17 -18
  303. package/dist/wire/vsr/header.d.ts +108 -0
  304. package/dist/wire/vsr/header.js +121 -0
  305. package/dist/wire/vsr/header.test.d.ts +2 -0
  306. package/dist/wire/vsr/header.test.js +75 -0
  307. package/dist/wire/vsr/index.d.ts +18 -0
  308. package/dist/wire/vsr/index.js +120 -0
  309. package/dist/wire/vsr/namespace.d.ts +19 -0
  310. package/dist/wire/vsr/namespace.js +177 -0
  311. package/dist/wire/vsr/namespace.test.d.ts +2 -0
  312. package/dist/wire/vsr/namespace.test.js +133 -0
  313. package/dist/wire/vsr/operation.d.ts +65 -0
  314. package/dist/wire/vsr/operation.js +144 -0
  315. package/dist/wire/vsr/operation.test.d.ts +2 -0
  316. package/dist/wire/vsr/operation.test.js +92 -0
  317. package/dist/wire/vsr/register.d.ts +27 -0
  318. package/dist/wire/vsr/register.js +90 -0
  319. package/dist/wire/vsr/register.test.d.ts +2 -0
  320. package/dist/wire/vsr/register.test.js +67 -0
  321. package/dist/wire/vsr/reply.d.ts +32 -0
  322. package/dist/wire/vsr/reply.js +151 -0
  323. package/dist/wire/vsr/reply.test.d.ts +2 -0
  324. package/dist/wire/vsr/reply.test.js +120 -0
  325. package/dist/wire/vsr/session.d.ts +38 -0
  326. package/dist/wire/vsr/session.js +105 -0
  327. package/dist/wire/vsr/session.test.d.ts +2 -0
  328. package/dist/wire/vsr/session.test.js +60 -0
  329. package/dist/wire/vsr/vsr.test.d.ts +2 -0
  330. package/dist/wire/vsr/vsr.test.js +72 -0
  331. package/package.json +14 -12
package/LICENSE CHANGED
@@ -198,4 +198,4 @@
198
198
  distributed under the License is distributed on an "AS IS" BASIS,
199
199
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
200
  See the License for the specific language governing permissions and
201
- limitations under the License.
201
+ limitations under the License.
package/README.md CHANGED
@@ -30,6 +30,66 @@ npm i --save apache-iggy
30
30
 
31
31
  ## basic usage
32
32
 
33
+ ### Response frame limit
34
+
35
+ **Compatibility note:** response frames larger than `maxResponseFrameSize` (default 64 MiB) are now rejected and close the connection under both framing modes. This is a behavior change for existing classic-framing clients. Raise the limit in the client configuration when polling very large batches.
36
+
37
+ ### VSR framing
38
+
39
+ Classic framing remains the default. Select VSR explicitly when connecting to
40
+ an Iggy VSR server:
41
+
42
+ ```typescript
43
+ import { SimpleClient, getRawClient } from "apache-iggy";
44
+
45
+ const config = {
46
+ protocol: "vsr" as const,
47
+ transport: "TCP" as const,
48
+ options: { host: "127.0.0.1", port: 8090 },
49
+ credentials: { username: "iggy", password: "iggy" },
50
+ };
51
+ const client = new SimpleClient(getRawClient(config));
52
+ const stats = await client.system.getStats();
53
+ ```
54
+
55
+ VSR is a runtime protocol choice in Node.js, not a build feature. Codes absent
56
+ from the SDK command table use `Operation::NonReplicated` and carry the command
57
+ code in the request header's reserved field. The server remains authoritative
58
+ for classifying or rejecting extension commands.
59
+
60
+ The same npm package supports both framing modes. VSR currently supports TCP
61
+ only and restricts `Client` to one pooled connection because authentication,
62
+ request sequencing, and consumer-group assignments belong to one consensus
63
+ session. Configurations requesting VSR over TLS or more than one pooled
64
+ connection fail before a socket is opened.
65
+
66
+ VSR authentication translates the existing password and personal-access-token
67
+ login APIs into the register handshake required by the consensus protocol. A
68
+ disconnect or eviction invalidates the session, and later work must register a
69
+ new session. Transient not-committed responses retry the exact encoded request
70
+ within one bounded deadline. A disconnected mutation is never replayed under a
71
+ new session.
72
+
73
+ When the server's `[heartbeat]` eviction is enabled, configure the client's `heartbeatInterval` below the server heartbeat interval. Client heartbeats are disabled when `heartbeatInterval` is unset.
74
+
75
+ `sendBinaryRequest(code, payload)` has the same signature under classic and VSR framing. Known replicated commands use their registered operation, while unknown codes reach the server as non-replicated requests and are rejected by servers that do not register them. Classic request bytes remain unchanged.
76
+
77
+ ```typescript
78
+ import { ResponseError } from "apache-iggy";
79
+
80
+ try {
81
+ await client.sendBinaryRequest(60_000, Buffer.from("opaque request"));
82
+ } catch (error) {
83
+ if (error instanceof ResponseError) {
84
+ console.error(error.commandCode, error.errorCode);
85
+ }
86
+ }
87
+ ```
88
+
89
+ The client includes its npm package version and the binary protocol crate
90
+ version in VSR registration. An incompatible server rejects registration with
91
+ a protocol-version error instead of accepting a mismatched wire contract.
92
+
33
93
  ```ts
34
94
  import { Client } from "apache-iggy";
35
95
 
@@ -60,7 +120,8 @@ npm run build
60
120
 
61
121
  ### test
62
122
 
63
- note: use env var `IGGY_TCP_ADDRESS="host:port"` to set server address for bdd and e2e tests.
123
+ note: use env var `IGGY_TCP_ADDRESS="host:port"` to set the server
124
+ address for bdd and e2e tests.
64
125
 
65
126
  #### unit tests
66
127
 
@@ -0,0 +1,6 @@
1
+ import type { ClientConfig, Protocol } from './client.type.js';
2
+ export declare const DEFAULT_MAX_RESPONSE_FRAME_SIZE: number;
3
+ export declare const normalizeClientConfig: (config: ClientConfig) => ClientConfig & {
4
+ protocol: Protocol;
5
+ };
6
+ //# sourceMappingURL=client.config.d.ts.map
@@ -0,0 +1,40 @@
1
+ // Licensed to the Apache Software Foundation (ASF) under one
2
+ // or more contributor license agreements. See the NOTICE file
3
+ // distributed with this work for additional information
4
+ // regarding copyright ownership. The ASF licenses this file
5
+ // to you under the Apache License, Version 2.0 (the
6
+ // "License"); you may not use this file except in compliance
7
+ // with the License. You may obtain a copy of the License at
8
+ //
9
+ // http://www.apache.org/licenses/LICENSE-2.0
10
+ //
11
+ // Unless required by applicable law or agreed to in writing,
12
+ // software distributed under the License is distributed on an
13
+ // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ // KIND, either express or implied. See the License for the
15
+ // specific language governing permissions and limitations
16
+ // under the License.
17
+ export const DEFAULT_MAX_RESPONSE_FRAME_SIZE = 64 * 1024 * 1024;
18
+ const isProtocol = (value) => value === 'classic' || value === 'vsr';
19
+ export const normalizeClientConfig = (config) => {
20
+ const protocol = config.protocol ?? 'classic';
21
+ if (!isProtocol(protocol))
22
+ throw new TypeError(`unsupported wire protocol: ${String(protocol)}`);
23
+ const maxResponseFrameSize = config.maxResponseFrameSize ?? DEFAULT_MAX_RESPONSE_FRAME_SIZE;
24
+ if (!Number.isSafeInteger(maxResponseFrameSize) ||
25
+ maxResponseFrameSize < 256)
26
+ throw new TypeError('maxResponseFrameSize must be a safe integer of at least 256 bytes');
27
+ if (protocol === 'vsr' && config.transport === 'TLS')
28
+ throw new TypeError('VSR framing currently supports the TCP transport only');
29
+ if (protocol === 'vsr' &&
30
+ ((config.poolSize?.min ?? 1) > 1 || (config.poolSize?.max ?? 1) > 1))
31
+ throw new TypeError('VSR clients currently support exactly one pooled connection');
32
+ return {
33
+ ...config,
34
+ protocol,
35
+ options: { ...config.options },
36
+ maxResponseFrameSize,
37
+ ...(protocol === 'vsr' ? { poolSize: { min: 1, max: 1 } } : {})
38
+ };
39
+ };
40
+ //# sourceMappingURL=client.config.js.map
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=client.config.test.d.ts.map
@@ -0,0 +1,68 @@
1
+ // Licensed to the Apache Software Foundation (ASF) under one
2
+ // or more contributor license agreements. See the NOTICE file
3
+ // distributed with this work for additional information
4
+ // regarding copyright ownership. The ASF licenses this file
5
+ // to you under the Apache License, Version 2.0 (the
6
+ // "License"); you may not use this file except in compliance
7
+ // with the License. You may obtain a copy of the License at
8
+ //
9
+ // http://www.apache.org/licenses/LICENSE-2.0
10
+ //
11
+ // Unless required by applicable law or agreed to in writing,
12
+ // software distributed under the License is distributed on an
13
+ // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ // KIND, either express or implied. See the License for the
15
+ // specific language governing permissions and limitations
16
+ // under the License.
17
+ import assert from 'node:assert/strict';
18
+ import { describe, it } from 'node:test';
19
+ import { DEFAULT_MAX_RESPONSE_FRAME_SIZE, normalizeClientConfig } from './client.config.js';
20
+ const config = () => ({
21
+ transport: 'TCP',
22
+ options: { host: '127.0.0.1', port: 8090 },
23
+ credentials: { username: 'iggy', password: 'iggy' }
24
+ });
25
+ describe('normalizeClientConfig', () => {
26
+ it('defaults to classic without changing classic pool sizing', () => {
27
+ const normalized = normalizeClientConfig({
28
+ ...config(),
29
+ poolSize: { min: 2, max: 4 }
30
+ });
31
+ assert.equal(normalized.protocol, 'classic');
32
+ assert.deepEqual(normalized.poolSize, { min: 2, max: 4 });
33
+ assert.equal(normalized.maxResponseFrameSize, DEFAULT_MAX_RESPONSE_FRAME_SIZE);
34
+ });
35
+ it('restricts VSR to one pooled connection', () => {
36
+ const normalized = normalizeClientConfig({
37
+ ...config(),
38
+ protocol: 'vsr'
39
+ });
40
+ assert.deepEqual(normalized.poolSize, { min: 1, max: 1 });
41
+ assert.throws(() => normalizeClientConfig({
42
+ ...config(),
43
+ protocol: 'vsr',
44
+ poolSize: { max: 2 }
45
+ }), /exactly one pooled connection/);
46
+ });
47
+ it('rejects invalid protocols before opening a socket', () => {
48
+ assert.throws(() => normalizeClientConfig({
49
+ ...config(),
50
+ protocol: 'auto'
51
+ }), /unsupported wire protocol/);
52
+ });
53
+ it('rejects VSR over an untested TLS transport', () => {
54
+ assert.throws(() => normalizeClientConfig({
55
+ ...config(),
56
+ protocol: 'vsr',
57
+ transport: 'TLS'
58
+ }), /TCP transport only/);
59
+ });
60
+ it('rejects unsafe response frame limits', () => {
61
+ for (const maxResponseFrameSize of [0, 255, 1.5, Number.MAX_VALUE])
62
+ assert.throws(() => normalizeClientConfig({
63
+ ...config(),
64
+ maxResponseFrameSize
65
+ }), /maxResponseFrameSize/);
66
+ });
67
+ });
68
+ //# sourceMappingURL=client.config.test.js.map
@@ -1,21 +1,3 @@
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
1
  import { EventEmitter } from 'node:events';
20
2
  import type { Socket } from 'node:net';
21
3
  import type { ClientConfig } from "./client.type.js";
@@ -34,34 +16,54 @@ export declare class IggyConnection extends EventEmitter {
34
16
  connecting: boolean;
35
17
  /** Whether the connection is being intentionally closed */
36
18
  ending: boolean;
37
- /** Whether waiting for more data to complete a response */
38
- private waitingResponseEnd;
39
19
  /** Reconnection configuration */
40
20
  private reconnectOption;
41
21
  /** Number of reconnection attempts made */
42
22
  private reconnectCount;
43
- /** Buffer for incomplete response data */
44
- private readBuffers;
23
+ /** Shared promise for concurrent callers waiting on one connection attempt */
24
+ private connectPromise?;
25
+ /** Shared promise for callers waiting on automatic reconnection */
26
+ private reconnectPromise?;
27
+ /** Endpoint the client was configured with, kept across leader redirects */
28
+ private readonly seedOptions;
29
+ /** Incremental response frame decoder */
30
+ private responseDecoder;
45
31
  /**
46
32
  * Creates a new IggyConnection.
47
33
  *
48
34
  * @param config - Client configuration
49
35
  */
50
36
  constructor(config: ClientConfig);
37
+ /**
38
+ * Attaches the lifecycle listeners exactly once per socket instance.
39
+ * Attaching them in `connect()` would stack duplicate handlers whenever a
40
+ * failed attempt is retried on the same socket.
41
+ */
42
+ private _installSocket;
51
43
  /**
52
44
  * Establishes the connection to the server.
53
- * Sets up event handlers for data, errors, and disconnection.
54
45
  *
55
46
  * @returns Promise that resolves when connected
56
47
  */
57
- connect(): Promise<unknown>;
48
+ connect(): Promise<this>;
49
+ private _waitForConnection;
58
50
  /**
59
51
  * Attempts to reconnect to the server.
60
52
  * Respects maxRetries limit and emits error when exceeded.
61
53
  *
62
54
  * @param err - Optional error that triggered the reconnection
63
55
  */
64
- reconnect(err?: Error): Promise<boolean | undefined>;
56
+ reconnect(err?: Error): Promise<this | undefined>;
57
+ private _reconnectUntilConnected;
58
+ /**
59
+ * Alternates reconnect dials between the current endpoint and the
60
+ * configured seed. After a leader redirect the current endpoint may die
61
+ * with the leader, and the seed is the way back to the rest of the cluster.
62
+ */
63
+ private _reconnectTarget;
64
+ redirect(host: string, port: number): Promise<void>;
65
+ abort(): void;
66
+ isConnectedTo(host: string, port: number): boolean;
65
67
  /**
66
68
  * Destroys the connection and marks it as ending.
67
69
  */
@@ -84,6 +86,7 @@ export declare class IggyConnection extends EventEmitter {
84
86
  * @param payload - Command payload
85
87
  * @returns True if the write was successful
86
88
  */
87
- writeCommand(command: number, payload: Buffer): boolean;
89
+ writeCommand(command: number, payload: Buffer): void;
90
+ writeFrame(frame: Buffer): void;
88
91
  }
89
92
  //# sourceMappingURL=client.connection.d.ts.map