@hotmeshio/hotmesh 0.1.15 → 0.1.17
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.
- package/README.md +623 -209
- package/build/index.d.ts +14 -3
- package/build/index.js +17 -4
- package/build/modules/enums.d.ts +12 -12
- package/build/modules/enums.js +15 -25
- package/build/modules/errors.d.ts +16 -16
- package/build/modules/errors.js +28 -28
- package/build/modules/key.d.ts +0 -37
- package/build/modules/key.js +4 -45
- package/build/modules/utils.d.ts +7 -15
- package/build/modules/utils.js +21 -44
- package/build/package.json +18 -15
- package/build/services/activities/activity.d.ts +0 -31
- package/build/services/activities/activity.js +1 -50
- package/build/services/activities/await.js +0 -4
- package/build/services/activities/cycle.d.ts +0 -7
- package/build/services/activities/cycle.js +1 -16
- package/build/services/activities/hook.d.ts +0 -6
- package/build/services/activities/hook.js +2 -12
- package/build/services/activities/interrupt.js +0 -8
- package/build/services/activities/signal.d.ts +0 -6
- package/build/services/activities/signal.js +0 -15
- package/build/services/activities/trigger.d.ts +4 -5
- package/build/services/activities/trigger.js +22 -16
- package/build/services/activities/worker.js +0 -4
- package/build/services/collator/index.d.ts +0 -70
- package/build/services/collator/index.js +1 -91
- package/build/services/compiler/deployer.js +6 -38
- package/build/services/compiler/index.d.ts +0 -15
- package/build/services/compiler/index.js +0 -20
- package/build/services/compiler/validator.d.ts +0 -3
- package/build/services/compiler/validator.js +0 -25
- package/build/services/connector/clients/ioredis.js +0 -2
- package/build/services/connector/clients/redis.js +0 -2
- package/build/services/connector/index.js +0 -2
- package/build/services/engine/index.d.ts +1 -10
- package/build/services/engine/index.js +1 -48
- package/build/services/exporter/index.d.ts +0 -27
- package/build/services/exporter/index.js +0 -33
- package/build/services/hotmesh/index.d.ts +8 -4
- package/build/services/hotmesh/index.js +20 -19
- package/build/services/logger/index.js +0 -2
- package/build/services/mapper/index.d.ts +0 -14
- package/build/services/mapper/index.js +0 -14
- package/build/services/meshcall/index.d.ts +21 -0
- package/build/services/meshcall/index.js +202 -0
- package/build/services/meshcall/schemas/factory.d.ts +2 -0
- package/build/services/meshcall/schemas/factory.js +179 -0
- package/build/services/meshdata/index.d.ts +75 -0
- package/build/services/meshdata/index.js +541 -0
- package/build/services/meshflow/client.d.ts +18 -0
- package/build/services/{durable → meshflow}/client.js +9 -40
- package/build/services/{durable → meshflow}/connection.d.ts +2 -1
- package/build/services/{durable → meshflow}/connection.js +1 -0
- package/build/services/meshflow/exporter.d.ts +29 -0
- package/build/services/{durable → meshflow}/exporter.js +0 -29
- package/build/services/meshflow/handle.d.ts +22 -0
- package/build/services/{durable → meshflow}/handle.js +0 -46
- package/build/services/meshflow/index.d.ts +17 -0
- package/build/services/meshflow/index.js +23 -0
- package/build/services/meshflow/schemas/factory.d.ts +4 -0
- package/build/services/{durable → meshflow}/schemas/factory.js +2 -30
- package/build/services/meshflow/search.d.ts +23 -0
- package/build/services/{durable → meshflow}/search.js +0 -99
- package/build/services/{durable → meshflow}/worker.d.ts +3 -2
- package/build/services/{durable → meshflow}/worker.js +23 -39
- package/build/services/meshflow/workflow.d.ts +27 -0
- package/build/services/{durable → meshflow}/workflow.js +27 -169
- package/build/services/pipe/functions/date.d.ts +0 -7
- package/build/services/pipe/functions/date.js +0 -7
- package/build/services/pipe/functions/math.js +0 -2
- package/build/services/pipe/index.d.ts +0 -15
- package/build/services/pipe/index.js +2 -23
- package/build/services/quorum/index.d.ts +1 -7
- package/build/services/quorum/index.js +0 -21
- package/build/services/reporter/index.d.ts +0 -5
- package/build/services/reporter/index.js +0 -9
- package/build/services/router/index.d.ts +0 -9
- package/build/services/router/index.js +2 -30
- package/build/services/serializer/index.js +6 -23
- package/build/services/store/cache.d.ts +0 -19
- package/build/services/store/cache.js +0 -19
- package/build/services/store/clients/ioredis.d.ts +0 -6
- package/build/services/store/clients/ioredis.js +0 -7
- package/build/services/store/clients/redis.d.ts +0 -6
- package/build/services/store/clients/redis.js +0 -6
- package/build/services/store/index.d.ts +0 -55
- package/build/services/store/index.js +14 -87
- package/build/services/stream/clients/ioredis.js +1 -4
- package/build/services/task/index.d.ts +0 -9
- package/build/services/task/index.js +0 -31
- package/build/services/telemetry/index.d.ts +0 -7
- package/build/services/telemetry/index.js +1 -13
- package/build/services/worker/index.d.ts +1 -4
- package/build/services/worker/index.js +0 -6
- package/build/types/activity.d.ts +0 -81
- package/build/types/error.d.ts +5 -5
- package/build/types/exporter.d.ts +1 -14
- package/build/types/hotmesh.d.ts +4 -12
- package/build/types/hotmesh.js +0 -3
- package/build/types/index.d.ts +5 -3
- package/build/types/index.js +1 -1
- package/build/types/job.d.ts +1 -95
- package/build/types/meshcall.d.ts +54 -0
- package/build/types/meshdata.d.ts +59 -0
- package/build/types/meshdata.js +2 -0
- package/build/types/meshflow.d.ts +202 -0
- package/build/types/meshflow.js +2 -0
- package/build/types/pipe.d.ts +0 -65
- package/build/types/quorum.d.ts +0 -12
- package/build/types/redis.d.ts +0 -6
- package/build/types/stream.d.ts +0 -59
- package/build/types/stream.js +0 -4
- package/index.ts +12 -3
- package/package.json +18 -15
- package/typedoc.json +38 -0
- package/types/error.ts +5 -5
- package/types/exporter.ts +1 -1
- package/types/hotmesh.ts +3 -2
- package/types/index.ts +25 -7
- package/types/job.ts +19 -1
- package/types/meshcall.ts +192 -0
- package/types/meshdata.ts +273 -0
- package/types/{durable.ts → meshflow.ts} +33 -9
- package/build/services/durable/client.d.ts +0 -49
- package/build/services/durable/exporter.d.ts +0 -51
- package/build/services/durable/handle.d.ts +0 -58
- package/build/services/durable/index.d.ts +0 -19
- package/build/services/durable/index.js +0 -25
- package/build/services/durable/schemas/factory.d.ts +0 -33
- package/build/services/durable/search.d.ts +0 -120
- package/build/services/durable/workflow.d.ts +0 -143
- package/build/types/durable.d.ts +0 -467
- /package/build/types/{durable.js → meshcall.js} +0 -0
package/types/hotmesh.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ILogger } from '../services/logger';
|
|
2
|
-
import { HotMeshService } from '../services/hotmesh';
|
|
2
|
+
import { HotMesh as HotMeshService } from '../services/hotmesh';
|
|
3
3
|
|
|
4
4
|
import { HookRules } from './hook';
|
|
5
5
|
import { RedisClass, RedisClient, RedisOptions } from './redis';
|
|
@@ -72,13 +72,14 @@ type HotMeshWorker = {
|
|
|
72
72
|
redis?: RedisConfig;
|
|
73
73
|
reclaimDelay?: number; //milliseconds
|
|
74
74
|
reclaimCount?: number; //max number of times to reclaim a stream
|
|
75
|
-
callback: (payload: StreamData) => Promise<StreamDataResponse
|
|
75
|
+
callback: (payload: StreamData) => Promise<StreamDataResponse>;
|
|
76
76
|
};
|
|
77
77
|
|
|
78
78
|
type HotMeshConfig = {
|
|
79
79
|
appId: string;
|
|
80
80
|
namespace?: string;
|
|
81
81
|
name?: string;
|
|
82
|
+
guid?: string;
|
|
82
83
|
logger?: ILogger;
|
|
83
84
|
logLevel?: LogLevel;
|
|
84
85
|
engine?: HotMeshEngine;
|
package/types/index.ts
CHANGED
|
@@ -26,6 +26,7 @@ export {
|
|
|
26
26
|
ActivityWorkflowDataType,
|
|
27
27
|
ChildResponseType,
|
|
28
28
|
ClientConfig,
|
|
29
|
+
ClientWorkflow,
|
|
29
30
|
ContextType,
|
|
30
31
|
ConnectionConfig,
|
|
31
32
|
Connection,
|
|
@@ -47,18 +48,18 @@ export {
|
|
|
47
48
|
WorkflowSearchSchema,
|
|
48
49
|
WorkflowDataType,
|
|
49
50
|
WorkflowOptions,
|
|
50
|
-
} from './
|
|
51
|
+
} from './meshflow';
|
|
51
52
|
export {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
53
|
+
MeshFlowChildErrorType,
|
|
54
|
+
MeshFlowProxyErrorType,
|
|
55
|
+
MeshFlowSleepErrorType,
|
|
56
|
+
MeshFlowWaitForAllErrorType,
|
|
57
|
+
MeshFlowWaitForErrorType,
|
|
57
58
|
} from './error';
|
|
58
59
|
export {
|
|
59
60
|
ActivityAction,
|
|
60
61
|
DependencyExport,
|
|
61
|
-
|
|
62
|
+
MeshFlowJobExport,
|
|
62
63
|
ExportCycles,
|
|
63
64
|
ExportItem,
|
|
64
65
|
ExportOptions,
|
|
@@ -116,6 +117,23 @@ export {
|
|
|
116
117
|
KeyStoreParams,
|
|
117
118
|
KeyType,
|
|
118
119
|
} from './hotmesh';
|
|
120
|
+
export {
|
|
121
|
+
MeshCallConnectParams,
|
|
122
|
+
MeshCallExecParams,
|
|
123
|
+
MeshCallCronParams,
|
|
124
|
+
MeshCallExecOptions,
|
|
125
|
+
MeshCallCronOptions,
|
|
126
|
+
MeshCallInterruptOptions,
|
|
127
|
+
MeshCallInterruptParams,
|
|
128
|
+
MeshCallFlushParams,
|
|
129
|
+
} from './meshcall';
|
|
130
|
+
export {
|
|
131
|
+
CallOptions,
|
|
132
|
+
MeshDataWorkflowOptions,
|
|
133
|
+
ConnectOptions,
|
|
134
|
+
ConnectionInput,
|
|
135
|
+
ExecInput,
|
|
136
|
+
} from './meshdata';
|
|
119
137
|
export {
|
|
120
138
|
ActivateMessage,
|
|
121
139
|
CronMessage,
|
package/types/job.ts
CHANGED
|
@@ -108,16 +108,34 @@ type ExtensionType = {
|
|
|
108
108
|
marker?: StringStringType;
|
|
109
109
|
|
|
110
110
|
/**
|
|
111
|
+
* Workflows that are 'pending' init with a status of `-1`.
|
|
112
|
+
*
|
|
111
113
|
* If provided, the job will initialize in a pending state, reserving
|
|
112
114
|
* only the job ID (HSETNX) and persisting search and marker (if provided).
|
|
113
115
|
* If a `resume` signal is sent before the specified number of seconds,
|
|
114
116
|
* the job will resume as normal, transitioning to the adjacent children
|
|
115
|
-
* of the trigger.
|
|
117
|
+
* of the trigger.
|
|
118
|
+
*
|
|
119
|
+
* If the job is not resumed within the number
|
|
116
120
|
* of seconds specified, the job will be scrubbed. No dependencies
|
|
117
121
|
* are added for a job in a pending state; however, dependencies
|
|
118
122
|
* will be added after the job is resumed if relevant.
|
|
119
123
|
*/
|
|
120
124
|
pending?: number;
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Workflows that apply a status threshold will be initialized
|
|
128
|
+
* with a status value of 1m - statusThreshold.
|
|
129
|
+
*
|
|
130
|
+
* The value provided should be the count of descendant activities
|
|
131
|
+
* (those that descend from the trigger) that should be allowed to
|
|
132
|
+
* remain open once 'done' event is emitted.
|
|
133
|
+
*
|
|
134
|
+
* If the job should not be removed from the cache, the `expire` field
|
|
135
|
+
* should be set to `0`.
|
|
136
|
+
*
|
|
137
|
+
*/
|
|
138
|
+
statusThreshold?: number;
|
|
121
139
|
};
|
|
122
140
|
|
|
123
141
|
/**
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
import { RedisConfig } from "./hotmesh";
|
|
2
|
+
import { LogLevel } from "./logger";
|
|
3
|
+
|
|
4
|
+
interface MeshCallExecOptions {
|
|
5
|
+
/**
|
|
6
|
+
* Cache id when caching, flushing and retrieving function results.
|
|
7
|
+
*/
|
|
8
|
+
id: string;
|
|
9
|
+
/**
|
|
10
|
+
* Time to live for the cache key. For example, `1 day`, `1 hour`. Refer to the syntax for the `ms` NPM package.
|
|
11
|
+
*/
|
|
12
|
+
ttl?: string;
|
|
13
|
+
/**
|
|
14
|
+
* If true, the cache will first be flushed and the function will be executed.
|
|
15
|
+
*/
|
|
16
|
+
flush?: boolean;
|
|
17
|
+
}
|
|
18
|
+
interface MeshCallConnectParams {
|
|
19
|
+
/**
|
|
20
|
+
* Log level for the worker
|
|
21
|
+
*/
|
|
22
|
+
logLevel?: LogLevel;
|
|
23
|
+
/**
|
|
24
|
+
* Idempotent GUID for the worker and engine
|
|
25
|
+
*/
|
|
26
|
+
guid?: string;
|
|
27
|
+
/**
|
|
28
|
+
* Namespace for grouping common functions
|
|
29
|
+
*/
|
|
30
|
+
namespace?: string;
|
|
31
|
+
/**
|
|
32
|
+
* Unique topic for the worker function
|
|
33
|
+
*/
|
|
34
|
+
topic: string;
|
|
35
|
+
/**
|
|
36
|
+
* Redis configuration for the worker
|
|
37
|
+
*/
|
|
38
|
+
redis: RedisConfig;
|
|
39
|
+
/**
|
|
40
|
+
* The linked worker function that will be called
|
|
41
|
+
*/
|
|
42
|
+
callback: (...args: any[]) => any;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
interface MeshCallExecParams {
|
|
46
|
+
/**
|
|
47
|
+
* namespace for grouping common functions
|
|
48
|
+
*/
|
|
49
|
+
namespace?: string;
|
|
50
|
+
/**
|
|
51
|
+
* topic assigned to the worker when it was connected
|
|
52
|
+
*/
|
|
53
|
+
topic: string;
|
|
54
|
+
/**
|
|
55
|
+
* Arguments to pass to the worker function
|
|
56
|
+
*/
|
|
57
|
+
args: any[];
|
|
58
|
+
/**
|
|
59
|
+
* Redis configuration
|
|
60
|
+
*/
|
|
61
|
+
redis: RedisConfig;
|
|
62
|
+
/**
|
|
63
|
+
* Execution options like caching ttl
|
|
64
|
+
*/
|
|
65
|
+
options?: MeshCallExecOptions;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
interface MeshCallFlushOptions {
|
|
69
|
+
/**
|
|
70
|
+
* Cache id when caching/flushing/retrieving function results.
|
|
71
|
+
*/
|
|
72
|
+
id: string;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
interface MeshCallFlushParams {
|
|
76
|
+
/**
|
|
77
|
+
* namespace for grouping common functions
|
|
78
|
+
*/
|
|
79
|
+
namespace?: string;
|
|
80
|
+
/**
|
|
81
|
+
* id for cached response to flush
|
|
82
|
+
*/
|
|
83
|
+
id?: string;
|
|
84
|
+
/**
|
|
85
|
+
* topic assigned to the worker when it was connected
|
|
86
|
+
*/
|
|
87
|
+
topic: string;
|
|
88
|
+
/**
|
|
89
|
+
* Redis configuration
|
|
90
|
+
*/
|
|
91
|
+
redis: RedisConfig;
|
|
92
|
+
/**
|
|
93
|
+
* Options for the flush
|
|
94
|
+
*/
|
|
95
|
+
options?: MeshCallFlushOptions;
|
|
96
|
+
}
|
|
97
|
+
interface MeshCallCronOptions {
|
|
98
|
+
/**
|
|
99
|
+
* Idempotent GUID for the function
|
|
100
|
+
* */
|
|
101
|
+
id: string;
|
|
102
|
+
/**
|
|
103
|
+
* For example, `1 day`, `1 hour`. Fidelity is generally
|
|
104
|
+
* within 5 seconds. Refer to the syntax for the `ms` NPM package.
|
|
105
|
+
*/
|
|
106
|
+
interval: string;
|
|
107
|
+
/**
|
|
108
|
+
* Maximum number of cycles to run before exiting the cron.
|
|
109
|
+
*/
|
|
110
|
+
maxCycles?: number;
|
|
111
|
+
/**
|
|
112
|
+
* Time in seconds to sleep before invoking the first cycle.
|
|
113
|
+
* For example, `1 day`, `1 hour`. Fidelity is generally
|
|
114
|
+
* within 5 seconds. Refer to the syntax for the `ms` NPM package.
|
|
115
|
+
*/
|
|
116
|
+
delay?: string;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
interface MeshCallInterruptOptions {
|
|
120
|
+
/**
|
|
121
|
+
* Idempotent GUID for the cron function
|
|
122
|
+
*/
|
|
123
|
+
id: string;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
interface MeshCallCronParams {
|
|
127
|
+
/**
|
|
128
|
+
* Log level for the cron
|
|
129
|
+
*/
|
|
130
|
+
logLevel?: LogLevel;
|
|
131
|
+
/**
|
|
132
|
+
* Idempotent GUID for the worker and engine used for the cron
|
|
133
|
+
*/
|
|
134
|
+
guid?: string;
|
|
135
|
+
/**
|
|
136
|
+
* Namespace for grouping common cron functions. The cron job keys in Redis
|
|
137
|
+
* will be prefixed with this namespace. (e.g. `hmsh:[namespace]:j:*`)
|
|
138
|
+
*/
|
|
139
|
+
namespace?: string;
|
|
140
|
+
/**
|
|
141
|
+
* Unique topic for the cron function to identify the worker
|
|
142
|
+
*/
|
|
143
|
+
topic: string;
|
|
144
|
+
/**
|
|
145
|
+
* Redis configuration for the cron job
|
|
146
|
+
*/
|
|
147
|
+
redis: RedisConfig;
|
|
148
|
+
/**
|
|
149
|
+
* Arguments to pass to the cron job; arguments will be passed to the callback
|
|
150
|
+
* each time it runs
|
|
151
|
+
*/
|
|
152
|
+
args: any[];
|
|
153
|
+
/**
|
|
154
|
+
* linked worker function to run
|
|
155
|
+
*/
|
|
156
|
+
callback: (...args: any[]) => any;
|
|
157
|
+
/**
|
|
158
|
+
* Options for the cron job
|
|
159
|
+
*/
|
|
160
|
+
options: MeshCallCronOptions;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
interface MeshCallInterruptParams {
|
|
164
|
+
/**
|
|
165
|
+
* namespace for grouping common functions
|
|
166
|
+
*/
|
|
167
|
+
namespace?: string;
|
|
168
|
+
/**
|
|
169
|
+
* topic assigned to the cron worker when it was connected
|
|
170
|
+
*/
|
|
171
|
+
topic: string;
|
|
172
|
+
/**
|
|
173
|
+
* Redis configuration
|
|
174
|
+
*/
|
|
175
|
+
redis: RedisConfig;
|
|
176
|
+
/**
|
|
177
|
+
* Options for interrupting the cron
|
|
178
|
+
*/
|
|
179
|
+
options: MeshCallInterruptOptions;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
export {
|
|
183
|
+
MeshCallConnectParams,
|
|
184
|
+
MeshCallExecParams,
|
|
185
|
+
MeshCallCronParams,
|
|
186
|
+
MeshCallExecOptions,
|
|
187
|
+
MeshCallCronOptions,
|
|
188
|
+
MeshCallInterruptOptions,
|
|
189
|
+
MeshCallInterruptParams,
|
|
190
|
+
MeshCallFlushOptions,
|
|
191
|
+
MeshCallFlushParams,
|
|
192
|
+
};
|
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
import { HookOptions, WorkflowConfig, WorkflowSearchOptions } from "./meshflow";
|
|
2
|
+
import { StringStringType } from "./serializer";
|
|
3
|
+
|
|
4
|
+
export type CallOptions = {
|
|
5
|
+
/**
|
|
6
|
+
* if provided along with a `ttl`, the function will be cached
|
|
7
|
+
*/
|
|
8
|
+
id?: string;
|
|
9
|
+
/**
|
|
10
|
+
* in format '1 minute', '5 minutes', '1 hour', 'infinity', etc
|
|
11
|
+
*/
|
|
12
|
+
ttl?: string;
|
|
13
|
+
/**
|
|
14
|
+
* full GUID (including prefix)
|
|
15
|
+
*/
|
|
16
|
+
$guid?: string;
|
|
17
|
+
/**
|
|
18
|
+
* exec, hook, proxy
|
|
19
|
+
*/
|
|
20
|
+
$type?: string;
|
|
21
|
+
/**
|
|
22
|
+
* if set to false explicitly it will not await the result
|
|
23
|
+
*/
|
|
24
|
+
await?: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* taskQueue for the workflowId (defaults to entity)
|
|
27
|
+
*/
|
|
28
|
+
taskQueue?: string;
|
|
29
|
+
/**
|
|
30
|
+
* defaults to `entity` input parameter; allows override of the workflowId prefix
|
|
31
|
+
*/
|
|
32
|
+
prefix?: string;
|
|
33
|
+
search?: WorkflowSearchOptions;
|
|
34
|
+
/**
|
|
35
|
+
* list of state field names to return (this is NOT the final response)
|
|
36
|
+
*/
|
|
37
|
+
fields?: string[];
|
|
38
|
+
/**
|
|
39
|
+
* namespace for the the execution client; how it appears in Redis (defaults to 'durable')
|
|
40
|
+
*/
|
|
41
|
+
namespace?: string; //optional namespace for the workflowId (defaults to 'durable')
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Custom marker data field used for adding a searchable marker to the job.
|
|
45
|
+
* markers always begin with a dash (-). Any field that does not
|
|
46
|
+
* begin with a dash will be removed and will not be inserted with
|
|
47
|
+
* the initial data set.
|
|
48
|
+
*/
|
|
49
|
+
marker?: StringStringType;
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* If provided, the job will initialize in an pending state, reserving
|
|
53
|
+
* only the job ID (HSETNX) and persisting search and marker (if provided).
|
|
54
|
+
* If a `resume` signal is sent before the specified number of seconds,
|
|
55
|
+
* the job will resume as normal. If the job is not resumed within the
|
|
56
|
+
* number of seconds provided, the job will be scrubbed. No dependencies
|
|
57
|
+
* are set for a job in a pending state; however, dependencies will be
|
|
58
|
+
* added after the job is resumed if necessary.
|
|
59
|
+
*/
|
|
60
|
+
pending?: number;
|
|
61
|
+
|
|
62
|
+
//flush?: boolean;
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
export type ConnectOptions = {
|
|
66
|
+
/**
|
|
67
|
+
* if set to infinity, callers may not override (the function will be durable)
|
|
68
|
+
*/
|
|
69
|
+
ttl?: string;
|
|
70
|
+
/**
|
|
71
|
+
* the task queue for the connected function for greater specificity
|
|
72
|
+
*/
|
|
73
|
+
taskQueue?: string;
|
|
74
|
+
/**
|
|
75
|
+
* prefix for the workflowId (defaults to entity value if not provided)
|
|
76
|
+
*/
|
|
77
|
+
prefix?: string;
|
|
78
|
+
/**
|
|
79
|
+
* optional namespace for the the worker; how it appears in Redis (defaults to 'durable')
|
|
80
|
+
*/
|
|
81
|
+
namespace?: string; //optional namespace for the workflowId (defaults to 'durable')
|
|
82
|
+
/**
|
|
83
|
+
* extended worker options
|
|
84
|
+
*/
|
|
85
|
+
options?: WorkerOptions;
|
|
86
|
+
/**
|
|
87
|
+
* optional search configuration
|
|
88
|
+
*/
|
|
89
|
+
search?: WorkflowSearchOptions;
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Connect a function to the operational data layer.
|
|
94
|
+
* @template T - the return type of the connected function
|
|
95
|
+
*/
|
|
96
|
+
export type ConnectionInput<T> = {
|
|
97
|
+
/**
|
|
98
|
+
* The connected function's entity identifier
|
|
99
|
+
*
|
|
100
|
+
* @example
|
|
101
|
+
* user
|
|
102
|
+
*/
|
|
103
|
+
entity: string;
|
|
104
|
+
/**
|
|
105
|
+
* The target function reference
|
|
106
|
+
*
|
|
107
|
+
* @example
|
|
108
|
+
* function() { return "hello world" }
|
|
109
|
+
*/
|
|
110
|
+
target: (...args: any[]) => T;
|
|
111
|
+
/**
|
|
112
|
+
* Extended connection options (e.g., ttl, taskQueue)
|
|
113
|
+
* @example
|
|
114
|
+
* { ttl: 'infinity' }
|
|
115
|
+
*/
|
|
116
|
+
options?: ConnectOptions;
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Executes a remote function by its global entity identifier with specified arguments.
|
|
121
|
+
* If options.ttl is infinity, the function will be cached indefinitely and can only be
|
|
122
|
+
* removed by calling `flush`. During this time, the function will remain active and can
|
|
123
|
+
* its state can be augmented by calling `set`, `incr`, `del`, etc OR by calling a
|
|
124
|
+
* transactional 'hook' function.
|
|
125
|
+
*
|
|
126
|
+
* @template T The expected return type of the remote function.
|
|
127
|
+
*/
|
|
128
|
+
export type ExecInput = {
|
|
129
|
+
/**
|
|
130
|
+
* the connected function's entity identifier
|
|
131
|
+
* @example
|
|
132
|
+
* user
|
|
133
|
+
*/
|
|
134
|
+
entity: string;
|
|
135
|
+
/**
|
|
136
|
+
* the function's input arguments
|
|
137
|
+
* @example
|
|
138
|
+
* ['Jane', 'Doe']
|
|
139
|
+
*/
|
|
140
|
+
args: any[];
|
|
141
|
+
/**
|
|
142
|
+
* Extended options for the hook function, like specifying a taskQueue or ttl
|
|
143
|
+
* @example
|
|
144
|
+
* { ttl: '5 minutes' }
|
|
145
|
+
*/
|
|
146
|
+
options?: Partial<MeshDataWorkflowOptions>;
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Hook function inputs. Hooks augment running jobs.
|
|
151
|
+
*/
|
|
152
|
+
export type HookInput = {
|
|
153
|
+
/**
|
|
154
|
+
* The target function's entity identifier
|
|
155
|
+
* @example 'user'
|
|
156
|
+
*/
|
|
157
|
+
entity: string;
|
|
158
|
+
/**
|
|
159
|
+
* The target execution id (workflowId/jobId)
|
|
160
|
+
* @example 'jsmith123'
|
|
161
|
+
*/
|
|
162
|
+
id: string;
|
|
163
|
+
/**
|
|
164
|
+
* The hook function's entity identifier
|
|
165
|
+
* @example 'user.notify'
|
|
166
|
+
*/
|
|
167
|
+
hookEntity: string;
|
|
168
|
+
/**
|
|
169
|
+
* The hook function's input arguments
|
|
170
|
+
* @example 'notify'
|
|
171
|
+
*/
|
|
172
|
+
hookArgs: any[];
|
|
173
|
+
/**
|
|
174
|
+
* Extended options for the hook function, like specifying a taskQueue
|
|
175
|
+
* @example { taskQueue: 'priority' }
|
|
176
|
+
*/
|
|
177
|
+
options?: Partial<HookOptions>;
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
export type MeshDataWorkflowOptions = {
|
|
182
|
+
/**
|
|
183
|
+
* The app deployment namespace; how it appears in redis (e.g., 'durable')
|
|
184
|
+
*/
|
|
185
|
+
namespace?: string;
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* Target connected functions more specifically by taskQueue
|
|
189
|
+
*/
|
|
190
|
+
taskQueue?: string;
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* The connected function's entity identifier
|
|
194
|
+
*/
|
|
195
|
+
prefix?: string;
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* The function execution id (shorthand for workflowId)
|
|
199
|
+
*/
|
|
200
|
+
id?: string;
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* The function execution id
|
|
204
|
+
*/
|
|
205
|
+
workflowId?: string;
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* The function name (`entity` is a shorthand for this)
|
|
209
|
+
*/
|
|
210
|
+
workflowName?: string;
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* The open telemetry trace context for the workflow, used for logging and tracing. If a sink is enabled, this will be sent to the sink.
|
|
214
|
+
*/
|
|
215
|
+
workflowTrace?: string;
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* The open telemetry span context for the workflow, used for logging and tracing. If a sink is enabled, this will be sent to the sink.
|
|
219
|
+
*/
|
|
220
|
+
workflowSpan?: string;
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* Search fields to seed function state when it first initializes
|
|
224
|
+
*/
|
|
225
|
+
search?: WorkflowSearchOptions;
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* Extended execution options
|
|
229
|
+
*/
|
|
230
|
+
config?: WorkflowConfig;
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
* Set to 'infinity' to make the function durable; otherwise, '1 minute', '1 hour', etc
|
|
234
|
+
*/
|
|
235
|
+
ttl?: string;
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* If set to false explicitly it will not await the result
|
|
239
|
+
* @default true
|
|
240
|
+
*/
|
|
241
|
+
await?: boolean;
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* Custom marker data field used for adding a searchable marker to the job.
|
|
245
|
+
* markers always begin with a dash (-). Any field that does not
|
|
246
|
+
* begin with a dash will be removed and will not be inserted with
|
|
247
|
+
* the initial data set.
|
|
248
|
+
*/
|
|
249
|
+
marker?: StringStringType;
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
* If provided, the job will initialize in a pending state, reserving
|
|
253
|
+
* only the job ID (HSETNX) and persisting search and marker (if provided).
|
|
254
|
+
* If a `resume` signal is sent before the specified number of seconds,
|
|
255
|
+
* the job will resume as normal. If the job is not resumed within the
|
|
256
|
+
* number of seconds provided, the job will be scrubbed. No dependencies
|
|
257
|
+
* are set for a job in a pending state; however, dependencies will be
|
|
258
|
+
* added after the job is resumed (if necessary).
|
|
259
|
+
*/
|
|
260
|
+
pending?: number;
|
|
261
|
+
|
|
262
|
+
/**
|
|
263
|
+
* sets the number of seconds a workflow may exist after completion. As the process engine is an in-memory cache, the default policy is to expire and scrub the job hash as soon as it completes.
|
|
264
|
+
* @default 1
|
|
265
|
+
*/
|
|
266
|
+
expire?: number;
|
|
267
|
+
|
|
268
|
+
/**
|
|
269
|
+
* set to false to optimize workflows that do not require a `signal in`
|
|
270
|
+
* @default true
|
|
271
|
+
*/
|
|
272
|
+
signalIn?: boolean;
|
|
273
|
+
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { WorkflowHandleService } from '../services/meshflow/handle';
|
|
1
2
|
import { LogLevel } from './logger';
|
|
2
3
|
import { RedisClass, RedisOptions } from './redis';
|
|
3
4
|
import { StringAnyType, StringStringType } from './serializer';
|
|
@@ -9,19 +10,19 @@ import { StreamData, StreamError } from './stream';
|
|
|
9
10
|
type WorkflowConfig = {
|
|
10
11
|
/**
|
|
11
12
|
* Backoff coefficient for retry mechanism.
|
|
12
|
-
* @default 10 (
|
|
13
|
+
* @default 10 (HMSH_MESHFLOW_EXP_BACKOFF)
|
|
13
14
|
*/
|
|
14
15
|
backoffCoefficient?: number;
|
|
15
16
|
|
|
16
17
|
/**
|
|
17
18
|
* Maximum number of attempts for retries.
|
|
18
|
-
* @default 5 (
|
|
19
|
+
* @default 5 (HMSH_MESHFLOW_MAX_ATTEMPTS)
|
|
19
20
|
*/
|
|
20
21
|
maximumAttempts?: number;
|
|
21
22
|
|
|
22
23
|
/**
|
|
23
24
|
* Maximum interval between retries.
|
|
24
|
-
* @default 120s (
|
|
25
|
+
* @default 120s (HMSH_MESHFLOW_MAX_INTERVAL)
|
|
25
26
|
*/
|
|
26
27
|
maximumInterval?: string;
|
|
27
28
|
|
|
@@ -335,6 +336,13 @@ type WorkflowOptions = {
|
|
|
335
336
|
* will be added after the job is resumed if relevant.
|
|
336
337
|
*/
|
|
337
338
|
pending?: number;
|
|
339
|
+
|
|
340
|
+
/**
|
|
341
|
+
* Provide to set the engine name. This MUST be unique, so do not
|
|
342
|
+
* provide unless it is guaranteed to be a unique engine/worker guid
|
|
343
|
+
* when identifying the point of presence within the mesh.
|
|
344
|
+
*/
|
|
345
|
+
guid?: string;
|
|
338
346
|
};
|
|
339
347
|
|
|
340
348
|
/**
|
|
@@ -446,6 +454,13 @@ type WorkerConfig = {
|
|
|
446
454
|
|
|
447
455
|
/** Search options for workflow execution details */
|
|
448
456
|
search?: WorkflowSearchOptions;
|
|
457
|
+
|
|
458
|
+
/**
|
|
459
|
+
* Provide to set the engine name. This MUST be unique, so do not
|
|
460
|
+
* provide unless it is guaranteed to be a unique engine/worker guid
|
|
461
|
+
* when identifying the point of presence within the mesh.
|
|
462
|
+
*/
|
|
463
|
+
guid?: string;
|
|
449
464
|
};
|
|
450
465
|
|
|
451
466
|
type FindWhereQuery = {
|
|
@@ -495,13 +510,13 @@ type WorkerOptions = {
|
|
|
495
510
|
/** Log level: debug, info, warn, error */
|
|
496
511
|
logLevel?: LogLevel;
|
|
497
512
|
|
|
498
|
-
/** Maximum number of attempts, default 5 (
|
|
513
|
+
/** Maximum number of attempts, default 5 (HMSH_MESHFLOW_MAX_ATTEMPTS) */
|
|
499
514
|
maximumAttempts?: number;
|
|
500
515
|
|
|
501
|
-
/** Backoff coefficient for retry logic, default 10 (
|
|
516
|
+
/** Backoff coefficient for retry logic, default 10 (HMSH_MESHFLOW_EXP_BACKOFF) */
|
|
502
517
|
backoffCoefficient?: number;
|
|
503
518
|
|
|
504
|
-
/** Maximum interval between retries, default 120s (
|
|
519
|
+
/** Maximum interval between retries, default 120s (HMSH_MESHFLOW_MAX_INTERVAL) */
|
|
505
520
|
maximumInterval?: string;
|
|
506
521
|
};
|
|
507
522
|
|
|
@@ -532,11 +547,11 @@ type ActivityConfig = {
|
|
|
532
547
|
|
|
533
548
|
/** Retry policy configuration for activities */
|
|
534
549
|
retryPolicy?: {
|
|
535
|
-
/** Maximum number of retry attempts, default is 5 (
|
|
550
|
+
/** Maximum number of retry attempts, default is 5 (HMSH_MESHFLOW_MAX_ATTEMPTS) */
|
|
536
551
|
maximumAttempts?: number;
|
|
537
|
-
/** Factor by which the retry timeout increases, default is 10 (
|
|
552
|
+
/** Factor by which the retry timeout increases, default is 10 (HMSH_MESHFLOW_MAX_INTERVAL) */
|
|
538
553
|
backoffCoefficient?: number;
|
|
539
|
-
/** Maximum interval between retries, default is '120s' (
|
|
554
|
+
/** Maximum interval between retries, default is '120s' (HMSH_MESHFLOW_EXP_BACKOFF) */
|
|
540
555
|
maximumInterval?: string;
|
|
541
556
|
/** Whether to throw an error on failure, default is true */
|
|
542
557
|
throwOnError?: boolean;
|
|
@@ -565,11 +580,20 @@ type ChildResponseType<T> = {
|
|
|
565
580
|
ju: string;
|
|
566
581
|
};
|
|
567
582
|
|
|
583
|
+
interface ClientWorkflow {
|
|
584
|
+
start(options: WorkflowOptions): Promise<WorkflowHandleService>;
|
|
585
|
+
signal(signalId: string, data: StringAnyType, namespace?: string): Promise<string>;
|
|
586
|
+
hook(options: HookOptions): Promise<string>;
|
|
587
|
+
getHandle(taskQueue: string, workflowName: string, workflowId: string, namespace?: string): Promise<WorkflowHandleService>;
|
|
588
|
+
search(taskQueue: string, workflowName: string, namespace: string | null, index: string, ...query: string[]): Promise<string[]>;
|
|
589
|
+
}
|
|
590
|
+
|
|
568
591
|
export {
|
|
569
592
|
ActivityConfig,
|
|
570
593
|
ActivityWorkflowDataType,
|
|
571
594
|
ChildResponseType,
|
|
572
595
|
ClientConfig,
|
|
596
|
+
ClientWorkflow,
|
|
573
597
|
ContextType,
|
|
574
598
|
ConnectionConfig,
|
|
575
599
|
Connection,
|