@hotmeshio/hotmesh 0.3.32 → 0.4.1
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 +128 -823
- package/build/index.d.ts +9 -9
- package/build/index.js +10 -10
- package/build/modules/enums.d.ts +23 -23
- package/build/modules/enums.js +26 -26
- package/build/modules/errors.d.ts +16 -16
- package/build/modules/errors.js +28 -28
- package/build/modules/key.js +190 -1
- package/build/modules/utils.js +374 -1
- package/build/package.json +22 -21
- package/build/services/activities/activity.js +549 -1
- package/build/services/activities/await.js +114 -1
- package/build/services/activities/cycle.js +112 -1
- package/build/services/activities/hook.js +168 -1
- package/build/services/activities/index.js +20 -1
- package/build/services/activities/interrupt.js +158 -1
- package/build/services/activities/signal.js +134 -1
- package/build/services/activities/trigger.js +246 -1
- package/build/services/activities/worker.js +106 -1
- package/build/services/collator/index.js +293 -1
- package/build/services/compiler/deployer.js +488 -1
- package/build/services/compiler/index.js +112 -1
- package/build/services/compiler/validator.js +147 -1
- package/build/services/engine/index.js +761 -1
- package/build/services/exporter/index.js +126 -1
- package/build/services/hotmesh/index.d.ts +160 -17
- package/build/services/hotmesh/index.js +160 -17
- package/build/services/mapper/index.js +81 -1
- package/build/services/{meshflow → memflow}/client.d.ts +3 -3
- package/build/services/{meshflow → memflow}/client.js +17 -16
- package/build/services/{meshflow → memflow}/connection.d.ts +2 -2
- package/build/services/{meshflow → memflow}/connection.js +1 -1
- package/build/services/memflow/context.d.ts +143 -0
- package/build/services/memflow/context.js +299 -0
- package/build/services/{meshflow → memflow}/exporter.d.ts +6 -6
- package/build/services/memflow/exporter.js +215 -0
- package/build/services/{meshflow → memflow}/handle.d.ts +4 -4
- package/build/services/{meshflow → memflow}/handle.js +2 -2
- package/build/services/{meshflow → memflow}/index.d.ts +18 -13
- package/build/services/{meshflow → memflow}/index.js +26 -21
- package/build/services/{meshflow → memflow}/schemas/factory.d.ts +4 -4
- package/build/services/{meshflow → memflow}/schemas/factory.js +5 -5
- package/build/services/{meshflow → memflow}/search.d.ts +1 -1
- package/build/services/{meshflow → memflow}/search.js +4 -4
- package/build/services/{meshflow → memflow}/worker.d.ts +5 -5
- package/build/services/{meshflow → memflow}/worker.js +24 -24
- package/build/services/memflow/workflow/common.d.ts +20 -0
- package/build/services/memflow/workflow/common.js +47 -0
- package/build/services/memflow/workflow/contextMethods.d.ts +14 -0
- package/build/services/memflow/workflow/contextMethods.js +33 -0
- package/build/services/{meshflow → memflow}/workflow/execChild.js +12 -12
- package/build/services/memflow/workflow/execHook.d.ts +65 -0
- package/build/services/memflow/workflow/execHook.js +73 -0
- package/build/services/{meshflow → memflow}/workflow/hook.js +19 -3
- package/build/services/{meshflow → memflow}/workflow/index.d.ts +7 -3
- package/build/services/{meshflow → memflow}/workflow/index.js +7 -3
- package/build/services/{meshflow → memflow}/workflow/proxyActivities.d.ts +2 -2
- package/build/services/{meshflow → memflow}/workflow/proxyActivities.js +8 -8
- package/build/services/{meshflow → memflow}/workflow/sleepFor.js +2 -2
- package/build/services/{meshflow → memflow}/workflow/waitFor.js +2 -2
- package/build/services/meshdata/index.d.ts +24 -24
- package/build/services/meshdata/index.js +40 -40
- package/build/services/pipe/functions/array.js +74 -1
- package/build/services/pipe/functions/bitwise.js +24 -1
- package/build/services/pipe/functions/conditional.js +36 -1
- package/build/services/pipe/functions/cron.js +40 -1
- package/build/services/pipe/functions/date.js +171 -1
- package/build/services/pipe/functions/index.js +30 -1
- package/build/services/pipe/functions/json.js +12 -1
- package/build/services/pipe/functions/logical.js +12 -1
- package/build/services/pipe/functions/math.js +184 -1
- package/build/services/pipe/functions/number.js +60 -1
- package/build/services/pipe/functions/object.js +81 -1
- package/build/services/pipe/functions/string.js +69 -1
- package/build/services/pipe/functions/symbol.js +33 -1
- package/build/services/pipe/functions/unary.js +18 -1
- package/build/services/pipe/index.js +242 -1
- package/build/services/quorum/index.js +263 -1
- package/build/services/reporter/index.js +348 -1
- package/build/services/router/config/index.d.ts +11 -0
- package/build/services/router/config/index.js +36 -0
- package/build/services/router/consumption/index.d.ts +34 -0
- package/build/services/router/consumption/index.js +395 -0
- package/build/services/router/error-handling/index.d.ts +8 -0
- package/build/services/router/error-handling/index.js +98 -0
- package/build/services/router/index.d.ts +13 -16
- package/build/services/router/index.js +121 -1
- package/build/services/router/lifecycle/index.d.ts +27 -0
- package/build/services/router/lifecycle/index.js +80 -0
- package/build/services/router/telemetry/index.d.ts +11 -0
- package/build/services/router/telemetry/index.js +32 -0
- package/build/services/router/throttling/index.d.ts +23 -0
- package/build/services/router/throttling/index.js +76 -0
- package/build/services/search/index.d.ts +2 -1
- package/build/services/search/providers/postgres/postgres.d.ts +2 -1
- package/build/services/search/providers/postgres/postgres.js +149 -1
- package/build/services/search/providers/redis/ioredis.d.ts +1 -0
- package/build/services/search/providers/redis/ioredis.js +121 -1
- package/build/services/search/providers/redis/redis.d.ts +1 -0
- package/build/services/search/providers/redis/redis.js +134 -1
- package/build/services/serializer/index.js +282 -1
- package/build/services/store/providers/postgres/kvsql.d.ts +1 -1
- package/build/services/store/providers/postgres/kvsql.js +198 -1
- package/build/services/store/providers/postgres/kvtables.js +441 -1
- package/build/services/store/providers/postgres/kvtransaction.js +248 -1
- package/build/services/store/providers/postgres/kvtypes/hash.d.ts +1 -1
- package/build/services/store/providers/postgres/kvtypes/hash.js +1287 -1
- package/build/services/store/providers/postgres/kvtypes/list.js +194 -1
- package/build/services/store/providers/postgres/kvtypes/string.js +115 -1
- package/build/services/store/providers/postgres/kvtypes/zset.js +214 -1
- package/build/services/store/providers/postgres/postgres.js +1036 -1
- package/build/services/store/providers/redis/_base.js +980 -1
- package/build/services/store/providers/redis/ioredis.js +180 -1
- package/build/services/store/providers/redis/redis.js +199 -1
- package/build/services/store/providers/store-initializable.js +2 -1
- package/build/services/stream/index.d.ts +5 -0
- package/build/services/stream/providers/nats/nats.d.ts +1 -0
- package/build/services/stream/providers/nats/nats.js +225 -1
- package/build/services/stream/providers/postgres/kvtables.d.ts +1 -0
- package/build/services/stream/providers/postgres/kvtables.js +146 -1
- package/build/services/stream/providers/postgres/postgres.d.ts +19 -0
- package/build/services/stream/providers/postgres/postgres.js +519 -1
- package/build/services/stream/providers/redis/ioredis.d.ts +1 -0
- package/build/services/stream/providers/redis/ioredis.js +272 -1
- package/build/services/stream/providers/redis/redis.d.ts +1 -0
- package/build/services/stream/providers/redis/redis.js +305 -1
- package/build/services/stream/providers/stream-initializable.js +2 -1
- package/build/services/sub/providers/nats/nats.js +105 -1
- package/build/services/sub/providers/postgres/postgres.js +92 -1
- package/build/services/sub/providers/redis/ioredis.js +81 -1
- package/build/services/sub/providers/redis/redis.js +72 -1
- package/build/services/task/index.js +206 -1
- package/build/services/telemetry/index.js +306 -1
- package/build/services/worker/index.js +197 -1
- package/build/types/error.d.ts +5 -5
- package/build/types/exporter.d.ts +1 -1
- package/build/types/index.d.ts +3 -3
- package/build/types/manifest.d.ts +2 -2
- package/build/types/{meshflow.d.ts → memflow.d.ts} +15 -15
- package/build/types/meshdata.d.ts +3 -3
- package/build/types/postgres.d.ts +7 -0
- package/build/types/stream.d.ts +3 -0
- package/index.ts +11 -11
- package/package.json +22 -21
- package/.github/ISSUE_TEMPLATE/bug_report.md +0 -38
- package/.github/ISSUE_TEMPLATE/feature_request.md +0 -20
- package/build/services/meshflow/exporter.js +0 -1
- package/build/services/meshflow/workflow/common.d.ts +0 -18
- package/build/services/meshflow/workflow/common.js +0 -45
- package/typedoc.json +0 -46
- package/types/activity.ts +0 -268
- package/types/app.ts +0 -20
- package/types/async.ts +0 -6
- package/types/cache.ts +0 -1
- package/types/collator.ts +0 -9
- package/types/error.ts +0 -56
- package/types/exporter.ts +0 -102
- package/types/hook.ts +0 -44
- package/types/hotmesh.ts +0 -314
- package/types/index.ts +0 -306
- package/types/job.ts +0 -233
- package/types/logger.ts +0 -8
- package/types/manifest.ts +0 -70
- package/types/map.ts +0 -5
- package/types/meshcall.ts +0 -235
- package/types/meshdata.ts +0 -278
- package/types/meshflow.ts +0 -645
- package/types/ms.d.ts +0 -7
- package/types/nats.ts +0 -270
- package/types/pipe.ts +0 -90
- package/types/postgres.ts +0 -105
- package/types/provider.ts +0 -161
- package/types/quorum.ts +0 -167
- package/types/redis.ts +0 -404
- package/types/serializer.ts +0 -40
- package/types/stats.ts +0 -117
- package/types/stream.ts +0 -227
- package/types/task.ts +0 -7
- package/types/telemetry.ts +0 -16
- package/types/transition.ts +0 -20
- /package/build/services/{meshflow → memflow}/workflow/all.d.ts +0 -0
- /package/build/services/{meshflow → memflow}/workflow/all.js +0 -0
- /package/build/services/{meshflow → memflow}/workflow/context.d.ts +0 -0
- /package/build/services/{meshflow → memflow}/workflow/context.js +0 -0
- /package/build/services/{meshflow → memflow}/workflow/didRun.d.ts +0 -0
- /package/build/services/{meshflow → memflow}/workflow/didRun.js +0 -0
- /package/build/services/{meshflow → memflow}/workflow/emit.d.ts +0 -0
- /package/build/services/{meshflow → memflow}/workflow/emit.js +0 -0
- /package/build/services/{meshflow → memflow}/workflow/enrich.d.ts +0 -0
- /package/build/services/{meshflow → memflow}/workflow/enrich.js +0 -0
- /package/build/services/{meshflow → memflow}/workflow/execChild.d.ts +0 -0
- /package/build/services/{meshflow → memflow}/workflow/hook.d.ts +0 -0
- /package/build/services/{meshflow → memflow}/workflow/interrupt.d.ts +0 -0
- /package/build/services/{meshflow → memflow}/workflow/interrupt.js +0 -0
- /package/build/services/{meshflow → memflow}/workflow/isSideEffectAllowed.d.ts +0 -0
- /package/build/services/{meshflow → memflow}/workflow/isSideEffectAllowed.js +0 -0
- /package/build/services/{meshflow → memflow}/workflow/random.d.ts +0 -0
- /package/build/services/{meshflow → memflow}/workflow/random.js +0 -0
- /package/build/services/{meshflow → memflow}/workflow/searchMethods.d.ts +0 -0
- /package/build/services/{meshflow → memflow}/workflow/searchMethods.js +0 -0
- /package/build/services/{meshflow → memflow}/workflow/signal.d.ts +0 -0
- /package/build/services/{meshflow → memflow}/workflow/signal.js +0 -0
- /package/build/services/{meshflow → memflow}/workflow/sleepFor.d.ts +0 -0
- /package/build/services/{meshflow → memflow}/workflow/trace.d.ts +0 -0
- /package/build/services/{meshflow → memflow}/workflow/trace.js +0 -0
- /package/build/services/{meshflow → memflow}/workflow/waitFor.d.ts +0 -0
- /package/build/types/{meshflow.js → memflow.js} +0 -0
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ExporterService = void 0;
|
|
4
|
+
const utils_1 = require("../../modules/utils");
|
|
5
|
+
const serializer_1 = require("../serializer");
|
|
6
|
+
class ExporterService {
|
|
7
|
+
constructor(appId, store, logger) {
|
|
8
|
+
this.appId = appId;
|
|
9
|
+
this.logger = logger;
|
|
10
|
+
this.store = store;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Convert the job hash from its compiles format into a MemFlowJobExport object with
|
|
14
|
+
* facets that describe the workflow in terms relevant to narrative storytelling.
|
|
15
|
+
*/
|
|
16
|
+
async export(jobId, options = {}) {
|
|
17
|
+
if (!ExporterService.symbols.has(this.appId)) {
|
|
18
|
+
const symbols = this.store.getAllSymbols();
|
|
19
|
+
ExporterService.symbols.set(this.appId, await symbols);
|
|
20
|
+
}
|
|
21
|
+
const jobData = await this.store.getRaw(jobId);
|
|
22
|
+
const jobExport = this.inflate(jobData, options);
|
|
23
|
+
return jobExport;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Inflates the job data from Redis into a MemFlowJobExport object
|
|
27
|
+
* @param jobHash - the job data from Redis
|
|
28
|
+
* @param dependencyList - the list of dependencies for the job
|
|
29
|
+
* @returns - the inflated job data
|
|
30
|
+
*/
|
|
31
|
+
inflate(jobHash, options) {
|
|
32
|
+
const timeline = [];
|
|
33
|
+
const state = {};
|
|
34
|
+
const data = {};
|
|
35
|
+
const transitionsObject = {};
|
|
36
|
+
const regex = /^([a-zA-Z]{3}),(\d+(?:,\d+)*)/;
|
|
37
|
+
Object.entries(jobHash).forEach(([key, value]) => {
|
|
38
|
+
const match = key.match(regex);
|
|
39
|
+
if (match) {
|
|
40
|
+
//transitions
|
|
41
|
+
this.inflateTransition(match, value, transitionsObject);
|
|
42
|
+
}
|
|
43
|
+
else if (key.startsWith('_')) {
|
|
44
|
+
//data
|
|
45
|
+
data[key.substring(1)] = value;
|
|
46
|
+
}
|
|
47
|
+
else if (key.startsWith('-')) {
|
|
48
|
+
//timeline
|
|
49
|
+
const keyParts = this.keyToObject(key);
|
|
50
|
+
timeline.push({
|
|
51
|
+
...keyParts,
|
|
52
|
+
key,
|
|
53
|
+
value: this.resolveValue(value, options.values),
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
else if (key.length === 3) {
|
|
57
|
+
//state
|
|
58
|
+
state[this.inflateKey(key)] = serializer_1.SerializerService.fromString(value);
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
return this.filterFields({
|
|
62
|
+
data: (0, utils_1.restoreHierarchy)(data),
|
|
63
|
+
state: Object.entries((0, utils_1.restoreHierarchy)(state))[0][1],
|
|
64
|
+
status: parseInt(jobHash[':'], 10),
|
|
65
|
+
timeline: this.sortParts(timeline),
|
|
66
|
+
transitions: this.sortEntriesByCreated(transitionsObject),
|
|
67
|
+
}, options.block, options.allow);
|
|
68
|
+
}
|
|
69
|
+
resolveValue(raw, withValues) {
|
|
70
|
+
const resolved = serializer_1.SerializerService.fromString(raw);
|
|
71
|
+
if (withValues !== false) {
|
|
72
|
+
return resolved;
|
|
73
|
+
}
|
|
74
|
+
if (resolved && typeof resolved === 'object') {
|
|
75
|
+
if ('data' in resolved) {
|
|
76
|
+
resolved.data = {};
|
|
77
|
+
}
|
|
78
|
+
if ('$error' in resolved) {
|
|
79
|
+
resolved.$error = {};
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return resolved;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Inflates the key from Redis, 3-character symbol
|
|
86
|
+
* into a human-readable JSON path, reflecting the
|
|
87
|
+
* tree-like structure of the unidimensional Hash
|
|
88
|
+
* @private
|
|
89
|
+
*/
|
|
90
|
+
inflateKey(key) {
|
|
91
|
+
const symbols = ExporterService.symbols.get(this.appId);
|
|
92
|
+
if (key in symbols) {
|
|
93
|
+
const path = symbols[key];
|
|
94
|
+
const parts = path.split('/');
|
|
95
|
+
return parts.join('/');
|
|
96
|
+
}
|
|
97
|
+
return key;
|
|
98
|
+
}
|
|
99
|
+
filterFields(fullObject, block = [], allow = []) {
|
|
100
|
+
let result = {};
|
|
101
|
+
if (allow && allow.length > 0) {
|
|
102
|
+
allow.forEach((field) => {
|
|
103
|
+
if (field in fullObject) {
|
|
104
|
+
result[field] = fullObject[field];
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
result = { ...fullObject };
|
|
110
|
+
}
|
|
111
|
+
if (block && block.length > 0) {
|
|
112
|
+
block.forEach((field) => {
|
|
113
|
+
if (field in result) {
|
|
114
|
+
delete result[field];
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
return result;
|
|
119
|
+
}
|
|
120
|
+
inflateTransition(match, value, transitionsObject) {
|
|
121
|
+
const [_, letters, dimensions] = match;
|
|
122
|
+
const path = this.inflateKey(letters);
|
|
123
|
+
const parts = path.split('/');
|
|
124
|
+
const activity = parts[0];
|
|
125
|
+
const isCreate = path.endsWith('/output/metadata/ac');
|
|
126
|
+
const isUpdate = path.endsWith('/output/metadata/au');
|
|
127
|
+
//for now only export activity start/stop; activity data would also be interesting
|
|
128
|
+
if (isCreate || isUpdate) {
|
|
129
|
+
const targetName = `${activity},${dimensions}`;
|
|
130
|
+
const target = transitionsObject[targetName];
|
|
131
|
+
if (!target) {
|
|
132
|
+
transitionsObject[targetName] = {
|
|
133
|
+
activity,
|
|
134
|
+
dimensions,
|
|
135
|
+
created: isCreate ? value : null,
|
|
136
|
+
updated: isUpdate ? value : null,
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
else {
|
|
140
|
+
target[isCreate ? 'created' : 'updated'] = value;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
sortEntriesByCreated(obj) {
|
|
145
|
+
const entriesArray = Object.values(obj);
|
|
146
|
+
entriesArray.sort((a, b) => {
|
|
147
|
+
return (a.created || a.updated).localeCompare(b.created || b.updated);
|
|
148
|
+
});
|
|
149
|
+
return entriesArray;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* marker names are overloaded with details like sequence, type, etc
|
|
153
|
+
*/
|
|
154
|
+
keyToObject(key) {
|
|
155
|
+
function extractDimension(label) {
|
|
156
|
+
const parts = label.split(',');
|
|
157
|
+
if (parts.length > 1) {
|
|
158
|
+
parts.shift();
|
|
159
|
+
return parts.join(',');
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
const parts = key.split('-');
|
|
163
|
+
if (parts.length === 4) {
|
|
164
|
+
//-proxy-5- -search-1-1-
|
|
165
|
+
return {
|
|
166
|
+
index: parseInt(parts[2], 10),
|
|
167
|
+
dimension: extractDimension(parts[1]),
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
else {
|
|
171
|
+
//-search,0,0-1-1- -proxy,0,0-1-
|
|
172
|
+
return {
|
|
173
|
+
index: parseInt(parts[2], 10),
|
|
174
|
+
secondary: parseInt(parts[3], 10),
|
|
175
|
+
dimension: extractDimension(parts[1]),
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* idem list has a complicated sort order based on indexes and dimensions
|
|
181
|
+
*/
|
|
182
|
+
sortParts(parts) {
|
|
183
|
+
return parts.sort((a, b) => {
|
|
184
|
+
const { dimension: aDim, index: aIdx, secondary: aSec } = a;
|
|
185
|
+
const { dimension: bDim, index: bIdx, secondary: bSec } = b;
|
|
186
|
+
if (aDim === undefined && bDim !== undefined)
|
|
187
|
+
return -1;
|
|
188
|
+
if (aDim !== undefined && bDim === undefined)
|
|
189
|
+
return 1;
|
|
190
|
+
if (aDim !== undefined && bDim !== undefined) {
|
|
191
|
+
if (aDim < bDim)
|
|
192
|
+
return -1;
|
|
193
|
+
if (aDim > bDim)
|
|
194
|
+
return 1;
|
|
195
|
+
}
|
|
196
|
+
if (aIdx < bIdx)
|
|
197
|
+
return -1;
|
|
198
|
+
if (aIdx > bIdx)
|
|
199
|
+
return 1;
|
|
200
|
+
if (aSec === undefined && bSec !== undefined)
|
|
201
|
+
return -1;
|
|
202
|
+
if (aSec !== undefined && bSec === undefined)
|
|
203
|
+
return 1;
|
|
204
|
+
if (aSec !== undefined && bSec !== undefined) {
|
|
205
|
+
if (aSec < bSec)
|
|
206
|
+
return -1;
|
|
207
|
+
if (aSec > bSec)
|
|
208
|
+
return 1;
|
|
209
|
+
}
|
|
210
|
+
return 0;
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
exports.ExporterService = ExporterService;
|
|
215
|
+
ExporterService.symbols = new Map();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { HotMesh } from '../hotmesh';
|
|
2
|
-
import {
|
|
2
|
+
import { MemFlowJobExport, ExportOptions } from '../../types/exporter';
|
|
3
3
|
import { JobInterruptOptions } from '../../types/job';
|
|
4
4
|
import { StreamError } from '../../types/stream';
|
|
5
5
|
import { ExporterService } from './exporter';
|
|
@@ -7,7 +7,7 @@ import { ExporterService } from './exporter';
|
|
|
7
7
|
* The WorkflowHandleService provides methods to interact with a running
|
|
8
8
|
* workflow. This includes exporting the workflow, sending signals, and
|
|
9
9
|
* querying the state of the workflow. It is instanced/accessed via the
|
|
10
|
-
*
|
|
10
|
+
* MemFlow.Client class.
|
|
11
11
|
*
|
|
12
12
|
* @example
|
|
13
13
|
* ```typescript
|
|
@@ -43,11 +43,11 @@ export declare class WorkflowHandleService {
|
|
|
43
43
|
/**
|
|
44
44
|
* Exports the workflow state to a JSON object.
|
|
45
45
|
*/
|
|
46
|
-
export(options?: ExportOptions): Promise<
|
|
46
|
+
export(options?: ExportOptions): Promise<MemFlowJobExport>;
|
|
47
47
|
/**
|
|
48
48
|
* Sends a signal to the workflow. This is a way to send
|
|
49
49
|
* a message to a workflow that is paused due to having
|
|
50
|
-
* executed `
|
|
50
|
+
* executed `MemFlow.workflow.waitFor`. The workflow
|
|
51
51
|
* will awaken if no other signals are pending.
|
|
52
52
|
*/
|
|
53
53
|
signal(signalId: string, data: Record<any, any>): Promise<void>;
|
|
@@ -6,7 +6,7 @@ const exporter_1 = require("./exporter");
|
|
|
6
6
|
* The WorkflowHandleService provides methods to interact with a running
|
|
7
7
|
* workflow. This includes exporting the workflow, sending signals, and
|
|
8
8
|
* querying the state of the workflow. It is instanced/accessed via the
|
|
9
|
-
*
|
|
9
|
+
* MemFlow.Client class.
|
|
10
10
|
*
|
|
11
11
|
* @example
|
|
12
12
|
* ```typescript
|
|
@@ -46,7 +46,7 @@ class WorkflowHandleService {
|
|
|
46
46
|
/**
|
|
47
47
|
* Sends a signal to the workflow. This is a way to send
|
|
48
48
|
* a message to a workflow that is paused due to having
|
|
49
|
-
* executed `
|
|
49
|
+
* executed `MemFlow.workflow.waitFor`. The workflow
|
|
50
50
|
* will awaken if no other signals are pending.
|
|
51
51
|
*/
|
|
52
52
|
async signal(signalId, data) {
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import { ContextType } from '../../types/
|
|
1
|
+
import { ContextType } from '../../types/memflow';
|
|
2
2
|
import { ClientService } from './client';
|
|
3
3
|
import { ConnectionService } from './connection';
|
|
4
4
|
import { Search } from './search';
|
|
5
|
+
import { Context } from './context';
|
|
5
6
|
import { WorkerService } from './worker';
|
|
6
7
|
import { WorkflowService } from './workflow';
|
|
7
8
|
import { WorkflowHandleService } from './handle';
|
|
8
9
|
/**
|
|
9
|
-
* The
|
|
10
|
+
* The MemFlow service is a collection of services that
|
|
10
11
|
* emulate Temporal's capabilities, but instead are
|
|
11
12
|
* backed by Postgres or Redis/ValKey. The following lifecycle example
|
|
12
13
|
* demonstrates how to start a new workflow, subscribe
|
|
@@ -14,7 +15,7 @@ import { WorkflowHandleService } from './handle';
|
|
|
14
15
|
*
|
|
15
16
|
* @example
|
|
16
17
|
* ```typescript
|
|
17
|
-
* import { Client, Worker,
|
|
18
|
+
* import { Client, Worker, MemFlow, HotMesh } from '@hotmeshio/hotmesh';
|
|
18
19
|
* import { Client as Postgres} from 'pg';
|
|
19
20
|
* import * as workflows from './workflows';
|
|
20
21
|
*
|
|
@@ -27,7 +28,7 @@ import { WorkflowHandleService } from './handle';
|
|
|
27
28
|
* }
|
|
28
29
|
* }
|
|
29
30
|
* taskQueue: 'default',
|
|
30
|
-
* namespace: '
|
|
31
|
+
* namespace: 'memflow',
|
|
31
32
|
* workflow: workflows.example,
|
|
32
33
|
* options: {
|
|
33
34
|
* backoffCoefficient: 2,
|
|
@@ -52,7 +53,7 @@ import { WorkflowHandleService } from './handle';
|
|
|
52
53
|
* taskQueue: 'default',
|
|
53
54
|
* workflowName: 'example',
|
|
54
55
|
* workflowId: HotMesh.guid(),
|
|
55
|
-
* namespace: '
|
|
56
|
+
* namespace: 'memflow',
|
|
56
57
|
* });
|
|
57
58
|
*
|
|
58
59
|
* //4) subscribe to the eventual result
|
|
@@ -60,21 +61,21 @@ import { WorkflowHandleService } from './handle';
|
|
|
60
61
|
* //logs '¡Hola, HotMesh!'
|
|
61
62
|
*
|
|
62
63
|
* //5) Shutdown (typically on sigint)
|
|
63
|
-
* await
|
|
64
|
+
* await MemFlow.shutdown();
|
|
64
65
|
* ```
|
|
65
66
|
*/
|
|
66
|
-
declare class
|
|
67
|
+
declare class MemFlowClass {
|
|
67
68
|
/**
|
|
68
69
|
* @private
|
|
69
70
|
*/
|
|
70
71
|
constructor();
|
|
71
72
|
/**
|
|
72
|
-
* The
|
|
73
|
+
* The MemFlow `Client` service is functionally
|
|
73
74
|
* equivalent to the Temporal `Client` service.
|
|
74
75
|
*/
|
|
75
76
|
static Client: typeof ClientService;
|
|
76
77
|
/**
|
|
77
|
-
* The
|
|
78
|
+
* The MemFlow `Connection` service is functionally
|
|
78
79
|
* equivalent to the Temporal `Connection` service.
|
|
79
80
|
*/
|
|
80
81
|
static Connection: typeof ConnectionService;
|
|
@@ -82,20 +83,24 @@ declare class MeshFlowClass {
|
|
|
82
83
|
* @private
|
|
83
84
|
*/
|
|
84
85
|
static Search: typeof Search;
|
|
86
|
+
/**
|
|
87
|
+
* @private
|
|
88
|
+
*/
|
|
89
|
+
static Context: typeof Context;
|
|
85
90
|
/**
|
|
86
91
|
* The Handle provides methods to interact with a running
|
|
87
92
|
* workflow. This includes exporting the workflow, sending signals, and
|
|
88
93
|
* querying the state of the workflow. An instance of the Handle service
|
|
89
|
-
* is typically accessed via the
|
|
94
|
+
* is typically accessed via the MemFlow.Client class (workflow.getHandle).
|
|
90
95
|
*/
|
|
91
96
|
static Handle: typeof WorkflowHandleService;
|
|
92
97
|
/**
|
|
93
|
-
* The
|
|
98
|
+
* The MemFlow `Worker` service is functionally
|
|
94
99
|
* equivalent to the Temporal `Worker` service.
|
|
95
100
|
*/
|
|
96
101
|
static Worker: typeof WorkerService;
|
|
97
102
|
/**
|
|
98
|
-
* The
|
|
103
|
+
* The MemFlow `workflow` service is functionally
|
|
99
104
|
* equivalent to the Temporal `Workflow` service
|
|
100
105
|
* with additional methods for managing workflows,
|
|
101
106
|
* including: `execChild`, `waitFor`, `sleep`, etc
|
|
@@ -107,5 +112,5 @@ declare class MeshFlowClass {
|
|
|
107
112
|
*/
|
|
108
113
|
static shutdown(): Promise<void>;
|
|
109
114
|
}
|
|
110
|
-
export {
|
|
115
|
+
export { MemFlowClass as MemFlow };
|
|
111
116
|
export type { ContextType };
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.MemFlow = void 0;
|
|
4
4
|
const hotmesh_1 = require("../hotmesh");
|
|
5
5
|
const client_1 = require("./client");
|
|
6
6
|
const connection_1 = require("./connection");
|
|
7
7
|
const search_1 = require("./search");
|
|
8
|
+
const context_1 = require("./context");
|
|
8
9
|
const worker_1 = require("./worker");
|
|
9
10
|
const workflow_1 = require("./workflow");
|
|
10
11
|
const handle_1 = require("./handle");
|
|
11
12
|
/**
|
|
12
|
-
* The
|
|
13
|
+
* The MemFlow service is a collection of services that
|
|
13
14
|
* emulate Temporal's capabilities, but instead are
|
|
14
15
|
* backed by Postgres or Redis/ValKey. The following lifecycle example
|
|
15
16
|
* demonstrates how to start a new workflow, subscribe
|
|
@@ -17,7 +18,7 @@ const handle_1 = require("./handle");
|
|
|
17
18
|
*
|
|
18
19
|
* @example
|
|
19
20
|
* ```typescript
|
|
20
|
-
* import { Client, Worker,
|
|
21
|
+
* import { Client, Worker, MemFlow, HotMesh } from '@hotmeshio/hotmesh';
|
|
21
22
|
* import { Client as Postgres} from 'pg';
|
|
22
23
|
* import * as workflows from './workflows';
|
|
23
24
|
*
|
|
@@ -30,7 +31,7 @@ const handle_1 = require("./handle");
|
|
|
30
31
|
* }
|
|
31
32
|
* }
|
|
32
33
|
* taskQueue: 'default',
|
|
33
|
-
* namespace: '
|
|
34
|
+
* namespace: 'memflow',
|
|
34
35
|
* workflow: workflows.example,
|
|
35
36
|
* options: {
|
|
36
37
|
* backoffCoefficient: 2,
|
|
@@ -55,7 +56,7 @@ const handle_1 = require("./handle");
|
|
|
55
56
|
* taskQueue: 'default',
|
|
56
57
|
* workflowName: 'example',
|
|
57
58
|
* workflowId: HotMesh.guid(),
|
|
58
|
-
* namespace: '
|
|
59
|
+
* namespace: 'memflow',
|
|
59
60
|
* });
|
|
60
61
|
*
|
|
61
62
|
* //4) subscribe to the eventual result
|
|
@@ -63,10 +64,10 @@ const handle_1 = require("./handle");
|
|
|
63
64
|
* //logs '¡Hola, HotMesh!'
|
|
64
65
|
*
|
|
65
66
|
* //5) Shutdown (typically on sigint)
|
|
66
|
-
* await
|
|
67
|
+
* await MemFlow.shutdown();
|
|
67
68
|
* ```
|
|
68
69
|
*/
|
|
69
|
-
class
|
|
70
|
+
class MemFlowClass {
|
|
70
71
|
/**
|
|
71
72
|
* @private
|
|
72
73
|
*/
|
|
@@ -76,42 +77,46 @@ class MeshFlowClass {
|
|
|
76
77
|
* Include in your signal handlers to ensure a clean shutdown.
|
|
77
78
|
*/
|
|
78
79
|
static async shutdown() {
|
|
79
|
-
await
|
|
80
|
-
await
|
|
80
|
+
await MemFlowClass.Client.shutdown();
|
|
81
|
+
await MemFlowClass.Worker.shutdown();
|
|
81
82
|
await hotmesh_1.HotMesh.stop();
|
|
82
83
|
}
|
|
83
84
|
}
|
|
84
|
-
exports.
|
|
85
|
+
exports.MemFlow = MemFlowClass;
|
|
85
86
|
/**
|
|
86
|
-
* The
|
|
87
|
+
* The MemFlow `Client` service is functionally
|
|
87
88
|
* equivalent to the Temporal `Client` service.
|
|
88
89
|
*/
|
|
89
|
-
|
|
90
|
+
MemFlowClass.Client = client_1.ClientService;
|
|
90
91
|
/**
|
|
91
|
-
* The
|
|
92
|
+
* The MemFlow `Connection` service is functionally
|
|
92
93
|
* equivalent to the Temporal `Connection` service.
|
|
93
94
|
*/
|
|
94
|
-
|
|
95
|
+
MemFlowClass.Connection = connection_1.ConnectionService;
|
|
95
96
|
/**
|
|
96
97
|
* @private
|
|
97
98
|
*/
|
|
98
|
-
|
|
99
|
+
MemFlowClass.Search = search_1.Search;
|
|
100
|
+
/**
|
|
101
|
+
* @private
|
|
102
|
+
*/
|
|
103
|
+
MemFlowClass.Context = context_1.Context;
|
|
99
104
|
/**
|
|
100
105
|
* The Handle provides methods to interact with a running
|
|
101
106
|
* workflow. This includes exporting the workflow, sending signals, and
|
|
102
107
|
* querying the state of the workflow. An instance of the Handle service
|
|
103
|
-
* is typically accessed via the
|
|
108
|
+
* is typically accessed via the MemFlow.Client class (workflow.getHandle).
|
|
104
109
|
*/
|
|
105
|
-
|
|
110
|
+
MemFlowClass.Handle = handle_1.WorkflowHandleService;
|
|
106
111
|
/**
|
|
107
|
-
* The
|
|
112
|
+
* The MemFlow `Worker` service is functionally
|
|
108
113
|
* equivalent to the Temporal `Worker` service.
|
|
109
114
|
*/
|
|
110
|
-
|
|
115
|
+
MemFlowClass.Worker = worker_1.WorkerService;
|
|
111
116
|
/**
|
|
112
|
-
* The
|
|
117
|
+
* The MemFlow `workflow` service is functionally
|
|
113
118
|
* equivalent to the Temporal `Workflow` service
|
|
114
119
|
* with additional methods for managing workflows,
|
|
115
120
|
* including: `execChild`, `waitFor`, `sleep`, etc
|
|
116
121
|
*/
|
|
117
|
-
|
|
122
|
+
MemFlowClass.workflow = workflow_1.WorkflowService;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*********** HOTMESH '
|
|
2
|
+
*********** HOTMESH 'MEMFLOW' MODULE APPLICATION GRAPH **********
|
|
3
3
|
*
|
|
4
4
|
* This HotMesh application spec uses 50 activities and 25 transitions
|
|
5
5
|
* to model and emulate the Temporal Application & Query servers using
|
|
@@ -18,10 +18,10 @@
|
|
|
18
18
|
* * Master Data Management systems
|
|
19
19
|
*/
|
|
20
20
|
declare const APP_VERSION = "4";
|
|
21
|
-
declare const APP_ID = "
|
|
21
|
+
declare const APP_ID = "memflow";
|
|
22
22
|
/**
|
|
23
|
-
* returns a new
|
|
24
|
-
* @param {string} app - app name (e.g., '
|
|
23
|
+
* returns a new memflow workflow schema
|
|
24
|
+
* @param {string} app - app name (e.g., 'memflow')
|
|
25
25
|
* @param {string} version - number as string (e.g., '1')
|
|
26
26
|
* @returns {string} HotMesh App YAML
|
|
27
27
|
*/
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/**
|
|
3
|
-
*********** HOTMESH '
|
|
3
|
+
*********** HOTMESH 'MEMFLOW' MODULE APPLICATION GRAPH **********
|
|
4
4
|
*
|
|
5
5
|
* This HotMesh application spec uses 50 activities and 25 transitions
|
|
6
6
|
* to model and emulate the Temporal Application & Query servers using
|
|
@@ -22,11 +22,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
22
22
|
exports.APP_ID = exports.APP_VERSION = exports.getWorkflowYAML = void 0;
|
|
23
23
|
const APP_VERSION = '4';
|
|
24
24
|
exports.APP_VERSION = APP_VERSION;
|
|
25
|
-
const APP_ID = '
|
|
25
|
+
const APP_ID = 'memflow';
|
|
26
26
|
exports.APP_ID = APP_ID;
|
|
27
27
|
/**
|
|
28
|
-
* returns a new
|
|
29
|
-
* @param {string} app - app name (e.g., '
|
|
28
|
+
* returns a new memflow workflow schema
|
|
29
|
+
* @param {string} app - app name (e.g., 'memflow')
|
|
30
30
|
* @param {string} version - number as string (e.g., '1')
|
|
31
31
|
* @returns {string} HotMesh App YAML
|
|
32
32
|
*/
|
|
@@ -37,7 +37,7 @@ const getWorkflowYAML = (app, version) => {
|
|
|
37
37
|
graphs:
|
|
38
38
|
|
|
39
39
|
###################################################
|
|
40
|
-
# THE
|
|
40
|
+
# THE MEMFLOW-REENTRANT-WORKFLOW #
|
|
41
41
|
# #
|
|
42
42
|
- subscribes: ${app}.execute
|
|
43
43
|
publishes: ${app}.executed
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { HotMesh } from '../hotmesh';
|
|
2
2
|
import { SearchService } from '../search';
|
|
3
|
-
import { WorkflowSearchOptions } from '../../types/
|
|
3
|
+
import { WorkflowSearchOptions } from '../../types/memflow';
|
|
4
4
|
/**
|
|
5
5
|
* The Search module provides methods for reading and
|
|
6
6
|
* writing record data to a workflow. The instance
|
|
@@ -105,7 +105,7 @@ class Search {
|
|
|
105
105
|
await searchService.createSearchIndex(`${search.index}`, prefixes, schema);
|
|
106
106
|
}
|
|
107
107
|
catch (error) {
|
|
108
|
-
hotMeshClient.engine.logger.info('
|
|
108
|
+
hotMeshClient.engine.logger.info('memflow-client-search-err', {
|
|
109
109
|
error,
|
|
110
110
|
});
|
|
111
111
|
}
|
|
@@ -123,7 +123,7 @@ class Search {
|
|
|
123
123
|
return await searchService.listSearchIndexes();
|
|
124
124
|
}
|
|
125
125
|
catch (error) {
|
|
126
|
-
hotMeshClient.engine.logger.info('
|
|
126
|
+
hotMeshClient.engine.logger.info('memflow-client-search-list-err', {
|
|
127
127
|
error,
|
|
128
128
|
});
|
|
129
129
|
return [];
|
|
@@ -192,7 +192,7 @@ class Search {
|
|
|
192
192
|
return value;
|
|
193
193
|
}
|
|
194
194
|
catch (error) {
|
|
195
|
-
this.hotMeshClient.logger.error('
|
|
195
|
+
this.hotMeshClient.logger.error('memflow-search-get-error', {
|
|
196
196
|
error,
|
|
197
197
|
});
|
|
198
198
|
return '';
|
|
@@ -227,7 +227,7 @@ class Search {
|
|
|
227
227
|
return returnValues;
|
|
228
228
|
}
|
|
229
229
|
catch (error) {
|
|
230
|
-
this.hotMeshClient.logger.error('
|
|
230
|
+
this.hotMeshClient.logger.error('memflow-search-mget-error', {
|
|
231
231
|
error,
|
|
232
232
|
});
|
|
233
233
|
return [];
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { HotMesh } from '../hotmesh';
|
|
2
|
-
import { Connection, Registry, WorkerConfig, WorkerOptions } from '../../types/
|
|
2
|
+
import { Connection, Registry, WorkerConfig, WorkerOptions } from '../../types/memflow';
|
|
3
3
|
/**
|
|
4
4
|
* The *Worker* service Registers worker functions and connects them to the mesh,
|
|
5
5
|
* using the target backend provider/s (Redis, Postgres, NATS, etc).
|
|
6
6
|
*
|
|
7
7
|
* @example
|
|
8
8
|
* ```typescript
|
|
9
|
-
* import {
|
|
9
|
+
* import { MemFlow } from '@hotmeshio/hotmesh';
|
|
10
10
|
* import { Client as Postgres } from 'pg';
|
|
11
11
|
* import * as workflows from './workflows';
|
|
12
12
|
*
|
|
13
13
|
* async function run() {
|
|
14
|
-
* const worker = await
|
|
14
|
+
* const worker = await MemFlow.Worker.create({
|
|
15
15
|
* connection: {
|
|
16
16
|
* class: Postgres,
|
|
17
17
|
* options: { connectionString: 'postgres://user:password@localhost:5432/db' }
|
|
@@ -63,12 +63,12 @@ export declare class WorkerService {
|
|
|
63
63
|
*
|
|
64
64
|
* @example
|
|
65
65
|
* ```typescript
|
|
66
|
-
* import {
|
|
66
|
+
* import { MemFlow } from '@hotmeshio/hotmesh';
|
|
67
67
|
* import { Client as Postgres } from 'pg';
|
|
68
68
|
* import * as workflows from './workflows';
|
|
69
69
|
*
|
|
70
70
|
* async function run() {
|
|
71
|
-
* const worker = await
|
|
71
|
+
* const worker = await MemFlow.Worker.create({
|
|
72
72
|
* connection: {
|
|
73
73
|
* class: Postgres,
|
|
74
74
|
* options: {
|