@hotmeshio/hotmesh 0.0.52 → 0.0.53

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 (126) hide show
  1. package/README.md +22 -18
  2. package/build/index.d.ts +1 -2
  3. package/build/index.js +1 -3
  4. package/build/modules/enums.d.ts +8 -3
  5. package/build/modules/enums.js +16 -8
  6. package/build/modules/errors.d.ts +98 -18
  7. package/build/modules/errors.js +90 -33
  8. package/build/package.json +7 -2
  9. package/build/services/activities/activity.d.ts +8 -0
  10. package/build/services/activities/activity.js +63 -14
  11. package/build/services/activities/await.js +6 -6
  12. package/build/services/activities/cycle.d.ts +2 -2
  13. package/build/services/activities/cycle.js +5 -5
  14. package/build/services/activities/hook.js +4 -4
  15. package/build/services/activities/interrupt.d.ts +3 -3
  16. package/build/services/activities/interrupt.js +15 -6
  17. package/build/services/activities/signal.d.ts +2 -2
  18. package/build/services/activities/signal.js +4 -4
  19. package/build/services/activities/trigger.js +12 -3
  20. package/build/services/activities/worker.js +6 -6
  21. package/build/services/compiler/deployer.js +33 -5
  22. package/build/services/compiler/validator.d.ts +2 -0
  23. package/build/services/compiler/validator.js +5 -1
  24. package/build/services/durable/client.d.ts +7 -1
  25. package/build/services/durable/client.js +56 -30
  26. package/build/services/durable/exporter.d.ts +7 -72
  27. package/build/services/durable/exporter.js +105 -295
  28. package/build/services/durable/handle.d.ts +11 -6
  29. package/build/services/durable/handle.js +59 -46
  30. package/build/services/durable/index.d.ts +0 -2
  31. package/build/services/durable/index.js +0 -2
  32. package/build/services/durable/schemas/factory.d.ts +33 -0
  33. package/build/services/durable/schemas/factory.js +2356 -0
  34. package/build/services/durable/search.js +8 -8
  35. package/build/services/durable/worker.js +117 -25
  36. package/build/services/durable/workflow.d.ts +46 -43
  37. package/build/services/durable/workflow.js +273 -277
  38. package/build/services/engine/index.js +3 -0
  39. package/build/services/exporter/index.d.ts +2 -4
  40. package/build/services/exporter/index.js +4 -5
  41. package/build/services/mapper/index.d.ts +6 -2
  42. package/build/services/mapper/index.js +6 -2
  43. package/build/services/pipe/functions/array.d.ts +2 -10
  44. package/build/services/pipe/functions/array.js +30 -28
  45. package/build/services/pipe/functions/conditional.d.ts +1 -0
  46. package/build/services/pipe/functions/conditional.js +3 -0
  47. package/build/services/pipe/functions/date.d.ts +1 -0
  48. package/build/services/pipe/functions/date.js +4 -0
  49. package/build/services/pipe/functions/index.d.ts +2 -0
  50. package/build/services/pipe/functions/index.js +2 -0
  51. package/build/services/pipe/functions/logical.d.ts +5 -0
  52. package/build/services/pipe/functions/logical.js +12 -0
  53. package/build/services/pipe/functions/object.d.ts +3 -0
  54. package/build/services/pipe/functions/object.js +25 -7
  55. package/build/services/pipe/index.d.ts +20 -3
  56. package/build/services/pipe/index.js +82 -16
  57. package/build/services/router/index.js +14 -3
  58. package/build/services/serializer/index.d.ts +3 -2
  59. package/build/services/serializer/index.js +11 -4
  60. package/build/services/store/clients/ioredis.js +6 -6
  61. package/build/services/store/clients/redis.js +7 -7
  62. package/build/services/store/index.d.ts +2 -0
  63. package/build/services/store/index.js +4 -1
  64. package/build/services/stream/clients/ioredis.js +8 -8
  65. package/build/services/stream/clients/redis.js +1 -1
  66. package/build/types/activity.d.ts +60 -5
  67. package/build/types/durable.d.ts +168 -33
  68. package/build/types/exporter.d.ts +26 -4
  69. package/build/types/index.d.ts +2 -2
  70. package/build/types/job.d.ts +69 -5
  71. package/build/types/pipe.d.ts +81 -3
  72. package/build/types/stream.d.ts +61 -1
  73. package/build/types/stream.js +4 -0
  74. package/index.ts +1 -2
  75. package/modules/enums.ts +16 -8
  76. package/modules/errors.ts +174 -32
  77. package/package.json +7 -2
  78. package/services/activities/activity.ts +63 -14
  79. package/services/activities/await.ts +6 -6
  80. package/services/activities/cycle.ts +7 -6
  81. package/services/activities/hook.ts +4 -4
  82. package/services/activities/interrupt.ts +19 -9
  83. package/services/activities/signal.ts +6 -5
  84. package/services/activities/trigger.ts +16 -4
  85. package/services/activities/worker.ts +7 -7
  86. package/services/compiler/deployer.ts +33 -6
  87. package/services/compiler/validator.ts +7 -3
  88. package/services/durable/client.ts +47 -14
  89. package/services/durable/exporter.ts +110 -318
  90. package/services/durable/handle.ts +63 -50
  91. package/services/durable/index.ts +0 -2
  92. package/services/durable/schemas/factory.ts +2358 -0
  93. package/services/durable/search.ts +8 -8
  94. package/services/durable/worker.ts +128 -29
  95. package/services/durable/workflow.ts +304 -288
  96. package/services/engine/index.ts +4 -0
  97. package/services/exporter/index.ts +10 -12
  98. package/services/mapper/index.ts +6 -2
  99. package/services/pipe/functions/array.ts +24 -37
  100. package/services/pipe/functions/conditional.ts +4 -0
  101. package/services/pipe/functions/date.ts +6 -0
  102. package/services/pipe/functions/index.ts +7 -5
  103. package/services/pipe/functions/logical.ts +11 -0
  104. package/services/pipe/functions/object.ts +26 -7
  105. package/services/pipe/index.ts +99 -21
  106. package/services/quorum/index.ts +1 -3
  107. package/services/router/index.ts +14 -3
  108. package/services/serializer/index.ts +12 -5
  109. package/services/store/clients/ioredis.ts +6 -6
  110. package/services/store/clients/redis.ts +7 -7
  111. package/services/store/index.ts +4 -1
  112. package/services/stream/clients/ioredis.ts +8 -8
  113. package/services/stream/clients/redis.ts +1 -1
  114. package/types/activity.ts +87 -15
  115. package/types/durable.ts +246 -73
  116. package/types/exporter.ts +31 -5
  117. package/types/index.ts +6 -7
  118. package/types/job.ts +130 -36
  119. package/types/pipe.ts +84 -3
  120. package/types/stream.ts +82 -23
  121. package/build/services/durable/factory.d.ts +0 -17
  122. package/build/services/durable/factory.js +0 -817
  123. package/build/services/durable/meshos.d.ts +0 -127
  124. package/build/services/durable/meshos.js +0 -380
  125. package/services/durable/factory.ts +0 -818
  126. package/services/durable/meshos.ts +0 -441
