@hotmeshio/hotmesh 0.3.31 → 0.4.0

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 (254) hide show
  1. package/README.md +128 -823
  2. package/build/index.d.ts +9 -9
  3. package/build/index.js +10 -10
  4. package/build/package.json +22 -21
  5. package/build/types/error.d.ts +5 -5
  6. package/build/types/exporter.d.ts +1 -1
  7. package/build/types/index.d.ts +3 -3
  8. package/build/types/manifest.d.ts +2 -2
  9. package/build/types/{meshflow.d.ts → memflow.d.ts} +15 -15
  10. package/build/types/meshdata.d.ts +3 -3
  11. package/build/types/postgres.d.ts +7 -0
  12. package/build/types/stream.d.ts +3 -0
  13. package/index.ts +11 -11
  14. package/package.json +22 -21
  15. package/typedoc.json +8 -7
  16. package/types/error.ts +5 -5
  17. package/types/exporter.ts +1 -1
  18. package/types/index.ts +7 -7
  19. package/types/manifest.ts +2 -2
  20. package/types/{meshflow.ts → memflow.ts} +15 -15
  21. package/types/meshdata.ts +3 -3
  22. package/types/postgres.ts +9 -0
  23. package/types/stream.ts +4 -0
  24. package/build/modules/enums.d.ts +0 -108
  25. package/build/modules/enums.js +0 -132
  26. package/build/modules/errors.d.ts +0 -124
  27. package/build/modules/errors.js +0 -191
  28. package/build/modules/key.d.ts +0 -66
  29. package/build/modules/key.js +0 -1
  30. package/build/modules/storage.d.ts +0 -3
  31. package/build/modules/storage.js +0 -5
  32. package/build/modules/utils.d.ts +0 -119
  33. package/build/modules/utils.js +0 -1
  34. package/build/services/activities/activity.d.ts +0 -104
  35. package/build/services/activities/activity.js +0 -1
  36. package/build/services/activities/await.d.ts +0 -12
  37. package/build/services/activities/await.js +0 -1
  38. package/build/services/activities/cycle.d.ts +0 -19
  39. package/build/services/activities/cycle.js +0 -1
  40. package/build/services/activities/hook.d.ts +0 -27
  41. package/build/services/activities/hook.js +0 -1
  42. package/build/services/activities/index.d.ts +0 -19
  43. package/build/services/activities/index.js +0 -1
  44. package/build/services/activities/interrupt.d.ts +0 -16
  45. package/build/services/activities/interrupt.js +0 -1
  46. package/build/services/activities/signal.d.ts +0 -20
  47. package/build/services/activities/signal.js +0 -1
  48. package/build/services/activities/trigger.d.ts +0 -37
  49. package/build/services/activities/trigger.js +0 -1
  50. package/build/services/activities/worker.d.ts +0 -12
  51. package/build/services/activities/worker.js +0 -1
  52. package/build/services/collator/index.d.ts +0 -111
  53. package/build/services/collator/index.js +0 -1
  54. package/build/services/compiler/deployer.d.ts +0 -40
  55. package/build/services/compiler/deployer.js +0 -1
  56. package/build/services/compiler/index.d.ts +0 -32
  57. package/build/services/compiler/index.js +0 -1
  58. package/build/services/compiler/validator.d.ts +0 -34
  59. package/build/services/compiler/validator.js +0 -1
  60. package/build/services/connector/factory.d.ts +0 -22
  61. package/build/services/connector/factory.js +0 -99
  62. package/build/services/connector/index.d.ts +0 -30
  63. package/build/services/connector/index.js +0 -54
  64. package/build/services/connector/providers/ioredis.d.ts +0 -9
  65. package/build/services/connector/providers/ioredis.js +0 -26
  66. package/build/services/connector/providers/nats.d.ts +0 -9
  67. package/build/services/connector/providers/nats.js +0 -34
  68. package/build/services/connector/providers/postgres.d.ts +0 -20
  69. package/build/services/connector/providers/postgres.js +0 -102
  70. package/build/services/connector/providers/redis.d.ts +0 -9
  71. package/build/services/connector/providers/redis.js +0 -38
  72. package/build/services/engine/index.d.ts +0 -264
  73. package/build/services/engine/index.js +0 -1
  74. package/build/services/exporter/index.d.ts +0 -44
  75. package/build/services/exporter/index.js +0 -1
  76. package/build/services/hotmesh/index.d.ts +0 -340
  77. package/build/services/hotmesh/index.js +0 -479
  78. package/build/services/logger/index.d.ts +0 -16
  79. package/build/services/logger/index.js +0 -54
  80. package/build/services/mapper/index.d.ts +0 -28
  81. package/build/services/mapper/index.js +0 -1
  82. package/build/services/meshcall/index.d.ts +0 -194
  83. package/build/services/meshcall/index.js +0 -452
  84. package/build/services/meshcall/schemas/factory.d.ts +0 -9
  85. package/build/services/meshcall/schemas/factory.js +0 -189
  86. package/build/services/meshdata/index.d.ts +0 -795
  87. package/build/services/meshdata/index.js +0 -1235
  88. package/build/services/meshflow/client.d.ts +0 -108
  89. package/build/services/meshflow/client.js +0 -371
  90. package/build/services/meshflow/connection.d.ts +0 -23
  91. package/build/services/meshflow/connection.js +0 -33
  92. package/build/services/meshflow/exporter.d.ts +0 -51
  93. package/build/services/meshflow/exporter.js +0 -1
  94. package/build/services/meshflow/handle.d.ts +0 -90
  95. package/build/services/meshflow/handle.js +0 -176
  96. package/build/services/meshflow/index.d.ts +0 -111
  97. package/build/services/meshflow/index.js +0 -117
  98. package/build/services/meshflow/schemas/factory.d.ts +0 -29
  99. package/build/services/meshflow/schemas/factory.js +0 -2492
  100. package/build/services/meshflow/search.d.ts +0 -142
  101. package/build/services/meshflow/search.js +0 -320
  102. package/build/services/meshflow/worker.d.ts +0 -124
  103. package/build/services/meshflow/worker.js +0 -514
  104. package/build/services/meshflow/workflow/all.d.ts +0 -7
  105. package/build/services/meshflow/workflow/all.js +0 -15
  106. package/build/services/meshflow/workflow/common.d.ts +0 -18
  107. package/build/services/meshflow/workflow/common.js +0 -45
  108. package/build/services/meshflow/workflow/context.d.ts +0 -6
  109. package/build/services/meshflow/workflow/context.js +0 -45
  110. package/build/services/meshflow/workflow/didRun.d.ts +0 -7
  111. package/build/services/meshflow/workflow/didRun.js +0 -22
  112. package/build/services/meshflow/workflow/emit.d.ts +0 -11
  113. package/build/services/meshflow/workflow/emit.js +0 -29
  114. package/build/services/meshflow/workflow/enrich.d.ts +0 -9
  115. package/build/services/meshflow/workflow/enrich.js +0 -17
  116. package/build/services/meshflow/workflow/execChild.d.ts +0 -18
  117. package/build/services/meshflow/workflow/execChild.js +0 -102
  118. package/build/services/meshflow/workflow/hook.d.ts +0 -9
  119. package/build/services/meshflow/workflow/hook.js +0 -40
  120. package/build/services/meshflow/workflow/index.d.ts +0 -70
  121. package/build/services/meshflow/workflow/index.js +0 -83
  122. package/build/services/meshflow/workflow/interrupt.d.ts +0 -9
  123. package/build/services/meshflow/workflow/interrupt.js +0 -24
  124. package/build/services/meshflow/workflow/isSideEffectAllowed.d.ts +0 -10
  125. package/build/services/meshflow/workflow/isSideEffectAllowed.js +0 -33
  126. package/build/services/meshflow/workflow/proxyActivities.d.ts +0 -20
  127. package/build/services/meshflow/workflow/proxyActivities.js +0 -97
  128. package/build/services/meshflow/workflow/random.d.ts +0 -6
  129. package/build/services/meshflow/workflow/random.js +0 -16
  130. package/build/services/meshflow/workflow/searchMethods.d.ts +0 -6
  131. package/build/services/meshflow/workflow/searchMethods.js +0 -25
  132. package/build/services/meshflow/workflow/signal.d.ts +0 -7
  133. package/build/services/meshflow/workflow/signal.js +0 -28
  134. package/build/services/meshflow/workflow/sleepFor.d.ts +0 -8
  135. package/build/services/meshflow/workflow/sleepFor.js +0 -35
  136. package/build/services/meshflow/workflow/trace.d.ts +0 -14
  137. package/build/services/meshflow/workflow/trace.js +0 -33
  138. package/build/services/meshflow/workflow/waitFor.d.ts +0 -8
  139. package/build/services/meshflow/workflow/waitFor.js +0 -35
  140. package/build/services/meshos/index.d.ts +0 -293
  141. package/build/services/meshos/index.js +0 -547
  142. package/build/services/pipe/functions/array.d.ts +0 -17
  143. package/build/services/pipe/functions/array.js +0 -1
  144. package/build/services/pipe/functions/bitwise.d.ts +0 -9
  145. package/build/services/pipe/functions/bitwise.js +0 -1
  146. package/build/services/pipe/functions/conditional.d.ts +0 -13
  147. package/build/services/pipe/functions/conditional.js +0 -1
  148. package/build/services/pipe/functions/cron.d.ts +0 -12
  149. package/build/services/pipe/functions/cron.js +0 -1
  150. package/build/services/pipe/functions/date.d.ts +0 -58
  151. package/build/services/pipe/functions/date.js +0 -1
  152. package/build/services/pipe/functions/index.d.ts +0 -29
  153. package/build/services/pipe/functions/index.js +0 -1
  154. package/build/services/pipe/functions/json.d.ts +0 -5
  155. package/build/services/pipe/functions/json.js +0 -1
  156. package/build/services/pipe/functions/logical.d.ts +0 -5
  157. package/build/services/pipe/functions/logical.js +0 -1
  158. package/build/services/pipe/functions/math.d.ts +0 -42
  159. package/build/services/pipe/functions/math.js +0 -1
  160. package/build/services/pipe/functions/number.d.ts +0 -21
  161. package/build/services/pipe/functions/number.js +0 -1
  162. package/build/services/pipe/functions/object.d.ts +0 -25
  163. package/build/services/pipe/functions/object.js +0 -1
  164. package/build/services/pipe/functions/string.d.ts +0 -23
  165. package/build/services/pipe/functions/string.js +0 -1
  166. package/build/services/pipe/functions/symbol.d.ts +0 -12
  167. package/build/services/pipe/functions/symbol.js +0 -1
  168. package/build/services/pipe/functions/unary.d.ts +0 -7
  169. package/build/services/pipe/functions/unary.js +0 -1
  170. package/build/services/pipe/index.d.ts +0 -48
  171. package/build/services/pipe/index.js +0 -1
  172. package/build/services/quorum/index.d.ts +0 -90
  173. package/build/services/quorum/index.js +0 -1
  174. package/build/services/reporter/index.d.ts +0 -50
  175. package/build/services/reporter/index.js +0 -1
  176. package/build/services/router/index.d.ts +0 -60
  177. package/build/services/router/index.js +0 -1
  178. package/build/services/search/factory.d.ts +0 -7
  179. package/build/services/search/factory.js +0 -24
  180. package/build/services/search/index.d.ts +0 -22
  181. package/build/services/search/index.js +0 -10
  182. package/build/services/search/providers/postgres/postgres.d.ts +0 -24
  183. package/build/services/search/providers/postgres/postgres.js +0 -1
  184. package/build/services/search/providers/redis/ioredis.d.ts +0 -18
  185. package/build/services/search/providers/redis/ioredis.js +0 -1
  186. package/build/services/search/providers/redis/redis.d.ts +0 -18
  187. package/build/services/search/providers/redis/redis.js +0 -1
  188. package/build/services/serializer/index.d.ts +0 -42
  189. package/build/services/serializer/index.js +0 -1
  190. package/build/services/store/cache.d.ts +0 -67
  191. package/build/services/store/cache.js +0 -128
  192. package/build/services/store/factory.d.ts +0 -8
  193. package/build/services/store/factory.js +0 -24
  194. package/build/services/store/index.d.ts +0 -89
  195. package/build/services/store/index.js +0 -9
  196. package/build/services/store/providers/postgres/kvsql.d.ts +0 -168
  197. package/build/services/store/providers/postgres/kvsql.js +0 -1
  198. package/build/services/store/providers/postgres/kvtables.d.ts +0 -20
  199. package/build/services/store/providers/postgres/kvtables.js +0 -1
  200. package/build/services/store/providers/postgres/kvtransaction.d.ts +0 -36
  201. package/build/services/store/providers/postgres/kvtransaction.js +0 -1
  202. package/build/services/store/providers/postgres/kvtypes/hash.d.ts +0 -60
  203. package/build/services/store/providers/postgres/kvtypes/hash.js +0 -1
  204. package/build/services/store/providers/postgres/kvtypes/list.d.ts +0 -33
  205. package/build/services/store/providers/postgres/kvtypes/list.js +0 -1
  206. package/build/services/store/providers/postgres/kvtypes/string.d.ts +0 -20
  207. package/build/services/store/providers/postgres/kvtypes/string.js +0 -1
  208. package/build/services/store/providers/postgres/kvtypes/zset.d.ts +0 -41
  209. package/build/services/store/providers/postgres/kvtypes/zset.js +0 -1
  210. package/build/services/store/providers/postgres/postgres.d.ts +0 -145
  211. package/build/services/store/providers/postgres/postgres.js +0 -1
  212. package/build/services/store/providers/redis/_base.d.ts +0 -137
  213. package/build/services/store/providers/redis/_base.js +0 -1
  214. package/build/services/store/providers/redis/ioredis.d.ts +0 -20
  215. package/build/services/store/providers/redis/ioredis.js +0 -1
  216. package/build/services/store/providers/redis/redis.d.ts +0 -18
  217. package/build/services/store/providers/redis/redis.js +0 -1
  218. package/build/services/store/providers/store-initializable.d.ts +0 -5
  219. package/build/services/store/providers/store-initializable.js +0 -1
  220. package/build/services/stream/factory.d.ts +0 -8
  221. package/build/services/stream/factory.js +0 -37
  222. package/build/services/stream/index.d.ts +0 -64
  223. package/build/services/stream/index.js +0 -11
  224. package/build/services/stream/providers/nats/nats.d.ts +0 -59
  225. package/build/services/stream/providers/nats/nats.js +0 -1
  226. package/build/services/stream/providers/postgres/kvtables.d.ts +0 -2
  227. package/build/services/stream/providers/postgres/kvtables.js +0 -1
  228. package/build/services/stream/providers/postgres/postgres.d.ts +0 -88
  229. package/build/services/stream/providers/postgres/postgres.js +0 -1
  230. package/build/services/stream/providers/redis/ioredis.d.ts +0 -60
  231. package/build/services/stream/providers/redis/ioredis.js +0 -1
  232. package/build/services/stream/providers/redis/redis.d.ts +0 -60
  233. package/build/services/stream/providers/redis/redis.js +0 -1
  234. package/build/services/stream/providers/stream-initializable.d.ts +0 -4
  235. package/build/services/stream/providers/stream-initializable.js +0 -1
  236. package/build/services/sub/factory.d.ts +0 -7
  237. package/build/services/sub/factory.js +0 -29
  238. package/build/services/sub/index.d.ts +0 -22
  239. package/build/services/sub/index.js +0 -10
  240. package/build/services/sub/providers/nats/nats.d.ts +0 -19
  241. package/build/services/sub/providers/nats/nats.js +0 -1
  242. package/build/services/sub/providers/postgres/postgres.d.ts +0 -19
  243. package/build/services/sub/providers/postgres/postgres.js +0 -1
  244. package/build/services/sub/providers/redis/ioredis.d.ts +0 -17
  245. package/build/services/sub/providers/redis/ioredis.js +0 -1
  246. package/build/services/sub/providers/redis/redis.d.ts +0 -17
  247. package/build/services/sub/providers/redis/redis.js +0 -1
  248. package/build/services/task/index.d.ts +0 -36
  249. package/build/services/task/index.js +0 -1
  250. package/build/services/telemetry/index.d.ts +0 -52
  251. package/build/services/telemetry/index.js +0 -1
  252. package/build/services/worker/index.d.ts +0 -77
  253. package/build/services/worker/index.js +0 -1
  254. /package/build/types/{meshflow.js → memflow.js} +0 -0
