@hotmeshio/hotmesh 0.0.7 → 0.0.9

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 (365) hide show
  1. package/LICENSE +4 -7
  2. package/README.md +37 -46
  3. package/build/{esm/package.json → package.json} +6 -11
  4. package/build/{cjs/services → services}/activities/activity.d.ts +6 -0
  5. package/build/{cjs/services → services}/activities/activity.js +83 -7
  6. package/build/{cjs/services → services}/activities/await.d.ts +2 -2
  7. package/build/{cjs/services → services}/activities/await.js +5 -5
  8. package/build/services/activities/cycle.d.ts +19 -0
  9. package/build/services/activities/cycle.js +77 -0
  10. package/build/{esm/services → services}/activities/index.d.ts +4 -2
  11. package/build/{cjs/services → services}/activities/index.js +4 -2
  12. package/build/{cjs/services → services}/activities/worker.d.ts +0 -8
  13. package/build/services/activities/worker.js +73 -0
  14. package/build/{esm/services → services}/collator/index.d.ts +18 -1
  15. package/build/{cjs/services → services}/collator/index.js +41 -11
  16. package/build/{cjs/services → services}/durable/factory.js +17 -1
  17. package/build/{cjs/services → services}/durable/native.js +2 -2
  18. package/build/{cjs/services → services}/durable/worker.d.ts +2 -3
  19. package/build/{esm/services → services}/durable/worker.js +35 -37
  20. package/build/{cjs/services → services}/durable/workflow.js +11 -2
  21. package/build/{cjs/services → services}/mapper/index.js +3 -0
  22. package/build/{cjs/services → services}/signaler/stream.js +0 -1
  23. package/build/{esm/types → types}/activity.d.ts +7 -2
  24. package/build/{cjs/types → types}/durable.d.ts +4 -6
  25. package/build/{cjs/types → types}/index.d.ts +1 -1
  26. package/package.json +6 -11
  27. package/services/activities/activity.ts +90 -7
  28. package/services/activities/await.ts +5 -5
  29. package/services/activities/cycle.ts +96 -0
  30. package/services/activities/index.ts +4 -2
  31. package/services/activities/worker.ts +2 -93
  32. package/services/collator/index.ts +43 -11
  33. package/services/durable/factory.ts +17 -1
  34. package/services/durable/native.ts +2 -2
  35. package/services/durable/worker.ts +19 -22
  36. package/services/durable/workflow.ts +11 -2
  37. package/services/mapper/index.ts +3 -0
  38. package/services/signaler/stream.ts +0 -1
  39. package/types/activity.ts +8 -1
  40. package/types/durable.ts +4 -4
  41. package/types/index.ts +1 -0
  42. package/build/cjs/package.json +0 -80
  43. package/build/cjs/services/activities/index.d.ts +0 -15
  44. package/build/cjs/services/activities/worker.js +0 -159
  45. package/build/cjs/services/collator/index.d.ts +0 -56
  46. package/build/cjs/services/durable/worker.js +0 -298
  47. package/build/cjs/types/activity.d.ts +0 -87
  48. package/build/esm/index.d.ts +0 -4
  49. package/build/esm/index.js +0 -3
  50. package/build/esm/modules/errors.d.ts +0 -28
  51. package/build/esm/modules/errors.js +0 -41
  52. package/build/esm/modules/key.d.ts +0 -75
  53. package/build/esm/modules/key.js +0 -111
  54. package/build/esm/modules/utils.d.ts +0 -34
  55. package/build/esm/modules/utils.js +0 -154
  56. package/build/esm/services/activities/activity.d.ts +0 -61
  57. package/build/esm/services/activities/activity.js +0 -410
  58. package/build/esm/services/activities/await.d.ts +0 -16
  59. package/build/esm/services/activities/await.js +0 -140
  60. package/build/esm/services/activities/emit.d.ts +0 -9
  61. package/build/esm/services/activities/emit.js +0 -10
  62. package/build/esm/services/activities/index.js +0 -14
  63. package/build/esm/services/activities/iterate.d.ts +0 -9
  64. package/build/esm/services/activities/iterate.js +0 -10
  65. package/build/esm/services/activities/trigger.d.ts +0 -22
  66. package/build/esm/services/activities/trigger.js +0 -158
  67. package/build/esm/services/activities/worker.d.ts +0 -19
  68. package/build/esm/services/activities/worker.js +0 -156
  69. package/build/esm/services/collator/index.js +0 -191
  70. package/build/esm/services/compiler/deployer.d.ts +0 -36
  71. package/build/esm/services/compiler/deployer.js +0 -423
  72. package/build/esm/services/compiler/index.d.ts +0 -30
  73. package/build/esm/services/compiler/index.js +0 -82
  74. package/build/esm/services/compiler/validator.d.ts +0 -32
  75. package/build/esm/services/compiler/validator.js +0 -131
  76. package/build/esm/services/connector/clients/ioredis.d.ts +0 -13
  77. package/build/esm/services/connector/clients/ioredis.js +0 -47
  78. package/build/esm/services/connector/clients/redis.d.ts +0 -13
  79. package/build/esm/services/connector/clients/redis.js +0 -59
  80. package/build/esm/services/connector/index.d.ts +0 -5
  81. package/build/esm/services/connector/index.js +0 -27
  82. package/build/esm/services/dimension/index.d.ts +0 -29
  83. package/build/esm/services/dimension/index.js +0 -32
  84. package/build/esm/services/durable/asyncLocalStorage.d.ts +0 -3
  85. package/build/esm/services/durable/asyncLocalStorage.js +0 -2
  86. package/build/esm/services/durable/client.d.ts +0 -15
  87. package/build/esm/services/durable/client.js +0 -114
  88. package/build/esm/services/durable/connection.d.ts +0 -4
  89. package/build/esm/services/durable/connection.js +0 -47
  90. package/build/esm/services/durable/factory.d.ts +0 -3
  91. package/build/esm/services/durable/factory.js +0 -119
  92. package/build/esm/services/durable/handle.d.ts +0 -8
  93. package/build/esm/services/durable/handle.js +0 -34
  94. package/build/esm/services/durable/index.d.ts +0 -57
  95. package/build/esm/services/durable/index.js +0 -55
  96. package/build/esm/services/durable/native.d.ts +0 -4
  97. package/build/esm/services/durable/native.js +0 -43
  98. package/build/esm/services/durable/worker.d.ts +0 -37
  99. package/build/esm/services/durable/workflow.d.ts +0 -6
  100. package/build/esm/services/durable/workflow.js +0 -128
  101. package/build/esm/services/engine/index.d.ts +0 -82
  102. package/build/esm/services/engine/index.js +0 -522
  103. package/build/esm/services/hotmesh/index.d.ts +0 -45
  104. package/build/esm/services/hotmesh/index.js +0 -131
  105. package/build/esm/services/logger/index.d.ts +0 -17
  106. package/build/esm/services/logger/index.js +0 -70
  107. package/build/esm/services/mapper/index.d.ts +0 -24
  108. package/build/esm/services/mapper/index.js +0 -69
  109. package/build/esm/services/pipe/functions/array.d.ts +0 -24
  110. package/build/esm/services/pipe/functions/array.js +0 -66
  111. package/build/esm/services/pipe/functions/bitwise.d.ts +0 -9
  112. package/build/esm/services/pipe/functions/bitwise.js +0 -21
  113. package/build/esm/services/pipe/functions/conditional.d.ts +0 -10
  114. package/build/esm/services/pipe/functions/conditional.js +0 -24
  115. package/build/esm/services/pipe/functions/date.d.ts +0 -57
  116. package/build/esm/services/pipe/functions/date.js +0 -164
  117. package/build/esm/services/pipe/functions/index.d.ts +0 -25
  118. package/build/esm/services/pipe/functions/index.js +0 -24
  119. package/build/esm/services/pipe/functions/json.d.ts +0 -5
  120. package/build/esm/services/pipe/functions/json.js +0 -9
  121. package/build/esm/services/pipe/functions/math.d.ts +0 -38
  122. package/build/esm/services/pipe/functions/math.js +0 -108
  123. package/build/esm/services/pipe/functions/number.d.ts +0 -25
  124. package/build/esm/services/pipe/functions/number.js +0 -130
  125. package/build/esm/services/pipe/functions/object.d.ts +0 -22
  126. package/build/esm/services/pipe/functions/object.js +0 -60
  127. package/build/esm/services/pipe/functions/string.d.ts +0 -23
  128. package/build/esm/services/pipe/functions/string.js +0 -66
  129. package/build/esm/services/pipe/functions/symbol.d.ts +0 -12
  130. package/build/esm/services/pipe/functions/symbol.js +0 -30
  131. package/build/esm/services/pipe/functions/unary.d.ts +0 -7
  132. package/build/esm/services/pipe/functions/unary.js +0 -15
  133. package/build/esm/services/pipe/index.d.ts +0 -30
  134. package/build/esm/services/pipe/index.js +0 -122
  135. package/build/esm/services/quorum/index.d.ts +0 -34
  136. package/build/esm/services/quorum/index.js +0 -144
  137. package/build/esm/services/reporter/index.d.ts +0 -47
  138. package/build/esm/services/reporter/index.js +0 -327
  139. package/build/esm/services/serializer/index.d.ts +0 -41
  140. package/build/esm/services/serializer/index.js +0 -251
  141. package/build/esm/services/signaler/store.d.ts +0 -15
  142. package/build/esm/services/signaler/store.js +0 -50
  143. package/build/esm/services/signaler/stream.d.ts +0 -43
  144. package/build/esm/services/signaler/stream.js +0 -315
  145. package/build/esm/services/store/cache.d.ts +0 -66
  146. package/build/esm/services/store/cache.js +0 -124
  147. package/build/esm/services/store/clients/ioredis.d.ts +0 -27
  148. package/build/esm/services/store/clients/ioredis.js +0 -93
  149. package/build/esm/services/store/clients/redis.d.ts +0 -29
  150. package/build/esm/services/store/clients/redis.js +0 -140
  151. package/build/esm/services/store/index.d.ts +0 -88
  152. package/build/esm/services/store/index.js +0 -623
  153. package/build/esm/services/stream/clients/ioredis.d.ts +0 -23
  154. package/build/esm/services/stream/clients/ioredis.js +0 -112
  155. package/build/esm/services/stream/clients/redis.d.ts +0 -23
  156. package/build/esm/services/stream/clients/redis.js +0 -116
  157. package/build/esm/services/stream/index.d.ts +0 -21
  158. package/build/esm/services/stream/index.js +0 -6
  159. package/build/esm/services/sub/clients/ioredis.d.ts +0 -20
  160. package/build/esm/services/sub/clients/ioredis.js +0 -69
  161. package/build/esm/services/sub/clients/redis.d.ts +0 -20
  162. package/build/esm/services/sub/clients/redis.js +0 -60
  163. package/build/esm/services/sub/index.d.ts +0 -18
  164. package/build/esm/services/sub/index.js +0 -6
  165. package/build/esm/services/task/index.d.ts +0 -18
  166. package/build/esm/services/task/index.js +0 -70
  167. package/build/esm/services/telemetry/index.d.ts +0 -49
  168. package/build/esm/services/telemetry/index.js +0 -217
  169. package/build/esm/services/worker/index.d.ts +0 -30
  170. package/build/esm/services/worker/index.js +0 -102
  171. package/build/esm/types/activity.js +0 -1
  172. package/build/esm/types/app.d.ts +0 -16
  173. package/build/esm/types/app.js +0 -1
  174. package/build/esm/types/async.d.ts +0 -5
  175. package/build/esm/types/async.js +0 -1
  176. package/build/esm/types/cache.d.ts +0 -1
  177. package/build/esm/types/cache.js +0 -1
  178. package/build/esm/types/collator.d.ts +0 -8
  179. package/build/esm/types/collator.js +0 -8
  180. package/build/esm/types/durable.d.ts +0 -59
  181. package/build/esm/types/durable.js +0 -1
  182. package/build/esm/types/hook.d.ts +0 -31
  183. package/build/esm/types/hook.js +0 -6
  184. package/build/esm/types/hotmesh.d.ts +0 -82
  185. package/build/esm/types/hotmesh.js +0 -1
  186. package/build/esm/types/index.d.ts +0 -20
  187. package/build/esm/types/index.js +0 -5
  188. package/build/esm/types/ioredisclient.d.ts +0 -5
  189. package/build/esm/types/ioredisclient.js +0 -2
  190. package/build/esm/types/job.d.ts +0 -50
  191. package/build/esm/types/job.js +0 -1
  192. package/build/esm/types/logger.d.ts +0 -6
  193. package/build/esm/types/logger.js +0 -1
  194. package/build/esm/types/map.d.ts +0 -4
  195. package/build/esm/types/map.js +0 -1
  196. package/build/esm/types/pipe.d.ts +0 -4
  197. package/build/esm/types/pipe.js +0 -1
  198. package/build/esm/types/quorum.d.ts +0 -46
  199. package/build/esm/types/quorum.js +0 -1
  200. package/build/esm/types/redis.d.ts +0 -8
  201. package/build/esm/types/redis.js +0 -1
  202. package/build/esm/types/redisclient.d.ts +0 -25
  203. package/build/esm/types/redisclient.js +0 -1
  204. package/build/esm/types/serializer.d.ts +0 -33
  205. package/build/esm/types/serializer.js +0 -1
  206. package/build/esm/types/stats.d.ts +0 -83
  207. package/build/esm/types/stats.js +0 -1
  208. package/build/esm/types/stream.d.ts +0 -67
  209. package/build/esm/types/stream.js +0 -22
  210. package/build/esm/types/telemetry.d.ts +0 -1
  211. package/build/esm/types/telemetry.js +0 -1
  212. package/build/esm/types/transition.d.ts +0 -17
  213. package/build/esm/types/transition.js +0 -1
  214. package/tsconfig.cjs.json +0 -8
  215. package/tsconfig.esm.json +0 -9
  216. /package/build/{cjs/index.d.ts → index.d.ts} +0 -0
  217. /package/build/{cjs/index.js → index.js} +0 -0
  218. /package/build/{cjs/modules → modules}/errors.d.ts +0 -0
  219. /package/build/{cjs/modules → modules}/errors.js +0 -0
  220. /package/build/{cjs/modules → modules}/key.d.ts +0 -0
  221. /package/build/{cjs/modules → modules}/key.js +0 -0
  222. /package/build/{cjs/modules → modules}/utils.d.ts +0 -0
  223. /package/build/{cjs/modules → modules}/utils.js +0 -0
  224. /package/build/{cjs/services → services}/activities/emit.d.ts +0 -0
  225. /package/build/{cjs/services → services}/activities/emit.js +0 -0
  226. /package/build/{cjs/services → services}/activities/iterate.d.ts +0 -0
  227. /package/build/{cjs/services → services}/activities/iterate.js +0 -0
  228. /package/build/{cjs/services → services}/activities/trigger.d.ts +0 -0
  229. /package/build/{cjs/services → services}/activities/trigger.js +0 -0
  230. /package/build/{cjs/services → services}/compiler/deployer.d.ts +0 -0
  231. /package/build/{cjs/services → services}/compiler/deployer.js +0 -0
  232. /package/build/{cjs/services → services}/compiler/index.d.ts +0 -0
  233. /package/build/{cjs/services → services}/compiler/index.js +0 -0
  234. /package/build/{cjs/services → services}/compiler/validator.d.ts +0 -0
  235. /package/build/{cjs/services → services}/compiler/validator.js +0 -0
  236. /package/build/{cjs/services → services}/connector/clients/ioredis.d.ts +0 -0
  237. /package/build/{cjs/services → services}/connector/clients/ioredis.js +0 -0
  238. /package/build/{cjs/services → services}/connector/clients/redis.d.ts +0 -0
  239. /package/build/{cjs/services → services}/connector/clients/redis.js +0 -0
  240. /package/build/{cjs/services → services}/connector/index.d.ts +0 -0
  241. /package/build/{cjs/services → services}/connector/index.js +0 -0
  242. /package/build/{cjs/services → services}/dimension/index.d.ts +0 -0
  243. /package/build/{cjs/services → services}/dimension/index.js +0 -0
  244. /package/build/{cjs/services → services}/durable/asyncLocalStorage.d.ts +0 -0
  245. /package/build/{cjs/services → services}/durable/asyncLocalStorage.js +0 -0
  246. /package/build/{cjs/services → services}/durable/client.d.ts +0 -0
  247. /package/build/{cjs/services → services}/durable/client.js +0 -0
  248. /package/build/{cjs/services → services}/durable/connection.d.ts +0 -0
  249. /package/build/{cjs/services → services}/durable/connection.js +0 -0
  250. /package/build/{cjs/services → services}/durable/factory.d.ts +0 -0
  251. /package/build/{cjs/services → services}/durable/handle.d.ts +0 -0
  252. /package/build/{cjs/services → services}/durable/handle.js +0 -0
  253. /package/build/{cjs/services → services}/durable/index.d.ts +0 -0
  254. /package/build/{cjs/services → services}/durable/index.js +0 -0
  255. /package/build/{cjs/services → services}/durable/native.d.ts +0 -0
  256. /package/build/{cjs/services → services}/durable/workflow.d.ts +0 -0
  257. /package/build/{cjs/services → services}/engine/index.d.ts +0 -0
  258. /package/build/{cjs/services → services}/engine/index.js +0 -0
  259. /package/build/{cjs/services → services}/hotmesh/index.d.ts +0 -0
  260. /package/build/{cjs/services → services}/hotmesh/index.js +0 -0
  261. /package/build/{cjs/services → services}/logger/index.d.ts +0 -0
  262. /package/build/{cjs/services → services}/logger/index.js +0 -0
  263. /package/build/{cjs/services → services}/mapper/index.d.ts +0 -0
  264. /package/build/{cjs/services → services}/pipe/functions/array.d.ts +0 -0
  265. /package/build/{cjs/services → services}/pipe/functions/array.js +0 -0
  266. /package/build/{cjs/services → services}/pipe/functions/bitwise.d.ts +0 -0
  267. /package/build/{cjs/services → services}/pipe/functions/bitwise.js +0 -0
  268. /package/build/{cjs/services → services}/pipe/functions/conditional.d.ts +0 -0
  269. /package/build/{cjs/services → services}/pipe/functions/conditional.js +0 -0
  270. /package/build/{cjs/services → services}/pipe/functions/date.d.ts +0 -0
  271. /package/build/{cjs/services → services}/pipe/functions/date.js +0 -0
  272. /package/build/{cjs/services → services}/pipe/functions/index.d.ts +0 -0
  273. /package/build/{cjs/services → services}/pipe/functions/index.js +0 -0
  274. /package/build/{cjs/services → services}/pipe/functions/json.d.ts +0 -0
  275. /package/build/{cjs/services → services}/pipe/functions/json.js +0 -0
  276. /package/build/{cjs/services → services}/pipe/functions/math.d.ts +0 -0
  277. /package/build/{cjs/services → services}/pipe/functions/math.js +0 -0
  278. /package/build/{cjs/services → services}/pipe/functions/number.d.ts +0 -0
  279. /package/build/{cjs/services → services}/pipe/functions/number.js +0 -0
  280. /package/build/{cjs/services → services}/pipe/functions/object.d.ts +0 -0
  281. /package/build/{cjs/services → services}/pipe/functions/object.js +0 -0
  282. /package/build/{cjs/services → services}/pipe/functions/string.d.ts +0 -0
  283. /package/build/{cjs/services → services}/pipe/functions/string.js +0 -0
  284. /package/build/{cjs/services → services}/pipe/functions/symbol.d.ts +0 -0
  285. /package/build/{cjs/services → services}/pipe/functions/symbol.js +0 -0
  286. /package/build/{cjs/services → services}/pipe/functions/unary.d.ts +0 -0
  287. /package/build/{cjs/services → services}/pipe/functions/unary.js +0 -0
  288. /package/build/{cjs/services → services}/pipe/index.d.ts +0 -0
  289. /package/build/{cjs/services → services}/pipe/index.js +0 -0
  290. /package/build/{cjs/services → services}/quorum/index.d.ts +0 -0
  291. /package/build/{cjs/services → services}/quorum/index.js +0 -0
  292. /package/build/{cjs/services → services}/reporter/index.d.ts +0 -0
  293. /package/build/{cjs/services → services}/reporter/index.js +0 -0
  294. /package/build/{cjs/services → services}/serializer/index.d.ts +0 -0
  295. /package/build/{cjs/services → services}/serializer/index.js +0 -0
  296. /package/build/{cjs/services → services}/signaler/store.d.ts +0 -0
  297. /package/build/{cjs/services → services}/signaler/store.js +0 -0
  298. /package/build/{cjs/services → services}/signaler/stream.d.ts +0 -0
  299. /package/build/{cjs/services → services}/store/cache.d.ts +0 -0
  300. /package/build/{cjs/services → services}/store/cache.js +0 -0
  301. /package/build/{cjs/services → services}/store/clients/ioredis.d.ts +0 -0
  302. /package/build/{cjs/services → services}/store/clients/ioredis.js +0 -0
  303. /package/build/{cjs/services → services}/store/clients/redis.d.ts +0 -0
  304. /package/build/{cjs/services → services}/store/clients/redis.js +0 -0
  305. /package/build/{cjs/services → services}/store/index.d.ts +0 -0
  306. /package/build/{cjs/services → services}/store/index.js +0 -0
  307. /package/build/{cjs/services → services}/stream/clients/ioredis.d.ts +0 -0
  308. /package/build/{cjs/services → services}/stream/clients/ioredis.js +0 -0
  309. /package/build/{cjs/services → services}/stream/clients/redis.d.ts +0 -0
  310. /package/build/{cjs/services → services}/stream/clients/redis.js +0 -0
  311. /package/build/{cjs/services → services}/stream/index.d.ts +0 -0
  312. /package/build/{cjs/services → services}/stream/index.js +0 -0
  313. /package/build/{cjs/services → services}/sub/clients/ioredis.d.ts +0 -0
  314. /package/build/{cjs/services → services}/sub/clients/ioredis.js +0 -0
  315. /package/build/{cjs/services → services}/sub/clients/redis.d.ts +0 -0
  316. /package/build/{cjs/services → services}/sub/clients/redis.js +0 -0
  317. /package/build/{cjs/services → services}/sub/index.d.ts +0 -0
  318. /package/build/{cjs/services → services}/sub/index.js +0 -0
  319. /package/build/{cjs/services → services}/task/index.d.ts +0 -0
  320. /package/build/{cjs/services → services}/task/index.js +0 -0
  321. /package/build/{cjs/services → services}/telemetry/index.d.ts +0 -0
  322. /package/build/{cjs/services → services}/telemetry/index.js +0 -0
  323. /package/build/{cjs/services → services}/worker/index.d.ts +0 -0
  324. /package/build/{cjs/services → services}/worker/index.js +0 -0
  325. /package/build/{cjs/types → types}/activity.js +0 -0
  326. /package/build/{cjs/types → types}/app.d.ts +0 -0
  327. /package/build/{cjs/types → types}/app.js +0 -0
  328. /package/build/{cjs/types → types}/async.d.ts +0 -0
  329. /package/build/{cjs/types → types}/async.js +0 -0
  330. /package/build/{cjs/types → types}/cache.d.ts +0 -0
  331. /package/build/{cjs/types → types}/cache.js +0 -0
  332. /package/build/{cjs/types → types}/collator.d.ts +0 -0
  333. /package/build/{cjs/types → types}/collator.js +0 -0
  334. /package/build/{cjs/types → types}/durable.js +0 -0
  335. /package/build/{cjs/types → types}/hook.d.ts +0 -0
  336. /package/build/{cjs/types → types}/hook.js +0 -0
  337. /package/build/{cjs/types → types}/hotmesh.d.ts +0 -0
  338. /package/build/{cjs/types → types}/hotmesh.js +0 -0
  339. /package/build/{cjs/types → types}/index.js +0 -0
  340. /package/build/{cjs/types → types}/ioredisclient.d.ts +0 -0
  341. /package/build/{cjs/types → types}/ioredisclient.js +0 -0
  342. /package/build/{cjs/types → types}/job.d.ts +0 -0
  343. /package/build/{cjs/types → types}/job.js +0 -0
  344. /package/build/{cjs/types → types}/logger.d.ts +0 -0
  345. /package/build/{cjs/types → types}/logger.js +0 -0
  346. /package/build/{cjs/types → types}/map.d.ts +0 -0
  347. /package/build/{cjs/types → types}/map.js +0 -0
  348. /package/build/{cjs/types → types}/pipe.d.ts +0 -0
  349. /package/build/{cjs/types → types}/pipe.js +0 -0
  350. /package/build/{cjs/types → types}/quorum.d.ts +0 -0
  351. /package/build/{cjs/types → types}/quorum.js +0 -0
  352. /package/build/{cjs/types → types}/redis.d.ts +0 -0
  353. /package/build/{cjs/types → types}/redis.js +0 -0
  354. /package/build/{cjs/types → types}/redisclient.d.ts +0 -0
  355. /package/build/{cjs/types → types}/redisclient.js +0 -0
  356. /package/build/{cjs/types → types}/serializer.d.ts +0 -0
  357. /package/build/{cjs/types → types}/serializer.js +0 -0
  358. /package/build/{cjs/types → types}/stats.d.ts +0 -0
  359. /package/build/{cjs/types → types}/stats.js +0 -0
  360. /package/build/{cjs/types → types}/stream.d.ts +0 -0
  361. /package/build/{cjs/types → types}/stream.js +0 -0
  362. /package/build/{cjs/types → types}/telemetry.d.ts +0 -0
  363. /package/build/{cjs/types → types}/telemetry.js +0 -0
  364. /package/build/{cjs/types → types}/transition.d.ts +0 -0
  365. /package/build/{cjs/types → types}/transition.js +0 -0
