@hotmeshio/hotmesh 0.0.4 → 0.0.5

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 (353) hide show
  1. package/README.md +2 -2
  2. package/build/{package.json → cjs/package.json} +12 -5
  3. package/build/{services → cjs/services}/activities/trigger.js +2 -2
  4. package/build/{services → cjs/services}/connector/index.js +3 -3
  5. package/build/{services → cjs/services}/durable/client.js +2 -2
  6. package/build/{services → cjs/services}/durable/connection.js +2 -2
  7. package/build/{services → cjs/services}/hotmesh/index.js +2 -2
  8. package/build/{services → cjs/services}/mapper/index.d.ts +3 -3
  9. package/build/{services → cjs/services}/store/index.js +1 -1
  10. package/build/esm/index.d.ts +4 -0
  11. package/build/esm/index.js +3 -0
  12. package/build/esm/modules/errors.d.ts +28 -0
  13. package/build/esm/modules/errors.js +41 -0
  14. package/build/esm/modules/key.d.ts +75 -0
  15. package/build/esm/modules/key.js +111 -0
  16. package/build/esm/modules/utils.d.ts +34 -0
  17. package/build/esm/modules/utils.js +154 -0
  18. package/build/esm/package.json +80 -0
  19. package/build/esm/services/activities/activity.d.ts +61 -0
  20. package/build/esm/services/activities/activity.js +411 -0
  21. package/build/esm/services/activities/await.d.ts +16 -0
  22. package/build/esm/services/activities/await.js +140 -0
  23. package/build/esm/services/activities/emit.d.ts +9 -0
  24. package/build/esm/services/activities/emit.js +10 -0
  25. package/build/esm/services/activities/index.d.ts +15 -0
  26. package/build/esm/services/activities/index.js +14 -0
  27. package/build/esm/services/activities/iterate.d.ts +9 -0
  28. package/build/esm/services/activities/iterate.js +10 -0
  29. package/build/esm/services/activities/trigger.d.ts +22 -0
  30. package/build/esm/services/activities/trigger.js +158 -0
  31. package/build/esm/services/activities/worker.d.ts +17 -0
  32. package/build/esm/services/activities/worker.js +162 -0
  33. package/build/esm/services/collator/index.d.ts +56 -0
  34. package/build/esm/services/collator/index.js +191 -0
  35. package/build/esm/services/compiler/deployer.d.ts +36 -0
  36. package/build/esm/services/compiler/deployer.js +423 -0
  37. package/build/esm/services/compiler/index.d.ts +30 -0
  38. package/build/esm/services/compiler/index.js +82 -0
  39. package/build/esm/services/compiler/validator.d.ts +32 -0
  40. package/build/esm/services/compiler/validator.js +131 -0
  41. package/build/esm/services/connector/clients/ioredis.d.ts +13 -0
  42. package/build/esm/services/connector/clients/ioredis.js +47 -0
  43. package/build/esm/services/connector/clients/redis.d.ts +13 -0
  44. package/build/esm/services/connector/clients/redis.js +59 -0
  45. package/build/esm/services/connector/index.d.ts +5 -0
  46. package/build/esm/services/connector/index.js +27 -0
  47. package/build/esm/services/dimension/index.d.ts +29 -0
  48. package/build/esm/services/dimension/index.js +32 -0
  49. package/build/esm/services/durable/asyncLocalStorage.d.ts +3 -0
  50. package/build/esm/services/durable/asyncLocalStorage.js +2 -0
  51. package/build/esm/services/durable/client.d.ts +15 -0
  52. package/build/esm/services/durable/client.js +114 -0
  53. package/build/esm/services/durable/connection.d.ts +4 -0
  54. package/build/esm/services/durable/connection.js +47 -0
  55. package/build/esm/services/durable/factory.d.ts +3 -0
  56. package/build/esm/services/durable/factory.js +119 -0
  57. package/build/esm/services/durable/handle.d.ts +8 -0
  58. package/build/esm/services/durable/handle.js +34 -0
  59. package/build/esm/services/durable/index.d.ts +57 -0
  60. package/build/esm/services/durable/index.js +55 -0
  61. package/build/esm/services/durable/native.d.ts +4 -0
  62. package/build/esm/services/durable/native.js +43 -0
  63. package/build/esm/services/durable/worker.d.ts +36 -0
  64. package/build/esm/services/durable/worker.js +258 -0
  65. package/build/esm/services/durable/workflow.d.ts +6 -0
  66. package/build/esm/services/durable/workflow.js +128 -0
  67. package/build/esm/services/engine/index.d.ts +82 -0
  68. package/build/esm/services/engine/index.js +522 -0
  69. package/build/esm/services/hotmesh/index.d.ts +45 -0
  70. package/build/esm/services/hotmesh/index.js +131 -0
  71. package/build/esm/services/logger/index.d.ts +17 -0
  72. package/build/esm/services/logger/index.js +70 -0
  73. package/build/esm/services/mapper/index.d.ts +24 -0
  74. package/build/esm/services/mapper/index.js +69 -0
  75. package/build/esm/services/pipe/functions/array.d.ts +24 -0
  76. package/build/esm/services/pipe/functions/array.js +66 -0
  77. package/build/esm/services/pipe/functions/bitwise.d.ts +9 -0
  78. package/build/esm/services/pipe/functions/bitwise.js +21 -0
  79. package/build/esm/services/pipe/functions/conditional.d.ts +10 -0
  80. package/build/esm/services/pipe/functions/conditional.js +24 -0
  81. package/build/esm/services/pipe/functions/date.d.ts +57 -0
  82. package/build/esm/services/pipe/functions/date.js +164 -0
  83. package/build/esm/services/pipe/functions/index.d.ts +25 -0
  84. package/build/esm/services/pipe/functions/index.js +24 -0
  85. package/build/esm/services/pipe/functions/json.d.ts +5 -0
  86. package/build/esm/services/pipe/functions/json.js +9 -0
  87. package/build/esm/services/pipe/functions/math.d.ts +38 -0
  88. package/build/esm/services/pipe/functions/math.js +108 -0
  89. package/build/esm/services/pipe/functions/number.d.ts +25 -0
  90. package/build/esm/services/pipe/functions/number.js +130 -0
  91. package/build/esm/services/pipe/functions/object.d.ts +22 -0
  92. package/build/esm/services/pipe/functions/object.js +60 -0
  93. package/build/esm/services/pipe/functions/string.d.ts +23 -0
  94. package/build/esm/services/pipe/functions/string.js +66 -0
  95. package/build/esm/services/pipe/functions/symbol.d.ts +12 -0
  96. package/build/esm/services/pipe/functions/symbol.js +30 -0
  97. package/build/esm/services/pipe/functions/unary.d.ts +7 -0
  98. package/build/esm/services/pipe/functions/unary.js +15 -0
  99. package/build/esm/services/pipe/index.d.ts +30 -0
  100. package/build/esm/services/pipe/index.js +122 -0
  101. package/build/esm/services/quorum/index.d.ts +34 -0
  102. package/build/esm/services/quorum/index.js +144 -0
  103. package/build/esm/services/reporter/index.d.ts +47 -0
  104. package/build/esm/services/reporter/index.js +327 -0
  105. package/build/esm/services/serializer/index.d.ts +41 -0
  106. package/build/esm/services/serializer/index.js +251 -0
  107. package/build/esm/services/signaler/store.d.ts +15 -0
  108. package/build/esm/services/signaler/store.js +50 -0
  109. package/build/esm/services/signaler/stream.d.ts +43 -0
  110. package/build/esm/services/signaler/stream.js +315 -0
  111. package/build/esm/services/store/cache.d.ts +66 -0
  112. package/build/esm/services/store/cache.js +124 -0
  113. package/build/esm/services/store/clients/ioredis.d.ts +27 -0
  114. package/build/esm/services/store/clients/ioredis.js +93 -0
  115. package/build/esm/services/store/clients/redis.d.ts +29 -0
  116. package/build/esm/services/store/clients/redis.js +140 -0
  117. package/build/esm/services/store/index.d.ts +88 -0
  118. package/build/esm/services/store/index.js +623 -0
  119. package/build/esm/services/stream/clients/ioredis.d.ts +23 -0
  120. package/build/esm/services/stream/clients/ioredis.js +112 -0
  121. package/build/esm/services/stream/clients/redis.d.ts +23 -0
  122. package/build/esm/services/stream/clients/redis.js +116 -0
  123. package/build/esm/services/stream/index.d.ts +21 -0
  124. package/build/esm/services/stream/index.js +6 -0
  125. package/build/esm/services/sub/clients/ioredis.d.ts +20 -0
  126. package/build/esm/services/sub/clients/ioredis.js +69 -0
  127. package/build/esm/services/sub/clients/redis.d.ts +20 -0
  128. package/build/esm/services/sub/clients/redis.js +60 -0
  129. package/build/esm/services/sub/index.d.ts +18 -0
  130. package/build/esm/services/sub/index.js +6 -0
  131. package/build/esm/services/task/index.d.ts +18 -0
  132. package/build/esm/services/task/index.js +70 -0
  133. package/build/esm/services/telemetry/index.d.ts +49 -0
  134. package/build/esm/services/telemetry/index.js +217 -0
  135. package/build/esm/services/worker/index.d.ts +30 -0
  136. package/build/esm/services/worker/index.js +102 -0
  137. package/build/esm/types/activity.d.ts +87 -0
  138. package/build/esm/types/activity.js +1 -0
  139. package/build/esm/types/app.d.ts +16 -0
  140. package/build/esm/types/app.js +1 -0
  141. package/build/esm/types/async.d.ts +5 -0
  142. package/build/esm/types/async.js +1 -0
  143. package/build/esm/types/cache.d.ts +1 -0
  144. package/build/esm/types/cache.js +1 -0
  145. package/build/esm/types/collator.d.ts +8 -0
  146. package/build/esm/types/collator.js +8 -0
  147. package/build/esm/types/durable.d.ts +59 -0
  148. package/build/esm/types/durable.js +1 -0
  149. package/build/esm/types/hook.d.ts +31 -0
  150. package/build/esm/types/hook.js +6 -0
  151. package/build/esm/types/hotmesh.d.ts +82 -0
  152. package/build/esm/types/hotmesh.js +1 -0
  153. package/build/esm/types/index.d.ts +20 -0
  154. package/build/esm/types/index.js +5 -0
  155. package/build/esm/types/ioredisclient.d.ts +5 -0
  156. package/build/esm/types/ioredisclient.js +2 -0
  157. package/build/esm/types/job.d.ts +50 -0
  158. package/build/esm/types/job.js +1 -0
  159. package/build/esm/types/logger.d.ts +6 -0
  160. package/build/esm/types/logger.js +1 -0
  161. package/build/esm/types/map.d.ts +4 -0
  162. package/build/esm/types/map.js +1 -0
  163. package/build/esm/types/pipe.d.ts +4 -0
  164. package/build/esm/types/pipe.js +1 -0
  165. package/build/esm/types/quorum.d.ts +46 -0
  166. package/build/esm/types/quorum.js +1 -0
  167. package/build/esm/types/redis.d.ts +8 -0
  168. package/build/esm/types/redis.js +1 -0
  169. package/build/esm/types/redisclient.d.ts +25 -0
  170. package/build/esm/types/redisclient.js +1 -0
  171. package/build/esm/types/serializer.d.ts +33 -0
  172. package/build/esm/types/serializer.js +1 -0
  173. package/build/esm/types/stats.d.ts +83 -0
  174. package/build/esm/types/stats.js +1 -0
  175. package/build/esm/types/stream.d.ts +67 -0
  176. package/build/esm/types/stream.js +22 -0
  177. package/build/esm/types/telemetry.d.ts +1 -0
  178. package/build/esm/types/telemetry.js +1 -0
  179. package/build/esm/types/transition.d.ts +17 -0
  180. package/build/esm/types/transition.js +1 -0
  181. package/package.json +12 -5
  182. package/services/activities/trigger.ts +2 -2
  183. package/services/connector/index.ts +3 -3
  184. package/services/durable/client.ts +2 -2
  185. package/services/durable/connection.ts +2 -2
  186. package/services/hotmesh/index.ts +2 -2
  187. package/services/mapper/index.ts +6 -7
  188. package/services/store/index.ts +3 -3
  189. package/tsconfig.cjs.json +8 -0
  190. package/tsconfig.esm.json +9 -0
  191. /package/build/{index.d.ts → cjs/index.d.ts} +0 -0
  192. /package/build/{index.js → cjs/index.js} +0 -0
  193. /package/build/{modules → cjs/modules}/errors.d.ts +0 -0
  194. /package/build/{modules → cjs/modules}/errors.js +0 -0
  195. /package/build/{modules → cjs/modules}/key.d.ts +0 -0
  196. /package/build/{modules → cjs/modules}/key.js +0 -0
  197. /package/build/{modules → cjs/modules}/utils.d.ts +0 -0
  198. /package/build/{modules → cjs/modules}/utils.js +0 -0
  199. /package/build/{services → cjs/services}/activities/activity.d.ts +0 -0
  200. /package/build/{services → cjs/services}/activities/activity.js +0 -0
  201. /package/build/{services → cjs/services}/activities/await.d.ts +0 -0
  202. /package/build/{services → cjs/services}/activities/await.js +0 -0
  203. /package/build/{services → cjs/services}/activities/emit.d.ts +0 -0
  204. /package/build/{services → cjs/services}/activities/emit.js +0 -0
  205. /package/build/{services → cjs/services}/activities/index.d.ts +0 -0
  206. /package/build/{services → cjs/services}/activities/index.js +0 -0
  207. /package/build/{services → cjs/services}/activities/iterate.d.ts +0 -0
  208. /package/build/{services → cjs/services}/activities/iterate.js +0 -0
  209. /package/build/{services → cjs/services}/activities/trigger.d.ts +0 -0
  210. /package/build/{services → cjs/services}/activities/worker.d.ts +0 -0
  211. /package/build/{services → cjs/services}/activities/worker.js +0 -0
  212. /package/build/{services → cjs/services}/collator/index.d.ts +0 -0
  213. /package/build/{services → cjs/services}/collator/index.js +0 -0
  214. /package/build/{services → cjs/services}/compiler/deployer.d.ts +0 -0
  215. /package/build/{services → cjs/services}/compiler/deployer.js +0 -0
  216. /package/build/{services → cjs/services}/compiler/index.d.ts +0 -0
  217. /package/build/{services → cjs/services}/compiler/index.js +0 -0
  218. /package/build/{services → cjs/services}/compiler/validator.d.ts +0 -0
  219. /package/build/{services → cjs/services}/compiler/validator.js +0 -0
  220. /package/build/{services → cjs/services}/connector/clients/ioredis.d.ts +0 -0
  221. /package/build/{services → cjs/services}/connector/clients/ioredis.js +0 -0
  222. /package/build/{services → cjs/services}/connector/clients/redis.d.ts +0 -0
  223. /package/build/{services → cjs/services}/connector/clients/redis.js +0 -0
  224. /package/build/{services → cjs/services}/connector/index.d.ts +0 -0
  225. /package/build/{services → cjs/services}/dimension/index.d.ts +0 -0
  226. /package/build/{services → cjs/services}/dimension/index.js +0 -0
  227. /package/build/{services → cjs/services}/durable/asyncLocalStorage.d.ts +0 -0
  228. /package/build/{services → cjs/services}/durable/asyncLocalStorage.js +0 -0
  229. /package/build/{services → cjs/services}/durable/client.d.ts +0 -0
  230. /package/build/{services → cjs/services}/durable/connection.d.ts +0 -0
  231. /package/build/{services → cjs/services}/durable/factory.d.ts +0 -0
  232. /package/build/{services → cjs/services}/durable/factory.js +0 -0
  233. /package/build/{services → cjs/services}/durable/handle.d.ts +0 -0
  234. /package/build/{services → cjs/services}/durable/handle.js +0 -0
  235. /package/build/{services → cjs/services}/durable/index.d.ts +0 -0
  236. /package/build/{services → cjs/services}/durable/index.js +0 -0
  237. /package/build/{services → cjs/services}/durable/native.d.ts +0 -0
  238. /package/build/{services → cjs/services}/durable/native.js +0 -0
  239. /package/build/{services → cjs/services}/durable/worker.d.ts +0 -0
  240. /package/build/{services → cjs/services}/durable/worker.js +0 -0
  241. /package/build/{services → cjs/services}/durable/workflow.d.ts +0 -0
  242. /package/build/{services → cjs/services}/durable/workflow.js +0 -0
  243. /package/build/{services → cjs/services}/engine/index.d.ts +0 -0
  244. /package/build/{services → cjs/services}/engine/index.js +0 -0
  245. /package/build/{services → cjs/services}/hotmesh/index.d.ts +0 -0
  246. /package/build/{services → cjs/services}/logger/index.d.ts +0 -0
  247. /package/build/{services → cjs/services}/logger/index.js +0 -0
  248. /package/build/{services → cjs/services}/mapper/index.js +0 -0
  249. /package/build/{services → cjs/services}/pipe/functions/array.d.ts +0 -0
  250. /package/build/{services → cjs/services}/pipe/functions/array.js +0 -0
  251. /package/build/{services → cjs/services}/pipe/functions/bitwise.d.ts +0 -0
  252. /package/build/{services → cjs/services}/pipe/functions/bitwise.js +0 -0
  253. /package/build/{services → cjs/services}/pipe/functions/conditional.d.ts +0 -0
  254. /package/build/{services → cjs/services}/pipe/functions/conditional.js +0 -0
  255. /package/build/{services → cjs/services}/pipe/functions/date.d.ts +0 -0
  256. /package/build/{services → cjs/services}/pipe/functions/date.js +0 -0
  257. /package/build/{services → cjs/services}/pipe/functions/index.d.ts +0 -0
  258. /package/build/{services → cjs/services}/pipe/functions/index.js +0 -0
  259. /package/build/{services → cjs/services}/pipe/functions/json.d.ts +0 -0
  260. /package/build/{services → cjs/services}/pipe/functions/json.js +0 -0
  261. /package/build/{services → cjs/services}/pipe/functions/math.d.ts +0 -0
  262. /package/build/{services → cjs/services}/pipe/functions/math.js +0 -0
  263. /package/build/{services → cjs/services}/pipe/functions/number.d.ts +0 -0
  264. /package/build/{services → cjs/services}/pipe/functions/number.js +0 -0
  265. /package/build/{services → cjs/services}/pipe/functions/object.d.ts +0 -0
  266. /package/build/{services → cjs/services}/pipe/functions/object.js +0 -0
  267. /package/build/{services → cjs/services}/pipe/functions/string.d.ts +0 -0
  268. /package/build/{services → cjs/services}/pipe/functions/string.js +0 -0
  269. /package/build/{services → cjs/services}/pipe/functions/symbol.d.ts +0 -0
  270. /package/build/{services → cjs/services}/pipe/functions/symbol.js +0 -0
  271. /package/build/{services → cjs/services}/pipe/functions/unary.d.ts +0 -0
  272. /package/build/{services → cjs/services}/pipe/functions/unary.js +0 -0
  273. /package/build/{services → cjs/services}/pipe/index.d.ts +0 -0
  274. /package/build/{services → cjs/services}/pipe/index.js +0 -0
  275. /package/build/{services → cjs/services}/quorum/index.d.ts +0 -0
  276. /package/build/{services → cjs/services}/quorum/index.js +0 -0
  277. /package/build/{services → cjs/services}/reporter/index.d.ts +0 -0
  278. /package/build/{services → cjs/services}/reporter/index.js +0 -0
  279. /package/build/{services → cjs/services}/serializer/index.d.ts +0 -0
  280. /package/build/{services → cjs/services}/serializer/index.js +0 -0
  281. /package/build/{services → cjs/services}/signaler/store.d.ts +0 -0
  282. /package/build/{services → cjs/services}/signaler/store.js +0 -0
  283. /package/build/{services → cjs/services}/signaler/stream.d.ts +0 -0
  284. /package/build/{services → cjs/services}/signaler/stream.js +0 -0
  285. /package/build/{services → cjs/services}/store/cache.d.ts +0 -0
  286. /package/build/{services → cjs/services}/store/cache.js +0 -0
  287. /package/build/{services → cjs/services}/store/clients/ioredis.d.ts +0 -0
  288. /package/build/{services → cjs/services}/store/clients/ioredis.js +0 -0
  289. /package/build/{services → cjs/services}/store/clients/redis.d.ts +0 -0
  290. /package/build/{services → cjs/services}/store/clients/redis.js +0 -0
  291. /package/build/{services → cjs/services}/store/index.d.ts +0 -0
  292. /package/build/{services → cjs/services}/stream/clients/ioredis.d.ts +0 -0
  293. /package/build/{services → cjs/services}/stream/clients/ioredis.js +0 -0
  294. /package/build/{services → cjs/services}/stream/clients/redis.d.ts +0 -0
  295. /package/build/{services → cjs/services}/stream/clients/redis.js +0 -0
  296. /package/build/{services → cjs/services}/stream/index.d.ts +0 -0
  297. /package/build/{services → cjs/services}/stream/index.js +0 -0
  298. /package/build/{services → cjs/services}/sub/clients/ioredis.d.ts +0 -0
  299. /package/build/{services → cjs/services}/sub/clients/ioredis.js +0 -0
  300. /package/build/{services → cjs/services}/sub/clients/redis.d.ts +0 -0
  301. /package/build/{services → cjs/services}/sub/clients/redis.js +0 -0
  302. /package/build/{services → cjs/services}/sub/index.d.ts +0 -0
  303. /package/build/{services → cjs/services}/sub/index.js +0 -0
  304. /package/build/{services → cjs/services}/task/index.d.ts +0 -0
  305. /package/build/{services → cjs/services}/task/index.js +0 -0
  306. /package/build/{services → cjs/services}/telemetry/index.d.ts +0 -0
  307. /package/build/{services → cjs/services}/telemetry/index.js +0 -0
  308. /package/build/{services → cjs/services}/worker/index.d.ts +0 -0
  309. /package/build/{services → cjs/services}/worker/index.js +0 -0
  310. /package/build/{types → cjs/types}/activity.d.ts +0 -0
  311. /package/build/{types → cjs/types}/activity.js +0 -0
  312. /package/build/{types → cjs/types}/app.d.ts +0 -0
  313. /package/build/{types → cjs/types}/app.js +0 -0
  314. /package/build/{types → cjs/types}/async.d.ts +0 -0
  315. /package/build/{types → cjs/types}/async.js +0 -0
  316. /package/build/{types → cjs/types}/cache.d.ts +0 -0
  317. /package/build/{types → cjs/types}/cache.js +0 -0
  318. /package/build/{types → cjs/types}/collator.d.ts +0 -0
  319. /package/build/{types → cjs/types}/collator.js +0 -0
  320. /package/build/{types → cjs/types}/durable.d.ts +0 -0
  321. /package/build/{types → cjs/types}/durable.js +0 -0
  322. /package/build/{types → cjs/types}/hook.d.ts +0 -0
  323. /package/build/{types → cjs/types}/hook.js +0 -0
  324. /package/build/{types → cjs/types}/hotmesh.d.ts +0 -0
  325. /package/build/{types → cjs/types}/hotmesh.js +0 -0
  326. /package/build/{types → cjs/types}/index.d.ts +0 -0
  327. /package/build/{types → cjs/types}/index.js +0 -0
  328. /package/build/{types → cjs/types}/ioredisclient.d.ts +0 -0
  329. /package/build/{types → cjs/types}/ioredisclient.js +0 -0
  330. /package/build/{types → cjs/types}/job.d.ts +0 -0
  331. /package/build/{types → cjs/types}/job.js +0 -0
  332. /package/build/{types → cjs/types}/logger.d.ts +0 -0
  333. /package/build/{types → cjs/types}/logger.js +0 -0
  334. /package/build/{types → cjs/types}/map.d.ts +0 -0
  335. /package/build/{types → cjs/types}/map.js +0 -0
  336. /package/build/{types → cjs/types}/pipe.d.ts +0 -0
  337. /package/build/{types → cjs/types}/pipe.js +0 -0
  338. /package/build/{types → cjs/types}/quorum.d.ts +0 -0
  339. /package/build/{types → cjs/types}/quorum.js +0 -0
  340. /package/build/{types → cjs/types}/redis.d.ts +0 -0
  341. /package/build/{types → cjs/types}/redis.js +0 -0
  342. /package/build/{types → cjs/types}/redisclient.d.ts +0 -0
  343. /package/build/{types → cjs/types}/redisclient.js +0 -0
  344. /package/build/{types → cjs/types}/serializer.d.ts +0 -0
  345. /package/build/{types → cjs/types}/serializer.js +0 -0
  346. /package/build/{types → cjs/types}/stats.d.ts +0 -0
  347. /package/build/{types → cjs/types}/stats.js +0 -0
  348. /package/build/{types → cjs/types}/stream.d.ts +0 -0
  349. /package/build/{types → cjs/types}/stream.js +0 -0
  350. /package/build/{types → cjs/types}/telemetry.d.ts +0 -0
  351. /package/build/{types → cjs/types}/telemetry.js +0 -0
  352. /package/build/{types → cjs/types}/transition.d.ts +0 -0
  353. /package/build/{types → cjs/types}/transition.js +0 -0