@@ -1,479 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.HotMesh = void 0;
4
- const key_1 = require("../../modules/key");
5
- const utils_1 = require("../../modules/utils");
6
- const factory_1 = require("../connector/factory");
7
- const engine_1 = require("../engine");
8
- const logger_1 = require("../logger");
9
- const quorum_1 = require("../quorum");
10
- const router_1 = require("../router");
11
- const worker_1 = require("../worker");
12
- const enums_1 = require("../../modules/enums");
13
- /**
14
- * This example shows the full lifecycle of a HotMesh engine instance,
15
- * including: initialization, deployment, activation and execution.
16
- *
17
- * Engine routers are self-managing, but subscribe to the 'quorum' channel
18
- * to establish consensus as necessary for distributed processing.
19
- * Completed workflows are always soft-deleted with a configurable
20
- * retention period.
21
- *
22
- * @example
23
- * ```typescript
24
- * import { Client as Postgres } from 'pg';
25
- * import { HotMesh } from '@hotmeshio/hotmesh';
26
- *
27
- * const hotMesh = await HotMesh.init({
28
- * appId: 'abc',
29
- * engine: {
30
- * connection: {
31
- * class: Postgres,
32
- * options: {
33
- * connectionString: 'postgresql://usr:pwd@localhost:5432/db',
34
- * }
35
- * }
36
- * }
37
- * });
38
- *
39
- * await hotMesh.deploy(`
40
- * app:
41
- * id: abc
42
- * version: '1'
43
- * graphs:
44
- * - subscribes: abc.test
45
- * activities:
46
- * t1:
47
- * type: trigger
48
- * `);
49
- *
50
- * await hotMesh.activate('1');
51
- *
52
- * await hotMesh.pubsub('abc.test');
53
- *
54
- * await HotMesh.stop();
55
- * ```
56
- */
57
- class HotMesh {
58
- /**
59
- * @private
60
- */
61
- verifyAndSetNamespace(namespace) {
62
- if (!namespace) {
63
- this.namespace = key_1.HMNS;
64
- }
65
- else if (!namespace.match(/^[A-Za-z0-9-]+$/)) {
66
- throw new Error(`config.namespace [${namespace}] is invalid`);
67
- }
68
- else {
69
- this.namespace = namespace;
70
- }
71
- }
72
- /**
73
- * @private
74
- */
75
- verifyAndSetAppId(appId) {
76
- if (!appId?.match(/^[A-Za-z0-9-]+$/)) {
77
- throw new Error(`config.appId [${appId}] is invalid`);
78
- }
79
- else if (appId === 'a') {
80
- throw new Error(`config.appId [${appId}] is reserved`);
81
- }
82
- else {
83
- this.appId = appId;
84
- }
85
- }
86
- /**
87
- * Instance initializer. Workers are configured
88
- * similarly to the engine, but as an array with
89
- * multiple worker objects.
90
- *
91
- * @example
92
- * ```typescript
93
- * const config: HotMeshConfig = {
94
- * appId: 'myapp',
95
- * engine: {
96
- * connection: {
97
- * class: Postgres,
98
- * options: {
99
- * connectionString: 'postgresql://usr:pwd@localhost:5432/db',
100
- * }
101
- * }
102
- * },
103
- * workers [...]
104
- * };
105
- * const hotMesh = await HotMesh.init(config);
106
- * ```
107
- */
108
- static async init(config) {
109
- const instance = new HotMesh();
110
- instance.guid = config.guid ?? (0, utils_1.guid)();
111
- instance.verifyAndSetNamespace(config.namespace);
112
- instance.verifyAndSetAppId(config.appId);
113
- instance.logger = new logger_1.LoggerService(config.appId, instance.guid, config.name || '', config.logLevel);
114
- await instance.initEngine(config, instance.logger);
115
- await instance.initQuorum(config, instance.engine, instance.logger);
116
- await instance.doWork(config, instance.logger);
117
- return instance;
118
- }
119
- /**
120
- * returns a guid using the same core guid
121
- * generator used by the HotMesh (nanoid)
122
- */
123
- static guid() {
124
- return (0, utils_1.guid)();
125
- }
126
- /**
127
- * @private
128
- */
129
- async initEngine(config, logger) {
130
- if (config.engine) {
131
- //connections that are 'readonly' transfer
132
- //this property directly to the engine,
133
- //and ALWAYS take precendence.
134
- if (config.engine.connection.readonly) {
135
- config.engine.readonly = true;
136
- }
137
- await factory_1.ConnectorService.initClients(config.engine);
138
- this.engine = await engine_1.EngineService.init(this.namespace, this.appId, this.guid, config, logger);
139
- }
140
- }
141
- /**
142
- * @private
143
- */
144
- async initQuorum(config, engine, logger) {
145
- if (engine) {
146
- this.quorum = await quorum_1.QuorumService.init(this.namespace, this.appId, this.guid, config, engine, logger);
147
- }
148
- }
149
- /**
150
- * @private
151
- */
152
- constructor() {
153
- /**
154
- * @private
155
- */
156
- this.engine = null;
157
- /**
158
- * @private
159
- */
160
- this.quorum = null;
161
- /**
162
- * @private
163
- */
164
- this.workers = [];
165
- }
166
- /**
167
- * @private
168
- */
169
- async doWork(config, logger) {
170
- this.workers = await worker_1.WorkerService.init(this.namespace, this.appId, this.guid, config, logger);
171
- }
172
- // ************* PUB/SUB METHODS *************
173
- /**
174
- * Starts a workflow
175
- * @example
176
- * ```typescript
177
- * await hotMesh.pub('a.b.c', { key: 'value' });
178
- * ```
179
- */
180
- async pub(topic, data = {}, context, extended) {
181
- return await this.engine?.pub(topic, data, context, extended);
182
- }
183
- /**
184
- * Subscribe (listen) to all output and interim emissions of a single
185
- * workflow topic. NOTE: Postgres does not support patterned
186
- * unsubscription, so this method is not supported for Postgres.
187
- *
188
- * @example
189
- * ```typescript
190
- * await hotMesh.psub('a.b.c', (topic, message) => {
191
- * console.log(message);
192
- * });
193
- * ```
194
- */
195
- async sub(topic, callback) {
196
- return await this.engine?.sub(topic, callback);
197
- }
198
- /**
199
- * Stop listening in on a single workflow topic
200
- */
201
- async unsub(topic) {
202
- return await this.engine?.unsub(topic);
203
- }
204
- /**
205
- * Listen to all output and interim emissions of a workflow topic
206
- * matching a wildcard pattern.
207
- * @example
208
- * ```typescript
209
- * await hotMesh.psub('a.b.c*', (topic, message) => {
210
- * console.log(message);
211
- * });
212
- * ```
213
- */
214
- async psub(wild, callback) {
215
- return await this.engine?.psub(wild, callback);
216
- }
217
- /**
218
- * Patterned unsubscribe. NOTE: Postgres does not support patterned
219
- * unsubscription, so this method is not supported for Postgres.
220
- */
221
- async punsub(wild) {
222
- return await this.engine?.punsub(wild);
223
- }
224
- /**
225
- * Starts a workflow and awaits the response
226
- * @example
227
- * ```typescript
228
- * await hotMesh.pubsub('a.b.c', { key: 'value' });
229
- * ```
230
- */
231
- async pubsub(topic, data = {}, context, timeout) {
232
- return await this.engine?.pubsub(topic, data, context, timeout);
233
- }
234
- /**
235
- * Add a transition message to the workstream, resuming leg 2 of a paused
236
- * reentrant activity (e.g., await, worker, hook)
237
- */
238
- async add(streamData) {
239
- return (await this.engine.add(streamData));
240
- }
241
- // ************* QUORUM METHODS *************
242
- /**
243
- * Request a roll call from the quorum (engine and workers)
244
- */
245
- async rollCall(delay) {
246
- return await this.quorum?.rollCall(delay);
247
- }
248
- /**
249
- * Sends a throttle message to the quorum (engine and/or workers)
250
- * to limit the rate of processing. Pass `-1` to throttle indefinitely.
251
- * The value must be a non-negative integer and not exceed `MAX_DELAY` ms.
252
- *
253
- * When throttling is set, the quorum will pause for the specified time
254
- * before processing the next message. Target specific engines and
255
- * workers by passing a `guid` and/or `topic`. Pass no arguments to
256
- * throttle the entire quorum.
257
- *
258
- * In this example, all processing has been paused indefinitely for
259
- * the entire quorum. This is equivalent to an emergency stop.
260
- *
261
- * HotMesh is a stateless sequence engine, so the throttle can be adjusted up
262
- * and down with no loss of data.
263
- *
264
- *
265
- * @example
266
- * ```typescript
267
- * await hotMesh.throttle({ throttle: -1 });
268
- * ```
269
- */
270
- async throttle(options) {
271
- let throttle;
272
- if (options.throttle === -1) {
273
- throttle = enums_1.MAX_DELAY;
274
- }
275
- else {
276
- throttle = options.throttle;
277
- }
278
- if (!Number.isInteger(throttle) || throttle < 0 || throttle > enums_1.MAX_DELAY) {
279
- throw new Error(`Throttle must be a non-negative integer and not exceed ${enums_1.MAX_DELAY} ms; send -1 to throttle indefinitely`);
280
- }
281
- const throttleMessage = {
282
- type: 'throttle',
283
- throttle: throttle,
284
- };
285
- if (options.guid) {
286
- throttleMessage.guid = options.guid;
287
- }
288
- if (options.topic !== undefined) {
289
- throttleMessage.topic = options.topic;
290
- }
291
- await this.engine.store.setThrottleRate(throttleMessage);
292
- return await this.quorum?.pub(throttleMessage);
293
- }
294
- /**
295
- * Publish a message to the quorum (engine and/or workers)
296
- */
297
- async pubQuorum(quorumMessage) {
298
- return await this.quorum?.pub(quorumMessage);
299
- }
300
- /**
301
- * Subscribe to quorum events (engine and workers)
302
- */
303
- async subQuorum(callback) {
304
- return await this.quorum?.sub(callback);
305
- }
306
- /**
307
- * Unsubscribe from quorum events (engine and workers)
308
- */
309
- async unsubQuorum(callback) {
310
- return await this.quorum?.unsub(callback);
311
- }
312
- // ************* LIFECYCLE METHODS *************
313
- /**
314
- * Preview changes and provide an analysis of risk
315
- * prior to deployment
316
- * @private
317
- */
318
- async plan(path) {
319
- return await this.engine?.plan(path);
320
- }
321
- /**
322
- * When the app YAML descriptor file is ready, the `deploy` function can be called.
323
- * This function is responsible for merging all referenced YAML source
324
- * files and writing the JSON output to the file system and to the provider backend. It
325
- * is also possible to embed the YAML in-line as a string.
326
- *
327
- * *The version will not be active until activation is explicitly called.*
328
- */
329
- async deploy(pathOrYAML) {
330
- return await this.engine?.deploy(pathOrYAML);
331
- }
332
- /**
333
- * Once the app YAML file is deployed to the provider backend, the `activate` function can be
334
- * called to enable it for the entire quorum at the same moment.
335
- *
336
- * The approach is to establish the coordinated health of the system through series
337
- * of call/response exchanges. Once it is established that the quorum is healthy,
338
- * the quorum is instructed to run their engine in `no-cache` mode, ensuring
339
- * that the provider backend is consulted for the active app version each time a
340
- * call is processed. This ensures that all engines are running the same version
341
- * of the app, switching over at the same moment and then enabling `cache` mode
342
- * to improve performance.
343
- *
344
- * *Add a delay for the quorum to reach consensus if traffic is busy, but
345
- * also consider throttling traffic flow to an acceptable level.*
346
- */
347
- async activate(version, delay) {
348
- return await this.quorum?.activate(version, delay);
349
- }
350
- /**
351
- * Returns the job state as a JSON object, useful
352
- * for understanding dependency chains
353
- */
354
- async export(jobId) {
355
- return await this.engine?.export(jobId);
356
- }
357
- /**
358
- * Returns all data (HGETALL) for a job.
359
- */
360
- async getRaw(jobId) {
361
- return await this.engine?.getRaw(jobId);
362
- }
363
- /**
364
- * Reporter-related method to get the status of a job
365
- * @private
366
- */
367
- async getStats(topic, query) {
368
- return await this.engine?.getStats(topic, query);
369
- }
370
- /**
371
- * Returns the status of a job. This is a numeric
372
- * semaphore value that indicates the job's state.
373
- * Any non-positive value indicates a completed job.
374
- * Jobs with a value of `-1` are pending and will
375
- * automatically be scrubbed after a set period.
376
- * Jobs a value around -1billion have been interrupted
377
- * and will be scrubbed after a set period. Jobs with
378
- * a value of 0 completed normally. Jobs with a
379
- * positive value are still running.
380
- */
381
- async getStatus(jobId) {
382
- return this.engine?.getStatus(jobId);
383
- }
384
- /**
385
- * Returns the job state (data and metadata) for a job.
386
- */
387
- async getState(topic, jobId) {
388
- return this.engine?.getState(topic, jobId);
389
- }
390
- /**
391
- * Returns searchable/queryable data for a job. In this
392
- * example a literal field is also searched (the colon
393
- * is used to track job status and is a reserved field;
394
- * it can be read but not written).
395
- *
396
- * @example
397
- * ```typescript
398
- * const fields = ['fred', 'barney', '":"'];
399
- * const queryState = await hotMesh.getQueryState('123', fields);
400
- * //returns { fred: 'flintstone', barney: 'rubble', ':': '1' }
401
- * ```
402
- */
403
- async getQueryState(jobId, fields) {
404
- return await this.engine?.getQueryState(jobId, fields);
405
- }
406
- /**
407
- * @private
408
- */
409
- async getIds(topic, query, queryFacets = []) {
410
- return await this.engine?.getIds(topic, query, queryFacets);
411
- }
412
- /**
413
- * @private
414
- */
415
- async resolveQuery(topic, query) {
416
- return await this.engine?.resolveQuery(topic, query);
417
- }
418
- /**
419
- * Interrupt an active job
420
- */
421
- async interrupt(topic, jobId, options = {}) {
422
- return await this.engine?.interrupt(topic, jobId, options);
423
- }
424
- /**
425
- * Immediately deletes (DEL) a completed job from the system.
426
- *
427
- * *Scrubbed jobs must be complete with a non-positive `status` value*
428
- */
429
- async scrub(jobId) {
430
- await this.engine?.scrub(jobId);
431
- }
432
- /**
433
- * Re/entry point for an active job. This is used to resume a paused job
434
- * and close the reentry point or leave it open for subsequent reentry.
435
- * Because `hooks` are public entry points, they include a `topic`
436
- * which is established in the app YAML file.
437
- *
438
- * When this method is called, a hook rule will be located to establish
439
- * the exact activity and activity dimension for reentry.
440
- */
441
- async hook(topic, data, status, code) {
442
- return await this.engine?.hook(topic, data, status, code);
443
- }
444
- /**
445
- * @private
446
- */
447
- async hookAll(hookTopic, data, query, queryFacets = []) {
448
- return await this.engine?.hookAll(hookTopic, data, query, queryFacets);
449
- }
450
- /**
451
- * Stop all points of presence, workers and engines
452
- */
453
- static async stop() {
454
- if (!this.disconnecting) {
455
- this.disconnecting = true;
456
- await router_1.Router.stopConsuming();
457
- await factory_1.ConnectorService.disconnectAll();
458
- }
459
- }
460
- /**
461
- * Stop this point of presence, workers and engines
462
- */
463
- stop() {
464
- this.engine?.taskService.cancelCleanup();
465
- this.quorum?.stop();
466
- this.workers?.forEach((worker) => {
467
- worker.stop();
468
- });
469
- }
470
- /**
471
- * @private
472
- * @deprecated
473
- */
474
- async compress(terms) {
475
- return await this.engine?.compress(terms);
476
- }
477
- }
478
- exports.HotMesh = HotMesh;
479
- HotMesh.disconnecting = false;
@@ -1,16 +0,0 @@
1
- import { Logger } from 'winston';
2
- import { ILogger } from '../../types/logger';
3
- declare class LoggerService implements ILogger {
4
- private appId;
5
- private instanceId;
6
- private name;
7
- private logLevel;
8
- private logger;
9
- constructor(appId?: string, instanceId?: string, name?: string, logLevel?: string, customLogger?: Logger);
10
- private createDefaultLogger;
11
- info(message: string, ...meta: any[]): void;
12
- error(message: string, ...meta: any[]): void;
13
- warn(message: string, ...meta: any[]): void;
14
- debug(message: string, ...meta: any[]): void;
15
- }
16
- export { LoggerService, ILogger };
@@ -1,54 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.LoggerService = void 0;
4
- const winston_1 = require("winston");
5
- class LoggerService {
6
- constructor(appId = 'appId', instanceId = 'instanceId', name = 'name', logLevel = 'info', customLogger) {
7
- this.appId = appId;
8
- this.instanceId = instanceId;
9
- this.name = name;
10
- this.logLevel = logLevel;
11
- this.logger = customLogger || this.createDefaultLogger();
12
- }
13
- createDefaultLogger() {
14
- // Custom format to ensure error objects include message and stack
15
- const errorFormat = (0, winston_1.format)((info) => {
16
- if (info.error instanceof Error) {
17
- return {
18
- ...info,
19
- error: {
20
- message: info.error.message,
21
- stack: info.error.stack,
22
- },
23
- };
24
- }
25
- return info;
26
- });
27
- return (0, winston_1.createLogger)({
28
- level: this.logLevel,
29
- format: winston_1.format.combine(winston_1.format.timestamp(), winston_1.format.errors({ stack: true }), errorFormat(), (0, winston_1.format)((info) => {
30
- info.ts = info.timestamp;
31
- delete info.timestamp;
32
- return info;
33
- })(), winston_1.format.json()),
34
- transports: [new winston_1.transports.Console()],
35
- defaultMeta: {
36
- app: this.name || this.appId,
37
- id: this.instanceId,
38
- },
39
- });
40
- }
41
- info(message, ...meta) {
42
- this.logger.info(message, ...meta);
43
- }
44
- error(message, ...meta) {
45
- this.logger.error(message, ...meta);
46
- }
47
- warn(message, ...meta) {
48
- this.logger.warn(message, ...meta);
49
- }
50
- debug(message, ...meta) {
51
- this.logger.debug(message, ...meta);
52
- }
53
- }
54
- exports.LoggerService = LoggerService;
@@ -1,28 +0,0 @@
1
- import { JobState } from '../../types/job';
2
- import { TransitionRule } from '../../types/transition';
3
- import { StreamCode } from '../../types';
4
- declare class MapperService {
5
- private rules;
6
- private data;
7
- constructor(rules: Record<string, unknown>, data: JobState);
8
- mapRules(): Record<string, unknown>;
9
- private traverseRules;
10
- /**
11
- * resolves a pipe expression of the form: { @pipe: [["{data.foo.bar}", 2, false, "hello world"]] }
12
- * @param value
13
- * @returns
14
- */
15
- private pipe;
16
- /**
17
- * resolves a mapping expression in the form: "{data.foo.bar}" or 2 or false or "hello world"
18
- * @param value
19
- * @returns
20
- */
21
- private resolve;
22
- /**
23
- * Evaluates a transition rule against the current job state and incoming Stream message
24
- * to determine which (if any) transition should be taken.
25
- */
26
- static evaluate(transitionRule: TransitionRule | boolean, context: JobState, code: StreamCode): boolean;
27
- }
28
- export { MapperService };
@@ -1 +0,0 @@
1
- 'use strict';const n=b;(function(c,d){const m=b,e=c();while(!![]){try{const f=-parseInt(m(0x151))/0x1*(-parseInt(m(0x156))/0x2)+-parseInt(m(0x13e))/0x3*(-parseInt(m(0x143))/0x4)+parseInt(m(0x144))/0x5+-parseInt(m(0x148))/0x6*(-parseInt(m(0x14b))/0x7)+-parseInt(m(0x153))/0x8*(-parseInt(m(0x14d))/0x9)+-parseInt(m(0x13b))/0xa*(-parseInt(m(0x154))/0xb)+-parseInt(m(0x150))/0xc;if(f===d)break;else e['push'](e['shift']());}catch(g){e['push'](e['shift']());}}}(a,0x2526d));function b(c,d){const e=a();return b=function(f,g){f=f-0x13a;let h=e[f];return h;},b(c,d);}Object[n(0x146)](exports,n(0x15b),{'value':!0x0}),exports[n(0x159)]=void 0x0;const pipe_1=require(n(0x15c));function a(){const v=['traverseRules','200914JtmmsA','Pipe','gate','MapperService','pipe','__esModule','../pipe','resolve','code','30XfIDUb','boolean','prototype','3kzztlI','object','evaluate','isArray','data','528QlKjoZ','1120070AmJqJz','rules','defineProperty','match','126sSsapn','toString','includes','26173teSZZN','hasOwnProperty','312651yYJWex','call','mapRules','7563432WrdJOh','1ngDPwr','process','32yIEHOf','881397EPzKrm'];a=function(){return v;};return a();}class MapperService{constructor(c,d){const o=n;this[o(0x145)]=c,this['data']=d;}[n(0x14f)](){const p=n;return this[p(0x155)](this[p(0x145)]);}[n(0x155)](c){const q=n;if(q(0x13f)==typeof c&&'@pipe'in c)return this[q(0x15a)](c['@pipe']);if(q(0x13f)==typeof c&&null!==c){const d={};for(const f in c)Object[q(0x13d)][q(0x14c)][q(0x14e)](c,f)&&(d[f]=this[q(0x155)](c[f]));return d;}return this[q(0x15d)](c);}[n(0x15a)](c){const r=n;return new pipe_1[(r(0x157))](c,this[r(0x142)])[r(0x152)]();}[n(0x15d)](c){const s=n;return new pipe_1['Pipe']([[c]],this[s(0x142)])[s(0x152)]();}static[n(0x140)](c,d,f){const t=n;if(t(0x13c)==typeof c)return c;if(Array[t(0x141)](c[t(0x13a)])&&c[t(0x13a)][t(0x14a)](f||0xc8)||f['toString']()===(c[t(0x13a)]||0xc8)[t(0x149)]()){if(!c[t(0x147)])return!0x0;const g='or'===c[t(0x158)];let h=!0x0,i=!0x1;return c[t(0x147)]['forEach'](({expected:j,actual:k})=>{const u=t;if(g&&!i||!g&&h){const l=pipe_1[u(0x157)][u(0x15d)](k,d)===j;g&&l?i=!0x0:g||l||(h=!0x1);}}),g?i:h;}return!0x1;}}exports['MapperService']=MapperService;