@hotmeshio/hotmesh 0.0.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/LICENSE +214 -0
- package/README.md +241 -0
- package/build/index.d.ts +4 -0
- package/build/index.js +7 -0
- package/build/modules/errors.d.ts +28 -0
- package/build/modules/errors.js +50 -0
- package/build/modules/key.d.ts +75 -0
- package/build/modules/key.js +116 -0
- package/build/modules/utils.d.ts +34 -0
- package/build/modules/utils.js +173 -0
- package/build/package.json +73 -0
- package/build/services/activities/activity.d.ts +59 -0
- package/build/services/activities/activity.js +396 -0
- package/build/services/activities/await.d.ts +16 -0
- package/build/services/activities/await.js +143 -0
- package/build/services/activities/emit.d.ts +9 -0
- package/build/services/activities/emit.js +13 -0
- package/build/services/activities/index.d.ts +15 -0
- package/build/services/activities/index.js +16 -0
- package/build/services/activities/iterate.d.ts +9 -0
- package/build/services/activities/iterate.js +13 -0
- package/build/services/activities/trigger.d.ts +22 -0
- package/build/services/activities/trigger.js +161 -0
- package/build/services/activities/worker.d.ts +17 -0
- package/build/services/activities/worker.js +164 -0
- package/build/services/collator/index.d.ts +54 -0
- package/build/services/collator/index.js +171 -0
- package/build/services/compiler/deployer.d.ts +35 -0
- package/build/services/compiler/deployer.js +412 -0
- package/build/services/compiler/index.d.ts +30 -0
- package/build/services/compiler/index.js +111 -0
- package/build/services/compiler/validator.d.ts +32 -0
- package/build/services/compiler/validator.js +134 -0
- package/build/services/connector/clients/ioredis.d.ts +13 -0
- package/build/services/connector/clients/ioredis.js +50 -0
- package/build/services/connector/clients/redis.d.ts +13 -0
- package/build/services/connector/clients/redis.js +62 -0
- package/build/services/connector/index.d.ts +5 -0
- package/build/services/connector/index.js +31 -0
- package/build/services/dimension/index.d.ts +29 -0
- package/build/services/dimension/index.js +35 -0
- package/build/services/durable/asyncLocalStorage.d.ts +3 -0
- package/build/services/durable/asyncLocalStorage.js +5 -0
- package/build/services/durable/client.d.ts +15 -0
- package/build/services/durable/client.js +108 -0
- package/build/services/durable/connection.d.ts +4 -0
- package/build/services/durable/connection.js +51 -0
- package/build/services/durable/factory.d.ts +3 -0
- package/build/services/durable/factory.js +123 -0
- package/build/services/durable/handle.d.ts +8 -0
- package/build/services/durable/handle.js +38 -0
- package/build/services/durable/index.d.ts +57 -0
- package/build/services/durable/index.js +58 -0
- package/build/services/durable/native.d.ts +4 -0
- package/build/services/durable/native.js +47 -0
- package/build/services/durable/worker.d.ts +36 -0
- package/build/services/durable/worker.js +266 -0
- package/build/services/durable/workflow.d.ts +6 -0
- package/build/services/durable/workflow.js +135 -0
- package/build/services/engine/index.d.ts +82 -0
- package/build/services/engine/index.js +511 -0
- package/build/services/hotmesh/index.d.ts +45 -0
- package/build/services/hotmesh/index.js +134 -0
- package/build/services/logger/index.d.ts +17 -0
- package/build/services/logger/index.js +73 -0
- package/build/services/mapper/index.d.ts +24 -0
- package/build/services/mapper/index.js +72 -0
- package/build/services/pipe/functions/array.d.ts +24 -0
- package/build/services/pipe/functions/array.js +69 -0
- package/build/services/pipe/functions/bitwise.d.ts +9 -0
- package/build/services/pipe/functions/bitwise.js +24 -0
- package/build/services/pipe/functions/conditional.d.ts +10 -0
- package/build/services/pipe/functions/conditional.js +27 -0
- package/build/services/pipe/functions/date.d.ts +57 -0
- package/build/services/pipe/functions/date.js +167 -0
- package/build/services/pipe/functions/index.d.ts +25 -0
- package/build/services/pipe/functions/index.js +26 -0
- package/build/services/pipe/functions/json.d.ts +5 -0
- package/build/services/pipe/functions/json.js +12 -0
- package/build/services/pipe/functions/math.d.ts +38 -0
- package/build/services/pipe/functions/math.js +111 -0
- package/build/services/pipe/functions/number.d.ts +25 -0
- package/build/services/pipe/functions/number.js +133 -0
- package/build/services/pipe/functions/object.d.ts +22 -0
- package/build/services/pipe/functions/object.js +63 -0
- package/build/services/pipe/functions/string.d.ts +23 -0
- package/build/services/pipe/functions/string.js +69 -0
- package/build/services/pipe/functions/symbol.d.ts +12 -0
- package/build/services/pipe/functions/symbol.js +33 -0
- package/build/services/pipe/functions/unary.d.ts +7 -0
- package/build/services/pipe/functions/unary.js +18 -0
- package/build/services/pipe/index.d.ts +30 -0
- package/build/services/pipe/index.js +128 -0
- package/build/services/quorum/index.d.ts +34 -0
- package/build/services/quorum/index.js +147 -0
- package/build/services/reporter/index.d.ts +47 -0
- package/build/services/reporter/index.js +330 -0
- package/build/services/serializer/index.d.ts +36 -0
- package/build/services/serializer/index.js +222 -0
- package/build/services/signaler/store.d.ts +15 -0
- package/build/services/signaler/store.js +53 -0
- package/build/services/signaler/stream.d.ts +43 -0
- package/build/services/signaler/stream.js +317 -0
- package/build/services/store/cache.d.ts +66 -0
- package/build/services/store/cache.js +127 -0
- package/build/services/store/clients/ioredis.d.ts +27 -0
- package/build/services/store/clients/ioredis.js +96 -0
- package/build/services/store/clients/redis.d.ts +29 -0
- package/build/services/store/clients/redis.js +143 -0
- package/build/services/store/index.d.ts +88 -0
- package/build/services/store/index.js +657 -0
- package/build/services/stream/clients/ioredis.d.ts +23 -0
- package/build/services/stream/clients/ioredis.js +115 -0
- package/build/services/stream/clients/redis.d.ts +23 -0
- package/build/services/stream/clients/redis.js +119 -0
- package/build/services/stream/index.d.ts +21 -0
- package/build/services/stream/index.js +9 -0
- package/build/services/sub/clients/ioredis.d.ts +20 -0
- package/build/services/sub/clients/ioredis.js +72 -0
- package/build/services/sub/clients/redis.d.ts +20 -0
- package/build/services/sub/clients/redis.js +63 -0
- package/build/services/sub/index.d.ts +18 -0
- package/build/services/sub/index.js +9 -0
- package/build/services/task/index.d.ts +18 -0
- package/build/services/task/index.js +73 -0
- package/build/services/telemetry/index.d.ts +49 -0
- package/build/services/telemetry/index.js +223 -0
- package/build/services/worker/index.d.ts +30 -0
- package/build/services/worker/index.js +105 -0
- package/build/types/activity.d.ts +86 -0
- package/build/types/activity.js +2 -0
- package/build/types/app.d.ts +16 -0
- package/build/types/app.js +2 -0
- package/build/types/async.d.ts +5 -0
- package/build/types/async.js +2 -0
- package/build/types/cache.d.ts +1 -0
- package/build/types/cache.js +2 -0
- package/build/types/collator.d.ts +8 -0
- package/build/types/collator.js +11 -0
- package/build/types/durable.d.ts +59 -0
- package/build/types/durable.js +2 -0
- package/build/types/hook.d.ts +31 -0
- package/build/types/hook.js +9 -0
- package/build/types/hotmesh.d.ts +82 -0
- package/build/types/hotmesh.js +2 -0
- package/build/types/index.d.ts +20 -0
- package/build/types/index.js +21 -0
- package/build/types/ioredisclient.d.ts +5 -0
- package/build/types/ioredisclient.js +5 -0
- package/build/types/job.d.ts +50 -0
- package/build/types/job.js +2 -0
- package/build/types/logger.d.ts +6 -0
- package/build/types/logger.js +2 -0
- package/build/types/map.d.ts +4 -0
- package/build/types/map.js +2 -0
- package/build/types/pipe.d.ts +4 -0
- package/build/types/pipe.js +2 -0
- package/build/types/quorum.d.ts +46 -0
- package/build/types/quorum.js +2 -0
- package/build/types/redis.d.ts +8 -0
- package/build/types/redis.js +2 -0
- package/build/types/redisclient.d.ts +25 -0
- package/build/types/redisclient.js +2 -0
- package/build/types/serializer.d.ts +33 -0
- package/build/types/serializer.js +2 -0
- package/build/types/stats.d.ts +83 -0
- package/build/types/stats.js +2 -0
- package/build/types/stream.d.ts +67 -0
- package/build/types/stream.js +25 -0
- package/build/types/telemetry.d.ts +1 -0
- package/build/types/telemetry.js +11 -0
- package/build/types/transition.d.ts +17 -0
- package/build/types/transition.js +2 -0
- package/index.ts +5 -0
- package/modules/errors.ts +55 -0
- package/modules/key.ts +129 -0
- package/modules/utils.ts +170 -0
- package/package.json +73 -0
- package/services/activities/activity.ts +473 -0
- package/services/activities/await.ts +172 -0
- package/services/activities/emit.ts +25 -0
- package/services/activities/index.ts +15 -0
- package/services/activities/iterate.ts +26 -0
- package/services/activities/trigger.ts +196 -0
- package/services/activities/worker.ts +190 -0
- package/services/collator/README.md +102 -0
- package/services/collator/index.ts +182 -0
- package/services/compiler/deployer.ts +432 -0
- package/services/compiler/index.ts +98 -0
- package/services/compiler/validator.ts +154 -0
- package/services/connector/clients/ioredis.ts +57 -0
- package/services/connector/clients/redis.ts +72 -0
- package/services/connector/index.ts +44 -0
- package/services/dimension/README.md +73 -0
- package/services/dimension/index.ts +39 -0
- package/services/durable/asyncLocalStorage.ts +3 -0
- package/services/durable/client.ts +116 -0
- package/services/durable/connection.ts +50 -0
- package/services/durable/factory.ts +124 -0
- package/services/durable/handle.ts +43 -0
- package/services/durable/index.ts +60 -0
- package/services/durable/native.ts +46 -0
- package/services/durable/worker.ts +254 -0
- package/services/durable/workflow.ts +136 -0
- package/services/engine/index.ts +615 -0
- package/services/hotmesh/index.ts +182 -0
- package/services/logger/index.ts +79 -0
- package/services/mapper/index.ts +84 -0
- package/services/pipe/functions/array.ts +87 -0
- package/services/pipe/functions/bitwise.ts +27 -0
- package/services/pipe/functions/conditional.ts +31 -0
- package/services/pipe/functions/date.ts +214 -0
- package/services/pipe/functions/index.ts +25 -0
- package/services/pipe/functions/json.ts +11 -0
- package/services/pipe/functions/math.ts +143 -0
- package/services/pipe/functions/number.ts +150 -0
- package/services/pipe/functions/object.ts +79 -0
- package/services/pipe/functions/string.ts +86 -0
- package/services/pipe/functions/symbol.ts +39 -0
- package/services/pipe/functions/unary.ts +19 -0
- package/services/pipe/index.ts +138 -0
- package/services/quorum/index.ts +200 -0
- package/services/reporter/index.ts +379 -0
- package/services/serializer/README.md +10 -0
- package/services/serializer/index.ts +243 -0
- package/services/signaler/store.ts +61 -0
- package/services/signaler/stream.ts +354 -0
- package/services/store/cache.ts +172 -0
- package/services/store/clients/ioredis.ts +123 -0
- package/services/store/clients/redis.ts +169 -0
- package/services/store/index.ts +757 -0
- package/services/stream/clients/ioredis.ts +148 -0
- package/services/stream/clients/redis.ts +144 -0
- package/services/stream/index.ts +57 -0
- package/services/sub/clients/ioredis.ts +83 -0
- package/services/sub/clients/redis.ts +74 -0
- package/services/sub/index.ts +25 -0
- package/services/task/index.ts +86 -0
- package/services/telemetry/index.ts +267 -0
- package/services/worker/index.ts +165 -0
- package/types/activity.ts +115 -0
- package/types/app.ts +20 -0
- package/types/async.ts +7 -0
- package/types/cache.ts +1 -0
- package/types/collator.ts +9 -0
- package/types/durable.ts +81 -0
- package/types/hook.ts +32 -0
- package/types/hotmesh.ts +102 -0
- package/types/index.ts +138 -0
- package/types/ioredisclient.ts +10 -0
- package/types/job.ts +59 -0
- package/types/logger.ts +6 -0
- package/types/map.ts +5 -0
- package/types/ms.d.ts +7 -0
- package/types/pipe.ts +7 -0
- package/types/quorum.ts +59 -0
- package/types/redis.ts +27 -0
- package/types/redisclient.ts +29 -0
- package/types/serializer.ts +38 -0
- package/types/stats.ts +100 -0
- package/types/stream.ts +75 -0
- package/types/telemetry.ts +15 -0
- package/types/transition.ts +20 -0
|
@@ -0,0 +1,396 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Activity = void 0;
|
|
4
|
+
const errors_1 = require("../../modules/errors");
|
|
5
|
+
const utils_1 = require("../../modules/utils");
|
|
6
|
+
const collator_1 = require("../collator");
|
|
7
|
+
const dimension_1 = require("../dimension");
|
|
8
|
+
const mapper_1 = require("../mapper");
|
|
9
|
+
const pipe_1 = require("../pipe");
|
|
10
|
+
const serializer_1 = require("../serializer");
|
|
11
|
+
const store_1 = require("../signaler/store");
|
|
12
|
+
const telemetry_1 = require("../telemetry");
|
|
13
|
+
const stream_1 = require("../../types/stream");
|
|
14
|
+
/**
|
|
15
|
+
* The base class for all activities
|
|
16
|
+
*/
|
|
17
|
+
class Activity {
|
|
18
|
+
constructor(config, data, metadata, hook, engine, context) {
|
|
19
|
+
this.status = stream_1.StreamStatus.SUCCESS;
|
|
20
|
+
this.code = 200;
|
|
21
|
+
this.adjacentIndex = 0; //can be updated by leg2 using 'as' metadata hincrby output
|
|
22
|
+
this.config = config;
|
|
23
|
+
this.data = data;
|
|
24
|
+
this.metadata = metadata;
|
|
25
|
+
this.hook = hook;
|
|
26
|
+
this.engine = engine;
|
|
27
|
+
this.context = context || { data: {}, metadata: {} };
|
|
28
|
+
this.logger = engine.logger;
|
|
29
|
+
this.store = engine.store;
|
|
30
|
+
}
|
|
31
|
+
//******** INITIAL ENTRY POINT (A) ********//
|
|
32
|
+
async process() {
|
|
33
|
+
this.logger.debug('activity-process', { jid: this.context.metadata.jid, aid: this.metadata.aid });
|
|
34
|
+
let telemetry;
|
|
35
|
+
try {
|
|
36
|
+
this.setLeg(1);
|
|
37
|
+
await collator_1.CollatorService.notarizeEntry(this);
|
|
38
|
+
await this.getState();
|
|
39
|
+
telemetry = new telemetry_1.TelemetryService(this.engine.appId, this.config, this.metadata, this.context);
|
|
40
|
+
telemetry.startActivitySpan(this.leg);
|
|
41
|
+
let multiResponse;
|
|
42
|
+
const multi = this.store.getMulti();
|
|
43
|
+
if (this.doesHook()) {
|
|
44
|
+
//sleep and wait to awaken upon a signal
|
|
45
|
+
await this.registerHook(multi);
|
|
46
|
+
this.mapJobData();
|
|
47
|
+
await this.setState(multi);
|
|
48
|
+
await collator_1.CollatorService.authorizeReentry(this, multi);
|
|
49
|
+
await this.setStatus(0, multi);
|
|
50
|
+
await multi.exec();
|
|
51
|
+
telemetry.mapActivityAttributes();
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
//end the activity and transition to its children
|
|
55
|
+
this.adjacencyList = await this.filterAdjacent();
|
|
56
|
+
this.mapJobData();
|
|
57
|
+
await this.setState(multi);
|
|
58
|
+
await collator_1.CollatorService.notarizeEarlyCompletion(this, multi);
|
|
59
|
+
await this.setStatus(this.adjacencyList.length - 1, multi);
|
|
60
|
+
multiResponse = await multi.exec();
|
|
61
|
+
telemetry.mapActivityAttributes();
|
|
62
|
+
const jobStatus = this.resolveStatus(multiResponse);
|
|
63
|
+
const attrs = { 'app.job.jss': jobStatus };
|
|
64
|
+
const messageIds = await this.transition(this.adjacencyList, jobStatus);
|
|
65
|
+
if (messageIds.length) {
|
|
66
|
+
attrs['app.activity.mids'] = messageIds.join(',');
|
|
67
|
+
}
|
|
68
|
+
telemetry.setActivityAttributes(attrs);
|
|
69
|
+
}
|
|
70
|
+
return this.context.metadata.aid;
|
|
71
|
+
}
|
|
72
|
+
catch (error) {
|
|
73
|
+
if (error instanceof errors_1.GetStateError) {
|
|
74
|
+
this.logger.error('activity-get-state-error', error);
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
this.logger.error('activity-process-error', error);
|
|
78
|
+
}
|
|
79
|
+
telemetry.setActivityError(error.message);
|
|
80
|
+
throw error;
|
|
81
|
+
}
|
|
82
|
+
finally {
|
|
83
|
+
telemetry.endActivitySpan();
|
|
84
|
+
this.logger.debug('activity-process-end', { jid: this.context.metadata.jid, aid: this.metadata.aid });
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
setLeg(leg) {
|
|
88
|
+
this.leg = leg;
|
|
89
|
+
}
|
|
90
|
+
//******** SIGNALER RE-ENTRY POINT (B) ********//
|
|
91
|
+
doesHook() {
|
|
92
|
+
return !!(this.config.hook?.topic || this.config.sleep);
|
|
93
|
+
}
|
|
94
|
+
async registerHook(multi) {
|
|
95
|
+
if (this.config.hook?.topic) {
|
|
96
|
+
const signaler = new store_1.StoreSignaler(this.store, this.logger);
|
|
97
|
+
return await signaler.registerWebHook(this.config.hook.topic, this.context, multi);
|
|
98
|
+
}
|
|
99
|
+
else if (this.config.sleep) {
|
|
100
|
+
const durationInSeconds = pipe_1.Pipe.resolve(this.config.sleep, this.context);
|
|
101
|
+
const jobId = this.context.metadata.jid;
|
|
102
|
+
const activityId = this.metadata.aid;
|
|
103
|
+
await this.engine.task.registerTimeHook(jobId, activityId, 'sleep', durationInSeconds);
|
|
104
|
+
return jobId;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
async processWebHookEvent() {
|
|
108
|
+
this.logger.debug('engine-process-web-hook-event', {
|
|
109
|
+
topic: this.config.hook.topic,
|
|
110
|
+
aid: this.metadata.aid
|
|
111
|
+
});
|
|
112
|
+
const signaler = new store_1.StoreSignaler(this.store, this.logger);
|
|
113
|
+
const data = { ...this.data };
|
|
114
|
+
const jobId = await signaler.processWebHookSignal(this.config.hook.topic, data);
|
|
115
|
+
if (jobId) {
|
|
116
|
+
await this.processHookEvent(jobId);
|
|
117
|
+
await signaler.deleteWebHookSignal(this.config.hook.topic, data);
|
|
118
|
+
} //else => already resolved
|
|
119
|
+
}
|
|
120
|
+
async processTimeHookEvent(jobId) {
|
|
121
|
+
this.logger.debug('engine-process-time-hook-event', {
|
|
122
|
+
jid: jobId,
|
|
123
|
+
aid: this.metadata.aid
|
|
124
|
+
});
|
|
125
|
+
return await this.processHookEvent(jobId);
|
|
126
|
+
}
|
|
127
|
+
//todo: hooks are currently singletons. but they can support
|
|
128
|
+
// dimensional threads like `await` and `worker` do.
|
|
129
|
+
// Copy code from those activities to support cyclical
|
|
130
|
+
// timehook and eventhook inputs by adding a 'pending'
|
|
131
|
+
// flag to hooks that allows for repeated signals
|
|
132
|
+
async processHookEvent(jobId) {
|
|
133
|
+
this.logger.debug('activity-process-hook-event', { jobId });
|
|
134
|
+
let telemetry;
|
|
135
|
+
try {
|
|
136
|
+
this.setLeg(2);
|
|
137
|
+
await this.getState(jobId);
|
|
138
|
+
const aState = await collator_1.CollatorService.notarizeReentry(this);
|
|
139
|
+
this.adjacentIndex = collator_1.CollatorService.getDimensionalIndex(aState);
|
|
140
|
+
telemetry = new telemetry_1.TelemetryService(this.engine.appId, this.config, this.metadata, this.context);
|
|
141
|
+
telemetry.startActivitySpan(this.leg);
|
|
142
|
+
this.bindActivityData('hook');
|
|
143
|
+
this.mapJobData();
|
|
144
|
+
this.adjacencyList = await this.filterAdjacent();
|
|
145
|
+
const multi = this.engine.store.getMulti();
|
|
146
|
+
await this.setState(multi);
|
|
147
|
+
await collator_1.CollatorService.notarizeCompletion(this, multi);
|
|
148
|
+
await this.setStatus(this.adjacencyList.length - 1, multi);
|
|
149
|
+
const multiResponse = await multi.exec();
|
|
150
|
+
telemetry.mapActivityAttributes();
|
|
151
|
+
const jobStatus = this.resolveStatus(multiResponse);
|
|
152
|
+
const attrs = { 'app.job.jss': jobStatus };
|
|
153
|
+
const messageIds = await this.transition(this.adjacencyList, jobStatus);
|
|
154
|
+
if (messageIds.length) {
|
|
155
|
+
attrs['app.activity.mids'] = messageIds.join(',');
|
|
156
|
+
}
|
|
157
|
+
telemetry.setActivityAttributes(attrs);
|
|
158
|
+
return jobStatus;
|
|
159
|
+
}
|
|
160
|
+
catch (error) {
|
|
161
|
+
this.logger.error('engine-process-hook-event-error', error);
|
|
162
|
+
telemetry.setActivityError(error.message);
|
|
163
|
+
throw error;
|
|
164
|
+
}
|
|
165
|
+
finally {
|
|
166
|
+
telemetry.endActivitySpan();
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
resolveStatus(multiResponse) {
|
|
170
|
+
const activityStatus = multiResponse[multiResponse.length - 1];
|
|
171
|
+
if (Array.isArray(activityStatus)) {
|
|
172
|
+
return Number(activityStatus[1]);
|
|
173
|
+
}
|
|
174
|
+
else {
|
|
175
|
+
return Number(activityStatus);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
mapJobData() {
|
|
179
|
+
if (this.config.job?.maps) {
|
|
180
|
+
const mapper = new mapper_1.MapperService(this.config.job.maps, this.context);
|
|
181
|
+
this.context.data = mapper.mapRules();
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
mapInputData() {
|
|
185
|
+
if (this.config.input?.maps) {
|
|
186
|
+
const mapper = new mapper_1.MapperService(this.config.input.maps, this.context);
|
|
187
|
+
this.context.data = mapper.mapRules();
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
async registerTimeout() {
|
|
191
|
+
//set timeout in support of hook and/or duplex
|
|
192
|
+
}
|
|
193
|
+
bindActivityError(data) {
|
|
194
|
+
//todo: map activity error data into the job error (if defined)
|
|
195
|
+
// map job status via: (500: [3**, 4**, 5**], 202: [$pending])
|
|
196
|
+
this.context.metadata.err = JSON.stringify(data);
|
|
197
|
+
}
|
|
198
|
+
async getTriggerConfig() {
|
|
199
|
+
return await this.store.getSchema(this.config.trigger, await this.engine.getVID());
|
|
200
|
+
}
|
|
201
|
+
getJobStatus() {
|
|
202
|
+
return null;
|
|
203
|
+
}
|
|
204
|
+
async setStatus(amount, multi) {
|
|
205
|
+
const { id: appId } = await this.engine.getVID();
|
|
206
|
+
await this.store.setStatus(amount, this.context.metadata.jid, appId, multi);
|
|
207
|
+
}
|
|
208
|
+
authorizeEntry(state) {
|
|
209
|
+
//pre-authorize activity state to allow entry for adjacent activities
|
|
210
|
+
return this.adjacencyList?.map((streamData) => {
|
|
211
|
+
const { metadata: { aid } } = streamData;
|
|
212
|
+
state[`${aid}/output/metadata/as`] = collator_1.CollatorService.getSeed();
|
|
213
|
+
return aid;
|
|
214
|
+
}) ?? [];
|
|
215
|
+
}
|
|
216
|
+
bindDimensionalAddress(state) {
|
|
217
|
+
const { aid, dad } = this.metadata;
|
|
218
|
+
state[`${aid}/output/metadata/dad`] = dad;
|
|
219
|
+
}
|
|
220
|
+
async setState(multi) {
|
|
221
|
+
const { id: appId } = await this.engine.getVID();
|
|
222
|
+
const jobId = this.context.metadata.jid;
|
|
223
|
+
this.bindJobMetadata();
|
|
224
|
+
this.bindActivityMetadata();
|
|
225
|
+
let state = {};
|
|
226
|
+
await this.bindJobState(state);
|
|
227
|
+
const presets = this.authorizeEntry(state);
|
|
228
|
+
this.bindDimensionalAddress(state);
|
|
229
|
+
this.bindActivityState(state);
|
|
230
|
+
//symbolNames holds symkeys
|
|
231
|
+
const symbolNames = [
|
|
232
|
+
`$${this.config.subscribes}`,
|
|
233
|
+
this.metadata.aid,
|
|
234
|
+
...presets
|
|
235
|
+
];
|
|
236
|
+
return await this.store.setState(state, this.getJobStatus(), jobId, appId, symbolNames, multi);
|
|
237
|
+
}
|
|
238
|
+
bindJobMetadata() {
|
|
239
|
+
//both legs of the most recently run activity (1 and 2) modify ju (job_updated)
|
|
240
|
+
this.context.metadata.ju = (0, utils_1.formatISODate)(new Date());
|
|
241
|
+
}
|
|
242
|
+
bindActivityMetadata() {
|
|
243
|
+
const self = this.context['$self'];
|
|
244
|
+
if (!self.output.metadata) {
|
|
245
|
+
self.output.metadata = {};
|
|
246
|
+
}
|
|
247
|
+
if (this.status === stream_1.StreamStatus.ERROR) {
|
|
248
|
+
self.output.metadata.err = JSON.stringify(this.data);
|
|
249
|
+
}
|
|
250
|
+
self.output.metadata.ac =
|
|
251
|
+
self.output.metadata.au = (0, utils_1.formatISODate)(new Date());
|
|
252
|
+
self.output.metadata.atp = this.config.type;
|
|
253
|
+
if (this.config.subtype) {
|
|
254
|
+
self.output.metadata.stp = this.config.subtype;
|
|
255
|
+
}
|
|
256
|
+
self.output.metadata.aid = this.metadata.aid;
|
|
257
|
+
}
|
|
258
|
+
async bindJobState(state) {
|
|
259
|
+
const triggerConfig = await this.getTriggerConfig();
|
|
260
|
+
const PRODUCES = [
|
|
261
|
+
...(triggerConfig.PRODUCES || []),
|
|
262
|
+
...this.bindJobMetadataPaths()
|
|
263
|
+
];
|
|
264
|
+
for (const path of PRODUCES) {
|
|
265
|
+
const value = (0, utils_1.getValueByPath)(this.context, path);
|
|
266
|
+
if (value !== undefined) {
|
|
267
|
+
state[path] = value;
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
telemetry_1.TelemetryService.bindJobTelemetryToState(state, this.config, this.context);
|
|
271
|
+
}
|
|
272
|
+
bindActivityState(state) {
|
|
273
|
+
const produces = [
|
|
274
|
+
...this.config.produces,
|
|
275
|
+
...this.bindActivityMetadataPaths()
|
|
276
|
+
];
|
|
277
|
+
for (const path of produces) {
|
|
278
|
+
const prefixedPath = `${this.metadata.aid}/${path}`;
|
|
279
|
+
const value = (0, utils_1.getValueByPath)(this.context, prefixedPath);
|
|
280
|
+
if (value !== undefined) {
|
|
281
|
+
state[prefixedPath] = value;
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
telemetry_1.TelemetryService.bindActivityTelemetryToState(state, this.config, this.metadata, this.context, this.leg);
|
|
285
|
+
}
|
|
286
|
+
bindJobMetadataPaths() {
|
|
287
|
+
return serializer_1.MDATA_SYMBOLS.JOB_UPDATE.KEYS.map((key) => `metadata/${key}`);
|
|
288
|
+
}
|
|
289
|
+
bindActivityMetadataPaths() {
|
|
290
|
+
const keys_to_save = this.leg === 1 ? 'ACTIVITY' : 'ACTIVITY_UPDATE';
|
|
291
|
+
return serializer_1.MDATA_SYMBOLS[keys_to_save].KEYS.map((key) => `output/metadata/${key}`);
|
|
292
|
+
}
|
|
293
|
+
async getState(jobId) {
|
|
294
|
+
//assemble list of paths necessary to create 'job state' from the 'symbol hash'
|
|
295
|
+
const jobSymbolHashName = `$${this.config.subscribes}`;
|
|
296
|
+
const consumes = {
|
|
297
|
+
[jobSymbolHashName]: serializer_1.MDATA_SYMBOLS.JOB.KEYS.map((key) => `metadata/${key}`)
|
|
298
|
+
};
|
|
299
|
+
for (let [activityId, paths] of Object.entries(this.config.consumes)) {
|
|
300
|
+
if (activityId === '$job') {
|
|
301
|
+
for (const path of paths) {
|
|
302
|
+
consumes[jobSymbolHashName].push(path);
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
else {
|
|
306
|
+
if (activityId === '$self') {
|
|
307
|
+
activityId = this.metadata.aid;
|
|
308
|
+
}
|
|
309
|
+
if (!consumes[activityId]) {
|
|
310
|
+
consumes[activityId] = [];
|
|
311
|
+
}
|
|
312
|
+
for (const path of paths) {
|
|
313
|
+
consumes[activityId].push(`${activityId}/${path}`);
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
telemetry_1.TelemetryService.addTargetTelemetryPaths(consumes, this.config, this.metadata, this.leg);
|
|
318
|
+
const { dad, jid } = this.context.metadata;
|
|
319
|
+
jobId = jobId || jid;
|
|
320
|
+
//`state` is a flat hash
|
|
321
|
+
const [state, status] = await this.store.getState(jobId, consumes);
|
|
322
|
+
//`context` is a tree
|
|
323
|
+
this.context = (0, utils_1.restoreHierarchy)(state);
|
|
324
|
+
this.initDimensionalAddress(dad);
|
|
325
|
+
this.initSelf(this.context);
|
|
326
|
+
this.initPolicies(this.context);
|
|
327
|
+
}
|
|
328
|
+
initDimensionalAddress(dad) {
|
|
329
|
+
this.metadata.dad = dad;
|
|
330
|
+
}
|
|
331
|
+
initSelf(context) {
|
|
332
|
+
const activityId = this.metadata.aid;
|
|
333
|
+
if (!context[activityId]) {
|
|
334
|
+
context[activityId] = {};
|
|
335
|
+
}
|
|
336
|
+
const self = context[activityId];
|
|
337
|
+
if (!self.output) {
|
|
338
|
+
self.output = {};
|
|
339
|
+
}
|
|
340
|
+
if (!self.input) {
|
|
341
|
+
self.input = {};
|
|
342
|
+
}
|
|
343
|
+
if (!self.hook) {
|
|
344
|
+
self.hook = {};
|
|
345
|
+
}
|
|
346
|
+
context['$self'] = self;
|
|
347
|
+
context['$job'] = context; //NEVER call STRINGIFY! (circular)
|
|
348
|
+
return context;
|
|
349
|
+
}
|
|
350
|
+
initPolicies(context) {
|
|
351
|
+
context.metadata.expire = this.config.expire;
|
|
352
|
+
}
|
|
353
|
+
bindActivityData(type) {
|
|
354
|
+
this.context[this.metadata.aid][type].data = this.data;
|
|
355
|
+
}
|
|
356
|
+
async filterAdjacent() {
|
|
357
|
+
const adjacencyList = [];
|
|
358
|
+
const transitions = await this.store.getTransitions(await this.engine.getVID());
|
|
359
|
+
const transition = transitions[`.${this.metadata.aid}`];
|
|
360
|
+
const adjacentSuffix = dimension_1.DimensionService.getSeed(this.adjacentIndex);
|
|
361
|
+
if (transition) {
|
|
362
|
+
for (const toActivityId in transition) {
|
|
363
|
+
const transitionRule = transition[toActivityId];
|
|
364
|
+
if (mapper_1.MapperService.evaluate(transitionRule, this.context, this.code)) {
|
|
365
|
+
adjacencyList.push({
|
|
366
|
+
metadata: {
|
|
367
|
+
jid: this.context.metadata.jid,
|
|
368
|
+
dad: `${this.metadata.dad}${adjacentSuffix}`,
|
|
369
|
+
aid: toActivityId,
|
|
370
|
+
spn: this.context['$self'].output.metadata?.l2s,
|
|
371
|
+
trc: this.context.metadata.trc,
|
|
372
|
+
},
|
|
373
|
+
type: stream_1.StreamDataType.TRANSITION,
|
|
374
|
+
data: {}
|
|
375
|
+
});
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
return adjacencyList;
|
|
380
|
+
}
|
|
381
|
+
async transition(adjacencyList, jobStatus) {
|
|
382
|
+
let mIds = [];
|
|
383
|
+
if (adjacencyList.length) {
|
|
384
|
+
const multi = this.store.getMulti();
|
|
385
|
+
for (const execSignal of adjacencyList) {
|
|
386
|
+
await this.engine.streamSignaler?.publishMessage(null, execSignal, multi);
|
|
387
|
+
}
|
|
388
|
+
mIds = (await multi.exec());
|
|
389
|
+
}
|
|
390
|
+
else if (jobStatus <= 0) {
|
|
391
|
+
await this.engine.runJobCompletionTasks(this.context);
|
|
392
|
+
}
|
|
393
|
+
return mIds;
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
exports.Activity = Activity;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Activity } from './activity';
|
|
2
|
+
import { EngineService } from '../engine';
|
|
3
|
+
import { ActivityData, ActivityMetadata, AwaitActivity, ActivityType } from '../../types/activity';
|
|
4
|
+
import { JobState } from '../../types/job';
|
|
5
|
+
import { MultiResponseFlags } from '../../types/redis';
|
|
6
|
+
import { StreamCode, StreamData, StreamStatus } from '../../types/stream';
|
|
7
|
+
declare class Await extends Activity {
|
|
8
|
+
config: AwaitActivity;
|
|
9
|
+
constructor(config: ActivityType, data: ActivityData, metadata: ActivityMetadata, hook: ActivityData | null, engine: EngineService, context?: JobState);
|
|
10
|
+
process(): Promise<string>;
|
|
11
|
+
execActivity(): Promise<string>;
|
|
12
|
+
processEvent(status?: StreamStatus, code?: StreamCode): Promise<void>;
|
|
13
|
+
processSuccess(adjacencyList: StreamData[]): Promise<MultiResponseFlags>;
|
|
14
|
+
processError(adjacencyList: StreamData[]): Promise<MultiResponseFlags>;
|
|
15
|
+
}
|
|
16
|
+
export { Await };
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Await = void 0;
|
|
4
|
+
const errors_1 = require("../../modules/errors");
|
|
5
|
+
const activity_1 = require("./activity");
|
|
6
|
+
const stream_1 = require("../../types/stream");
|
|
7
|
+
const telemetry_1 = require("../telemetry");
|
|
8
|
+
const collator_1 = require("../collator");
|
|
9
|
+
class Await extends activity_1.Activity {
|
|
10
|
+
constructor(config, data, metadata, hook, engine, context) {
|
|
11
|
+
super(config, data, metadata, hook, engine, context);
|
|
12
|
+
}
|
|
13
|
+
//******** INITIAL ENTRY POINT (A) ********//
|
|
14
|
+
async process() {
|
|
15
|
+
this.logger.debug('await-process', { jid: this.context.metadata.jid, aid: this.metadata.aid });
|
|
16
|
+
let telemetry;
|
|
17
|
+
try {
|
|
18
|
+
this.setLeg(1);
|
|
19
|
+
await collator_1.CollatorService.notarizeEntry(this);
|
|
20
|
+
await this.getState();
|
|
21
|
+
telemetry = new telemetry_1.TelemetryService(this.engine.appId, this.config, this.metadata, this.context);
|
|
22
|
+
telemetry.startActivitySpan(this.leg);
|
|
23
|
+
this.mapInputData();
|
|
24
|
+
const multi = this.store.getMulti();
|
|
25
|
+
//await this.registerTimeout();
|
|
26
|
+
await collator_1.CollatorService.authorizeReentry(this, multi);
|
|
27
|
+
await this.setState(multi);
|
|
28
|
+
await this.setStatus(0, multi);
|
|
29
|
+
const multiResponse = await multi.exec();
|
|
30
|
+
telemetry.mapActivityAttributes();
|
|
31
|
+
const jobStatus = this.resolveStatus(multiResponse);
|
|
32
|
+
const messageId = await this.execActivity();
|
|
33
|
+
telemetry.setActivityAttributes({
|
|
34
|
+
'app.activity.mid': messageId,
|
|
35
|
+
'app.job.jss': jobStatus
|
|
36
|
+
});
|
|
37
|
+
return this.context.metadata.aid;
|
|
38
|
+
}
|
|
39
|
+
catch (error) {
|
|
40
|
+
telemetry.setActivityError(error.message);
|
|
41
|
+
if (error instanceof errors_1.GetStateError) {
|
|
42
|
+
this.logger.error('await-get-state-error', error);
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
this.logger.error('await-process-error', error);
|
|
46
|
+
}
|
|
47
|
+
throw error;
|
|
48
|
+
}
|
|
49
|
+
finally {
|
|
50
|
+
telemetry.endActivitySpan();
|
|
51
|
+
this.logger.debug('await-process-end', { jid: this.context.metadata.jid, aid: this.metadata.aid });
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
async execActivity() {
|
|
55
|
+
const streamData = {
|
|
56
|
+
metadata: {
|
|
57
|
+
jid: this.context.metadata.jid,
|
|
58
|
+
dad: this.metadata.dad,
|
|
59
|
+
aid: this.metadata.aid,
|
|
60
|
+
topic: this.config.subtype,
|
|
61
|
+
spn: this.context['$self'].output.metadata?.l1s,
|
|
62
|
+
trc: this.context.metadata.trc,
|
|
63
|
+
},
|
|
64
|
+
type: stream_1.StreamDataType.AWAIT,
|
|
65
|
+
data: this.context.data
|
|
66
|
+
};
|
|
67
|
+
if (this.config.retry) {
|
|
68
|
+
streamData.policies = {
|
|
69
|
+
retry: this.config.retry
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
return (await this.engine.streamSignaler?.publishMessage(null, streamData));
|
|
73
|
+
}
|
|
74
|
+
//******** `RESOLVE` ENTRY POINT (B) ********//
|
|
75
|
+
//this method is invoked when the job spawned by this job ends;
|
|
76
|
+
//`this.data` is the job data produced by the spawned job
|
|
77
|
+
async processEvent(status = stream_1.StreamStatus.SUCCESS, code = 200) {
|
|
78
|
+
this.setLeg(2);
|
|
79
|
+
const jid = this.context.metadata.jid;
|
|
80
|
+
const aid = this.metadata.aid;
|
|
81
|
+
if (!jid) {
|
|
82
|
+
throw new Error('await-process-event-error');
|
|
83
|
+
}
|
|
84
|
+
this.logger.debug('await-resolve-await', { jid, aid, status, code });
|
|
85
|
+
this.status = status;
|
|
86
|
+
this.code = code;
|
|
87
|
+
let telemetry;
|
|
88
|
+
try {
|
|
89
|
+
await this.getState();
|
|
90
|
+
const aState = await collator_1.CollatorService.notarizeReentry(this);
|
|
91
|
+
this.adjacentIndex = collator_1.CollatorService.getDimensionalIndex(aState);
|
|
92
|
+
telemetry = new telemetry_1.TelemetryService(this.engine.appId, this.config, this.metadata, this.context);
|
|
93
|
+
telemetry.startActivitySpan(this.leg);
|
|
94
|
+
let multiResponse = [];
|
|
95
|
+
if (status === stream_1.StreamStatus.SUCCESS) {
|
|
96
|
+
this.bindActivityData('output');
|
|
97
|
+
this.adjacencyList = await this.filterAdjacent();
|
|
98
|
+
multiResponse = await this.processSuccess(this.adjacencyList);
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
this.bindActivityError(this.data);
|
|
102
|
+
this.adjacencyList = await this.filterAdjacent();
|
|
103
|
+
multiResponse = await this.processError(this.adjacencyList);
|
|
104
|
+
}
|
|
105
|
+
telemetry.mapActivityAttributes();
|
|
106
|
+
const jobStatus = this.resolveStatus(multiResponse);
|
|
107
|
+
const attrs = { 'app.job.jss': jobStatus };
|
|
108
|
+
const messageIds = await this.transition(this.adjacencyList, jobStatus);
|
|
109
|
+
if (messageIds.length) {
|
|
110
|
+
attrs['app.activity.mids'] = messageIds.join(',');
|
|
111
|
+
}
|
|
112
|
+
telemetry.setActivityAttributes(attrs);
|
|
113
|
+
}
|
|
114
|
+
catch (error) {
|
|
115
|
+
this.logger.error('await-resolve-await-error', error);
|
|
116
|
+
telemetry.setActivityError(error.message);
|
|
117
|
+
throw error;
|
|
118
|
+
}
|
|
119
|
+
finally {
|
|
120
|
+
telemetry.endActivitySpan();
|
|
121
|
+
this.logger.debug('await-resolve-await-end', { jid, aid, status, code });
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
async processSuccess(adjacencyList) {
|
|
125
|
+
this.mapJobData();
|
|
126
|
+
const multi = this.store.getMulti();
|
|
127
|
+
await this.setState(multi);
|
|
128
|
+
await collator_1.CollatorService.notarizeCompletion(this, multi);
|
|
129
|
+
await this.setStatus(adjacencyList.length - 1, multi);
|
|
130
|
+
return await multi.exec();
|
|
131
|
+
}
|
|
132
|
+
async processError(adjacencyList) {
|
|
133
|
+
//todo: if adjacencyList.length == 0, then map to the job output
|
|
134
|
+
// this method would be added to Base activity class
|
|
135
|
+
//this.mapJobData();
|
|
136
|
+
const multi = this.store.getMulti();
|
|
137
|
+
await this.setState(multi);
|
|
138
|
+
await collator_1.CollatorService.notarizeCompletion(this, multi);
|
|
139
|
+
await this.setStatus(adjacencyList.length - 1, multi);
|
|
140
|
+
return await multi.exec();
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
exports.Await = Await;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { EngineService } from '../engine';
|
|
2
|
+
import { Activity, ActivityType } from './activity';
|
|
3
|
+
import { ActivityData, ActivityMetadata, EmitActivity } from '../../types/activity';
|
|
4
|
+
declare class Emit extends Activity {
|
|
5
|
+
config: EmitActivity;
|
|
6
|
+
constructor(config: ActivityType, data: ActivityData, metadata: ActivityMetadata, hook: ActivityData | null, engine: EngineService);
|
|
7
|
+
mapInputData(): Promise<void>;
|
|
8
|
+
}
|
|
9
|
+
export { Emit };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Emit = void 0;
|
|
4
|
+
const activity_1 = require("./activity");
|
|
5
|
+
class Emit extends activity_1.Activity {
|
|
6
|
+
constructor(config, data, metadata, hook, engine) {
|
|
7
|
+
super(config, data, metadata, hook, engine);
|
|
8
|
+
}
|
|
9
|
+
async mapInputData() {
|
|
10
|
+
this.logger.info('emit-map-input-data');
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
exports.Emit = Emit;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Activity } from './activity';
|
|
2
|
+
import { Await } from './await';
|
|
3
|
+
import { Worker } from './worker';
|
|
4
|
+
import { Iterate } from './iterate';
|
|
5
|
+
import { Emit } from './emit';
|
|
6
|
+
import { Trigger } from './trigger';
|
|
7
|
+
declare const _default: {
|
|
8
|
+
activity: typeof Activity;
|
|
9
|
+
await: typeof Await;
|
|
10
|
+
iterate: typeof Iterate;
|
|
11
|
+
emit: typeof Emit;
|
|
12
|
+
trigger: typeof Trigger;
|
|
13
|
+
worker: typeof Worker;
|
|
14
|
+
};
|
|
15
|
+
export default _default;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const activity_1 = require("./activity");
|
|
4
|
+
const await_1 = require("./await");
|
|
5
|
+
const worker_1 = require("./worker");
|
|
6
|
+
const iterate_1 = require("./iterate");
|
|
7
|
+
const emit_1 = require("./emit");
|
|
8
|
+
const trigger_1 = require("./trigger");
|
|
9
|
+
exports.default = {
|
|
10
|
+
activity: activity_1.Activity,
|
|
11
|
+
await: await_1.Await,
|
|
12
|
+
iterate: iterate_1.Iterate,
|
|
13
|
+
emit: emit_1.Emit,
|
|
14
|
+
trigger: trigger_1.Trigger,
|
|
15
|
+
worker: worker_1.Worker,
|
|
16
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { EngineService } from '../engine';
|
|
2
|
+
import { Activity, ActivityType } from './activity';
|
|
3
|
+
import { ActivityData, ActivityMetadata, IterateActivity } from '../../types/activity';
|
|
4
|
+
declare class Iterate extends Activity {
|
|
5
|
+
config: IterateActivity;
|
|
6
|
+
constructor(config: ActivityType, data: ActivityData, metadata: ActivityMetadata, hook: ActivityData | null, engine: EngineService);
|
|
7
|
+
mapInputData(): Promise<void>;
|
|
8
|
+
}
|
|
9
|
+
export { Iterate };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Iterate = void 0;
|
|
4
|
+
const activity_1 = require("./activity");
|
|
5
|
+
class Iterate extends activity_1.Activity {
|
|
6
|
+
constructor(config, data, metadata, hook, engine) {
|
|
7
|
+
super(config, data, metadata, hook, engine);
|
|
8
|
+
}
|
|
9
|
+
async mapInputData() {
|
|
10
|
+
this.logger.info('iterate-map-input-data');
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
exports.Iterate = Iterate;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Activity } from './activity';
|
|
2
|
+
import { EngineService } from '../engine';
|
|
3
|
+
import { ActivityData, ActivityMetadata, ActivityType, TriggerActivity } from '../../types/activity';
|
|
4
|
+
import { JobState } from '../../types/job';
|
|
5
|
+
import { RedisMulti } from '../../types/redis';
|
|
6
|
+
declare class Trigger extends Activity {
|
|
7
|
+
config: TriggerActivity;
|
|
8
|
+
constructor(config: ActivityType, data: ActivityData, metadata: ActivityMetadata, hook: ActivityData | null, engine: EngineService, context?: JobState);
|
|
9
|
+
process(): Promise<string>;
|
|
10
|
+
setStatus(amount: number): Promise<void>;
|
|
11
|
+
createInputContext(): Partial<JobState>;
|
|
12
|
+
getState(): Promise<void>;
|
|
13
|
+
bindJobMetadataPaths(): string[];
|
|
14
|
+
bindActivityMetadataPaths(): string[];
|
|
15
|
+
resolveGranularity(): string;
|
|
16
|
+
getJobStatus(): number;
|
|
17
|
+
resolveJobId(context: Partial<JobState>): string;
|
|
18
|
+
resolveJobKey(context: Partial<JobState>): string;
|
|
19
|
+
setStateNX(): Promise<void>;
|
|
20
|
+
setStats(multi?: RedisMulti): Promise<void>;
|
|
21
|
+
}
|
|
22
|
+
export { Trigger };
|