@@ -0,0 +1,43 @@
1
+ /// <reference types="node" />
2
+ import { ILogger } from '../logger';
3
+ import { StoreService } from '../store';
4
+ import { StreamService } from '../stream';
5
+ import { RedisClient, RedisMulti } from '../../types/redis';
6
+ import { ReclaimedMessageType, StreamConfig, StreamData, StreamDataResponse, StreamRole } from '../../types/stream';
7
+ declare class StreamSignaler {
8
+ static signalers: Set<StreamSignaler>;
9
+ appId: string;
10
+ guid: string;
11
+ role: StreamRole;
12
+ topic: string | undefined;
13
+ store: StoreService<RedisClient, RedisMulti>;
14
+ stream: StreamService<RedisClient, RedisMulti>;
15
+ reclaimDelay: number;
16
+ reclaimCount: number;
17
+ logger: ILogger;
18
+ throttle: number;
19
+ errorCount: number;
20
+ currentTimerId: NodeJS.Timeout | null;
21
+ shouldConsume: boolean;
22
+ constructor(config: StreamConfig, stream: StreamService<RedisClient, RedisMulti>, store: StoreService<RedisClient, RedisMulti>, logger: ILogger);
23
+ createGroup(stream: string, group: string): Promise<void>;
24
+ publishMessage(topic: string, streamData: StreamData | StreamDataResponse, multi?: RedisMulti): Promise<string | RedisMulti>;
25
+ consumeMessages(stream: string, group: string, consumer: string, callback: (streamData: StreamData) => Promise<StreamDataResponse | void>): Promise<void>;
26
+ isStreamMessage(result: any): boolean;
27
+ consumeOne(stream: string, group: string, id: string, message: string[], callback: (streamData: StreamData) => Promise<StreamDataResponse | void>): Promise<void>;
28
+ execStreamLeg(input: StreamData, stream: string, id: string, callback: (streamData: StreamData) => Promise<StreamDataResponse | void>): Promise<StreamDataResponse>;
29
+ ackAndDelete(stream: string, group: string, id: string): Promise<void>;
30
+ publishResponse(input: StreamData, output: StreamDataResponse | void): Promise<string>;
31
+ shouldRetry(input: StreamData, output: StreamDataResponse): [boolean, number];
32
+ structureUnhandledError(input: StreamData, err: Error): StreamDataResponse;
33
+ structureUnacknowledgedError(input: StreamData): StreamDataResponse;
34
+ structureError(input: StreamData, output: StreamDataResponse): StreamDataResponse;
35
+ static stopConsuming(): Promise<void>;
36
+ stopConsuming(): Promise<void>;
37
+ cancelThrottle(): void;
38
+ setThrottle(delayInMillis: number): void;
39
+ claimUnacknowledged(stream: string, group: string, consumer: string, idleTimeMs?: number, limit?: number): Promise<[string, [string, string]][]>;
40
+ expireUnacknowledged(reclaimedMessage: ReclaimedMessageType, stream: string, group: string, consumer: string, id: string, count: number): Promise<void>;
41
+ parseStreamData(str: string): [undefined, StreamData] | [Error];
42
+ }
43
+ export { StreamSignaler };
@@ -0,0 +1,315 @@
1
+ import { KeyType } from '../../modules/key';
2
+ import { XSleepFor, sleepFor } from '../../modules/utils';
3
+ import { TelemetryService } from '../telemetry';
4
+ import { StreamDataType, StreamRole, StreamStatus } from '../../types/stream';
5
+ const MAX_RETRIES = 4; //max delay (10s using exponential backoff);
6
+ const MAX_TIMEOUT_MS = 60000;
7
+ const GRADUATED_INTERVAL_MS = 5000;
8
+ const BLOCK_DURATION = 15000; //Set to `15` so SIGINT/SIGTERM can interrupt; set to `0` to BLOCK indefinitely
9
+ const TEST_BLOCK_DURATION = 1000; //Set to `1000` so tests can interrupt quickly
10
+ const BLOCK_TIME_MS = process.env.NODE_ENV === 'test' ? TEST_BLOCK_DURATION : BLOCK_DURATION;
11
+ const SYSTEM_STATUS_CODE = 999;
12
+ const UNKNOWN_STATUS_CODE = 500;
13
+ const UNKNOWN_STATUS_MESSAGE = 'unknown';
14
+ const XCLAIM_DELAY_MS = 1000 * 60; //max time a message can be unacked before it is claimed by another
15
+ const XCLAIM_COUNT = 3; //max number of times a message can be claimed by another before it is dead-lettered
16
+ const XPENDING_COUNT = 10;
17
+ class StreamSignaler {
18
+ constructor(config, stream, store, logger) {
19
+ this.throttle = 0;
20
+ this.errorCount = 0;
21
+ this.currentTimerId = null;
22
+ this.appId = config.appId;
23
+ this.guid = config.guid;
24
+ this.role = config.role;
25
+ this.topic = config.topic;
26
+ this.stream = stream;
27
+ this.store = store;
28
+ this.reclaimDelay = config.reclaimDelay || XCLAIM_DELAY_MS;
29
+ this.reclaimCount = config.reclaimCount || XCLAIM_COUNT;
30
+ this.logger = logger;
31
+ }
32
+ async createGroup(stream, group) {
33
+ try {
34
+ await this.store.xgroup('CREATE', stream, group, '$', 'MKSTREAM');
35
+ }
36
+ catch (err) {
37
+ this.logger.info('consumer-group-exists', { stream, group });
38
+ }
39
+ }
40
+ async publishMessage(topic, streamData, multi) {
41
+ const stream = this.store.mintKey(KeyType.STREAMS, { appId: this.store.appId, topic });
42
+ return await this.store.xadd(stream, '*', 'message', JSON.stringify(streamData), multi);
43
+ }
44
+ async consumeMessages(stream, group, consumer, callback) {
45
+ this.logger.info(`stream-consumer-starting`, { group, consumer, stream });
46
+ StreamSignaler.signalers.add(this);
47
+ this.shouldConsume = true;
48
+ await this.createGroup(stream, group);
49
+ let lastCheckedPendingMessagesAt = Date.now();
50
+ async function consume() {
51
+ let sleep = XSleepFor(this.throttle);
52
+ this.currentTimerId = sleep.timerId;
53
+ await sleep.promise;
54
+ if (!this.shouldConsume) {
55
+ this.logger.info(`stream-consumer-stopping`, { group, consumer, stream });
56
+ return;
57
+ }
58
+ try {
59
+ const result = await this.stream.xreadgroup('GROUP', group, consumer, 'BLOCK', BLOCK_TIME_MS, 'STREAMS', stream, '>');
60
+ if (this.isStreamMessage(result)) {
61
+ const [[, messages]] = result;
62
+ for (const [id, message] of messages) {
63
+ await this.consumeOne(stream, group, id, message, callback);
64
+ }
65
+ }
66
+ // Check for pending messages (note: Redis 6.2 simplifies)
67
+ const now = Date.now();
68
+ if (now - lastCheckedPendingMessagesAt > this.reclaimDelay) {
69
+ lastCheckedPendingMessagesAt = now;
70
+ const pendingMessages = await this.claimUnacknowledged(stream, group, consumer);
71
+ for (const [id, message] of pendingMessages) {
72
+ await this.consumeOne(stream, group, id, message, callback);
73
+ }
74
+ }
75
+ setImmediate(consume.bind(this));
76
+ }
77
+ catch (err) {
78
+ if (this.shouldConsume && process.env.NODE_ENV !== 'test') {
79
+ this.logger.error(`stream-consume-message-error`, { err, stream, group, consumer });
80
+ this.errorCount++;
81
+ const timeout = Math.min(GRADUATED_INTERVAL_MS * (2 ** this.errorCount), MAX_TIMEOUT_MS);
82
+ setTimeout(consume.bind(this), timeout);
83
+ }
84
+ }
85
+ }
86
+ consume.call(this);
87
+ }
88
+ isStreamMessage(result) {
89
+ return Array.isArray(result) && Array.isArray(result[0]);
90
+ }
91
+ async consumeOne(stream, group, id, message, callback) {
92
+ this.logger.debug(`stream-consume-one`, { group, stream, id });
93
+ const [err, input] = this.parseStreamData(message[1]);
94
+ let output;
95
+ let telemetry;
96
+ try {
97
+ telemetry = new TelemetryService(this.appId);
98
+ telemetry.startStreamSpan(input, this.role);
99
+ output = await this.execStreamLeg(input, stream, id, callback.bind(this));
100
+ if (output?.status === StreamStatus.ERROR) {
101
+ telemetry.setStreamError(`Function Status Code ${output.code || UNKNOWN_STATUS_CODE}`);
102
+ }
103
+ this.errorCount = 0;
104
+ }
105
+ catch (err) {
106
+ this.logger.error(`stream-consume-one-error`, { group, stream, id, err });
107
+ telemetry.setStreamError(err.message);
108
+ }
109
+ const messageId = await this.publishResponse(input, output);
110
+ telemetry.setStreamAttributes({ 'app.worker.mid': messageId });
111
+ await this.ackAndDelete(stream, group, id);
112
+ telemetry.endStreamSpan();
113
+ this.logger.debug(`stream-consume-one-end`, { group, stream, id });
114
+ }
115
+ async execStreamLeg(input, stream, id, callback) {
116
+ let output;
117
+ try {
118
+ output = await callback(input);
119
+ }
120
+ catch (err) {
121
+ console.error(err);
122
+ this.logger.error(`stream-call-function-error`, { stream, id, err });
123
+ output = this.structureUnhandledError(input, err);
124
+ }
125
+ return output;
126
+ }
127
+ async ackAndDelete(stream, group, id) {
128
+ const multi = this.stream.getMulti();
129
+ await this.stream.xack(stream, group, id, multi);
130
+ await this.stream.xdel(stream, id, multi);
131
+ await multi.exec();
132
+ }
133
+ async publishResponse(input, output) {
134
+ if (output && typeof output === 'object') {
135
+ if (output.status === 'error') {
136
+ const [shouldRetry, timeout] = this.shouldRetry(input, output);
137
+ if (shouldRetry) {
138
+ await sleepFor(timeout);
139
+ return await this.publishMessage(input.metadata.topic, {
140
+ data: input.data,
141
+ metadata: { ...input.metadata, try: (input.metadata.try || 0) + 1 },
142
+ policies: input.policies,
143
+ });
144
+ }
145
+ else {
146
+ output = this.structureError(input, output);
147
+ }
148
+ }
149
+ output.type = StreamDataType.RESPONSE;
150
+ return await this.publishMessage(null, output);
151
+ }
152
+ }
153
+ shouldRetry(input, output) {
154
+ const policies = input.policies?.retry;
155
+ const errorCode = output.code.toString();
156
+ const policy = policies?.[errorCode];
157
+ const maxRetries = policy?.[0];
158
+ const tryCount = Math.min(input.metadata.try || 0, MAX_RETRIES);
159
+ if (maxRetries >= tryCount) {
160
+ return [true, Math.pow(10, tryCount)];
161
+ }
162
+ return [false, 0];
163
+ }
164
+ structureUnhandledError(input, err) {
165
+ let error = {};
166
+ if (typeof err.message === 'string') {
167
+ error.message = err.message;
168
+ }
169
+ else {
170
+ error.message = UNKNOWN_STATUS_MESSAGE;
171
+ }
172
+ if (typeof err.stack === 'string') {
173
+ error.stack = err.stack;
174
+ }
175
+ if (typeof err.name === 'string') {
176
+ error.name = err.name;
177
+ }
178
+ return {
179
+ status: 'error',
180
+ code: UNKNOWN_STATUS_CODE,
181
+ metadata: { ...input.metadata },
182
+ data: error
183
+ };
184
+ }
185
+ structureUnacknowledgedError(input) {
186
+ const message = 'stream message max delivery count exceeded';
187
+ const code = SYSTEM_STATUS_CODE;
188
+ const data = { message, code };
189
+ const output = {
190
+ metadata: { ...input.metadata },
191
+ status: StreamStatus.ERROR,
192
+ code,
193
+ data,
194
+ };
195
+ //send unacknowleded errors to the engine (it has no topic)
196
+ delete output.metadata.topic;
197
+ return output;
198
+ }
199
+ structureError(input, output) {
200
+ const message = output.data?.message ? output.data?.message.toString() : UNKNOWN_STATUS_MESSAGE;
201
+ const statusCode = output.code || output.data?.code;
202
+ const code = isNaN(statusCode) ? UNKNOWN_STATUS_CODE : parseInt(statusCode.toString());
203
+ const data = { message, code };
204
+ if (typeof output.data?.error === 'object') {
205
+ data.error = { ...output.data.error };
206
+ }
207
+ return {
208
+ status: StreamStatus.ERROR,
209
+ code,
210
+ metadata: { ...input.metadata },
211
+ data
212
+ };
213
+ }
214
+ static async stopConsuming() {
215
+ for (const instance of [...StreamSignaler.signalers]) {
216
+ instance.stopConsuming();
217
+ }
218
+ await sleepFor(BLOCK_TIME_MS);
219
+ }
220
+ async stopConsuming() {
221
+ this.shouldConsume = false;
222
+ this.logger.info(`stream-consumer-stopping`, this.topic ? { topic: this.topic } : undefined);
223
+ this.cancelThrottle();
224
+ await sleepFor(BLOCK_TIME_MS);
225
+ }
226
+ cancelThrottle() {
227
+ if (this.currentTimerId !== undefined) {
228
+ clearTimeout(this.currentTimerId);
229
+ this.currentTimerId = undefined;
230
+ }
231
+ }
232
+ setThrottle(delayInMillis) {
233
+ if (!Number.isInteger(delayInMillis) || delayInMillis < 0) {
234
+ throw new Error('Throttle must be a non-negative integer');
235
+ }
236
+ this.throttle = delayInMillis;
237
+ this.logger.info(`stream-throttle-reset`, { delay: this.throttle, topic: this.topic });
238
+ }
239
+ async claimUnacknowledged(stream, group, consumer, idleTimeMs = this.reclaimDelay, limit = XPENDING_COUNT) {
240
+ let pendingMessages = [];
241
+ const pendingMessagesInfo = await this.stream.xpending(stream, group, '-', '+', limit); //[[ '1688768134881-0', 'testConsumer1', 1017, 1 ]]
242
+ for (const pendingMessageInfo of pendingMessagesInfo) {
243
+ if (Array.isArray(pendingMessageInfo)) {
244
+ const [id, , elapsedTimeMs, deliveryCount] = pendingMessageInfo;
245
+ if (elapsedTimeMs > idleTimeMs) {
246
+ const reclaimedMessage = await this.stream.xclaim(stream, group, consumer, idleTimeMs, id);
247
+ if (reclaimedMessage.length) {
248
+ if (deliveryCount <= this.reclaimCount) {
249
+ pendingMessages = pendingMessages.concat(reclaimedMessage);
250
+ }
251
+ else {
252
+ await this.expireUnacknowledged(reclaimedMessage, stream, group, consumer, id, deliveryCount);
253
+ }
254
+ }
255
+ }
256
+ }
257
+ }
258
+ return pendingMessages;
259
+ }
260
+ async expireUnacknowledged(reclaimedMessage, stream, group, consumer, id, count) {
261
+ //The stream activity was not processed within established limits. Possibilities Include:
262
+ // 1) user error: the workers were not properly configured and are timing out
263
+ // 2a) system error: JSON is corrupt
264
+ // i) bad/unwitting actor
265
+ // ii) corrupt hardware/network/transport/etc
266
+ // 3b) system error: Redis unable to accept `xadd` request
267
+ // 4c) system error: Redis unable to accept `xdel`/`xack` request
268
+ this.logger.error('stream-message-max-delivery-count-exceeded', { id, stream, group, consumer, code: SYSTEM_STATUS_CODE, count });
269
+ const streamData = reclaimedMessage[0]?.[1]?.[1];
270
+ //fatal risk point 1 of 3): json is corrupt
271
+ const [err, input] = this.parseStreamData(streamData);
272
+ if (err) {
273
+ return this.logger.error('expire-unacknowledged-parse-fatal-error', { id, err });
274
+ }
275
+ else if (!input || !input.metadata) {
276
+ return this.logger.error('expire-unacknowledged-parse-fatal-error', { id });
277
+ }
278
+ let telemetry;
279
+ let messageId;
280
+ try {
281
+ telemetry = new TelemetryService(this.appId);
282
+ telemetry.startStreamSpan(input, StreamRole.SYSTEM);
283
+ telemetry.setStreamError(`Stream Message Max Delivery Count Exceeded`);
284
+ //fatal risk point 2 of 3): unable to publish error message (to notify the parent job)
285
+ const output = this.structureUnacknowledgedError(input);
286
+ messageId = await this.publishResponse(input, output);
287
+ telemetry.setStreamAttributes({ 'app.worker.mid': messageId });
288
+ //fatal risk point 3 of 3): unable to ack and delete stream message
289
+ await this.ackAndDelete(stream, group, id);
290
+ }
291
+ catch (err) {
292
+ if (messageId) {
293
+ this.logger.error('expire-unacknowledged-pub-fatal-error', { id, err, ...input.metadata });
294
+ telemetry.setStreamAttributes({ 'app.system.fatal': 'expire-unacknowledged-pub-fatal-error' });
295
+ }
296
+ else {
297
+ this.logger.error('expire-unacknowledged-ack-fatal-error', { id, err, ...input.metadata });
298
+ telemetry.setStreamAttributes({ 'app.system.fatal': 'expire-unacknowledged-ack-fatal-error' });
299
+ }
300
+ }
301
+ finally {
302
+ telemetry.endStreamSpan();
303
+ }
304
+ }
305
+ parseStreamData(str) {
306
+ try {
307
+ return [, JSON.parse(str)];
308
+ }
309
+ catch (e) {
310
+ return [e];
311
+ }
312
+ }
313
+ }
314
+ StreamSignaler.signalers = new Set();
315
+ export { StreamSignaler };
@@ -0,0 +1,66 @@
1
+ /**
2
+ * The Cache is a key/value store and used to store commonly accessed Redis metadata
3
+ * (mainly the execution rules for the app) to save time accessing them as they
4
+ * are immutable per verison. The only time the rules are ejected are when
5
+ * a new version is deployed to the quorum and the cache is invalidated/cleared.
6
+ */
7
+ import { ActivityType } from "../../types/activity";
8
+ import { HookRule } from "../../types/hook";
9
+ import { HotMeshApp, HotMeshSettings } from "../../types/hotmesh";
10
+ import { Symbols } from "../../types/serializer";
11
+ import { Transitions } from "../../types/transition";
12
+ declare class Cache {
13
+ settings: HotMeshSettings;
14
+ appId: string;
15
+ apps: Record<string, HotMeshApp>;
16
+ schemas: Record<string, ActivityType>;
17
+ subscriptions: Record<string, Record<string, string>>;
18
+ symbols: Record<string, Symbols>;
19
+ symvals: Record<string, Symbols>;
20
+ transitions: Record<string, Record<string, unknown>>;
21
+ hookRules: Record<string, Record<string, HookRule[]>>;
22
+ workItems: Record<string, string>;
23
+ /**
24
+ * The cache is ALWAYS initialized with HotMeshSettings. The other parameters are optional.
25
+ * @param settings
26
+ * @param apps
27
+ * @param schemas
28
+ * @param subscriptions
29
+ * @param transitions
30
+ * @param hookRules
31
+ */
32
+ constructor(appId: string, settings: HotMeshSettings, apps?: Record<string, HotMeshApp>, schemas?: Record<string, ActivityType>, subscriptions?: Record<string, Record<string, string>>, symbols?: Record<string, Symbols>, symvals?: Record<string, Symbols>, transitions?: Record<string, Record<string, unknown>>, hookRules?: Record<string, Record<string, HookRule[]>>, workItems?: Record<string, string>);
33
+ /**
34
+ * invalidate the cache; settings are not invalidated!
35
+ */
36
+ invalidate(): void;
37
+ getSettings(): HotMeshSettings;
38
+ setSettings(settings: HotMeshSettings): void;
39
+ getApps(): Record<string, HotMeshApp>;
40
+ getApp(appId: string): HotMeshApp;
41
+ setApps(apps: Record<string, HotMeshApp>): void;
42
+ setApp(appId: string, app: HotMeshApp): void;
43
+ getSchemas(appId: string, version: string): Record<string, ActivityType>;
44
+ getSchema(appId: string, version: string, activityId: string): ActivityType;
45
+ setSchemas(appId: string, version: string, schemas: Record<string, ActivityType>): void;
46
+ setSchema(appId: string, version: string, activityId: string, schema: ActivityType): void;
47
+ getSubscriptions(appId: string, version: string): Record<string, string>;
48
+ getSubscription(appId: string, version: string, topic: string): unknown;
49
+ setSubscriptions(appId: string, version: string, subscriptions: Record<string, string>): void;
50
+ getSymbols(appId: string, targetEntityId: string): Symbols;
51
+ setSymbols(appId: string, targetEntityId: string, symbols: Symbols): void;
52
+ deleteSymbols(appId: string, targetEntityId: string): void;
53
+ getSymbolValues(appId: string): Symbols;
54
+ setSymbolValues(appId: string, symvals: Symbols): void;
55
+ deleteSymbolValues(appId: string): void;
56
+ getTransitions(appId: string, version: string): Transitions;
57
+ setTransitions(appId: string, version: string, transitions: Transitions): void;
58
+ getHookRules(appId: string): Record<string, HookRule[]>;
59
+ setHookRules(appId: string, hookRules: Record<string, HookRule[]>): void;
60
+ getSignals(appId: string, version: string): Record<string, unknown>;
61
+ setSignals(appId: string, version: string): Record<string, unknown>;
62
+ getActiveTaskQueue(appId: string): string;
63
+ setWorkItem(appId: string, workItem: string): void;
64
+ removeWorkItem(appId: string): void;
65
+ }
66
+ export { Cache };
@@ -0,0 +1,124 @@
1
+ /**
2
+ * The Cache is a key/value store and used to store commonly accessed Redis metadata
3
+ * (mainly the execution rules for the app) to save time accessing them as they
4
+ * are immutable per verison. The only time the rules are ejected are when
5
+ * a new version is deployed to the quorum and the cache is invalidated/cleared.
6
+ */
7
+ class Cache {
8
+ /**
9
+ * The cache is ALWAYS initialized with HotMeshSettings. The other parameters are optional.
10
+ * @param settings
11
+ * @param apps
12
+ * @param schemas
13
+ * @param subscriptions
14
+ * @param transitions
15
+ * @param hookRules
16
+ */
17
+ constructor(appId, settings, apps = {}, schemas = {}, subscriptions = {}, symbols = {}, symvals = {}, transitions = {}, hookRules = {}, workItems = {}) {
18
+ this.appId = appId;
19
+ this.settings = settings;
20
+ this.apps = apps;
21
+ this.schemas = schemas;
22
+ this.subscriptions = subscriptions;
23
+ this.symbols = symbols;
24
+ this.symvals = symvals;
25
+ this.transitions = transitions;
26
+ this.hookRules = hookRules;
27
+ this.workItems = workItems;
28
+ }
29
+ /**
30
+ * invalidate the cache; settings are not invalidated!
31
+ */
32
+ invalidate() {
33
+ this.apps = {};
34
+ this.schemas = {};
35
+ this.subscriptions = {};
36
+ this.transitions = {};
37
+ this.hookRules = {};
38
+ }
39
+ getSettings() {
40
+ return this.settings;
41
+ }
42
+ setSettings(settings) {
43
+ this.settings = settings;
44
+ }
45
+ getApps() {
46
+ return this.apps;
47
+ }
48
+ getApp(appId) {
49
+ return this.apps[appId];
50
+ }
51
+ setApps(apps) {
52
+ this.apps = apps;
53
+ }
54
+ setApp(appId, app) {
55
+ this.apps[appId] = app;
56
+ }
57
+ getSchemas(appId, version) {
58
+ return this.schemas[`${appId}/${version}`];
59
+ }
60
+ getSchema(appId, version, activityId) {
61
+ return this.schemas?.[`${appId}/${version}`]?.[activityId];
62
+ }
63
+ setSchemas(appId, version, schemas) {
64
+ this.schemas[`${appId}/${version}`] = schemas;
65
+ }
66
+ setSchema(appId, version, activityId, schema) {
67
+ this.schemas[`${appId}/${version}`][activityId] = schema;
68
+ }
69
+ getSubscriptions(appId, version) {
70
+ return this.subscriptions[`${appId}/${version}`];
71
+ }
72
+ getSubscription(appId, version, topic) {
73
+ return this.subscriptions?.[`${appId}/${version}`]?.[topic];
74
+ }
75
+ setSubscriptions(appId, version, subscriptions) {
76
+ this.subscriptions[`${appId}/${version}`] = subscriptions;
77
+ }
78
+ getSymbols(appId, targetEntityId) {
79
+ return this.symbols[`${appId}/${targetEntityId}`];
80
+ }
81
+ setSymbols(appId, targetEntityId, symbols) {
82
+ this.symbols[`${appId}/${targetEntityId}`] = symbols;
83
+ }
84
+ deleteSymbols(appId, targetEntityId) {
85
+ delete this.symbols[`${appId}/${targetEntityId}`];
86
+ }
87
+ getSymbolValues(appId) {
88
+ return this.symvals[`${appId}`];
89
+ }
90
+ setSymbolValues(appId, symvals) {
91
+ this.symvals[`${appId}`] = symvals;
92
+ }
93
+ deleteSymbolValues(appId) {
94
+ delete this.symvals[`${appId}`];
95
+ }
96
+ getTransitions(appId, version) {
97
+ return this.transitions[`${appId}/${version}`];
98
+ }
99
+ setTransitions(appId, version, transitions) {
100
+ this.transitions[`${appId}/${version}`] = transitions;
101
+ }
102
+ getHookRules(appId) {
103
+ return this.hookRules[`${appId}`];
104
+ }
105
+ setHookRules(appId, hookRules) {
106
+ this.hookRules[`${appId}`] = hookRules;
107
+ }
108
+ getSignals(appId, version) {
109
+ throw new Error("SIGNAL (getHooks) is not supported");
110
+ }
111
+ setSignals(appId, version) {
112
+ throw new Error("SIGNAL (setHook) is not supported");
113
+ }
114
+ getActiveTaskQueue(appId) {
115
+ return this.workItems[appId];
116
+ }
117
+ setWorkItem(appId, workItem) {
118
+ this.workItems[appId] = workItem;
119
+ }
120
+ removeWorkItem(appId) {
121
+ delete this.workItems[appId];
122
+ }
123
+ }
124
+ export { Cache };
@@ -0,0 +1,27 @@
1
+ import { KeyType } from '../../../modules/key';
2
+ import { ILogger } from '../../logger';
3
+ import { SerializerService as Serializer } from '../../serializer';
4
+ import { Cache } from '../cache';
5
+ import { StoreService } from '../index';
6
+ import { RedisClientType, RedisMultiType } from '../../../types/ioredisclient';
7
+ import { ReclaimedMessageType } from '../../../types/stream';
8
+ declare class IORedisStoreService extends StoreService<RedisClientType, RedisMultiType> {
9
+ redisClient: RedisClientType;
10
+ cache: Cache;
11
+ namespace: string;
12
+ appId: string;
13
+ logger: ILogger;
14
+ serializer: Serializer;
15
+ constructor(redisClient: RedisClientType);
16
+ getMulti(): RedisMultiType;
17
+ hGetAllResult(result: any): any;
18
+ addTaskQueues(keys: string[]): Promise<void>;
19
+ publish(keyType: KeyType.QUORUM, message: Record<string, any>, appId: string, engineId?: string): Promise<boolean>;
20
+ xgroup(command: 'CREATE', key: string, groupName: string, id: string, mkStream?: 'MKSTREAM'): Promise<boolean>;
21
+ xadd(key: string, id: string, messageId: string, messageValue: string, multi?: RedisMultiType): Promise<string | RedisMultiType>;
22
+ xpending(key: string, group: string, start?: string, end?: string, count?: number, consumer?: string): Promise<[string, string, number, [string, number][]][] | [string, string, number, number] | unknown[]>;
23
+ xclaim(key: string, group: string, consumer: string, minIdleTime: number, id: string, ...args: string[]): Promise<ReclaimedMessageType>;
24
+ xack(key: string, group: string, id: string, multi?: RedisMultiType): Promise<number | RedisMultiType>;
25
+ xdel(key: string, id: string, multi?: RedisMultiType): Promise<number | RedisMultiType>;
26
+ }
27
+ export { IORedisStoreService };
@@ -0,0 +1,93 @@
1
+ import { KeyType } from '../../../modules/key';
2
+ import { StoreService } from '../index';
3
+ class IORedisStoreService extends StoreService {
4
+ constructor(redisClient) {
5
+ super(redisClient);
6
+ }
7
+ getMulti() {
8
+ return this.redisClient.multi();
9
+ }
10
+ hGetAllResult(result) {
11
+ //ioredis response signature is [null, {}] or [null, null]
12
+ return result[1];
13
+ }
14
+ async addTaskQueues(keys) {
15
+ const multi = this.redisClient.multi();
16
+ const zsetKey = this.mintKey(KeyType.WORK_ITEMS, { appId: this.appId });
17
+ for (const key of keys) {
18
+ multi.zadd(zsetKey, 'NX', Date.now(), key);
19
+ }
20
+ await multi.exec();
21
+ }
22
+ async publish(keyType, message, appId, engineId) {
23
+ const topic = this.mintKey(keyType, { appId, engineId });
24
+ const status = await this.redisClient.publish(topic, JSON.stringify(message));
25
+ return status === 1;
26
+ }
27
+ async xgroup(command, key, groupName, id, mkStream) {
28
+ if (mkStream === 'MKSTREAM') {
29
+ try {
30
+ return (await this.redisClient.xgroup(command, key, groupName, id, mkStream)) === 'OK';
31
+ }
32
+ catch (err) {
33
+ this.logger.info(`Consumer group not created with MKSTREAM for key: ${key} and group: ${groupName}`);
34
+ throw err;
35
+ }
36
+ }
37
+ else {
38
+ try {
39
+ return (await this.redisClient.xgroup(command, key, groupName, id)) === 'OK';
40
+ }
41
+ catch (err) {
42
+ this.logger.info(`Consumer group not created for key: ${key} and group: ${groupName}`);
43
+ throw err;
44
+ }
45
+ }
46
+ }
47
+ async xadd(key, id, messageId, messageValue, multi) {
48
+ try {
49
+ return await (multi || this.redisClient).xadd(key, id, messageId, messageValue);
50
+ }
51
+ catch (err) {
52
+ this.logger.error(`Error publishing 'xadd'; key: ${key}`, err);
53
+ throw err;
54
+ }
55
+ }
56
+ async xpending(key, group, start, end, count, consumer) {
57
+ try {
58
+ return await this.redisClient.xpending(key, group, start, end, count, consumer);
59
+ }
60
+ catch (err) {
61
+ this.logger.error(`Error in retrieving pending messages for [stream ${key}], [group ${group}]`, err);
62
+ throw err;
63
+ }
64
+ }
65
+ async xclaim(key, group, consumer, minIdleTime, id, ...args) {
66
+ try {
67
+ return await this.redisClient.xclaim(key, group, consumer, minIdleTime, id, ...args);
68
+ }
69
+ catch (err) {
70
+ this.logger.error(`Error in claiming message with id: ${id} in group: ${group} for key: ${key}`, err);
71
+ throw err;
72
+ }
73
+ }
74
+ async xack(key, group, id, multi) {
75
+ try {
76
+ return await (multi || this.redisClient).xack(key, group, id);
77
+ }
78
+ catch (err) {
79
+ this.logger.error(`Error in acknowledging messages in group: ${group} for key: ${key}`, err);
80
+ throw err;
81
+ }
82
+ }
83
+ async xdel(key, id, multi) {
84
+ try {
85
+ return await (multi || this.redisClient).xdel(key, id);
86
+ }
87
+ catch (err) {
88
+ this.logger.error(`Error in deleting messages with id: ${id} for key: ${key}`, err);
89
+ throw err;
90
+ }
91
+ }
92
+ }
93
+ export { IORedisStoreService };