package/README.md CHANGED
@@ -109,15 +109,19 @@ HotMesh's *Durable* module is a TypeScript Library modeled after Temporal.io. If
109
109
  ```
110
110
 
111
111
  #### Workflow Extensions
112
- Redis governance delivers more than just reliability. Externalizing state fundamentally changes the execution profile for your functions, allowing you to design long-running, durable workflows. The `Durable` base class (shown in the examples above) provides additional methods for solving the most common state management challenges.
112
+ Externalizing state fundamentally changes the execution profile for your functions, allowing you to design long-running, durable workflows. The `Durable` base class (shown in the examples above) provides additional methods for solving the most common state management challenges.
113
113
 
114
- - `waitForSignal` Pause your function and wait for external event(s) before continuing. The *waitForSignal* method will collate and cache the signals and only awaken your function once all signals have arrived.
115
- ```javascript
116
- const signals = [a, b] = await Durable.workflow.waitForSignal('sig1', 'sig2')`
114
+ - `waitFor` Pause your function using your chosen signal key, and only awaken when the signal is received from the outide. Use a standard `Promise` to collate and cache the signals and only awaken your function once all signals have arrived.
115
+ ```javascript
116
+ const { waitFor } = Durable.workflow;
117
+ const [a, b] = await Promise.all([
118
+ waitFor<{payload: string}>('sig1'),
119
+ waitFor<number>('sig2')
120
+ ]);
117
121
  ```
118
- - `signal` Send a signal (and optional payload) to a paused function awaiting the signal.
122
+ - `signal` Send a signal (and payload) to a paused function awaiting the signal. Signals may also be sent from the outside to awaken a paused function.
119
123
  ```javascript
120
- await Durable.workflow.signal('sig1', {payload: 'hi!'});
124
+ await Durable.workflow.signal('sig1', {payload: 'hi!'});
121
125
  ```
122
126
  - `hook` Redis governance converts your functions into 're-entrant processes'. Optionally use the *hook* method to spawn parallel execution threads to augment a running workflow.
123
127
  ```javascript
@@ -135,9 +139,9 @@ Redis governance delivers more than just reliability. Externalizing state fundam
135
139
  ```javascript
136
140
  const random = await Durable.workflow.random();
137
141
  ```
138
- - `executeChild` Call another durable function and await the response. *Design sophisticated, multi-process solutions by leveraging this command.*
142
+ - `execChild` Call another durable function and await the response. *Design sophisticated, multi-process solutions by leveraging this command.*
139
143
  ```javascript
140
- const jobResponse = await Durable.workflow.executeChild({
144
+ const jobResponse = await Durable.workflow.execChild({
141
145
  workflowName: 'newsletter',
142
146
  taskQueue: 'default',
143
147
  args: [{ id, user_id, etc }],
@@ -151,7 +155,7 @@ Redis governance delivers more than just reliability. Externalizing state fundam
151
155
  args: [{ id, user_id, etc }],
152
156
  });
153
157
  ```
154
- - `getContext` Get the current workflow context (workflowId, etc).
158
+ - `getContext` Get the current workflow context (workflowId, replay history, replay index, etc).
155
159
  ```javascript
156
160
  const context = await Durable.workflow.getContext();
157
161
  ```
