@hotmeshio/hotmesh 0.0.59 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/build/modules/enums.d.ts +2 -1
- package/build/modules/enums.js +13 -3
- package/build/modules/errors.d.ts +3 -3
- package/build/modules/errors.js +8 -8
- package/build/modules/key.d.ts +1 -1
- package/build/modules/key.js +3 -3
- package/build/modules/utils.d.ts +6 -6
- package/build/modules/utils.js +22 -14
- package/build/package.json +41 -38
- package/build/services/activities/activity.js +37 -20
- package/build/services/activities/await.d.ts +1 -1
- package/build/services/activities/await.js +15 -7
- package/build/services/activities/cycle.d.ts +1 -1
- package/build/services/activities/cycle.js +16 -8
- package/build/services/activities/hook.d.ts +1 -1
- package/build/services/activities/hook.js +8 -4
- package/build/services/activities/interrupt.d.ts +1 -1
- package/build/services/activities/interrupt.js +14 -6
- package/build/services/activities/signal.d.ts +1 -1
- package/build/services/activities/signal.js +12 -4
- package/build/services/activities/trigger.d.ts +1 -1
- package/build/services/activities/trigger.js +19 -12
- package/build/services/activities/worker.d.ts +1 -1
- package/build/services/activities/worker.js +15 -7
- package/build/services/collator/index.js +12 -12
- package/build/services/compiler/deployer.js +17 -12
- package/build/services/compiler/index.js +4 -4
- package/build/services/compiler/validator.d.ts +3 -3
- package/build/services/compiler/validator.js +12 -3
- package/build/services/durable/client.d.ts +1 -1
- package/build/services/durable/client.js +18 -12
- package/build/services/durable/connection.d.ts +1 -1
- package/build/services/durable/exporter.d.ts +1 -1
- package/build/services/durable/exporter.js +3 -4
- package/build/services/durable/handle.d.ts +1 -1
- package/build/services/durable/handle.js +4 -1
- package/build/services/durable/index.d.ts +1 -1
- package/build/services/durable/index.js +2 -2
- package/build/services/durable/schemas/factory.d.ts +1 -1
- package/build/services/durable/search.js +19 -11
- package/build/services/durable/worker.js +50 -30
- package/build/services/durable/workflow.d.ts +5 -5
- package/build/services/durable/workflow.js +34 -18
- package/build/services/engine/index.js +33 -26
- package/build/services/exporter/index.d.ts +1 -1
- package/build/services/exporter/index.js +3 -3
- package/build/services/hotmesh/index.js +1 -1
- package/build/services/logger/index.js +1 -1
- package/build/services/mapper/index.js +3 -1
- package/build/services/pipe/functions/date.js +1 -1
- package/build/services/pipe/index.js +37 -10
- package/build/services/quorum/index.js +14 -11
- package/build/services/reporter/index.js +15 -12
- package/build/services/router/index.d.ts +2 -2
- package/build/services/router/index.js +73 -23
- package/build/services/serializer/index.js +48 -26
- package/build/services/store/cache.d.ts +5 -5
- package/build/services/store/cache.js +2 -2
- package/build/services/store/clients/ioredis.js +3 -3
- package/build/services/store/clients/redis.js +24 -4
- package/build/services/store/index.d.ts +9 -3
- package/build/services/store/index.js +122 -60
- package/build/services/stream/clients/ioredis.js +4 -4
- package/build/services/stream/clients/redis.js +31 -4
- package/build/services/task/index.js +8 -11
- package/build/services/telemetry/index.js +21 -14
- package/build/services/worker/index.d.ts +6 -6
- package/build/services/worker/index.js +12 -7
- package/build/types/activity.d.ts +3 -3
- package/build/types/exporter.d.ts +2 -2
- package/build/types/exporter.js +0 -6
- package/build/types/hook.d.ts +1 -1
- package/build/types/hotmesh.js +0 -1
- package/build/types/index.d.ts +12 -12
- package/build/types/job.d.ts +1 -1
- package/build/types/logger.js +0 -1
- package/build/types/quorum.d.ts +1 -1
- package/build/types/stats.d.ts +1 -1
- package/build/types/stream.d.ts +1 -2
- package/build/types/telemetry.d.ts +1 -1
- package/build/types/transition.d.ts +1 -1
- package/package.json +41 -38
- package/types/activity.ts +56 -39
- package/types/async.ts +2 -3
- package/types/collator.ts +5 -5
- package/types/durable.ts +161 -161
- package/types/error.ts +37 -37
- package/types/exporter.ts +14 -9
- package/types/hook.ts +11 -4
- package/types/hotmesh.ts +26 -25
- package/types/index.ts +53 -53
- package/types/job.ts +33 -33
- package/types/logger.ts +1 -1
- package/types/map.ts +1 -1
- package/types/pipe.ts +10 -8
- package/types/quorum.ts +20 -13
- package/types/redis.ts +70 -15
- package/types/serializer.ts +8 -6
- package/types/stats.ts +22 -6
- package/types/stream.ts +9 -9
- package/types/task.ts +7 -1
- package/types/telemetry.ts +2 -1
- package/types/transition.ts +8 -8
|
@@ -42,7 +42,6 @@ class Deployer {
|
|
|
42
42
|
}
|
|
43
43
|
async generateSymKeys() {
|
|
44
44
|
//note: symbol ranges are additive (per version); path assignments are immutable
|
|
45
|
-
const appId = this.manifest.app.id;
|
|
46
45
|
for (const graph of this.manifest.app.graphs) {
|
|
47
46
|
//generate JOB symbols
|
|
48
47
|
const [, trigger] = this.findTrigger(graph);
|
|
@@ -79,9 +78,9 @@ class Deployer {
|
|
|
79
78
|
}
|
|
80
79
|
}
|
|
81
80
|
bindSymbols(startIndex, maxIndex, existingSymbols, prefix, produces) {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
for (
|
|
81
|
+
const newSymbols = {};
|
|
82
|
+
const currentSymbols = { ...existingSymbols };
|
|
83
|
+
for (const path of produces) {
|
|
85
84
|
const fullPath = `${prefix}${path}`;
|
|
86
85
|
if (!currentSymbols[fullPath]) {
|
|
87
86
|
if (startIndex > maxIndex) {
|
|
@@ -157,7 +156,9 @@ class Deployer {
|
|
|
157
156
|
const activities = graph.activities;
|
|
158
157
|
for (const activityKey in activities) {
|
|
159
158
|
const activity = activities[activityKey];
|
|
160
|
-
if (['worker', 'await'].includes(activity.type) &&
|
|
159
|
+
if (['worker', 'await'].includes(activity.type) &&
|
|
160
|
+
activity.topic &&
|
|
161
|
+
!activity.subtype) {
|
|
161
162
|
activity.subtype = activity.topic;
|
|
162
163
|
}
|
|
163
164
|
}
|
|
@@ -237,11 +238,13 @@ class Deployer {
|
|
|
237
238
|
}
|
|
238
239
|
resolveJobMapsPaths() {
|
|
239
240
|
function parsePaths(obj) {
|
|
240
|
-
|
|
241
|
+
const result = [];
|
|
241
242
|
function traverse(obj, path = []) {
|
|
242
|
-
for (
|
|
243
|
-
if (typeof obj[key] === 'object' &&
|
|
244
|
-
|
|
243
|
+
for (const key in obj) {
|
|
244
|
+
if (typeof obj[key] === 'object' &&
|
|
245
|
+
obj[key] !== null &&
|
|
246
|
+
!('@pipe' in obj[key])) {
|
|
247
|
+
const newPath = [...path, key];
|
|
245
248
|
traverse(obj[key], newPath);
|
|
246
249
|
}
|
|
247
250
|
else {
|
|
@@ -296,7 +299,8 @@ class Deployer {
|
|
|
296
299
|
if (typeof obj[key] === 'string') {
|
|
297
300
|
const stringValue = obj[key];
|
|
298
301
|
const dynamicMappingRuleMatch = stringValue.match(/^\{[^@].*}$/);
|
|
299
|
-
if (dynamicMappingRuleMatch &&
|
|
302
|
+
if (dynamicMappingRuleMatch &&
|
|
303
|
+
!validator_1.Validator.CONTEXT_VARS.includes(stringValue)) {
|
|
300
304
|
if (stringValue.split('.')[1] !== 'input') {
|
|
301
305
|
dynamicMappingRules.push(stringValue);
|
|
302
306
|
consumes.push(stringValue);
|
|
@@ -354,7 +358,7 @@ class Deployer {
|
|
|
354
358
|
const prefix = {
|
|
355
359
|
hook: 'hook/data',
|
|
356
360
|
input: 'input/data',
|
|
357
|
-
output: subtype === 'data' ? 'output/data' : 'output/metadata'
|
|
361
|
+
output: subtype === 'data' ? 'output/data' : 'output/metadata',
|
|
358
362
|
}[type];
|
|
359
363
|
return [group, `${prefix}/${path.join('/')}`];
|
|
360
364
|
}
|
|
@@ -460,7 +464,8 @@ class Deployer {
|
|
|
460
464
|
for (const activityKey in activities) {
|
|
461
465
|
const activity = activities[activityKey];
|
|
462
466
|
//only precreate if the topic is concrete and not `mappable`
|
|
463
|
-
if (activity.type === 'worker' &&
|
|
467
|
+
if (activity.type === 'worker' &&
|
|
468
|
+
pipe_1.Pipe.resolve(activity.subtype, {}) === activity.subtype) {
|
|
464
469
|
params.topic = activity.subtype;
|
|
465
470
|
const key = this.store.mintKey(key_1.KeyType.STREAMS, params);
|
|
466
471
|
//create one worker group per unique activity subtype (the topic)
|
|
@@ -27,10 +27,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
29
|
exports.CompilerService = void 0;
|
|
30
|
-
const json_schema_ref_parser_1 = __importDefault(require("@apidevtools/json-schema-ref-parser"));
|
|
31
|
-
const js_yaml_1 = __importDefault(require("js-yaml"));
|
|
32
30
|
const fs = __importStar(require("fs/promises"));
|
|
33
31
|
const path = __importStar(require("path"));
|
|
32
|
+
const json_schema_ref_parser_1 = __importDefault(require("@apidevtools/json-schema-ref-parser"));
|
|
33
|
+
const js_yaml_1 = __importDefault(require("js-yaml"));
|
|
34
34
|
const deployer_1 = require("./deployer");
|
|
35
35
|
const validator_1 = require("./validator");
|
|
36
36
|
/**
|
|
@@ -49,7 +49,7 @@ class CompilerService {
|
|
|
49
49
|
try {
|
|
50
50
|
let schema;
|
|
51
51
|
if (this.isPath(mySchemaOrPath)) {
|
|
52
|
-
schema = await json_schema_ref_parser_1.default.dereference(mySchemaOrPath);
|
|
52
|
+
schema = (await json_schema_ref_parser_1.default.dereference(mySchemaOrPath));
|
|
53
53
|
}
|
|
54
54
|
else {
|
|
55
55
|
schema = js_yaml_1.default.load(mySchemaOrPath);
|
|
@@ -74,7 +74,7 @@ class CompilerService {
|
|
|
74
74
|
try {
|
|
75
75
|
let schema;
|
|
76
76
|
if (this.isPath(mySchemaOrPath)) {
|
|
77
|
-
schema = await json_schema_ref_parser_1.default.dereference(mySchemaOrPath);
|
|
77
|
+
schema = (await json_schema_ref_parser_1.default.dereference(mySchemaOrPath));
|
|
78
78
|
await this.saveAsJSON(mySchemaOrPath, schema);
|
|
79
79
|
}
|
|
80
80
|
else {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { StoreService } from '../store';
|
|
2
|
-
import { MappingStatements } from
|
|
3
|
-
import { HotMeshManifest } from
|
|
4
|
-
import { RedisClient, RedisMulti } from
|
|
2
|
+
import { MappingStatements } from '../../types/map';
|
|
3
|
+
import { HotMeshManifest } from '../../types/hotmesh';
|
|
4
|
+
import { RedisClient, RedisMulti } from '../../types/redis';
|
|
5
5
|
declare class Validator {
|
|
6
6
|
manifest: HotMeshManifest | null;
|
|
7
7
|
activityIds: string[];
|
|
@@ -46,7 +46,7 @@ class Validator {
|
|
|
46
46
|
this.activityIds = Array.from(activityIdsSet);
|
|
47
47
|
}
|
|
48
48
|
isMappingStatement(value) {
|
|
49
|
-
return typeof value === 'string' && value.startsWith('{') && value.endsWith('}');
|
|
49
|
+
return (typeof value === 'string' && value.startsWith('{') && value.endsWith('}'));
|
|
50
50
|
}
|
|
51
51
|
extractMappingStatements(obj, result, currentActivityId) {
|
|
52
52
|
for (const key in obj) {
|
|
@@ -83,7 +83,10 @@ class Validator {
|
|
|
83
83
|
if (statement.startsWith('{') && statement.endsWith('}')) {
|
|
84
84
|
const statementParts = statement.slice(1, -1).split('.');
|
|
85
85
|
const referencedActivityId = statementParts[0];
|
|
86
|
-
if (!(Validator.SYS_VARS.includes(referencedActivityId) ||
|
|
86
|
+
if (!(Validator.SYS_VARS.includes(referencedActivityId) ||
|
|
87
|
+
activityIds.includes(referencedActivityId) ||
|
|
88
|
+
this.isFunction(statement) ||
|
|
89
|
+
this.isContextVariable(statement))) {
|
|
87
90
|
throw new Error(`Mapping statement references non-existent activity: ${statement}`);
|
|
88
91
|
}
|
|
89
92
|
}
|
|
@@ -135,4 +138,10 @@ class Validator {
|
|
|
135
138
|
}
|
|
136
139
|
exports.Validator = Validator;
|
|
137
140
|
Validator.SYS_VARS = ['$app', '$self', '$graph', '$job'];
|
|
138
|
-
Validator.CONTEXT_VARS = [
|
|
141
|
+
Validator.CONTEXT_VARS = [
|
|
142
|
+
'{$input}',
|
|
143
|
+
'{$output}',
|
|
144
|
+
'{$item}',
|
|
145
|
+
'{$key}',
|
|
146
|
+
'{$index}',
|
|
147
|
+
];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { WorkflowHandleService } from './handle';
|
|
2
1
|
import { HotMeshService as HotMesh } from '../hotmesh';
|
|
3
2
|
import { ClientConfig, Connection, HookOptions, WorkflowOptions } from '../../types/durable';
|
|
3
|
+
import { WorkflowHandleService } from './handle';
|
|
4
4
|
export declare class ClientService {
|
|
5
5
|
connection: Connection;
|
|
6
6
|
options: WorkflowOptions;
|
|
@@ -6,14 +6,14 @@ var _a;
|
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
7
|
exports.ClientService = void 0;
|
|
8
8
|
const ms_1 = __importDefault(require("ms"));
|
|
9
|
-
const factory_1 = require("./schemas/factory");
|
|
10
9
|
const enums_1 = require("../../modules/enums");
|
|
11
10
|
const utils_1 = require("../../modules/utils");
|
|
12
|
-
const handle_1 = require("./handle");
|
|
13
11
|
const hotmesh_1 = require("../hotmesh");
|
|
14
12
|
const key_1 = require("../../modules/key");
|
|
15
|
-
const search_1 = require("./search");
|
|
16
13
|
const types_1 = require("../../types");
|
|
14
|
+
const search_1 = require("./search");
|
|
15
|
+
const handle_1 = require("./handle");
|
|
16
|
+
const factory_1 = require("./schemas/factory");
|
|
17
17
|
class ClientService {
|
|
18
18
|
constructor(config) {
|
|
19
19
|
this.getHotMeshClient = async (workflowTopic, namespace) => {
|
|
@@ -35,8 +35,8 @@ class ClientService {
|
|
|
35
35
|
redis: {
|
|
36
36
|
class: this.connection.class,
|
|
37
37
|
options: this.connection.options,
|
|
38
|
-
}
|
|
39
|
-
}
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
40
|
});
|
|
41
41
|
ClientService.instances.set(targetNS, hotMeshClient);
|
|
42
42
|
await ClientService.createStream(await hotMeshClient, workflowTopic, namespace);
|
|
@@ -46,9 +46,9 @@ class ClientService {
|
|
|
46
46
|
this.search = async (hotMeshClient, index, query) => {
|
|
47
47
|
const store = hotMeshClient.engine.store;
|
|
48
48
|
if (query[0]?.startsWith('FT.')) {
|
|
49
|
-
return await store.exec(...query);
|
|
49
|
+
return (await store.exec(...query));
|
|
50
50
|
}
|
|
51
|
-
return await store.exec('FT.SEARCH', index, ...query);
|
|
51
|
+
return (await store.exec('FT.SEARCH', index, ...query));
|
|
52
52
|
};
|
|
53
53
|
this.workflow = {
|
|
54
54
|
start: async (options) => {
|
|
@@ -69,7 +69,8 @@ class ClientService {
|
|
|
69
69
|
workflowTopic: workflowTopic,
|
|
70
70
|
backoffCoefficient: options.config?.backoffCoefficient || enums_1.HMSH_DURABLE_EXP_BACKOFF,
|
|
71
71
|
maximumAttempts: options.config?.maximumAttempts || enums_1.HMSH_DURABLE_MAX_ATTEMPTS,
|
|
72
|
-
maximumInterval: (0, ms_1.default)(options.config?.maximumInterval || enums_1.HMSH_DURABLE_MAX_INTERVAL) /
|
|
72
|
+
maximumInterval: (0, ms_1.default)(options.config?.maximumInterval || enums_1.HMSH_DURABLE_MAX_INTERVAL) /
|
|
73
|
+
1000,
|
|
73
74
|
};
|
|
74
75
|
const context = { metadata: { trc, spn }, data: {} };
|
|
75
76
|
const jobId = await hotMeshClient.pub(`${options.namespace ?? factory_1.APP_ID}.execute`, payload, context, { search: options?.search?.data, marker: options?.marker });
|
|
@@ -96,7 +97,8 @@ class ClientService {
|
|
|
96
97
|
workflowTopic,
|
|
97
98
|
backoffCoefficient: options.config?.backoffCoefficient || enums_1.HMSH_DURABLE_EXP_BACKOFF,
|
|
98
99
|
maximumAttempts: options.config?.maximumAttempts || enums_1.HMSH_DURABLE_MAX_ATTEMPTS,
|
|
99
|
-
maximumInterval: (0, ms_1.default)(options.config?.maximumInterval || enums_1.HMSH_DURABLE_MAX_INTERVAL) /
|
|
100
|
+
maximumInterval: (0, ms_1.default)(options.config?.maximumInterval || enums_1.HMSH_DURABLE_MAX_INTERVAL) /
|
|
101
|
+
1000,
|
|
100
102
|
};
|
|
101
103
|
//seed search data if presentthe hook before entering
|
|
102
104
|
const hotMeshClient = await this.getHotMeshClient(workflowTopic, options.namespace);
|
|
@@ -121,10 +123,12 @@ class ClientService {
|
|
|
121
123
|
return await this.search(hotMeshClient, index, query);
|
|
122
124
|
}
|
|
123
125
|
catch (error) {
|
|
124
|
-
hotMeshClient.engine.logger.error('durable-client-search-err', {
|
|
126
|
+
hotMeshClient.engine.logger.error('durable-client-search-err', {
|
|
127
|
+
...error,
|
|
128
|
+
});
|
|
125
129
|
throw error;
|
|
126
130
|
}
|
|
127
|
-
}
|
|
131
|
+
},
|
|
128
132
|
};
|
|
129
133
|
this.connection = config.connection;
|
|
130
134
|
}
|
|
@@ -149,7 +153,9 @@ class ClientService {
|
|
|
149
153
|
await hotMesh.activate(version);
|
|
150
154
|
}
|
|
151
155
|
catch (error) {
|
|
152
|
-
hotMesh.engine.logger.error('durable-client-deploy-activate-err', {
|
|
156
|
+
hotMesh.engine.logger.error('durable-client-deploy-activate-err', {
|
|
157
|
+
...error,
|
|
158
|
+
});
|
|
153
159
|
throw error;
|
|
154
160
|
}
|
|
155
161
|
}
|
|
@@ -2,7 +2,7 @@ import { ILogger } from '../logger';
|
|
|
2
2
|
import { StoreService } from '../store';
|
|
3
3
|
import { ExportOptions, DurableJobExport, TimelineType, TransitionType, ExportFields } from '../../types/exporter';
|
|
4
4
|
import { RedisClient, RedisMulti } from '../../types/redis';
|
|
5
|
-
import { StringStringType, Symbols } from
|
|
5
|
+
import { StringStringType, Symbols } from '../../types/serializer';
|
|
6
6
|
declare class ExporterService {
|
|
7
7
|
appId: string;
|
|
8
8
|
logger: ILogger;
|
|
@@ -99,7 +99,7 @@ class ExporterService {
|
|
|
99
99
|
filterFields(fullObject, block = [], allow = []) {
|
|
100
100
|
let result = {};
|
|
101
101
|
if (allow && allow.length > 0) {
|
|
102
|
-
allow.forEach(field => {
|
|
102
|
+
allow.forEach((field) => {
|
|
103
103
|
if (field in fullObject) {
|
|
104
104
|
result[field] = fullObject[field];
|
|
105
105
|
}
|
|
@@ -109,7 +109,7 @@ class ExporterService {
|
|
|
109
109
|
result = { ...fullObject };
|
|
110
110
|
}
|
|
111
111
|
if (block && block.length > 0) {
|
|
112
|
-
block.forEach(field => {
|
|
112
|
+
block.forEach((field) => {
|
|
113
113
|
if (field in result) {
|
|
114
114
|
delete result[field];
|
|
115
115
|
}
|
|
@@ -127,7 +127,7 @@ class ExporterService {
|
|
|
127
127
|
//for now only export activity start/stop; activity data would also be interesting
|
|
128
128
|
if (isCreate || isUpdate) {
|
|
129
129
|
const targetName = `${activity},${dimensions}`;
|
|
130
|
-
|
|
130
|
+
const target = transitionsObject[targetName];
|
|
131
131
|
if (!target) {
|
|
132
132
|
transitionsObject[targetName] = {
|
|
133
133
|
activity,
|
|
@@ -210,7 +210,6 @@ class ExporterService {
|
|
|
210
210
|
return 0;
|
|
211
211
|
});
|
|
212
212
|
}
|
|
213
|
-
;
|
|
214
213
|
}
|
|
215
214
|
exports.ExporterService = ExporterService;
|
|
216
215
|
ExporterService.symbols = new Map();
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { ExporterService } from './exporter';
|
|
2
1
|
import { HotMeshService as HotMesh } from '../hotmesh';
|
|
3
2
|
import { DurableJobExport, ExportOptions } from '../../types/exporter';
|
|
4
3
|
import { JobInterruptOptions } from '../../types/job';
|
|
5
4
|
import { StreamError } from '../../types/stream';
|
|
5
|
+
import { ExporterService } from './exporter';
|
|
6
6
|
export declare class WorkflowHandleService {
|
|
7
7
|
exporter: ExporterService;
|
|
8
8
|
hotMesh: HotMesh;
|
|
@@ -19,7 +19,10 @@ class WorkflowHandleService {
|
|
|
19
19
|
* will awaken if no other signals are pending.
|
|
20
20
|
*/
|
|
21
21
|
async signal(signalId, data) {
|
|
22
|
-
await this.hotMesh.hook(`${this.hotMesh.appId}.wfs.signal`, {
|
|
22
|
+
await this.hotMesh.hook(`${this.hotMesh.appId}.wfs.signal`, {
|
|
23
|
+
id: signalId,
|
|
24
|
+
data,
|
|
25
|
+
});
|
|
23
26
|
}
|
|
24
27
|
/**
|
|
25
28
|
* Returns the job state of the workflow. If the workflow has completed
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
import { ContextType } from '../../types/durable';
|
|
1
2
|
import { ClientService } from './client';
|
|
2
3
|
import { ConnectionService } from './connection';
|
|
3
4
|
import { Search } from './search';
|
|
4
5
|
import { WorkerService } from './worker';
|
|
5
6
|
import { WorkflowService } from './workflow';
|
|
6
|
-
import { ContextType } from '../../types/durable';
|
|
7
7
|
export declare const Durable: {
|
|
8
8
|
Client: typeof ClientService;
|
|
9
9
|
Connection: typeof ConnectionService;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Durable = void 0;
|
|
4
|
+
const hotmesh_1 = require("../hotmesh");
|
|
4
5
|
const client_1 = require("./client");
|
|
5
6
|
const connection_1 = require("./connection");
|
|
6
7
|
const search_1 = require("./search");
|
|
7
8
|
const worker_1 = require("./worker");
|
|
8
9
|
const workflow_1 = require("./workflow");
|
|
9
|
-
const hotmesh_1 = require("../hotmesh");
|
|
10
10
|
exports.Durable = {
|
|
11
11
|
Client: client_1.ClientService,
|
|
12
12
|
Connection: connection_1.ConnectionService,
|
|
@@ -21,5 +21,5 @@ exports.Durable = {
|
|
|
21
21
|
await client_1.ClientService.shutdown();
|
|
22
22
|
await worker_1.WorkerService.shutdown();
|
|
23
23
|
await hotmesh_1.HotMeshService.stop();
|
|
24
|
-
}
|
|
24
|
+
},
|
|
25
25
|
};
|
|
@@ -9,7 +9,7 @@ class Search {
|
|
|
9
9
|
this.cachedFields = {};
|
|
10
10
|
const keyParams = {
|
|
11
11
|
appId: hotMeshClient.appId,
|
|
12
|
-
jobId: workflowId
|
|
12
|
+
jobId: workflowId,
|
|
13
13
|
};
|
|
14
14
|
this.jobId = key_1.KeyService.mintKey(hotMeshClient.namespace, key_1.KeyType.JOB_STATE, keyParams);
|
|
15
15
|
this.searchSessionId = searchSessionId;
|
|
@@ -72,14 +72,16 @@ class Search {
|
|
|
72
72
|
try {
|
|
73
73
|
const keyParams = {
|
|
74
74
|
appId: hotMeshClient.appId,
|
|
75
|
-
jobId: ''
|
|
75
|
+
jobId: '',
|
|
76
76
|
};
|
|
77
77
|
const hotMeshPrefix = key_1.KeyService.mintKey(hotMeshClient.namespace, key_1.KeyType.JOB_STATE, keyParams);
|
|
78
78
|
const prefixes = search.prefix.map((prefix) => `${hotMeshPrefix}${prefix}`);
|
|
79
79
|
await store.exec('FT.CREATE', `${search.index}`, 'ON', 'HASH', 'PREFIX', prefixes.length.toString(), ...prefixes, 'SCHEMA', ...schema);
|
|
80
80
|
}
|
|
81
81
|
catch (error) {
|
|
82
|
-
hotMeshClient.engine.logger.info('durable-client-search-err', {
|
|
82
|
+
hotMeshClient.engine.logger.info('durable-client-search-err', {
|
|
83
|
+
...error,
|
|
84
|
+
});
|
|
83
85
|
}
|
|
84
86
|
}
|
|
85
87
|
}
|
|
@@ -99,7 +101,9 @@ class Search {
|
|
|
99
101
|
return searchIndexes;
|
|
100
102
|
}
|
|
101
103
|
catch (error) {
|
|
102
|
-
hotMeshClient.engine.logger.info('durable-client-search-list-err', {
|
|
104
|
+
hotMeshClient.engine.logger.info('durable-client-search-list-err', {
|
|
105
|
+
...error,
|
|
106
|
+
});
|
|
103
107
|
return [];
|
|
104
108
|
}
|
|
105
109
|
}
|
|
@@ -155,7 +159,7 @@ class Search {
|
|
|
155
159
|
if (key in this.cachedFields) {
|
|
156
160
|
return this.cachedFields[key];
|
|
157
161
|
}
|
|
158
|
-
const value = await this.store.exec('HGET', this.jobId, this.safeKey(key));
|
|
162
|
+
const value = (await this.store.exec('HGET', this.jobId, this.safeKey(key)));
|
|
159
163
|
this.cachedFields[key] = value;
|
|
160
164
|
return value;
|
|
161
165
|
}
|
|
@@ -186,7 +190,7 @@ class Search {
|
|
|
186
190
|
if (isCached) {
|
|
187
191
|
return values;
|
|
188
192
|
}
|
|
189
|
-
const returnValues = await this.store.exec('HMGET', this.jobId, ...safeArgs);
|
|
193
|
+
const returnValues = (await this.store.exec('HMGET', this.jobId, ...safeArgs));
|
|
190
194
|
returnValues.forEach((value, index) => {
|
|
191
195
|
if (value !== null) {
|
|
192
196
|
this.cachedFields[args[index]] = value;
|
|
@@ -195,7 +199,9 @@ class Search {
|
|
|
195
199
|
return returnValues;
|
|
196
200
|
}
|
|
197
201
|
catch (error) {
|
|
198
|
-
this.hotMeshClient.logger.error('durable-search-mget-error', {
|
|
202
|
+
this.hotMeshClient.logger.error('durable-search-mget-error', {
|
|
203
|
+
...error,
|
|
204
|
+
});
|
|
199
205
|
return [];
|
|
200
206
|
}
|
|
201
207
|
}
|
|
@@ -223,7 +229,9 @@ class Search {
|
|
|
223
229
|
return Number(replay[ssGuid]);
|
|
224
230
|
}
|
|
225
231
|
const response = await this.store.exec('HDEL', this.jobId, ...safeArgs);
|
|
226
|
-
const formattedResponse = isNaN(response)
|
|
232
|
+
const formattedResponse = isNaN(response)
|
|
233
|
+
? 0
|
|
234
|
+
: Number(response);
|
|
227
235
|
this.store.exec('HSET', this.jobId, ssGuid, formattedResponse.toString());
|
|
228
236
|
return formattedResponse;
|
|
229
237
|
}
|
|
@@ -247,7 +255,7 @@ class Search {
|
|
|
247
255
|
if (ssGuid in replay) {
|
|
248
256
|
return Number(replay[ssGuid]);
|
|
249
257
|
}
|
|
250
|
-
const num = await this.store.exec('HINCRBYFLOAT', this.jobId, this.safeKey(key), val.toString());
|
|
258
|
+
const num = (await this.store.exec('HINCRBYFLOAT', this.jobId, this.safeKey(key), val.toString()));
|
|
251
259
|
this.store.exec('HSET', this.jobId, ssGuid, num.toString());
|
|
252
260
|
return Number(num);
|
|
253
261
|
}
|
|
@@ -271,10 +279,10 @@ class Search {
|
|
|
271
279
|
if (ssGuid in replay) {
|
|
272
280
|
return Math.exp(Number(replay[ssGuid]));
|
|
273
281
|
}
|
|
274
|
-
const ssGuidValue = Number(await this.store.exec('HINCRBYFLOAT', this.jobId, ssGuid, '1'));
|
|
282
|
+
const ssGuidValue = Number((await this.store.exec('HINCRBYFLOAT', this.jobId, ssGuid, '1')));
|
|
275
283
|
if (ssGuidValue === 1) {
|
|
276
284
|
const log = Math.log(val);
|
|
277
|
-
const logTotal = await this.store.exec('HINCRBYFLOAT', this.jobId, this.safeKey(key), log.toString());
|
|
285
|
+
const logTotal = (await this.store.exec('HINCRBYFLOAT', this.jobId, this.safeKey(key), log.toString()));
|
|
278
286
|
this.store.exec('HSET', this.jobId, ssGuid, logTotal.toString());
|
|
279
287
|
return Math.exp(Number(logTotal));
|
|
280
288
|
}
|