package/LICENSE CHANGED
@@ -178,13 +178,10 @@ Terms and Conditions for Use, Reproduction, and Distribution
178
178
  product that includes the Work or any part of it, as a commercial
179
179
  service to third parties, or in any other commercial context where
180
180
  you derive direct or indirect financial benefit from the use of the
181
- Work. This includes, but is not limited to, providing
182
- routing-as-a-service, bpm-as-a-service, workflow-as-a-service,
183
- integration-as-a-service, operational-data-as-a-service
184
- or any other similar service that would compete with
185
- HotMesh's commercial offering of workflow and routing services.
186
- Any such use requires explicit written permission from the
187
- Licensor.
181
+ Work in a manner that would compete with the Licensor's commercial
182
+ service-mesh-as-a-service, bpm-as-a-service, workflow-as-a-service,
183
+ integration-as-a-service or similar orchestration-type service.
184
+ Any such use requires explicit written permission from the Licensor.
188
185
 
189
186
  END OF TERMS AND CONDITIONS
190
187
 
package/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # HotMesh
2
2
  ![alpha release](https://img.shields.io/badge/release-alpha-yellow)
3
3
 
4
- Build sophisticated, durable workflows without the overhead of a dedicated server cluster. With HotMesh, your code remains front and center using [infrastructure](https://github.com/hotmeshio/sdk-typescript/blob/main/docs/faq.md#what-is-hotmesh) you already own.
4
+ Elevate Redis from an in-memory data store to a game-changing **service mesh**, delivering *durable* workflows without the overhead of a dedicated control plane. With HotMesh, you can keep your code at the forefront, utilizing [Redis infrastructure](https://github.com/hotmeshio/sdk-typescript/blob/main/docs/faq.md#what-is-hotmesh) you already trust and own.
5
5
 
6
6
  ## Install
7
7
  [![npm version](https://badge.fury.io/js/%40hotmeshio%2Fhotmesh.svg)](https://badge.fury.io/js/%40hotmeshio%2Fhotmesh)
@@ -11,7 +11,9 @@ npm install @hotmeshio/hotmesh
11
11
  ```
12
12
 
13
13
  ## Design
14
- HotMesh's TypeScript SDK is modeled after [Temporal IO's](https://github.com/temporalio) developer-friendly approach. Design and deploy durable workflows using familiar paradigms that keep your code delightful to maintain. Deploying Temporal's [hello-world tutorial](https://github.com/temporalio/samples-typescript/tree/main/hello-world/src), for example, requires few changes beyond using the HotMesh SDK and saving to Redis.
14
+ HotMesh's TypeScript SDK is modeled after Temporal IO's developer-friendly approach. Design and deploy durable workflows using your preferred coding style. Write your functions as you normally would, then use the HotMesh to make them durable. Temporal's [hello-world tutorial](https://github.com/temporalio/samples-typescript/tree/main/hello-world/src), for example, requires few changes beyond importing the HotMesh SDK.
15
+
16
+ >Start by defining activities. These are the functions that will be invoked by your workflow. They can be written in any style, using any framework, and can even be legacy functions you've already written. The only requirement is that they return a Promise.
15
17
 
16
18
  **./activities.ts**
17
19
  ```javascript
@@ -20,85 +22,74 @@ export async function greet(name: string): Promise<string> {
20
22
  }
21
23
  ```
22
24
 
25
+ >Next, define your workflow. Include conditional logic, loops, etc. It's vanilla code written in your own coding style--just make sure to call `proxyActivities` to run your activities durably.
26
+
23
27
  **./workflows.ts**
24
28
  ```javascript
25
29
  import { Durable } from '@hotmeshio/hotmesh';
26
- import type * as activities from './activities';
30
+ import * as activities from './activities';
27
31
 
28
- const { greet } = Durable.workflow.proxyActivities<typeof activities>();
32
+ const { greet } = Durable.workflow
33
+ .proxyActivities<typeof activities>({
34
+ activities
35
+ });
29
36
 
30
37
  export async function example(name: string): Promise<string> {
31
38
  return await greet(name);
32
39
  }
33
40
  ```
34
41
 
35
- **./worker.ts**
36
- ```javascript
37
- import { Durable } from '@hotmeshio/hotmesh';
38
- import Redis from 'ioredis'; //OR `import * as Redis from 'redis';`
39
- import * as activities from './activities';
40
-
41
- async function run() {
42
- const connection = await Durable.NativeConnection.connect({
43
- class: Redis,
44
- options: {
45
- host: 'localhost',
46
- port: 6379,
47
- },
48
- });
49
- const worker = await Durable.Worker.create({
50
- connection,
51
- namespace: 'default',
52
- taskQueue: 'hello-world',
53
- workflowsPath: require.resolve('./workflows'),
54
- activities,
55
- });
56
- await worker.run();
57
- }
58
-
59
- run().catch((err) => {
60
- console.error(err);
61
- process.exit(1);
62
- });
63
- ```
42
+ >Finally, create a worker and client. The *client* triggers workflows, while the *worker* runs them, retrying as necessary until the workflow succeeds--all without the need for complicated retry logic.
64
43
 
65
44
  **./client.ts**
66
45
  ```javascript
67
46
  import { Durable } from '@hotmeshio/hotmesh';
68
- import Redis from 'ioredis';
47
+ import Redis from 'ioredis'; //OR `import * as Redis from 'redis';`
69
48
  import { v4 as uuidv4 } from 'uuid';
70
49
 
71
50
  async function run() {
72
51
  const connection = await Durable.Connection.connect({
73
52
  class: Redis,
74
- options: {
75
- host: 'localhost',
76
- port: 6379,
77
- },
53
+ options: { host: 'localhost', port: 6379 }
78
54
  });
79
55
 
80
56
  const client = new Durable.Client({
81
- connection,
57
+ connection
82
58
  });
83
59
 
84
60
  const handle = await client.workflow.start({
85
61
  args: ['HotMesh'],
86
62
  taskQueue: 'hello-world',
87
63
  workflowName: 'example',
88
- workflowId: 'workflow-' + uuidv4(),
64
+ workflowId: 'workflow-' + uuidv4()
89
65
  });
90
66
 
91
- console.log(`Started workflow ${handle.workflowId}`);
92
67
  console.log(await handle.result());
93
68
  }
69
+ ```
94
70
 
95
- run().catch((err) => {
96
- console.error(err);
97
- process.exit(1);
98
- });
71
+ **./worker.ts**
72
+ ```javascript
73
+ import { Durable } from '@hotmeshio/hotmesh';
74
+ import Redis from 'ioredis';
75
+ import * as workflows from './workflows';
76
+
77
+ async function run() {
78
+ const connection = await Durable.NativeConnection.connect({
79
+ class: Redis,
80
+ options: { host: 'localhost', port: 6379 },
81
+ });
82
+ const worker = await Durable.Worker.create({
83
+ connection,
84
+ namespace: 'default',
85
+ taskQueue: 'hello-world',
86
+ workflow: workflows.example,
87
+ });
88
+ await worker.run();
89
+ }
99
90
  ```
100
91
 
101
- >HotMesh delivers durable function execution using a [distributed service mesh](https://github.com/hotmeshio/sdk-typescript/blob/main/docs/distributed_orchestration.md). The design consumes leftover CPU on your microservices to execute workflows without the cost and complexity of a central server/control plane.
92
+ >HotMesh delivers durable function execution using a [distributed service mesh](https://github.com/hotmeshio/sdk-typescript/blob/main/docs/distributed_orchestration.md). The design delivers durable workflows without the cost and complexity of a centralized service mesh/control plane. Refer to the [hotmeshio/samples-typescript](https://github.com/hotmeshio/samples-typescript) Git Repo for a range of examples, including nested workflows.
102
93
 
103
94
  ## Advanced Design
104
95
  HotMesh's TypeScript SDK is the easiest way to make your functions durable. But if you need full control over your function lifecycles (including high-volume, high-speed use cases), you can use HotMesh's underlying YAML models to optimize your durable workflows. The following model depicts a sequence of activities orchestrated by HotMesh. Any function you associate with a `topic` in your YAML definition is guaranteed to be durable.
@@ -1,14 +1,9 @@
1
1
  {
2
2
  "name": "@hotmeshio/hotmesh",
3
- "version": "0.0.7",
3
+ "version": "0.0.9",
4
4
  "description": "Durable Workflows",
5
- "main": "build/cjs/index.js",
6
- "module": "build/esm/index.js",
7
- "types": "build/cjs/index.d.ts",
8
- "exports": {
9
- "import": "./build/esm/index.js",
10
- "require": "./build/cjs/index.js"
11
- },
5
+ "main": "build/index.js",
6
+ "types": "build/index.d.ts",
12
7
  "repository": {
13
8
  "type": "git",
14
9
  "url": "https://github.com/hotmeshio/sdk-typescript.git"
@@ -19,9 +14,7 @@
19
14
  },
20
15
  "scripts": {
21
16
  "clean": "rimraf ./build",
22
- "build:cjs": "tsc --build tsconfig.cjs.json",
23
- "build:esm": "tsc --build tsconfig.esm.json",
24
- "build": "npm run build:cjs && npm run build:esm",
17
+ "build": "tsc --build tsconfig.json",
25
18
  "clean-build": "npm run clean && npm run build",
26
19
  "lint": "eslint . --ext .ts",
27
20
  "lint:fix": "eslint . --fix --ext .ts",
@@ -29,6 +22,7 @@
29
22
  "test": "NODE_ENV=test jest --detectOpenHandles --forceExit --verbose",
30
23
  "test:hmsh": "NODE_ENV=test jest ./tests/functional/index.test.ts --detectOpenHandles --verbose",
31
24
  "test:compile": "NODE_ENV=test jest ./tests/functional/compile/index.test.ts --detectOpenHandles --forceExit --verbose",
25
+ "test:cycle": "NODE_ENV=test jest ./tests/functional/cycle/index.test.ts --detectOpenHandles --forceExit --verbose",
32
26
  "test:connect": "NODE_ENV=test jest ./tests/unit/services/connector/index.test.ts --detectOpenHandles --forceExit --verbose",
33
27
  "test:connect:redis": "NODE_ENV=test jest ./tests/unit/services/connector/clients/redis.test.ts --detectOpenHandles --forceExit --verbose",
34
28
  "test:connect:ioredis": "NODE_ENV=test jest ./tests/unit/services/connector/clients/ioredis.test.ts --detectOpenHandles --forceExit --verbose",
@@ -48,6 +42,7 @@
48
42
  "test:durable": "NODE_ENV=test jest ./tests/durable/*/index.test.ts --detectOpenHandles --forceExit --verbose",
49
43
  "test:durable:hello": "NODE_ENV=test jest ./tests/durable/helloworld/index.test.ts --detectOpenHandles --forceExit --verbose",
50
44
  "test:durable:goodbye": "NODE_ENV=test jest ./tests/durable/goodbye/index.test.ts --detectOpenHandles --forceExit --verbose",
45
+ "test:durable:retry": "NODE_ENV=test jest ./tests/durable/retry/index.test.ts --detectOpenHandles --forceExit --verbose",
51
46
  "test:durable:loopactivity": "NODE_ENV=test jest ./tests/durable/loopactivity/index.test.ts --detectOpenHandles --forceExit --verbose",
52
47
  "test:durable:nested": "NODE_ENV=test jest ./tests/durable/nested/index.test.ts --detectOpenHandles --forceExit --verbose"
53
48
  },
@@ -1,6 +1,7 @@
1
1
  import { EngineService } from '../engine';
2
2
  import { ILogger } from '../logger';
3
3
  import { StoreService } from '../store';
4
+ import { TelemetryService } from '../telemetry';
4
5
  import { ActivityData, ActivityLeg, ActivityMetadata, ActivityType } from '../../types/activity';
5
6
  import { JobState, JobStatus } from '../../types/job';
6
7
  import { MultiResponseFlags, RedisClient, RedisMulti } from '../../types/redis';
@@ -31,6 +32,11 @@ declare class Activity {
31
32
  processWebHookEvent(): Promise<JobStatus | void>;
32
33
  processTimeHookEvent(jobId: string): Promise<JobStatus | void>;
33
34
  processHookEvent(jobId: string): Promise<JobStatus | void>;
35
+ processEvent(status?: StreamStatus, code?: StreamCode): Promise<void>;
36
+ processPending(telemetry: TelemetryService): Promise<MultiResponseFlags>;
37
+ processSuccess(telemetry: TelemetryService): Promise<MultiResponseFlags>;
38
+ processError(telemetry: TelemetryService): Promise<MultiResponseFlags>;
39
+ transitionAdjacent(multiResponse: MultiResponseFlags, telemetry: TelemetryService): Promise<void>;
34
40
  resolveStatus(multiResponse: MultiResponseFlags): number;
35
41
  mapJobData(): void;
36
42
  mapInputData(): void;
@@ -87,7 +87,7 @@ class Activity {
87
87
  setLeg(leg) {
88
88
  this.leg = leg;
89
89
  }
90
- //******** SIGNALER RE-ENTRY POINT (B) ********//
90
+ //******** SIGNAL RE-ENTRY POINT ********//
91
91
  doesHook() {
92
92
  return !!(this.config.hook?.topic || this.config.sleep);
93
93
  }
@@ -125,11 +125,6 @@ class Activity {
125
125
  });
126
126
  return await this.processHookEvent(jobId);
127
127
  }
128
- //todo: hooks are currently singletons. but they can support
129
- // dimensional threads like `await` and `worker` do.
130
- // Copy code from those activities to support cyclical
131
- // timehook and eventhook inputs by adding a 'pending'
132
- // flag to hooks that allows for repeated signals
133
128
  async processHookEvent(jobId) {
134
129
  this.logger.debug('activity-process-hook-event', { jobId });
135
130
  let telemetry;
@@ -159,7 +154,6 @@ class Activity {
159
154
  return jobStatus;
160
155
  }
161
156
  catch (error) {
162
- console.error('this error?', error);
163
157
  this.logger.error('engine-process-hook-event-error', error);
164
158
  telemetry.setActivityError(error.message);
165
159
  throw error;
@@ -168,6 +162,88 @@ class Activity {
168
162
  telemetry.endActivitySpan();
169
163
  }
170
164
  }
165
+ //******** DUPLEX RE-ENTRY POINT ********//
166
+ async processEvent(status = stream_1.StreamStatus.SUCCESS, code = 200) {
167
+ this.setLeg(2);
168
+ const jid = this.context.metadata.jid;
169
+ const aid = this.metadata.aid;
170
+ this.status = status;
171
+ this.code = code;
172
+ this.logger.debug('activity-process-event', { topic: this.config.subtype, jid, aid, status, code });
173
+ let telemetry;
174
+ try {
175
+ await this.getState();
176
+ const aState = await collator_1.CollatorService.notarizeReentry(this);
177
+ this.adjacentIndex = collator_1.CollatorService.getDimensionalIndex(aState);
178
+ telemetry = new telemetry_1.TelemetryService(this.engine.appId, this.config, this.metadata, this.context);
179
+ let isComplete = collator_1.CollatorService.isActivityComplete(this.context.metadata.js);
180
+ if (isComplete) {
181
+ this.logger.warn('activity-process-event-duplicate', { jid, aid });
182
+ this.logger.debug('activity-process-event-duplicate-resolution', { resolution: 'Increase HotMesh config `reclaimDelay` timeout.' });
183
+ return;
184
+ }
185
+ telemetry.startActivitySpan(this.leg);
186
+ let multiResponse;
187
+ if (status === stream_1.StreamStatus.PENDING) {
188
+ multiResponse = await this.processPending(telemetry);
189
+ }
190
+ else if (status === stream_1.StreamStatus.SUCCESS) {
191
+ multiResponse = await this.processSuccess(telemetry);
192
+ }
193
+ else {
194
+ multiResponse = await this.processError(telemetry);
195
+ }
196
+ this.transitionAdjacent(multiResponse, telemetry);
197
+ }
198
+ catch (error) {
199
+ this.logger.error('activity-process-event-error', error);
200
+ telemetry.setActivityError(error.message);
201
+ throw error;
202
+ }
203
+ finally {
204
+ telemetry.endActivitySpan();
205
+ this.logger.debug('activity-process-event-end', { jid, aid });
206
+ }
207
+ }
208
+ async processPending(telemetry) {
209
+ this.bindActivityData('output');
210
+ this.adjacencyList = await this.filterAdjacent();
211
+ this.mapJobData();
212
+ const multi = this.store.getMulti();
213
+ await this.setState(multi);
214
+ await collator_1.CollatorService.notarizeContinuation(this, multi);
215
+ await this.setStatus(this.adjacencyList.length, multi);
216
+ return await multi.exec();
217
+ }
218
+ async processSuccess(telemetry) {
219
+ this.bindActivityData('output');
220
+ this.adjacencyList = await this.filterAdjacent();
221
+ this.mapJobData();
222
+ const multi = this.store.getMulti();
223
+ await this.setState(multi);
224
+ await collator_1.CollatorService.notarizeCompletion(this, multi);
225
+ await this.setStatus(this.adjacencyList.length - 1, multi);
226
+ return await multi.exec();
227
+ }
228
+ async processError(telemetry) {
229
+ this.bindActivityError(this.data);
230
+ this.adjacencyList = await this.filterAdjacent();
231
+ const multi = this.store.getMulti();
232
+ await this.setState(multi);
233
+ await collator_1.CollatorService.notarizeCompletion(this, multi);
234
+ await this.setStatus(this.adjacencyList.length - 1, multi);
235
+ return await multi.exec();
236
+ }
237
+ async transitionAdjacent(multiResponse, telemetry) {
238
+ telemetry.mapActivityAttributes();
239
+ const jobStatus = this.resolveStatus(multiResponse);
240
+ const attrs = { 'app.job.jss': jobStatus };
241
+ const messageIds = await this.transition(this.adjacencyList, jobStatus);
242
+ if (messageIds.length) {
243
+ attrs['app.activity.mids'] = messageIds.join(',');
244
+ }
245
+ telemetry.setActivityAttributes(attrs);
246
+ }
171
247
  resolveStatus(multiResponse) {
172
248
  const activityStatus = multiResponse[multiResponse.length - 1];
173
249
  if (Array.isArray(activityStatus)) {
@@ -10,7 +10,7 @@ declare class Await extends Activity {
10
10
  process(): Promise<string>;
11
11
  execActivity(): Promise<string>;
12
12
  processEvent(status?: StreamStatus, code?: StreamCode): Promise<void>;
13
- processSuccess(adjacencyList: StreamData[]): Promise<MultiResponseFlags>;
14
- processError(adjacencyList: StreamData[]): Promise<MultiResponseFlags>;
13
+ processSuccessResponse(adjacencyList: StreamData[]): Promise<MultiResponseFlags>;
14
+ processErrorResponse(adjacencyList: StreamData[]): Promise<MultiResponseFlags>;
15
15
  }
16
16
  export { Await };
@@ -22,7 +22,7 @@ class Await extends activity_1.Activity {
22
22
  telemetry.startActivitySpan(this.leg);
23
23
  this.mapInputData();
24
24
  const multi = this.store.getMulti();
25
- //await this.registerTimeout();
25
+ //todo: await this.registerTimeout();
26
26
  await collator_1.CollatorService.authorizeReentry(this, multi);
27
27
  await this.setState(multi);
28
28
  await this.setStatus(0, multi);
@@ -95,12 +95,12 @@ class Await extends activity_1.Activity {
95
95
  if (status === stream_1.StreamStatus.SUCCESS) {
96
96
  this.bindActivityData('output');
97
97
  this.adjacencyList = await this.filterAdjacent();
98
- multiResponse = await this.processSuccess(this.adjacencyList);
98
+ multiResponse = await this.processSuccessResponse(this.adjacencyList);
99
99
  }
100
100
  else {
101
101
  this.bindActivityError(this.data);
102
102
  this.adjacencyList = await this.filterAdjacent();
103
- multiResponse = await this.processError(this.adjacencyList);
103
+ multiResponse = await this.processErrorResponse(this.adjacencyList);
104
104
  }
105
105
  telemetry.mapActivityAttributes();
106
106
  const jobStatus = this.resolveStatus(multiResponse);
@@ -121,7 +121,7 @@ class Await extends activity_1.Activity {
121
121
  this.logger.debug('await-resolve-await-end', { jid, aid, status, code });
122
122
  }
123
123
  }
124
- async processSuccess(adjacencyList) {
124
+ async processSuccessResponse(adjacencyList) {
125
125
  this.mapJobData();
126
126
  const multi = this.store.getMulti();
127
127
  await this.setState(multi);
@@ -129,7 +129,7 @@ class Await extends activity_1.Activity {
129
129
  await this.setStatus(adjacencyList.length - 1, multi);
130
130
  return await multi.exec();
131
131
  }
132
- async processError(adjacencyList) {
132
+ async processErrorResponse(adjacencyList) {
133
133
  //todo: if adjacencyList.length == 0, then map to the job output
134
134
  // this method would be added to Base activity class
135
135
  //this.mapJobData();
@@ -0,0 +1,19 @@
1
+ import { EngineService } from '../engine';
2
+ import { Activity, ActivityType } from './activity';
3
+ import { ActivityData, ActivityMetadata, CycleActivity } from '../../types/activity';
4
+ import { JobState } from '../../types/job';
5
+ import { RedisMulti } from '../../types/redis';
6
+ declare class Cycle extends Activity {
7
+ config: CycleActivity;
8
+ constructor(config: ActivityType, data: ActivityData, metadata: ActivityMetadata, hook: ActivityData | null, engine: EngineService, context?: JobState);
9
+ process(): Promise<string>;
10
+ /**
11
+ * Trigger the target ancestor to execute in a cycle,
12
+ * without violating the constraints of the DAG. Immutable
13
+ * `individual activity state` will execute in a new dimensional
14
+ * thread while `shared job state` can change. This
15
+ * pattern allows for retries without violating the DAG.
16
+ */
17
+ cycleAncestorActivity(multi: RedisMulti): Promise<string>;
18
+ }
19
+ export { Cycle };
@@ -0,0 +1,77 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Cycle = void 0;
4
+ const errors_1 = require("../../modules/errors");
5
+ const collator_1 = require("../collator");
6
+ const activity_1 = require("./activity");
7
+ const telemetry_1 = require("../telemetry");
8
+ class Cycle extends activity_1.Activity {
9
+ constructor(config, data, metadata, hook, engine, context) {
10
+ super(config, data, metadata, hook, engine, context);
11
+ }
12
+ //******** LEG 1 ENTRY ********//
13
+ async process() {
14
+ this.logger.debug('cycle-process', { jid: this.context.metadata.jid, aid: this.metadata.aid });
15
+ let telemetry;
16
+ try {
17
+ //verify entry is allowed
18
+ this.setLeg(1);
19
+ await collator_1.CollatorService.notarizeEntry(this);
20
+ await this.getState();
21
+ telemetry = new telemetry_1.TelemetryService(this.engine.appId, this.config, this.metadata, this.context);
22
+ telemetry.startActivitySpan(this.leg);
23
+ this.mapInputData();
24
+ //set state/status
25
+ let multi = this.store.getMulti();
26
+ await this.setState(multi);
27
+ await this.setStatus(0, multi); //leg 1 never changes job status
28
+ const multiResponse = await multi.exec();
29
+ telemetry.mapActivityAttributes();
30
+ const jobStatus = this.resolveStatus(multiResponse);
31
+ //cycle the target ancestor
32
+ multi = this.store.getMulti();
33
+ const messageId = await this.cycleAncestorActivity(multi);
34
+ telemetry.setActivityAttributes({
35
+ 'app.activity.mid': messageId,
36
+ 'app.job.jss': jobStatus
37
+ });
38
+ //exit early (`Cycle` activities only execute Leg 1)
39
+ await collator_1.CollatorService.notarizeEarlyExit(this, multi);
40
+ await multi.exec();
41
+ return this.context.metadata.aid;
42
+ }
43
+ catch (error) {
44
+ if (error instanceof errors_1.GetStateError) {
45
+ this.logger.error('cycle-get-state-error', error);
46
+ }
47
+ else {
48
+ this.logger.error('cycle-process-error', error);
49
+ }
50
+ telemetry.setActivityError(error.message);
51
+ throw error;
52
+ }
53
+ finally {
54
+ telemetry.endActivitySpan();
55
+ this.logger.debug('cycle-process-end', { jid: this.context.metadata.jid, aid: this.metadata.aid });
56
+ }
57
+ }
58
+ /**
59
+ * Trigger the target ancestor to execute in a cycle,
60
+ * without violating the constraints of the DAG. Immutable
61
+ * `individual activity state` will execute in a new dimensional
62
+ * thread while `shared job state` can change. This
63
+ * pattern allows for retries without violating the DAG.
64
+ */
65
+ async cycleAncestorActivity(multi) {
66
+ const streamData = {
67
+ metadata: {
68
+ dad: collator_1.CollatorService.resolveReentryDimension(this),
69
+ jid: this.context.metadata.jid,
70
+ aid: this.config.ancestor,
71
+ },
72
+ data: {} //todo: verify immutability, before enabling: `this.context.data`
73
+ };
74
+ return (await this.engine.streamSignaler?.publishMessage(null, streamData, multi));
75
+ }
76
+ }
77
+ exports.Cycle = Cycle;
@@ -1,12 +1,14 @@
1
1
  import { Activity } from './activity';
2
2
  import { Await } from './await';
3
- import { Worker } from './worker';
4
- import { Iterate } from './iterate';
3
+ import { Cycle } from './cycle';
5
4
  import { Emit } from './emit';
5
+ import { Iterate } from './iterate';
6
6
  import { Trigger } from './trigger';
7
+ import { Worker } from './worker';
7
8
  declare const _default: {
8
9
  activity: typeof Activity;
9
10
  await: typeof Await;
11
+ cycle: typeof Cycle;
10
12
  iterate: typeof Iterate;
11
13
  emit: typeof Emit;
12
14
  trigger: typeof Trigger;
@@ -2,13 +2,15 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const activity_1 = require("./activity");
4
4
  const await_1 = require("./await");
5
- const worker_1 = require("./worker");
6
- const iterate_1 = require("./iterate");
5
+ const cycle_1 = require("./cycle");
7
6
  const emit_1 = require("./emit");
7
+ const iterate_1 = require("./iterate");
8
8
  const trigger_1 = require("./trigger");
9
+ const worker_1 = require("./worker");
9
10
  exports.default = {
10
11
  activity: activity_1.Activity,
11
12
  await: await_1.Await,
13
+ cycle: cycle_1.Cycle,
12
14
  iterate: iterate_1.Iterate,
13
15
  emit: emit_1.Emit,
14
16
  trigger: trigger_1.Trigger,
@@ -2,18 +2,10 @@ import { Activity } from './activity';
2
2
  import { EngineService } from '../engine';
3
3
  import { ActivityData, ActivityMetadata, ActivityType, WorkerActivity } from '../../types/activity';
4
4
  import { JobState } from '../../types/job';
5
- import { MultiResponseFlags } from '../../types/redis';
6
- import { StreamCode, StreamStatus } from '../../types/stream';
7
- import { TelemetryService } from '../telemetry';
8
5
  declare class Worker extends Activity {
9
6
  config: WorkerActivity;
10
7
  constructor(config: ActivityType, data: ActivityData, metadata: ActivityMetadata, hook: ActivityData | null, engine: EngineService, context?: JobState);
11
8
  process(): Promise<string>;
12
9
  execActivity(): Promise<string>;
13
- processEvent(status?: StreamStatus, code?: StreamCode): Promise<void>;
14
- processPending(telemetry: TelemetryService): Promise<void>;
15
- processSuccess(telemetry: TelemetryService): Promise<void>;
16
- processError(telemetry: TelemetryService): Promise<void>;
17
- transitionAdjacent(multiResponse: MultiResponseFlags, telemetry: TelemetryService): Promise<void>;
18
10
  }
19
11
  export { Worker };
@@ -0,0 +1,73 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Worker = void 0;
4
+ const errors_1 = require("../../modules/errors");
5
+ const activity_1 = require("./activity");
6
+ const collator_1 = require("../collator");
7
+ const telemetry_1 = require("../telemetry");
8
+ class Worker extends activity_1.Activity {
9
+ constructor(config, data, metadata, hook, engine, context) {
10
+ super(config, data, metadata, hook, engine, context);
11
+ }
12
+ //******** INITIAL ENTRY POINT (A) ********//
13
+ async process() {
14
+ this.logger.debug('worker-process', { jid: this.context.metadata.jid, aid: this.metadata.aid });
15
+ let telemetry;
16
+ try {
17
+ this.setLeg(1);
18
+ await collator_1.CollatorService.notarizeEntry(this);
19
+ await this.getState();
20
+ telemetry = new telemetry_1.TelemetryService(this.engine.appId, this.config, this.metadata, this.context);
21
+ telemetry.startActivitySpan(this.leg);
22
+ this.mapInputData();
23
+ const multi = this.store.getMulti();
24
+ //todo: await this.registerTimeout();
25
+ await collator_1.CollatorService.authorizeReentry(this, multi);
26
+ await this.setState(multi);
27
+ await this.setStatus(0, multi);
28
+ const multiResponse = await multi.exec();
29
+ telemetry.mapActivityAttributes();
30
+ const jobStatus = this.resolveStatus(multiResponse);
31
+ const messageId = await this.execActivity();
32
+ telemetry.setActivityAttributes({
33
+ 'app.activity.mid': messageId,
34
+ 'app.job.jss': jobStatus
35
+ });
36
+ return this.context.metadata.aid;
37
+ }
38
+ catch (error) {
39
+ if (error instanceof errors_1.GetStateError) {
40
+ this.logger.error('worker-get-state-error', error);
41
+ }
42
+ else {
43
+ this.logger.error('worker-process-error', error);
44
+ }
45
+ telemetry.setActivityError(error.message);
46
+ throw error;
47
+ }
48
+ finally {
49
+ telemetry.endActivitySpan();
50
+ this.logger.debug('worker-process-end', { jid: this.context.metadata.jid, aid: this.metadata.aid });
51
+ }
52
+ }
53
+ async execActivity() {
54
+ const streamData = {
55
+ metadata: {
56
+ jid: this.context.metadata.jid,
57
+ dad: this.metadata.dad,
58
+ aid: this.metadata.aid,
59
+ topic: this.config.subtype,
60
+ spn: this.context['$self'].output.metadata.l1s,
61
+ trc: this.context.metadata.trc,
62
+ },
63
+ data: this.context.data
64
+ };
65
+ if (this.config.retry) {
66
+ streamData.policies = {
67
+ retry: this.config.retry
68
+ };
69
+ }
70
+ return (await this.engine.streamSignaler?.publishMessage(this.config.subtype, streamData));
71
+ }
72
+ }
73
+ exports.Worker = Worker;
@@ -3,11 +3,28 @@ import { CollationStage } from '../../types/collator';
3
3
  import { ActivityDuplex } from '../../types/activity';
4
4
  import { HotMeshGraph } from '../../types/hotmesh';
5
5
  import { Activity } from '../activities/activity';
6
+ import { Cycle } from '../activities/cycle';
6
7
  declare class CollatorService {
7
8
  static targetLength: number;
8
- static getDimensionalAddress(activity: Activity): Record<string, string>;
9
+ /**
10
+ * returns the dimensional address (dad) for the target; due
11
+ * to the nature of the notary system, the dad for leg 2 entry
12
+ * must target the `0` index while leg 2 exit must target the
13
+ * current index (0)
14
+ */
15
+ static getDimensionalAddress(activity: Activity, isEntry?: boolean): Record<string, string>;
16
+ /**
17
+ * resolves the dimensional address for the
18
+ * ancestor in the graph to go back to. this address
19
+ * is determined by trimming the last digits from
20
+ * the `dad` (including the target).
21
+ * the target activity index is then set to `0`, so that
22
+ * the origin node can be queried for approval/entry.
23
+ */
24
+ static resolveReentryDimension(activity: Cycle): string;
9
25
  static notarizeEntry(activity: Activity, multi?: RedisMulti): Promise<number>;
10
26
  static authorizeReentry(activity: Activity, multi?: RedisMulti): Promise<number>;
27
+ static notarizeEarlyExit(activity: Activity, multi?: RedisMulti): Promise<number>;
11
28
  static notarizeEarlyCompletion(activity: Activity, multi?: RedisMulti): Promise<number>;
12
29
  static notarizeReentry(activity: Activity, multi?: RedisMulti): Promise<number>;
13
30
  static notarizeContinuation(activity: Activity, multi?: RedisMulti): Promise<number>;