@@ -294,28 +298,28 @@ const hotMesh = await HotMesh.init({
294
298
  ```
295
299
 
296
300
  ### Observability
297
- Workflows and activities are run according to the rules you define, offering [Graph-Oriented](https://github.com/hotmeshio/sdk-typescript/blob/main/docs/system_lifecycle.md#telemetry) telemetry insights into your legacy function executions.
301
+ Workflows and activities are run according to the rules you define, offering [Graph-Oriented](https://github.com/hotmeshio/sdk-typescript/tree/main/docs/system_lifecycle.md#telemetry) telemetry insights into your legacy function executions.
298
302
 
299
303
  ## FAQ
300
- Refer to the [FAQ](https://github.com/hotmeshio/sdk-typescript/blob/main/docs/faq.md) for terminology, definitions, and an exploration of how HotMesh facilitates orchestration use cases.
304
+ Refer to the [FAQ](https://github.com/hotmeshio/sdk-typescript/tree/main/docs/faq.md) for terminology, definitions, and an exploration of how HotMesh facilitates orchestration use cases.
301
305
 
302
306
  ## Quick Start
303
- Refer to the [Quick Start](https://github.com/hotmeshio/sdk-typescript/blob/main/docs/quickstart.md) for sample flows you can easily copy, paste, and modify to get started.
307
+ Refer to the [Quick Start](https://github.com/hotmeshio/sdk-typescript/tree/main/docs/quickstart.md) for sample flows you can easily copy, paste, and modify to get started.
304
308
 
305
309
  ## Developer Guide
306
- For more details on the complete development process, including information about schemas, APIs, and deployment, consult the [Developer Guide](https://github.com/hotmeshio/sdk-typescript/blob/main/docs/developer_guide.md).
310
+ For more details on the complete development process, including information about schemas, APIs, and deployment, consult the [Developer Guide](https://github.com/hotmeshio/sdk-typescript/tree/main/docs/developer_guide.md).
307
311
 
308
312
  ## Model Driven Development
309
- [Model Driven Development](https://github.com/hotmeshio/sdk-typescript/blob/main/docs/model_driven_development.md) is an established strategy for managing process-oriented tasks. Check out this guide to understand its foundational principles.
313
+ [Model Driven Development](https://github.com/hotmeshio/sdk-typescript/tree/main/docs/model_driven_development.md) is an established strategy for managing process-oriented tasks. Check out this guide to understand its foundational principles.
310
314
 
311
315
  ## Data Mapping
312
- Exchanging data between activities is central to HotMesh. For detailed information on supported functions and the functional mapping syntax (@pipes), see the [Data Mapping Overview](https://github.com/hotmeshio/sdk-typescript/blob/main/docs/data_mapping.md).
316
+ Exchanging data between activities is central to HotMesh. For detailed information on supported functions and the functional mapping syntax (@pipes), see the [Data Mapping Overview](https://github.com/hotmeshio/sdk-typescript/tree/main/docs/data_mapping.md).
313
317
 
314
318
  ## Composition
315
- While the simplest graphs are linear, detailing a consistent sequence of non-cyclical activities, graphs can be layered to represent intricate business scenarios. Some can even be designed to accommodate long-lasting workflows that span months. For more details, check out the [Composable Workflow Guide](https://github.com/hotmeshio/sdk-typescript/blob/main/docs/composable_workflow.md).
319
+ While the simplest graphs are linear, detailing a consistent sequence of non-cyclical activities, graphs can be layered to represent intricate business scenarios. Some can even be designed to accommodate long-lasting workflows that span months. For more details, check out the [Composable Workflow Guide](https://github.com/hotmeshio/sdk-typescript/tree/main/docs/composable_workflow.md).
316
320
 
317
321
  ## Distributed Orchestration
318
- HotMesh is a distributed orchestration engine. Refer to the [Distributed Orchestration Guide](https://github.com/hotmeshio/sdk-typescript/blob/main/docs/distributed_orchestration.md) for a detailed breakdown of the approach.
322
+ HotMesh is a distributed orchestration engine. Refer to the [Distributed Orchestration Guide](https://github.com/hotmeshio/sdk-typescript/tree/main/docs/distributed_orchestration.md) for a detailed breakdown of the approach.
319
323
 
320
324
  ## System Lifecycle
321
- Gain insight into HotMesh's monitoring, exception handling, and alarm configurations via the [System Lifecycle Guide](https://github.com/hotmeshio/sdk-typescript/blob/main/docs/system_lifecycle.md).
325
+ Gain insight into HotMesh's monitoring, exception handling, and alarm configurations via the [System Lifecycle Guide](https://github.com/hotmeshio/sdk-typescript/tree/main/docs/system_lifecycle.md).
package/build/index.d.ts CHANGED
@@ -1,6 +1,5 @@
1
1
  import { Durable } from './services/durable';
2
- import { MeshOSService as MeshOS } from './services/durable/meshos';
3
2
  import { HotMeshService as HotMesh } from './services/hotmesh';
4
3
  import { HotMeshConfig } from './types/hotmesh';
5
- export { Durable, HotMesh, HotMeshConfig, MeshOS };
4
+ export { Durable, HotMesh, HotMeshConfig };
6
5
  export * as Types from './types';
package/build/index.js CHANGED
@@ -23,11 +23,9 @@ var __importStar = (this && this.__importStar) || function (mod) {
23
23
  return result;
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.Types = exports.MeshOS = exports.HotMesh = exports.Durable = void 0;
26
+ exports.Types = exports.HotMesh = exports.Durable = void 0;
27
27
  const durable_1 = require("./services/durable");
28
28
  Object.defineProperty(exports, "Durable", { enumerable: true, get: function () { return durable_1.Durable; } });
29
- const meshos_1 = require("./services/durable/meshos");
30
- Object.defineProperty(exports, "MeshOS", { enumerable: true, get: function () { return meshos_1.MeshOSService; } });
31
29
  const hotmesh_1 = require("./services/hotmesh");
32
30
  Object.defineProperty(exports, "HotMesh", { enumerable: true, get: function () { return hotmesh_1.HotMeshService; } });
33
31
  exports.Types = __importStar(require("./types"));
@@ -7,9 +7,11 @@ export declare const HMSH_CODE_INTERRUPT = 410;
7
7
  export declare const HMSH_CODE_UNKNOWN = 500;
8
8
  export declare const HMSH_CODE_TIMEOUT = 504;
9
9
  export declare const HMSH_CODE_UNACKED = 999;
10
- export declare const HMSH_CODE_DURABLE_SLEEPFOR = 592;
11
- export declare const HMSH_CODE_DURABLE_INCOMPLETE = 593;
12
- export declare const HMSH_CODE_DURABLE_WAITFOR = 594;
10
+ export declare const HMSH_CODE_DURABLE_SLEEP = 588;
11
+ export declare const HMSH_CODE_DURABLE_ALL = 589;
12
+ export declare const HMSH_CODE_DURABLE_CHILD = 590;
13
+ export declare const HMSH_CODE_DURABLE_PROXY = 591;
14
+ export declare const HMSH_CODE_DURABLE_WAIT = 595;
13
15
  export declare const HMSH_CODE_DURABLE_TIMEOUT = 596;
14
16
  export declare const HMSH_CODE_DURABLE_MAXED = 597;
15
17
  export declare const HMSH_CODE_DURABLE_FATAL = 598;
@@ -23,6 +25,9 @@ export declare const HMSH_EXPIRE_JOB_SECONDS: number;
23
25
  export declare const HMSH_MAX_RETRIES: number;
24
26
  export declare const HMSH_MAX_TIMEOUT_MS: number;
25
27
  export declare const HMSH_GRADUATED_INTERVAL_MS: number;
28
+ export declare const HMSH_DURABLE_MAX_ATTEMPTS = 3;
29
+ export declare const HMSH_DURABLE_MAX_INTERVAL = "120s";
30
+ export declare const HMSH_DURABLE_EXP_BACKOFF = 10;
26
31
  export declare const HMSH_BLOCK_TIME_MS: number;
27
32
  export declare const HMSH_XCLAIM_DELAY_MS: number;
28
33
  export declare const HMSH_XCLAIM_COUNT: number;
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.HMSH_SCOUT_INTERVAL_SECONDS = exports.HMSH_FIDELITY_SECONDS = exports.HMSH_EXPIRE_DURATION = exports.HMSH_XPENDING_COUNT = exports.HMSH_XCLAIM_COUNT = exports.HMSH_XCLAIM_DELAY_MS = exports.HMSH_BLOCK_TIME_MS = exports.HMSH_GRADUATED_INTERVAL_MS = exports.HMSH_MAX_TIMEOUT_MS = exports.HMSH_MAX_RETRIES = exports.HMSH_EXPIRE_JOB_SECONDS = exports.HMSH_OTT_WAIT_TIME = exports.HMSH_ACTIVATION_MAX_RETRY = exports.HMSH_QUORUM_DELAY_MS = exports.HMSH_QUORUM_ROLLCALL_CYCLES = exports.HMSH_STATUS_UNKNOWN = exports.HMSH_CODE_DURABLE_RETRYABLE = exports.HMSH_CODE_DURABLE_FATAL = exports.HMSH_CODE_DURABLE_MAXED = exports.HMSH_CODE_DURABLE_TIMEOUT = exports.HMSH_CODE_DURABLE_WAITFOR = exports.HMSH_CODE_DURABLE_INCOMPLETE = exports.HMSH_CODE_DURABLE_SLEEPFOR = exports.HMSH_CODE_UNACKED = exports.HMSH_CODE_TIMEOUT = exports.HMSH_CODE_UNKNOWN = exports.HMSH_CODE_INTERRUPT = exports.HMSH_CODE_NOTFOUND = exports.HMSH_CODE_PENDING = exports.HMSH_CODE_SUCCESS = exports.HMSH_LOGLEVEL = void 0;
3
+ exports.HMSH_SCOUT_INTERVAL_SECONDS = exports.HMSH_FIDELITY_SECONDS = exports.HMSH_EXPIRE_DURATION = exports.HMSH_XPENDING_COUNT = exports.HMSH_XCLAIM_COUNT = exports.HMSH_XCLAIM_DELAY_MS = exports.HMSH_BLOCK_TIME_MS = exports.HMSH_DURABLE_EXP_BACKOFF = exports.HMSH_DURABLE_MAX_INTERVAL = exports.HMSH_DURABLE_MAX_ATTEMPTS = exports.HMSH_GRADUATED_INTERVAL_MS = exports.HMSH_MAX_TIMEOUT_MS = exports.HMSH_MAX_RETRIES = exports.HMSH_EXPIRE_JOB_SECONDS = exports.HMSH_OTT_WAIT_TIME = exports.HMSH_ACTIVATION_MAX_RETRY = exports.HMSH_QUORUM_DELAY_MS = exports.HMSH_QUORUM_ROLLCALL_CYCLES = exports.HMSH_STATUS_UNKNOWN = exports.HMSH_CODE_DURABLE_RETRYABLE = exports.HMSH_CODE_DURABLE_FATAL = exports.HMSH_CODE_DURABLE_MAXED = exports.HMSH_CODE_DURABLE_TIMEOUT = exports.HMSH_CODE_DURABLE_WAIT = exports.HMSH_CODE_DURABLE_PROXY = exports.HMSH_CODE_DURABLE_CHILD = exports.HMSH_CODE_DURABLE_ALL = exports.HMSH_CODE_DURABLE_SLEEP = exports.HMSH_CODE_UNACKED = exports.HMSH_CODE_TIMEOUT = exports.HMSH_CODE_UNKNOWN = exports.HMSH_CODE_INTERRUPT = exports.HMSH_CODE_NOTFOUND = exports.HMSH_CODE_PENDING = exports.HMSH_CODE_SUCCESS = exports.HMSH_LOGLEVEL = void 0;
4
4
  // HOTMESH SYSTEM
5
5
  exports.HMSH_LOGLEVEL = process.env.HMSH_LOGLEVEL || 'info';
6
- // STATUS CODES AND MESSAGES
6
+ // HOTMESH STATUS CODES
7
7
  exports.HMSH_CODE_SUCCESS = 200;
8
8
  exports.HMSH_CODE_PENDING = 202;
9
9
  exports.HMSH_CODE_NOTFOUND = 404;
@@ -11,13 +11,17 @@ exports.HMSH_CODE_INTERRUPT = 410;
11
11
  exports.HMSH_CODE_UNKNOWN = 500;
12
12
  exports.HMSH_CODE_TIMEOUT = 504;
13
13
  exports.HMSH_CODE_UNACKED = 999;
14
- exports.HMSH_CODE_DURABLE_SLEEPFOR = 592;
15
- exports.HMSH_CODE_DURABLE_INCOMPLETE = 593;
16
- exports.HMSH_CODE_DURABLE_WAITFOR = 594;
14
+ // DURABLE STATUS CODES
15
+ exports.HMSH_CODE_DURABLE_SLEEP = 588;
16
+ exports.HMSH_CODE_DURABLE_ALL = 589;
17
+ exports.HMSH_CODE_DURABLE_CHILD = 590;
18
+ exports.HMSH_CODE_DURABLE_PROXY = 591;
19
+ exports.HMSH_CODE_DURABLE_WAIT = 595;
17
20
  exports.HMSH_CODE_DURABLE_TIMEOUT = 596;
18
21
  exports.HMSH_CODE_DURABLE_MAXED = 597;
19
22
  exports.HMSH_CODE_DURABLE_FATAL = 598;
20
23
  exports.HMSH_CODE_DURABLE_RETRYABLE = 599;
24
+ // HOTMESH MESSAGES
21
25
  exports.HMSH_STATUS_UNKNOWN = 'unknown';
22
26
  // QUORUM
23
27
  exports.HMSH_QUORUM_ROLLCALL_CYCLES = 12; //max iterations
@@ -30,8 +34,12 @@ exports.HMSH_EXPIRE_JOB_SECONDS = parseInt(process.env.HMSH_EXPIRE_JOB_SECONDS,
30
34
  exports.HMSH_MAX_RETRIES = parseInt(process.env.HMSH_MAX_RETRIES, 10) || 3;
31
35
  exports.HMSH_MAX_TIMEOUT_MS = parseInt(process.env.HMSH_MAX_TIMEOUT_MS, 10) || 60000;
32
36
  exports.HMSH_GRADUATED_INTERVAL_MS = parseInt(process.env.HMSH_GRADUATED_INTERVAL_MS, 10) || 5000;
33
- const BASE_BLOCK_DURATION = 10000; // Modified for clarity
34
- const TEST_BLOCK_DURATION = 1000; // Modified for clarity
37
+ // DURABLE
38
+ exports.HMSH_DURABLE_MAX_ATTEMPTS = 3;
39
+ exports.HMSH_DURABLE_MAX_INTERVAL = '120s';
40
+ exports.HMSH_DURABLE_EXP_BACKOFF = 10;
41
+ const BASE_BLOCK_DURATION = 10000;
42
+ const TEST_BLOCK_DURATION = 1000;
35
43
  exports.HMSH_BLOCK_TIME_MS = process.env.HMSH_BLOCK_TIME_MS ? parseInt(process.env.HMSH_BLOCK_TIME_MS, 10) : (process.env.NODE_ENV === 'test' ? TEST_BLOCK_DURATION : BASE_BLOCK_DURATION);
36
44
  exports.HMSH_XCLAIM_DELAY_MS = parseInt(process.env.HMSH_XCLAIM_DELAY_MS, 10) || 1000 * 60;
37
45
  exports.HMSH_XCLAIM_COUNT = parseInt(process.env.HMSH_XCLAIM_COUNT, 10) || 3;
@@ -39,6 +47,6 @@ exports.HMSH_XPENDING_COUNT = parseInt(process.env.HMSH_XPENDING_COUNT, 10) || 1
39
47
  // TASK WORKER
40
48
  exports.HMSH_EXPIRE_DURATION = parseInt(process.env.HMSH_EXPIRE_DURATION, 10) || 1;
41
49
  const BASE_FIDELITY_SECONDS = 5;
42
- const TEST_FIDELITY_SECONDS = 5;
50
+ const TEST_FIDELITY_SECONDS = 1;
43
51
  exports.HMSH_FIDELITY_SECONDS = process.env.HMSH_FIDELITY_SECONDS ? parseInt(process.env.HMSH_FIDELITY_SECONDS, 10) : (process.env.NODE_ENV === 'test' ? TEST_FIDELITY_SECONDS : BASE_FIDELITY_SECONDS);
44
52
  exports.HMSH_SCOUT_INTERVAL_SECONDS = parseInt(process.env.HMSH_SCOUT_INTERVAL_SECONDS, 10) || 60;
@@ -8,43 +8,122 @@ declare class GetStateError extends Error {
8
8
  declare class SetStateError extends Error {
9
9
  constructor();
10
10
  }
11
- declare class DurableIncompleteSignalError extends Error {
11
+ declare class DurableWaitForError extends Error {
12
12
  code: number;
13
- constructor(message: string);
14
- }
15
- declare class DurableWaitForSignalError extends Error {
13
+ signalId: string;
14
+ workflowId: string;
15
+ index: number;
16
+ workflowDimension: string;
17
+ constructor(params: {
18
+ signalId: string;
19
+ index: number;
20
+ workflowDimension: string;
21
+ workflowId: string;
22
+ });
23
+ }
24
+ declare class DurableProxyError extends Error {
25
+ activityName: string;
26
+ arguments: string[];
27
+ backoffCoefficient: number;
16
28
  code: number;
17
- signals: {
18
- signal: string;
29
+ index: number;
30
+ maximumAttempts: number;
31
+ maximumInterval: number;
32
+ originJobId: string | null;
33
+ parentWorkflowId: string;
34
+ workflowDimension: string;
35
+ workflowId: string;
36
+ workflowTopic: string;
37
+ constructor(params: {
38
+ arguments: string[];
39
+ activityName: string;
40
+ backoffCoefficient?: number;
19
41
  index: number;
20
- }[];
21
- constructor(message: string, signals: {
22
- signal: string;
42
+ maximumAttempts?: number;
43
+ maximumInterval?: number;
44
+ originJobId: string | null;
45
+ parentWorkflowId: string;
46
+ workflowDimension: string;
47
+ workflowId: string;
48
+ workflowTopic: string;
49
+ });
50
+ }
51
+ declare class DurableChildError extends Error {
52
+ await: boolean;
53
+ arguments: string[];
54
+ backoffCoefficient: number;
55
+ code: number;
56
+ workflowDimension: string;
57
+ index: number;
58
+ maximumAttempts: number;
59
+ maximumInterval: number;
60
+ originJobId: string | null;
61
+ parentWorkflowId: string;
62
+ workflowId: string;
63
+ workflowTopic: string;
64
+ constructor(params: {
65
+ arguments: string[];
66
+ await?: boolean;
67
+ backoffCoefficient?: number;
23
68
  index: number;
24
- }[]);
69
+ maximumAttempts?: number;
70
+ maximumInterval?: number;
71
+ originJobId: string | null;
72
+ parentWorkflowId: string;
73
+ workflowDimension: string;
74
+ workflowId: string;
75
+ workflowTopic: string;
76
+ });
77
+ }
78
+ declare class DurableWaitForAllError extends Error {
79
+ items: any[];
80
+ code: number;
81
+ workflowDimension: string;
82
+ size: number;
83
+ index: number;
84
+ originJobId: string | null;
85
+ parentWorkflowId: string;
86
+ workflowId: string;
87
+ workflowTopic: string;
88
+ constructor(params: {
89
+ items: string[];
90
+ workflowId: string;
91
+ workflowTopic: string;
92
+ parentWorkflowId: string;
93
+ originJobId: string | null;
94
+ size: number;
95
+ index: number;
96
+ workflowDimension: string;
97
+ });
25
98
  }
26
- declare class DurableSleepForError extends Error {
99
+ declare class DurableSleepError extends Error {
100
+ workflowId: string;
27
101
  code: number;
28
102
  duration: number;
29
103
  index: number;
30
- dimension: string;
31
- constructor(message: string, duration: number, index: number, dimension: string);
104
+ workflowDimension: string;
105
+ constructor(params: {
106
+ duration: number;
107
+ index: number;
108
+ workflowDimension: string;
109
+ workflowId: string;
110
+ });
32
111
  }
33
112
  declare class DurableTimeoutError extends Error {
34
113
  code: number;
35
- constructor(message: string);
114
+ constructor(message: string, stack?: string);
36
115
  }
37
116
  declare class DurableMaxedError extends Error {
38
117
  code: number;
39
- constructor(message: string);
118
+ constructor(message: string, stackTrace?: string);
40
119
  }
41
120
  declare class DurableFatalError extends Error {
42
121
  code: number;
43
- constructor(message: string);
122
+ constructor(message: string, stackTrace?: string);
44
123
  }
45
124
  declare class DurableRetryError extends Error {
46
125
  code: number;
47
- constructor(message: string);
126
+ constructor(message: string, stackTrace?: string);
48
127
  }
49
128
  declare class MapDataError extends Error {
50
129
  constructor();
@@ -53,6 +132,7 @@ declare class RegisterTimeoutError extends Error {
53
132
  constructor();
54
133
  }
55
134
  declare class DuplicateJobError extends Error {
135
+ jobId: string;
56
136
  constructor(jobId: string);
57
137
  }
58
138
  declare class InactiveJobError extends Error {
@@ -79,4 +159,4 @@ declare class CollationError extends Error {
79
159
  fault: CollationFaultType;
80
160
  constructor(status: number, leg: ActivityDuplex, stage: CollationStage, fault?: CollationFaultType);
81
161
  }
82
- export { CollationError, DurableFatalError, DurableIncompleteSignalError, DurableMaxedError, DurableRetryError, DurableSleepForError, DurableTimeoutError, DurableWaitForSignalError, DuplicateJobError, ExecActivityError, GenerationalError, GetStateError, InactiveJobError, MapDataError, RegisterTimeoutError, SetStateError, };
162
+ export { CollationError, DurableChildError, DurableFatalError, DurableMaxedError, DurableProxyError, DurableRetryError, DurableSleepError, DurableTimeoutError, DurableWaitForAllError, DurableWaitForError, DuplicateJobError, ExecActivityError, GenerationalError, GetStateError, InactiveJobError, MapDataError, RegisterTimeoutError, SetStateError, };
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SetStateError = exports.RegisterTimeoutError = exports.MapDataError = exports.InactiveJobError = exports.GetStateError = exports.GenerationalError = exports.ExecActivityError = exports.DuplicateJobError = exports.DurableWaitForSignalError = exports.DurableTimeoutError = exports.DurableSleepForError = exports.DurableRetryError = exports.DurableMaxedError = exports.DurableIncompleteSignalError = exports.DurableFatalError = exports.CollationError = void 0;
3
+ exports.SetStateError = exports.RegisterTimeoutError = exports.MapDataError = exports.InactiveJobError = exports.GetStateError = exports.GenerationalError = exports.ExecActivityError = exports.DuplicateJobError = exports.DurableWaitForError = exports.DurableWaitForAllError = exports.DurableTimeoutError = exports.DurableSleepError = exports.DurableRetryError = exports.DurableProxyError = exports.DurableMaxedError = exports.DurableFatalError = exports.DurableChildError = exports.CollationError = void 0;
4
4
  const enums_1 = require("./enums");
5
5
  class GetStateError extends Error {
6
6
  constructor(jobId) {
@@ -16,58 +16,114 @@ class SetStateError extends Error {
16
16
  }
17
17
  }
18
18
  exports.SetStateError = SetStateError;
19
- //thrown when a signal set is incomplete but already configured
20
- //if a waitFor set has 'n' items, this can be thrown `n - 1` times
21
- class DurableIncompleteSignalError extends Error {
22
- constructor(message) {
23
- super(message);
24
- this.code = enums_1.HMSH_CODE_DURABLE_INCOMPLETE;
25
- }
26
- }
27
- exports.DurableIncompleteSignalError = DurableIncompleteSignalError;
28
- //the original waitFor error that is thrown for a new signal set
29
- class DurableWaitForSignalError extends Error {
30
- constructor(message, signals) {
31
- super(message);
32
- this.signals = signals;
33
- this.code = enums_1.HMSH_CODE_DURABLE_WAITFOR;
34
- }
35
- }
36
- exports.DurableWaitForSignalError = DurableWaitForSignalError;
37
- class DurableSleepForError extends Error {
38
- constructor(message, duration, index, dimension) {
39
- super(message);
40
- this.duration = duration;
41
- this.index = index;
42
- this.dimension = dimension;
43
- this.code = enums_1.HMSH_CODE_DURABLE_SLEEPFOR;
44
- }
45
- }
46
- exports.DurableSleepForError = DurableSleepForError;
19
+ class DurableWaitForError extends Error {
20
+ constructor(params) {
21
+ super(`Durable WaitFor Error [${params.workflowId}]`);
22
+ this.signalId = params.signalId;
23
+ this.index = params.index;
24
+ this.workflowDimension = params.workflowDimension;
25
+ this.code = enums_1.HMSH_CODE_DURABLE_WAIT;
26
+ }
27
+ }
28
+ exports.DurableWaitForError = DurableWaitForError;
29
+ class DurableProxyError extends Error {
30
+ constructor(params) {
31
+ super(`Durable Proxy Activity Error [${params.parentWorkflowId}] => [${params.workflowId}]`);
32
+ this.arguments = params.arguments;
33
+ this.workflowId = params.workflowId;
34
+ this.workflowTopic = params.workflowTopic;
35
+ this.parentWorkflowId = params.parentWorkflowId;
36
+ this.originJobId = params.originJobId;
37
+ this.index = params.index;
38
+ this.activityName = params.activityName;
39
+ this.workflowDimension = params.workflowDimension;
40
+ this.backoffCoefficient = params.backoffCoefficient;
41
+ this.maximumAttempts = params.maximumAttempts;
42
+ this.maximumInterval = params.maximumInterval;
43
+ this.code = enums_1.HMSH_CODE_DURABLE_PROXY;
44
+ }
45
+ }
46
+ exports.DurableProxyError = DurableProxyError;
47
+ class DurableChildError extends Error {
48
+ constructor(params) {
49
+ super(`Durable Child Error [${params.parentWorkflowId}] => [${params.workflowId}]`);
50
+ this.arguments = params.arguments;
51
+ this.workflowId = params.workflowId;
52
+ this.workflowTopic = params.workflowTopic;
53
+ this.parentWorkflowId = params.parentWorkflowId;
54
+ this.originJobId = params.originJobId;
55
+ this.index = params.index;
56
+ this.workflowDimension = params.workflowDimension;
57
+ this.code = enums_1.HMSH_CODE_DURABLE_CHILD;
58
+ this.await = params.await;
59
+ this.backoffCoefficient = params.backoffCoefficient;
60
+ this.maximumAttempts = params.maximumAttempts;
61
+ this.maximumInterval = params.maximumInterval;
62
+ }
63
+ }
64
+ exports.DurableChildError = DurableChildError;
65
+ class DurableWaitForAllError extends Error {
66
+ constructor(params) {
67
+ super(`Durable Wait for All Error [${params.parentWorkflowId}] => [${params.workflowId}]`);
68
+ this.items = params.items;
69
+ this.size = params.size;
70
+ this.workflowId = params.workflowId;
71
+ this.workflowTopic = params.workflowTopic;
72
+ this.parentWorkflowId = params.parentWorkflowId;
73
+ this.originJobId = params.originJobId;
74
+ this.index = params.index;
75
+ this.workflowDimension = params.workflowDimension;
76
+ this.code = enums_1.HMSH_CODE_DURABLE_ALL;
77
+ }
78
+ }
79
+ exports.DurableWaitForAllError = DurableWaitForAllError;
80
+ class DurableSleepError extends Error {
81
+ constructor(params) {
82
+ super(`Durable Sleep Error [${params.workflowId}]`);
83
+ this.duration = params.duration;
84
+ this.workflowId = params.workflowId;
85
+ this.index = params.index;
86
+ this.workflowDimension = params.workflowDimension;
87
+ this.code = enums_1.HMSH_CODE_DURABLE_SLEEP;
88
+ }
89
+ }
90
+ exports.DurableSleepError = DurableSleepError;
47
91
  class DurableTimeoutError extends Error {
48
- constructor(message) {
92
+ constructor(message, stack) {
49
93
  super(message);
94
+ if (this.stack) {
95
+ this.stack = stack;
96
+ }
50
97
  this.code = enums_1.HMSH_CODE_DURABLE_TIMEOUT;
51
98
  }
52
99
  }
53
100
  exports.DurableTimeoutError = DurableTimeoutError;
54
101
  class DurableMaxedError extends Error {
55
- constructor(message) {
102
+ constructor(message, stackTrace) {
56
103
  super(message);
104
+ if (stackTrace) {
105
+ this.stack = stackTrace;
106
+ }
57
107
  this.code = enums_1.HMSH_CODE_DURABLE_MAXED;
58
108
  }
59
109
  }
60
110
  exports.DurableMaxedError = DurableMaxedError;
61
111
  class DurableFatalError extends Error {
62
- constructor(message) {
112
+ constructor(message, stackTrace) {
63
113
  super(message);
114
+ if (stackTrace) {
115
+ this.stack = stackTrace;
116
+ }
64
117
  this.code = enums_1.HMSH_CODE_DURABLE_FATAL;
65
118
  }
66
119
  }
67
120
  exports.DurableFatalError = DurableFatalError;
68
121
  class DurableRetryError extends Error {
69
- constructor(message) {
122
+ constructor(message, stackTrace) {
70
123
  super(message);
124
+ if (stackTrace) {
125
+ this.stack = stackTrace;
126
+ }
71
127
  this.code = enums_1.HMSH_CODE_DURABLE_RETRYABLE;
72
128
  }
73
129
  }
@@ -87,6 +143,7 @@ exports.RegisterTimeoutError = RegisterTimeoutError;
87
143
  class DuplicateJobError extends Error {
88
144
  constructor(jobId) {
89
145
  super("Duplicate job");
146
+ this.jobId = jobId;
90
147
  this.message = `Duplicate job: ${jobId}`;
91
148
  }
92
149
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hotmeshio/hotmesh",
3
- "version": "0.0.52",
3
+ "version": "0.0.53",
4
4
  "description": "Unbreakable Workflows",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",
@@ -21,13 +21,16 @@
21
21
  "start": "ts-node src/index.ts",
22
22
  "test": "NODE_ENV=test jest --detectOpenHandles --forceExit --verbose",
23
23
  "test:hmsh": "NODE_ENV=test jest ./tests/functional/index.test.ts --detectOpenHandles --verbose",
24
+ "test:pipe": "NODE_ENV=test jest ./tests/unit/services/pipe/index.test.ts --detectOpenHandles --forceExit --verbose",
24
25
  "test:compile": "NODE_ENV=test jest ./tests/functional/compile/index.test.ts --detectOpenHandles --forceExit --verbose",
25
26
  "test:cycle": "NODE_ENV=test jest ./tests/functional/cycle/index.test.ts --detectOpenHandles --forceExit --verbose",
26
27
  "test:trigger": "NODE_ENV=test jest ./tests/unit/services/activities/trigger.test.ts --detectOpenHandles --forceExit --verbose",
27
28
  "test:connect": "NODE_ENV=test jest ./tests/unit/services/connector/index.test.ts --detectOpenHandles --forceExit --verbose",
28
29
  "test:connect:redis": "NODE_ENV=test jest ./tests/unit/services/connector/clients/redis.test.ts --detectOpenHandles --forceExit --verbose",
29
30
  "test:connect:ioredis": "NODE_ENV=test jest ./tests/unit/services/connector/clients/ioredis.test.ts --detectOpenHandles --forceExit --verbose",
31
+ "test:functional": "NODE_ENV=test jest ./tests/functional/*/index.test.ts --detectOpenHandles --forceExit --verbose",
30
32
  "test:emit": "NODE_ENV=test jest ./tests/functional/emit/index.test.ts --detectOpenHandles --forceExit --verbose",
33
+ "test:reentrant": "NODE_ENV=test jest ./tests/functional/reentrant/index.test.ts --detectOpenHandles --forceExit --verbose",
31
34
  "test:await": "NODE_ENV=test jest ./tests/functional/awaiter/index.test.ts --detectOpenHandles --forceExit --verbose",
32
35
  "test:hook": "NODE_ENV=test jest ./tests/functional/hook/index.test.ts --detectOpenHandles --forceExit --verbose",
33
36
  "test:signal": "NODE_ENV=test jest ./tests/functional/signal/index.test.ts --detectOpenHandles --forceExit --verbose",
@@ -46,13 +49,15 @@
46
49
  "test:sub:redis": "NODE_ENV=test jest ./tests/functional/sub/clients/redis.test.ts --detectOpenHandles --forceExit --verbose",
47
50
  "test:sub:ioredis": "NODE_ENV=test jest ./tests/functional/sub/clients/ioredis.test.ts --detectOpenHandles --forceExit --verbose",
48
51
  "test:durable": "NODE_ENV=test jest ./tests/durable/*/index.test.ts --detectOpenHandles --forceExit --verbose",
49
- "test:durable:meshos": "NODE_ENV=test jest ./tests/durable/meshos/index.test.ts --detectOpenHandles --forceExit --verbose",
52
+ "test:durable:basic": "NODE_ENV=test jest ./tests/durable/basic/index.test.ts --detectOpenHandles --forceExit --verbose",
53
+ "test:durable:collision": "NODE_ENV=test jest ./tests/durable/collision/index.test.ts --detectOpenHandles --forceExit --verbose",
50
54
  "test:durable:hello": "NODE_ENV=test jest ./tests/durable/helloworld/index.test.ts --detectOpenHandles --forceExit --verbose",
51
55
  "test:durable:interrupt": "NODE_ENV=test jest ./tests/durable/interrupt/index.test.ts --detectOpenHandles --forceExit --verbose",
52
56
  "test:durable:goodbye": "NODE_ENV=test jest ./tests/durable/goodbye/index.test.ts --detectOpenHandles --forceExit --verbose",
53
57
  "test:durable:hook": "NODE_ENV=test jest ./tests/durable/hook/index.test.ts --detectOpenHandles --forceExit --verbose",
54
58
  "test:durable:retry": "NODE_ENV=test jest ./tests/durable/retry/index.test.ts --detectOpenHandles --forceExit --verbose",
55
59
  "test:durable:fatal": "NODE_ENV=test jest ./tests/durable/fatal/index.test.ts --detectOpenHandles --forceExit --verbose",
60
+ "test:durable:unknown": "NODE_ENV=test jest ./tests/durable/unknown/index.test.ts --detectOpenHandles --forceExit --verbose",
56
61
  "test:durable:sleep": "NODE_ENV=test jest ./tests/durable/sleep/index.test.ts --detectOpenHandles --forceExit --verbose",
57
62
  "test:durable:signal": "NODE_ENV=test jest ./tests/durable/signal/index.test.ts --detectOpenHandles --forceExit --verbose",
58
63
  "test:durable:loopactivity": "NODE_ENV=test jest ./tests/durable/loopactivity/index.test.ts --detectOpenHandles --forceExit --verbose",
@@ -46,7 +46,15 @@ declare class Activity {
46
46
  mapInputData(): void;
47
47
  mapOutputData(): void;
48
48
  registerTimeout(): Promise<void>;
49
+ /**
50
+ * Any StreamMessage with a status of ERROR is bound to the activity
51
+ */
49
52
  bindActivityError(data: Record<string, unknown>): void;
53
+ /**
54
+ * unhandled activity errors (activities that return an ERROR StreamMessage
55
+ * status and have no adjacent children to transition to) are bound to the job
56
+ */
57
+ bindJobError(data: Record<string, unknown>): void;
50
58
  getTriggerConfig(): Promise<ActivityType>;
51
59
  getJobStatus(): null | number;
52
60
  setStatus(amount: number, multi?: RedisMulti): Promise<void>;