@hotmeshio/hotmesh 0.0.60 → 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 +1 -1
- package/build/modules/enums.js +10 -2
- 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 +5 -5
- package/build/modules/utils.js +20 -16
- 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
|
@@ -3,18 +3,22 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.Await = void 0;
|
|
4
4
|
const errors_1 = require("../../modules/errors");
|
|
5
5
|
const utils_1 = require("../../modules/utils");
|
|
6
|
-
const activity_1 = require("./activity");
|
|
7
6
|
const collator_1 = require("../collator");
|
|
8
7
|
const pipe_1 = require("../pipe");
|
|
9
8
|
const telemetry_1 = require("../telemetry");
|
|
10
9
|
const stream_1 = require("../../types/stream");
|
|
10
|
+
const activity_1 = require("./activity");
|
|
11
11
|
class Await extends activity_1.Activity {
|
|
12
12
|
constructor(config, data, metadata, hook, engine, context) {
|
|
13
13
|
super(config, data, metadata, hook, engine, context);
|
|
14
14
|
}
|
|
15
15
|
//******** INITIAL ENTRY POINT (A) ********//
|
|
16
16
|
async process() {
|
|
17
|
-
this.logger.debug('await-process', {
|
|
17
|
+
this.logger.debug('await-process', {
|
|
18
|
+
jid: this.context.metadata.jid,
|
|
19
|
+
gid: this.context.metadata.gid,
|
|
20
|
+
aid: this.metadata.aid,
|
|
21
|
+
});
|
|
18
22
|
let telemetry;
|
|
19
23
|
try {
|
|
20
24
|
await this.verifyEntry();
|
|
@@ -28,13 +32,13 @@ class Await extends activity_1.Activity {
|
|
|
28
32
|
await collator_1.CollatorService.authorizeReentry(this, multi);
|
|
29
33
|
await this.setState(multi);
|
|
30
34
|
await this.setStatus(0, multi);
|
|
31
|
-
const multiResponse = await multi.exec();
|
|
35
|
+
const multiResponse = (await multi.exec());
|
|
32
36
|
//telemetry
|
|
33
37
|
telemetry.mapActivityAttributes();
|
|
34
38
|
const jobStatus = this.resolveStatus(multiResponse);
|
|
35
39
|
telemetry.setActivityAttributes({
|
|
36
40
|
'app.activity.mid': messageId,
|
|
37
|
-
'app.job.jss': jobStatus
|
|
41
|
+
'app.job.jss': jobStatus,
|
|
38
42
|
});
|
|
39
43
|
return this.context.metadata.aid;
|
|
40
44
|
}
|
|
@@ -59,7 +63,11 @@ class Await extends activity_1.Activity {
|
|
|
59
63
|
}
|
|
60
64
|
finally {
|
|
61
65
|
telemetry?.endActivitySpan();
|
|
62
|
-
this.logger.debug('await-process-end', {
|
|
66
|
+
this.logger.debug('await-process-end', {
|
|
67
|
+
jid: this.context.metadata.jid,
|
|
68
|
+
gid: this.context.metadata.gid,
|
|
69
|
+
aid: this.metadata.aid,
|
|
70
|
+
});
|
|
63
71
|
}
|
|
64
72
|
}
|
|
65
73
|
async execActivity(multi) {
|
|
@@ -76,7 +84,7 @@ class Await extends activity_1.Activity {
|
|
|
76
84
|
trc: this.context.metadata.trc,
|
|
77
85
|
},
|
|
78
86
|
type: stream_1.StreamDataType.AWAIT,
|
|
79
|
-
data: this.context.data
|
|
87
|
+
data: this.context.data,
|
|
80
88
|
};
|
|
81
89
|
if (this.config.await !== true) {
|
|
82
90
|
const doAwait = pipe_1.Pipe.resolve(this.config.await, this.context);
|
|
@@ -86,7 +94,7 @@ class Await extends activity_1.Activity {
|
|
|
86
94
|
}
|
|
87
95
|
if (this.config.retry) {
|
|
88
96
|
streamData.policies = {
|
|
89
|
-
retry: this.config.retry
|
|
97
|
+
retry: this.config.retry,
|
|
90
98
|
};
|
|
91
99
|
}
|
|
92
100
|
return (await this.engine.router?.publishMessage(null, streamData, multi));
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { EngineService } from '../engine';
|
|
2
|
-
import { Activity } from './activity';
|
|
3
2
|
import { ActivityData, ActivityMetadata, ActivityType, CycleActivity } from '../../types/activity';
|
|
4
3
|
import { JobState } from '../../types/job';
|
|
5
4
|
import { RedisMulti } from '../../types/redis';
|
|
5
|
+
import { Activity } from './activity';
|
|
6
6
|
declare class Cycle extends Activity {
|
|
7
7
|
config: CycleActivity;
|
|
8
8
|
constructor(config: ActivityType, data: ActivityData, metadata: ActivityMetadata, hook: ActivityData | null, engine: EngineService, context?: JobState);
|
|
@@ -4,15 +4,19 @@ exports.Cycle = void 0;
|
|
|
4
4
|
const errors_1 = require("../../modules/errors");
|
|
5
5
|
const utils_1 = require("../../modules/utils");
|
|
6
6
|
const collator_1 = require("../collator");
|
|
7
|
-
const activity_1 = require("./activity");
|
|
8
7
|
const telemetry_1 = require("../telemetry");
|
|
8
|
+
const activity_1 = require("./activity");
|
|
9
9
|
class Cycle extends activity_1.Activity {
|
|
10
10
|
constructor(config, data, metadata, hook, engine, context) {
|
|
11
11
|
super(config, data, metadata, hook, engine, context);
|
|
12
12
|
}
|
|
13
13
|
//******** LEG 1 ENTRY ********//
|
|
14
14
|
async process() {
|
|
15
|
-
this.logger.debug('cycle-process', {
|
|
15
|
+
this.logger.debug('cycle-process', {
|
|
16
|
+
jid: this.context.metadata.jid,
|
|
17
|
+
gid: this.context.metadata.gid,
|
|
18
|
+
aid: this.metadata.aid,
|
|
19
|
+
});
|
|
16
20
|
let telemetry;
|
|
17
21
|
try {
|
|
18
22
|
await this.verifyEntry();
|
|
@@ -23,7 +27,7 @@ class Cycle extends activity_1.Activity {
|
|
|
23
27
|
let multi = this.store.getMulti();
|
|
24
28
|
await this.setState(multi);
|
|
25
29
|
await this.setStatus(0, multi); //leg 1 never changes job status
|
|
26
|
-
const multiResponse = await multi.exec();
|
|
30
|
+
const multiResponse = (await multi.exec());
|
|
27
31
|
telemetry.mapActivityAttributes();
|
|
28
32
|
const jobStatus = this.resolveStatus(multiResponse);
|
|
29
33
|
//cycle the target ancestor
|
|
@@ -31,11 +35,11 @@ class Cycle extends activity_1.Activity {
|
|
|
31
35
|
const messageId = await this.cycleAncestorActivity(multi);
|
|
32
36
|
telemetry.setActivityAttributes({
|
|
33
37
|
'app.activity.mid': messageId,
|
|
34
|
-
'app.job.jss': jobStatus
|
|
38
|
+
'app.job.jss': jobStatus,
|
|
35
39
|
});
|
|
36
40
|
//exit early (`Cycle` activities only execute Leg 1)
|
|
37
41
|
await collator_1.CollatorService.notarizeEarlyExit(this, multi);
|
|
38
|
-
await multi.exec();
|
|
42
|
+
(await multi.exec());
|
|
39
43
|
return this.context.metadata.aid;
|
|
40
44
|
}
|
|
41
45
|
catch (error) {
|
|
@@ -59,7 +63,11 @@ class Cycle extends activity_1.Activity {
|
|
|
59
63
|
}
|
|
60
64
|
finally {
|
|
61
65
|
telemetry?.endActivitySpan();
|
|
62
|
-
this.logger.debug('cycle-process-end', {
|
|
66
|
+
this.logger.debug('cycle-process-end', {
|
|
67
|
+
jid: this.context.metadata.jid,
|
|
68
|
+
gid: this.context.metadata.gid,
|
|
69
|
+
aid: this.metadata.aid,
|
|
70
|
+
});
|
|
63
71
|
}
|
|
64
72
|
}
|
|
65
73
|
/**
|
|
@@ -71,7 +79,7 @@ class Cycle extends activity_1.Activity {
|
|
|
71
79
|
*/
|
|
72
80
|
async cycleAncestorActivity(multi) {
|
|
73
81
|
//Cycle activity L1 is a standin for the target ancestor L1.
|
|
74
|
-
//Input data mapping (mapInputData) allows for the
|
|
82
|
+
//Input data mapping (mapInputData) allows for the
|
|
75
83
|
//next dimensonal thread to execute with different
|
|
76
84
|
//input data than the current dimensional thread
|
|
77
85
|
this.mapInputData();
|
|
@@ -85,7 +93,7 @@ class Cycle extends activity_1.Activity {
|
|
|
85
93
|
spn: this.context['$self'].output.metadata?.l1s,
|
|
86
94
|
trc: this.context.metadata.trc,
|
|
87
95
|
},
|
|
88
|
-
data: this.context.data
|
|
96
|
+
data: this.context.data,
|
|
89
97
|
};
|
|
90
98
|
return (await this.engine.router?.publishMessage(null, streamData, multi));
|
|
91
99
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { Activity } from './activity';
|
|
2
1
|
import { EngineService } from '../engine';
|
|
3
2
|
import { TelemetryService } from '../telemetry';
|
|
4
3
|
import { ActivityData, ActivityMetadata, ActivityType, HookActivity } from '../../types/activity';
|
|
@@ -6,6 +5,7 @@ import { HookRule } from '../../types/hook';
|
|
|
6
5
|
import { JobState, JobStatus } from '../../types/job';
|
|
7
6
|
import { RedisMulti } from '../../types/redis';
|
|
8
7
|
import { StreamCode, StreamStatus } from '../../types/stream';
|
|
8
|
+
import { Activity } from './activity';
|
|
9
9
|
/**
|
|
10
10
|
* Supports `signal hook`, `time hook`, and `cycle hook` patterns
|
|
11
11
|
*/
|
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Hook = void 0;
|
|
4
4
|
const errors_1 = require("../../modules/errors");
|
|
5
|
-
const activity_1 = require("./activity");
|
|
6
5
|
const collator_1 = require("../collator");
|
|
7
6
|
const pipe_1 = require("../pipe");
|
|
8
7
|
const task_1 = require("../task");
|
|
9
8
|
const telemetry_1 = require("../telemetry");
|
|
10
9
|
const stream_1 = require("../../types/stream");
|
|
10
|
+
const activity_1 = require("./activity");
|
|
11
11
|
/**
|
|
12
12
|
* Supports `signal hook`, `time hook`, and `cycle hook` patterns
|
|
13
13
|
*/
|
|
@@ -58,7 +58,11 @@ class Hook extends activity_1.Activity {
|
|
|
58
58
|
}
|
|
59
59
|
finally {
|
|
60
60
|
telemetry?.endActivitySpan();
|
|
61
|
-
this.logger.debug('hook-process-end', {
|
|
61
|
+
this.logger.debug('hook-process-end', {
|
|
62
|
+
jid: this.context.metadata.jid,
|
|
63
|
+
gid: this.context.metadata.gid,
|
|
64
|
+
aid: this.metadata.aid,
|
|
65
|
+
});
|
|
62
66
|
}
|
|
63
67
|
}
|
|
64
68
|
/**
|
|
@@ -91,7 +95,7 @@ class Hook extends activity_1.Activity {
|
|
|
91
95
|
await this.setState(multi);
|
|
92
96
|
await collator_1.CollatorService.notarizeEarlyCompletion(this, multi);
|
|
93
97
|
await this.setStatus(this.adjacencyList.length - 1, multi);
|
|
94
|
-
multiResponse = await multi.exec();
|
|
98
|
+
multiResponse = (await multi.exec());
|
|
95
99
|
telemetry.mapActivityAttributes();
|
|
96
100
|
const jobStatus = this.resolveStatus(multiResponse);
|
|
97
101
|
const attrs = { 'app.job.jss': jobStatus };
|
|
@@ -141,7 +145,7 @@ class Hook extends activity_1.Activity {
|
|
|
141
145
|
this.logger.debug('hook-process-time-hook-event', {
|
|
142
146
|
jid: jobId,
|
|
143
147
|
gid: this.context.metadata.gid,
|
|
144
|
-
aid: this.metadata.aid
|
|
148
|
+
aid: this.metadata.aid,
|
|
145
149
|
});
|
|
146
150
|
await this.processEvent(stream_1.StreamStatus.SUCCESS, 200, 'hook');
|
|
147
151
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { Activity } from './activity';
|
|
2
1
|
import { EngineService } from '../engine';
|
|
3
2
|
import { TelemetryService } from '../telemetry';
|
|
4
3
|
import { ActivityData, ActivityMetadata, ActivityType, InterruptActivity } from '../../types/activity';
|
|
5
4
|
import { JobInterruptOptions, JobState } from '../../types/job';
|
|
5
|
+
import { Activity } from './activity';
|
|
6
6
|
declare class Interrupt extends Activity {
|
|
7
7
|
config: InterruptActivity;
|
|
8
8
|
constructor(config: ActivityType, data: ActivityData, metadata: ActivityMetadata, hook: ActivityData | null, engine: EngineService, context?: JobState);
|
|
@@ -3,16 +3,20 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.Interrupt = void 0;
|
|
4
4
|
const errors_1 = require("../../modules/errors");
|
|
5
5
|
const collator_1 = require("../collator");
|
|
6
|
-
const activity_1 = require("./activity");
|
|
7
6
|
const pipe_1 = require("../pipe");
|
|
8
7
|
const telemetry_1 = require("../telemetry");
|
|
8
|
+
const activity_1 = require("./activity");
|
|
9
9
|
class Interrupt extends activity_1.Activity {
|
|
10
10
|
constructor(config, data, metadata, hook, engine, context) {
|
|
11
11
|
super(config, data, metadata, hook, engine, context);
|
|
12
12
|
}
|
|
13
13
|
//******** LEG 1 ENTRY ********//
|
|
14
14
|
async process() {
|
|
15
|
-
this.logger.debug('interrupt-process', {
|
|
15
|
+
this.logger.debug('interrupt-process', {
|
|
16
|
+
jid: this.context.metadata.jid,
|
|
17
|
+
gid: this.context.metadata.gid,
|
|
18
|
+
aid: this.metadata.aid,
|
|
19
|
+
});
|
|
16
20
|
let telemetry;
|
|
17
21
|
try {
|
|
18
22
|
await this.verifyEntry();
|
|
@@ -46,7 +50,11 @@ class Interrupt extends activity_1.Activity {
|
|
|
46
50
|
}
|
|
47
51
|
finally {
|
|
48
52
|
telemetry?.endActivitySpan();
|
|
49
|
-
this.logger.debug('interrupt-process-end', {
|
|
53
|
+
this.logger.debug('interrupt-process-end', {
|
|
54
|
+
jid: this.context.metadata.jid,
|
|
55
|
+
gid: this.context.metadata.gid,
|
|
56
|
+
aid: this.metadata.aid,
|
|
57
|
+
});
|
|
50
58
|
}
|
|
51
59
|
}
|
|
52
60
|
async interruptSelf(telemetry) {
|
|
@@ -62,11 +70,11 @@ class Interrupt extends activity_1.Activity {
|
|
|
62
70
|
const multi = this.store.getMulti();
|
|
63
71
|
await collator_1.CollatorService.notarizeEarlyCompletion(this, multi);
|
|
64
72
|
await this.setStatus(-1, multi);
|
|
65
|
-
const multiResponse = await multi.exec();
|
|
73
|
+
const multiResponse = (await multi.exec());
|
|
66
74
|
const jobStatus = this.resolveStatus(multiResponse);
|
|
67
75
|
telemetry.setActivityAttributes({
|
|
68
76
|
'app.activity.mid': messageId,
|
|
69
|
-
'app.job.jss': jobStatus
|
|
77
|
+
'app.job.jss': jobStatus,
|
|
70
78
|
});
|
|
71
79
|
return this.context.metadata.aid;
|
|
72
80
|
}
|
|
@@ -87,7 +95,7 @@ class Interrupt extends activity_1.Activity {
|
|
|
87
95
|
const multi = this.store.getMulti();
|
|
88
96
|
await collator_1.CollatorService.notarizeEarlyCompletion(this, multi);
|
|
89
97
|
await this.setStatus(this.adjacencyList.length - 1, multi);
|
|
90
|
-
const multiResponse = await multi.exec();
|
|
98
|
+
const multiResponse = (await multi.exec());
|
|
91
99
|
const jobStatus = this.resolveStatus(multiResponse);
|
|
92
100
|
attrs['app.job.jss'] = jobStatus;
|
|
93
101
|
// Transition next generation and log
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Activity } from './activity';
|
|
2
1
|
import { EngineService } from '../engine';
|
|
3
2
|
import { ActivityData, ActivityMetadata, ActivityType, SignalActivity } from '../../types/activity';
|
|
4
3
|
import { JobState } from '../../types/job';
|
|
4
|
+
import { Activity } from './activity';
|
|
5
5
|
declare class Signal extends Activity {
|
|
6
6
|
config: SignalActivity;
|
|
7
7
|
constructor(config: ActivityType, data: ActivityData, metadata: ActivityMetadata, hook: ActivityData | null, engine: EngineService, context?: JobState);
|
|
@@ -2,18 +2,22 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Signal = void 0;
|
|
4
4
|
const errors_1 = require("../../modules/errors");
|
|
5
|
-
const activity_1 = require("./activity");
|
|
6
5
|
const collator_1 = require("../collator");
|
|
7
6
|
const mapper_1 = require("../mapper");
|
|
8
7
|
const pipe_1 = require("../pipe");
|
|
9
8
|
const telemetry_1 = require("../telemetry");
|
|
9
|
+
const activity_1 = require("./activity");
|
|
10
10
|
class Signal extends activity_1.Activity {
|
|
11
11
|
constructor(config, data, metadata, hook, engine, context) {
|
|
12
12
|
super(config, data, metadata, hook, engine, context);
|
|
13
13
|
}
|
|
14
14
|
//******** LEG 1 ENTRY ********//
|
|
15
15
|
async process() {
|
|
16
|
-
this.logger.debug('signal-process', {
|
|
16
|
+
this.logger.debug('signal-process', {
|
|
17
|
+
jid: this.context.metadata.jid,
|
|
18
|
+
gid: this.context.metadata.gid,
|
|
19
|
+
aid: this.metadata.aid,
|
|
20
|
+
});
|
|
17
21
|
let telemetry;
|
|
18
22
|
try {
|
|
19
23
|
await this.verifyEntry();
|
|
@@ -27,7 +31,7 @@ class Signal extends activity_1.Activity {
|
|
|
27
31
|
await this.setState(multi);
|
|
28
32
|
await collator_1.CollatorService.notarizeEarlyCompletion(this, multi);
|
|
29
33
|
await this.setStatus(this.adjacencyList.length - 1, multi);
|
|
30
|
-
const multiResponse = await multi.exec();
|
|
34
|
+
const multiResponse = (await multi.exec());
|
|
31
35
|
//todo: this should execute BEFORE the status is decremented
|
|
32
36
|
if (this.config.subtype === 'all') {
|
|
33
37
|
await this.hookAll();
|
|
@@ -67,7 +71,11 @@ class Signal extends activity_1.Activity {
|
|
|
67
71
|
}
|
|
68
72
|
finally {
|
|
69
73
|
telemetry?.endActivitySpan();
|
|
70
|
-
this.logger.debug('signal-process-end', {
|
|
74
|
+
this.logger.debug('signal-process-end', {
|
|
75
|
+
jid: this.context.metadata.jid,
|
|
76
|
+
gid: this.context.metadata.gid,
|
|
77
|
+
aid: this.metadata.aid,
|
|
78
|
+
});
|
|
71
79
|
}
|
|
72
80
|
}
|
|
73
81
|
mapSignalData() {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { Activity } from './activity';
|
|
2
1
|
import { EngineService } from '../engine';
|
|
3
2
|
import { ActivityData, ActivityMetadata, ActivityType, TriggerActivity } from '../../types/activity';
|
|
4
3
|
import { JobState, ExtensionType } from '../../types/job';
|
|
5
4
|
import { RedisMulti } from '../../types/redis';
|
|
5
|
+
import { Activity } from './activity';
|
|
6
6
|
declare class Trigger extends Activity {
|
|
7
7
|
config: TriggerActivity;
|
|
8
8
|
constructor(config: ActivityType, data: ActivityData, metadata: ActivityMetadata, hook: ActivityData | null, engine: EngineService, context?: JobState);
|
|
@@ -3,18 +3,20 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.Trigger = void 0;
|
|
4
4
|
const errors_1 = require("../../modules/errors");
|
|
5
5
|
const utils_1 = require("../../modules/utils");
|
|
6
|
-
const activity_1 = require("./activity");
|
|
7
6
|
const collator_1 = require("../collator");
|
|
8
7
|
const pipe_1 = require("../pipe");
|
|
9
8
|
const reporter_1 = require("../reporter");
|
|
10
9
|
const serializer_1 = require("../serializer");
|
|
11
10
|
const telemetry_1 = require("../telemetry");
|
|
11
|
+
const activity_1 = require("./activity");
|
|
12
12
|
class Trigger extends activity_1.Activity {
|
|
13
13
|
constructor(config, data, metadata, hook, engine, context) {
|
|
14
14
|
super(config, data, metadata, hook, engine, context);
|
|
15
15
|
}
|
|
16
16
|
async process(options) {
|
|
17
|
-
this.logger.debug('trigger-process', {
|
|
17
|
+
this.logger.debug('trigger-process', {
|
|
18
|
+
subscribes: this.config.subscribes,
|
|
19
|
+
});
|
|
18
20
|
let telemetry;
|
|
19
21
|
try {
|
|
20
22
|
this.setLeg(2);
|
|
@@ -60,7 +62,11 @@ class Trigger extends activity_1.Activity {
|
|
|
60
62
|
finally {
|
|
61
63
|
telemetry?.endJobSpan();
|
|
62
64
|
telemetry?.endActivitySpan();
|
|
63
|
-
this.logger.debug('trigger-process-end', {
|
|
65
|
+
this.logger.debug('trigger-process-end', {
|
|
66
|
+
subscribes: this.config.subscribes,
|
|
67
|
+
jid: this.context.metadata.jid,
|
|
68
|
+
gid: this.context.metadata.gid,
|
|
69
|
+
});
|
|
64
70
|
}
|
|
65
71
|
}
|
|
66
72
|
safeKey(key) {
|
|
@@ -94,7 +100,7 @@ class Trigger extends activity_1.Activity {
|
|
|
94
100
|
job_id: this.context.metadata.jid,
|
|
95
101
|
jc: timestamp,
|
|
96
102
|
ju: timestamp,
|
|
97
|
-
}
|
|
103
|
+
},
|
|
98
104
|
};
|
|
99
105
|
await this.engine.execAdjacentParent(this.context, jobStartedConfirmationMessage);
|
|
100
106
|
}
|
|
@@ -102,11 +108,11 @@ class Trigger extends activity_1.Activity {
|
|
|
102
108
|
createInputContext() {
|
|
103
109
|
const input = {
|
|
104
110
|
[this.metadata.aid]: {
|
|
105
|
-
input: { data: this.data }
|
|
111
|
+
input: { data: this.data },
|
|
106
112
|
},
|
|
107
|
-
|
|
113
|
+
$self: {
|
|
108
114
|
input: { data: this.data },
|
|
109
|
-
output: { data: this.data }
|
|
115
|
+
output: { data: this.data },
|
|
110
116
|
},
|
|
111
117
|
};
|
|
112
118
|
return input;
|
|
@@ -151,11 +157,11 @@ class Trigger extends activity_1.Activity {
|
|
|
151
157
|
[this.metadata.aid]: {
|
|
152
158
|
input: {
|
|
153
159
|
data: this.data,
|
|
154
|
-
metadata: activityMetadata
|
|
160
|
+
metadata: activityMetadata,
|
|
155
161
|
},
|
|
156
162
|
output: {
|
|
157
163
|
data: this.data,
|
|
158
|
-
metadata: activityMetadata
|
|
164
|
+
metadata: activityMetadata,
|
|
159
165
|
},
|
|
160
166
|
settings: { data: {} },
|
|
161
167
|
errors: { data: {} },
|
|
@@ -171,7 +177,7 @@ class Trigger extends activity_1.Activity {
|
|
|
171
177
|
return serializer_1.MDATA_SYMBOLS.ACTIVITY.KEYS.map((key) => `output/metadata/${key}`);
|
|
172
178
|
}
|
|
173
179
|
resolveGranularity() {
|
|
174
|
-
return this.config.stats?.granularity || reporter_1.ReporterService.DEFAULT_GRANULARITY;
|
|
180
|
+
return (this.config.stats?.granularity || reporter_1.ReporterService.DEFAULT_GRANULARITY);
|
|
175
181
|
}
|
|
176
182
|
getJobStatus() {
|
|
177
183
|
return this.context.metadata.js;
|
|
@@ -198,12 +204,13 @@ class Trigger extends activity_1.Activity {
|
|
|
198
204
|
const depKey = this.config.stats?.parent ?? this.context.metadata.pj;
|
|
199
205
|
let resolvedDepKey = depKey ? pipe_1.Pipe.resolve(depKey, this.context) : '';
|
|
200
206
|
const adjKey = this.config.stats?.adjacent;
|
|
201
|
-
|
|
207
|
+
const resolvedAdjKey = depKey ? pipe_1.Pipe.resolve(adjKey, this.context) : '';
|
|
202
208
|
if (!resolvedDepKey) {
|
|
203
209
|
resolvedDepKey = this.context.metadata.pj;
|
|
204
210
|
}
|
|
205
211
|
if (resolvedDepKey) {
|
|
206
|
-
const isParentOrigin =
|
|
212
|
+
const isParentOrigin = resolvedDepKey === this.context.metadata.pj ||
|
|
213
|
+
resolvedDepKey === resolvedAdjKey;
|
|
207
214
|
let type;
|
|
208
215
|
if (isParentOrigin) {
|
|
209
216
|
if (this.context.metadata.px) {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { Activity } from './activity';
|
|
2
1
|
import { EngineService } from '../engine';
|
|
3
2
|
import { ActivityData, ActivityMetadata, ActivityType, WorkerActivity } from '../../types/activity';
|
|
4
3
|
import { JobState } from '../../types/job';
|
|
5
4
|
import { RedisMulti } from '../../types/redis';
|
|
5
|
+
import { Activity } from './activity';
|
|
6
6
|
declare class Worker extends Activity {
|
|
7
7
|
config: WorkerActivity;
|
|
8
8
|
constructor(config: ActivityType, data: ActivityData, metadata: ActivityMetadata, hook: ActivityData | null, engine: EngineService, context?: JobState);
|
|
@@ -3,17 +3,21 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.Worker = void 0;
|
|
4
4
|
const errors_1 = require("../../modules/errors");
|
|
5
5
|
const utils_1 = require("../../modules/utils");
|
|
6
|
-
const activity_1 = require("./activity");
|
|
7
6
|
const collator_1 = require("../collator");
|
|
8
7
|
const pipe_1 = require("../pipe");
|
|
9
8
|
const telemetry_1 = require("../telemetry");
|
|
9
|
+
const activity_1 = require("./activity");
|
|
10
10
|
class Worker extends activity_1.Activity {
|
|
11
11
|
constructor(config, data, metadata, hook, engine, context) {
|
|
12
12
|
super(config, data, metadata, hook, engine, context);
|
|
13
13
|
}
|
|
14
14
|
//******** INITIAL ENTRY POINT (A) ********//
|
|
15
15
|
async process() {
|
|
16
|
-
this.logger.debug('worker-process', {
|
|
16
|
+
this.logger.debug('worker-process', {
|
|
17
|
+
jid: this.context.metadata.jid,
|
|
18
|
+
gid: this.context.metadata.gid,
|
|
19
|
+
aid: this.metadata.aid,
|
|
20
|
+
});
|
|
17
21
|
let telemetry;
|
|
18
22
|
try {
|
|
19
23
|
await this.verifyEntry();
|
|
@@ -27,13 +31,13 @@ class Worker extends activity_1.Activity {
|
|
|
27
31
|
await collator_1.CollatorService.authorizeReentry(this, multi);
|
|
28
32
|
await this.setState(multi);
|
|
29
33
|
await this.setStatus(0, multi);
|
|
30
|
-
const multiResponse = await multi.exec();
|
|
34
|
+
const multiResponse = (await multi.exec());
|
|
31
35
|
//telemetry
|
|
32
36
|
telemetry.mapActivityAttributes();
|
|
33
37
|
const jobStatus = this.resolveStatus(multiResponse);
|
|
34
38
|
telemetry.setActivityAttributes({
|
|
35
39
|
'app.activity.mid': messageId,
|
|
36
|
-
'app.job.jss': jobStatus
|
|
40
|
+
'app.job.jss': jobStatus,
|
|
37
41
|
});
|
|
38
42
|
return this.context.metadata.aid;
|
|
39
43
|
}
|
|
@@ -58,7 +62,11 @@ class Worker extends activity_1.Activity {
|
|
|
58
62
|
}
|
|
59
63
|
finally {
|
|
60
64
|
telemetry?.endActivitySpan();
|
|
61
|
-
this.logger.debug('worker-process-end', {
|
|
65
|
+
this.logger.debug('worker-process-end', {
|
|
66
|
+
jid: this.context.metadata.jid,
|
|
67
|
+
gid: this.context.metadata.gid,
|
|
68
|
+
aid: this.metadata.aid,
|
|
69
|
+
});
|
|
62
70
|
}
|
|
63
71
|
}
|
|
64
72
|
async execActivity(multi) {
|
|
@@ -74,11 +82,11 @@ class Worker extends activity_1.Activity {
|
|
|
74
82
|
spn: this.context['$self'].output.metadata.l1s,
|
|
75
83
|
trc: this.context.metadata.trc,
|
|
76
84
|
},
|
|
77
|
-
data: this.context.data
|
|
85
|
+
data: this.context.data,
|
|
78
86
|
};
|
|
79
87
|
if (this.config.retry) {
|
|
80
88
|
streamData.policies = {
|
|
81
|
-
retry: this.config.retry
|
|
89
|
+
retry: this.config.retry,
|
|
82
90
|
};
|
|
83
91
|
}
|
|
84
92
|
return (await this.engine.router?.publishMessage(topic, streamData, multi));
|
|
@@ -48,7 +48,6 @@ class CollatorService {
|
|
|
48
48
|
this.verifyInteger(amount, 1, 'enter');
|
|
49
49
|
return amount;
|
|
50
50
|
}
|
|
51
|
-
;
|
|
52
51
|
static async authorizeReentry(activity, multi) {
|
|
53
52
|
//set second digit to 8, allowing for re-entry
|
|
54
53
|
//decrement by -10_000_000_000_000
|
|
@@ -59,14 +58,14 @@ class CollatorService {
|
|
|
59
58
|
//decrement the 2nd and 3rd digits to fully deactivate (`cycle` activities use this command to fully exit after leg 1) (should result in `888000000000000`)
|
|
60
59
|
return await activity.store.collate(activity.context.metadata.jid, activity.metadata.aid, -11000000000000, this.getDimensionalAddress(activity), multi);
|
|
61
60
|
}
|
|
62
|
-
;
|
|
63
61
|
static async notarizeEarlyCompletion(activity, multi) {
|
|
64
62
|
//initialize both `possible` (1m) and `actualized` (1) zero dimension, while decrementing the 2nd
|
|
65
63
|
//3rd digit is optionally kept open if the activity might be used in a cycle
|
|
66
|
-
const decrement = activity.config.cycle
|
|
64
|
+
const decrement = activity.config.cycle
|
|
65
|
+
? 10000000000000
|
|
66
|
+
: 11000000000000;
|
|
67
67
|
return await activity.store.collate(activity.context.metadata.jid, activity.metadata.aid, 1000001 - decrement, this.getDimensionalAddress(activity), multi);
|
|
68
68
|
}
|
|
69
|
-
;
|
|
70
69
|
/**
|
|
71
70
|
* verifies both the concrete and synthetic keys for the activity; concrete keys
|
|
72
71
|
* exist in the original model and are effectively the 'real' keys. In reality,
|
|
@@ -84,25 +83,26 @@ class CollatorService {
|
|
|
84
83
|
await activity.store.collate(jid, activity.metadata.aid, 1000000, this.getDimensionalAddress(activity, true), localMulti);
|
|
85
84
|
await activity.store.collateSynthetic(jid, guid, 1000000, localMulti);
|
|
86
85
|
const [_amountConcrete, _amountSynthetic] = await localMulti.exec();
|
|
87
|
-
const amountConcrete = Array.isArray(_amountConcrete)
|
|
88
|
-
|
|
86
|
+
const amountConcrete = Array.isArray(_amountConcrete)
|
|
87
|
+
? _amountConcrete[1]
|
|
88
|
+
: _amountConcrete;
|
|
89
|
+
const amountSynthetic = Array.isArray(_amountSynthetic)
|
|
90
|
+
? _amountSynthetic[1]
|
|
91
|
+
: _amountSynthetic;
|
|
89
92
|
this.verifyInteger(amountConcrete, 2, 'enter');
|
|
90
93
|
this.verifySyntheticInteger(amountSynthetic);
|
|
91
94
|
return amountConcrete;
|
|
92
95
|
}
|
|
93
|
-
;
|
|
94
96
|
static async notarizeContinuation(activity, multi) {
|
|
95
97
|
//keep open; actualize the leg2 dimension (+1)
|
|
96
98
|
return await activity.store.collate(activity.context.metadata.jid, activity.metadata.aid, 1, this.getDimensionalAddress(activity), multi);
|
|
97
99
|
}
|
|
98
|
-
;
|
|
99
100
|
static async notarizeCompletion(activity, multi) {
|
|
100
101
|
//1) ALWAYS actualize leg2 dimension (+1)
|
|
101
102
|
//2) IF the activity is used in a cycle, don't close leg 2!
|
|
102
103
|
const decrement = activity.config.cycle ? 0 : 1000000000000;
|
|
103
104
|
return await activity.store.collate(activity.context.metadata.jid, activity.metadata.aid, 1 - decrement, this.getDimensionalAddress(activity), multi);
|
|
104
105
|
}
|
|
105
|
-
;
|
|
106
106
|
static getDigitAtIndex(num, targetDigitIndex) {
|
|
107
107
|
const numStr = num.toString();
|
|
108
108
|
if (targetDigitIndex < 0 || targetDigitIndex >= numStr.length) {
|
|
@@ -132,8 +132,8 @@ class CollatorService {
|
|
|
132
132
|
return amount != -100000000000000;
|
|
133
133
|
}
|
|
134
134
|
else {
|
|
135
|
-
return this.getDigitAtIndex(amount, 0) < 9 &&
|
|
136
|
-
this.getDigitAtIndex(amount, 1) < 9;
|
|
135
|
+
return (this.getDigitAtIndex(amount, 0) < 9 &&
|
|
136
|
+
this.getDigitAtIndex(amount, 1) < 9);
|
|
137
137
|
}
|
|
138
138
|
}
|
|
139
139
|
/**
|
|
@@ -195,7 +195,7 @@ class CollatorService {
|
|
|
195
195
|
//loop through the ancestors list and create a map of the ancestor to the dimensional address.
|
|
196
196
|
//return { 't1': ',0', 'a1': ',0,5', 'a1': ',0,5,3', $ADJACENT: ',0,5,3,0' };
|
|
197
197
|
// `adjacent` is a special key that is used to track the dimensional address of adjacent activities
|
|
198
|
-
const map = {
|
|
198
|
+
const map = { $ADJACENT: `${dad},0` };
|
|
199
199
|
let dadStr = dad;
|
|
200
200
|
ancestors.reverse().forEach((ancestor) => {
|
|
201
201
|
map[ancestor] = dadStr;
|