@hotmeshio/hotmesh 0.12.1 → 0.14.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 +18 -22
- package/build/modules/enums.d.ts +60 -5
- package/build/modules/enums.js +62 -7
- package/build/modules/errors.d.ts +15 -2
- package/build/modules/errors.js +17 -1
- package/build/modules/storage.d.ts +1 -0
- package/build/modules/storage.js +2 -1
- package/build/package.json +8 -2
- package/build/services/activities/activity/context.d.ts +22 -0
- package/build/services/activities/activity/context.js +76 -0
- package/build/services/activities/activity/index.d.ts +116 -0
- package/build/services/activities/activity/index.js +299 -0
- package/build/services/activities/activity/mapping.d.ts +12 -0
- package/build/services/activities/activity/mapping.js +63 -0
- package/build/services/activities/activity/process.d.ts +28 -0
- package/build/services/activities/activity/process.js +100 -0
- package/build/services/activities/activity/protocol.d.ts +39 -0
- package/build/services/activities/activity/protocol.js +151 -0
- package/build/services/activities/activity/state.d.ts +40 -0
- package/build/services/activities/activity/state.js +143 -0
- package/build/services/activities/activity/transition.d.ts +23 -0
- package/build/services/activities/activity/transition.js +71 -0
- package/build/services/activities/activity/verify.d.ts +22 -0
- package/build/services/activities/activity/verify.js +85 -0
- package/build/services/activities/await.d.ts +1 -4
- package/build/services/activities/await.js +2 -36
- package/build/services/activities/cycle.d.ts +1 -11
- package/build/services/activities/cycle.js +3 -46
- package/build/services/activities/hook.d.ts +2 -11
- package/build/services/activities/hook.js +30 -50
- package/build/services/activities/interrupt.d.ts +2 -4
- package/build/services/activities/interrupt.js +4 -38
- package/build/services/activities/signal.d.ts +1 -11
- package/build/services/activities/signal.js +3 -48
- package/build/services/activities/trigger.d.ts +1 -3
- package/build/services/activities/trigger.js +0 -3
- package/build/services/activities/worker.d.ts +3 -6
- package/build/services/activities/worker.js +4 -40
- package/build/services/connector/factory.d.ts +6 -0
- package/build/services/connector/factory.js +24 -0
- package/build/services/dba/index.d.ts +14 -4
- package/build/services/dba/index.js +57 -18
- package/build/services/durable/activity.d.ts +30 -0
- package/build/services/durable/activity.js +46 -0
- package/build/services/durable/client.d.ts +26 -31
- package/build/services/durable/client.js +26 -31
- package/build/services/durable/connection.d.ts +13 -7
- package/build/services/durable/connection.js +13 -7
- package/build/services/durable/exporter.d.ts +2 -2
- package/build/services/durable/exporter.js +27 -12
- package/build/services/durable/handle.d.ts +59 -41
- package/build/services/durable/handle.js +61 -41
- package/build/services/durable/index.d.ts +152 -283
- package/build/services/durable/index.js +161 -289
- package/build/services/durable/interceptor.d.ts +43 -33
- package/build/services/durable/interceptor.js +59 -39
- package/build/services/durable/schemas/factory.d.ts +2 -3
- package/build/services/durable/schemas/factory.js +180 -30
- package/build/services/durable/telemetry.d.ts +80 -0
- package/build/services/durable/telemetry.js +137 -0
- package/build/services/durable/worker.d.ts +100 -21
- package/build/services/durable/worker.js +314 -60
- package/build/services/durable/workflow/all.d.ts +1 -1
- package/build/services/durable/workflow/all.js +1 -1
- package/build/services/durable/workflow/cancellationScope.d.ts +104 -0
- package/build/services/durable/workflow/cancellationScope.js +139 -0
- package/build/services/durable/workflow/common.d.ts +5 -4
- package/build/services/durable/workflow/common.js +6 -1
- package/build/services/durable/workflow/{waitFor.d.ts → condition.d.ts} +9 -8
- package/build/services/durable/workflow/{waitFor.js → condition.js} +44 -11
- package/build/services/durable/workflow/continueAsNew.d.ts +65 -0
- package/build/services/durable/workflow/continueAsNew.js +92 -0
- package/build/services/durable/workflow/didRun.d.ts +2 -2
- package/build/services/durable/workflow/didRun.js +4 -4
- package/build/services/durable/workflow/enrich.d.ts +5 -0
- package/build/services/durable/workflow/enrich.js +5 -0
- package/build/services/durable/workflow/entityMethods.d.ts +7 -0
- package/build/services/durable/workflow/entityMethods.js +7 -0
- package/build/services/durable/workflow/execHook.js +3 -3
- package/build/services/durable/workflow/execHookBatch.js +2 -2
- package/build/services/durable/workflow/{execChild.d.ts → executeChild.d.ts} +4 -40
- package/build/services/durable/workflow/{execChild.js → executeChild.js} +36 -45
- package/build/services/durable/workflow/hook.d.ts +1 -1
- package/build/services/durable/workflow/hook.js +4 -3
- package/build/services/durable/workflow/index.d.ts +45 -50
- package/build/services/durable/workflow/index.js +46 -51
- package/build/services/durable/workflow/interruption.d.ts +7 -6
- package/build/services/durable/workflow/interruption.js +11 -7
- package/build/services/durable/workflow/patched.d.ts +72 -0
- package/build/services/durable/workflow/patched.js +110 -0
- package/build/services/durable/workflow/proxyActivities.d.ts +7 -7
- package/build/services/durable/workflow/proxyActivities.js +51 -15
- package/build/services/durable/workflow/searchMethods.d.ts +7 -0
- package/build/services/durable/workflow/searchMethods.js +7 -0
- package/build/services/durable/workflow/signal.d.ts +4 -4
- package/build/services/durable/workflow/signal.js +4 -4
- package/build/services/durable/workflow/{sleepFor.d.ts → sleep.d.ts} +7 -7
- package/build/services/durable/workflow/{sleepFor.js → sleep.js} +39 -10
- package/build/services/durable/workflow/terminate.d.ts +55 -0
- package/build/services/durable/workflow/{interrupt.js → terminate.js} +21 -21
- package/build/services/durable/workflow/trace.js +2 -2
- package/build/services/durable/workflow/uuid4.d.ts +14 -0
- package/build/services/durable/workflow/uuid4.js +39 -0
- package/build/services/durable/workflow/{context.d.ts → workflowInfo.d.ts} +5 -5
- package/build/services/durable/workflow/{context.js → workflowInfo.js} +7 -7
- package/build/services/engine/compiler.d.ts +19 -0
- package/build/services/engine/compiler.js +20 -0
- package/build/services/engine/completion.d.ts +46 -0
- package/build/services/engine/completion.js +145 -0
- package/build/services/engine/dispatch.d.ts +24 -0
- package/build/services/engine/dispatch.js +98 -0
- package/build/services/engine/index.d.ts +49 -81
- package/build/services/engine/index.js +175 -573
- package/build/services/engine/init.d.ts +42 -0
- package/build/services/engine/init.js +74 -0
- package/build/services/engine/pubsub.d.ts +50 -0
- package/build/services/engine/pubsub.js +118 -0
- package/build/services/engine/reporting.d.ts +20 -0
- package/build/services/engine/reporting.js +38 -0
- package/build/services/engine/schema.d.ts +23 -0
- package/build/services/engine/schema.js +62 -0
- package/build/services/engine/signal.d.ts +57 -0
- package/build/services/engine/signal.js +117 -0
- package/build/services/engine/state.d.ts +35 -0
- package/build/services/engine/state.js +61 -0
- package/build/services/engine/version.d.ts +31 -0
- package/build/services/engine/version.js +73 -0
- package/build/services/hotmesh/deployment.d.ts +21 -0
- package/build/services/hotmesh/deployment.js +25 -0
- package/build/services/hotmesh/index.d.ts +142 -533
- package/build/services/hotmesh/index.js +223 -674
- package/build/services/hotmesh/init.d.ts +42 -0
- package/build/services/hotmesh/init.js +93 -0
- package/build/services/hotmesh/jobs.d.ts +67 -0
- package/build/services/hotmesh/jobs.js +99 -0
- package/build/services/hotmesh/pubsub.d.ts +38 -0
- package/build/services/hotmesh/pubsub.js +54 -0
- package/build/services/hotmesh/quorum.d.ts +30 -0
- package/build/services/hotmesh/quorum.js +62 -0
- package/build/services/hotmesh/validation.d.ts +6 -0
- package/build/services/hotmesh/validation.js +28 -0
- package/build/services/quorum/index.js +1 -0
- package/build/services/router/consumption/index.d.ts +11 -5
- package/build/services/router/consumption/index.js +24 -17
- package/build/services/router/error-handling/index.d.ts +2 -2
- package/build/services/router/error-handling/index.js +14 -14
- package/build/services/router/index.d.ts +1 -1
- package/build/services/router/index.js +2 -2
- package/build/services/serializer/index.d.ts +22 -0
- package/build/services/serializer/index.js +39 -1
- package/build/services/store/index.d.ts +1 -0
- package/build/services/store/providers/postgres/exporter-sql.d.ts +2 -2
- package/build/services/store/providers/postgres/exporter-sql.js +4 -4
- package/build/services/store/providers/postgres/kvtables.js +7 -6
- package/build/services/store/providers/postgres/kvtypes/hash/basic.js +67 -52
- package/build/services/store/providers/postgres/kvtypes/hash/jsonb.js +87 -72
- package/build/services/store/providers/postgres/kvtypes/hash/udata.js +106 -79
- package/build/services/store/providers/postgres/kvtypes/hash/utils.d.ts +16 -0
- package/build/services/store/providers/postgres/kvtypes/hash/utils.js +29 -16
- package/build/services/store/providers/postgres/postgres.d.ts +1 -0
- package/build/services/store/providers/postgres/postgres.js +14 -4
- package/build/services/stream/factory.d.ts +3 -1
- package/build/services/stream/factory.js +2 -2
- package/build/services/stream/index.d.ts +1 -0
- package/build/services/stream/providers/nats/nats.d.ts +1 -0
- package/build/services/stream/providers/nats/nats.js +1 -0
- package/build/services/stream/providers/postgres/credentials.d.ts +56 -0
- package/build/services/stream/providers/postgres/credentials.js +129 -0
- package/build/services/stream/providers/postgres/kvtables.js +18 -0
- package/build/services/stream/providers/postgres/messages.js +7 -7
- package/build/services/stream/providers/postgres/notifications.js +16 -2
- package/build/services/stream/providers/postgres/postgres.d.ts +7 -0
- package/build/services/stream/providers/postgres/postgres.js +35 -4
- package/build/services/stream/providers/postgres/procedures.d.ts +21 -0
- package/build/services/stream/providers/postgres/procedures.js +213 -0
- package/build/services/stream/providers/postgres/secured.d.ts +34 -0
- package/build/services/stream/providers/postgres/secured.js +146 -0
- package/build/services/stream/providers/postgres/stats.d.ts +1 -0
- package/build/services/stream/providers/postgres/stats.js +1 -0
- package/build/services/stream/registry.d.ts +1 -1
- package/build/services/stream/registry.js +5 -2
- package/build/services/telemetry/index.d.ts +10 -1
- package/build/services/telemetry/index.js +40 -7
- package/build/services/worker/credentials.d.ts +51 -0
- package/build/services/worker/credentials.js +87 -0
- package/build/services/worker/index.d.ts +2 -2
- package/build/services/worker/index.js +7 -6
- package/build/types/codec.d.ts +84 -0
- package/build/types/codec.js +2 -0
- package/build/types/dba.d.ts +39 -3
- package/build/types/durable.d.ts +123 -25
- package/build/types/error.d.ts +10 -0
- package/build/types/exporter.d.ts +1 -1
- package/build/types/hotmesh.d.ts +67 -4
- package/build/types/index.d.ts +2 -1
- package/build/types/provider.d.ts +2 -2
- package/build/types/quorum.d.ts +35 -1
- package/build/types/stream.d.ts +12 -6
- package/package.json +8 -2
- package/build/services/activities/activity.d.ts +0 -192
- package/build/services/activities/activity.js +0 -786
- package/build/services/durable/workflow/interrupt.d.ts +0 -55
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Cycle = void 0;
|
|
4
|
-
const errors_1 = require("../../modules/errors");
|
|
5
4
|
const utils_1 = require("../../modules/utils");
|
|
6
5
|
const collator_1 = require("../collator");
|
|
7
6
|
const telemetry_1 = require("../telemetry");
|
|
@@ -89,10 +88,6 @@ const activity_1 = require("./activity");
|
|
|
89
88
|
* @see {@link CycleActivity} for the TypeScript interface
|
|
90
89
|
*/
|
|
91
90
|
class Cycle extends activity_1.Activity {
|
|
92
|
-
constructor(config, data, metadata, hook, engine, context) {
|
|
93
|
-
super(config, data, metadata, hook, engine, context);
|
|
94
|
-
}
|
|
95
|
-
//******** LEG 1 ENTRY ********//
|
|
96
91
|
async process() {
|
|
97
92
|
this.logger.debug('cycle-process', {
|
|
98
93
|
jid: this.context.metadata.jid,
|
|
@@ -105,10 +100,9 @@ class Cycle extends activity_1.Activity {
|
|
|
105
100
|
telemetry = new telemetry_1.TelemetryService(this.engine.appId, this.config, this.metadata, this.context);
|
|
106
101
|
telemetry.startActivitySpan(this.leg);
|
|
107
102
|
this.mapInputData();
|
|
108
|
-
//set state/status, cycle ancestor, and mark Leg1 complete — single transaction
|
|
109
103
|
const transaction = this.store.transact();
|
|
110
104
|
await this.setState(transaction);
|
|
111
|
-
await this.setStatus(0, transaction);
|
|
105
|
+
await this.setStatus(0, transaction);
|
|
112
106
|
const messageId = await this.cycleAncestorActivity(transaction);
|
|
113
107
|
await collator_1.CollatorService.notarizeLeg1Completion(this, transaction);
|
|
114
108
|
const txResponse = (await transaction.exec());
|
|
@@ -121,34 +115,8 @@ class Cycle extends activity_1.Activity {
|
|
|
121
115
|
return this.context.metadata.aid;
|
|
122
116
|
}
|
|
123
117
|
catch (error) {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
return;
|
|
127
|
-
}
|
|
128
|
-
else if (error instanceof errors_1.GenerationalError) {
|
|
129
|
-
this.logger.info('process-event-generational-job-error', { error });
|
|
130
|
-
return;
|
|
131
|
-
}
|
|
132
|
-
else if (error instanceof errors_1.GetStateError) {
|
|
133
|
-
this.logger.error('cycle-get-state-error', { error });
|
|
134
|
-
return;
|
|
135
|
-
}
|
|
136
|
-
else if (error instanceof errors_1.CollationError) {
|
|
137
|
-
if (error.fault === 'duplicate') {
|
|
138
|
-
this.logger.info('cycle-collation-overage', {
|
|
139
|
-
job_id: this.context.metadata.jid,
|
|
140
|
-
guid: this.context.metadata.guid,
|
|
141
|
-
});
|
|
142
|
-
return;
|
|
143
|
-
}
|
|
144
|
-
//unknown collation error
|
|
145
|
-
this.logger.error('cycle-collation-error', { error });
|
|
146
|
-
}
|
|
147
|
-
else {
|
|
148
|
-
this.logger.error('cycle-process-error', { error });
|
|
149
|
-
}
|
|
150
|
-
telemetry?.setActivityError(error.message);
|
|
151
|
-
throw error;
|
|
118
|
+
this.handleProcessError(error, telemetry, 'cycle');
|
|
119
|
+
return;
|
|
152
120
|
}
|
|
153
121
|
finally {
|
|
154
122
|
telemetry?.endActivitySpan();
|
|
@@ -159,18 +127,7 @@ class Cycle extends activity_1.Activity {
|
|
|
159
127
|
});
|
|
160
128
|
}
|
|
161
129
|
}
|
|
162
|
-
/**
|
|
163
|
-
* Trigger the target ancestor to execute in a cycle,
|
|
164
|
-
* without violating the constraints of the DAG. Immutable
|
|
165
|
-
* `individual activity state` will execute in a new dimensional
|
|
166
|
-
* thread while `shared job state` can change. This
|
|
167
|
-
* pattern allows for retries without violating the DAG.
|
|
168
|
-
*/
|
|
169
130
|
async cycleAncestorActivity(transaction) {
|
|
170
|
-
//Cycle activity L1 is a standin for the target ancestor L1.
|
|
171
|
-
//Input data mapping (mapInputData) allows for the
|
|
172
|
-
//next dimensonal thread to execute with different
|
|
173
|
-
//input data than the current dimensional thread
|
|
174
131
|
this.mapInputData();
|
|
175
132
|
const streamData = {
|
|
176
133
|
metadata: {
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { EngineService } from '../engine';
|
|
2
1
|
import { TelemetryService } from '../telemetry';
|
|
3
|
-
import {
|
|
2
|
+
import { HookActivity } from '../../types/activity';
|
|
4
3
|
import { HookRule } from '../../types/hook';
|
|
5
|
-
import {
|
|
4
|
+
import { JobStatus } from '../../types/job';
|
|
6
5
|
import { ProviderTransaction } from '../../types/provider';
|
|
7
6
|
import { StreamCode, StreamStatus } from '../../types/stream';
|
|
8
7
|
import { Activity } from './activity';
|
|
@@ -149,16 +148,8 @@ import { Activity } from './activity';
|
|
|
149
148
|
*/
|
|
150
149
|
declare class Hook extends Activity {
|
|
151
150
|
config: HookActivity;
|
|
152
|
-
constructor(config: ActivityType, data: ActivityData, metadata: ActivityMetadata, hook: ActivityData | null, engine: EngineService, context?: JobState);
|
|
153
151
|
process(): Promise<string>;
|
|
154
|
-
/**
|
|
155
|
-
* Static config check: does this activity have a hook or sleep config?
|
|
156
|
-
* Used for routing before context is loaded.
|
|
157
|
-
*/
|
|
158
152
|
isConfiguredAsHook(): boolean;
|
|
159
|
-
/**
|
|
160
|
-
* does this activity use a time-hook or web-hook
|
|
161
|
-
*/
|
|
162
153
|
doesHook(): boolean;
|
|
163
154
|
doHook(telemetry: TelemetryService): Promise<void>;
|
|
164
155
|
doPassThrough(telemetry: TelemetryService): Promise<void>;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Hook = void 0;
|
|
4
|
-
const errors_1 = require("../../modules/errors");
|
|
5
4
|
const collator_1 = require("../collator");
|
|
6
5
|
const pipe_1 = require("../pipe");
|
|
7
6
|
const task_1 = require("../task");
|
|
@@ -150,10 +149,6 @@ const activity_1 = require("./activity");
|
|
|
150
149
|
* @see {@link HookActivity} for the TypeScript interface
|
|
151
150
|
*/
|
|
152
151
|
class Hook extends activity_1.Activity {
|
|
153
|
-
constructor(config, data, metadata, hook, engine, context) {
|
|
154
|
-
super(config, data, metadata, hook, engine, context);
|
|
155
|
-
}
|
|
156
|
-
//******** INITIAL ENTRY POINT (A) ********//
|
|
157
152
|
async process() {
|
|
158
153
|
this.logger.debug('hook-process', {
|
|
159
154
|
jid: this.context.metadata.jid,
|
|
@@ -173,7 +168,6 @@ class Hook extends activity_1.Activity {
|
|
|
173
168
|
if (!isResume) {
|
|
174
169
|
await this.doHook(telemetry);
|
|
175
170
|
}
|
|
176
|
-
//If resume, Leg1 already ran — Leg2 will handle completion
|
|
177
171
|
}
|
|
178
172
|
else {
|
|
179
173
|
//Category B: passthrough with crash-safe step protocol + GUID ledger
|
|
@@ -182,34 +176,8 @@ class Hook extends activity_1.Activity {
|
|
|
182
176
|
return this.context.metadata.aid;
|
|
183
177
|
}
|
|
184
178
|
catch (error) {
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
return;
|
|
188
|
-
}
|
|
189
|
-
else if (error instanceof errors_1.GenerationalError) {
|
|
190
|
-
this.logger.info('process-event-generational-job-error', { error });
|
|
191
|
-
return;
|
|
192
|
-
}
|
|
193
|
-
else if (error instanceof errors_1.GetStateError) {
|
|
194
|
-
this.logger.error('hook-get-state-error', { error });
|
|
195
|
-
return;
|
|
196
|
-
}
|
|
197
|
-
else if (error instanceof errors_1.CollationError) {
|
|
198
|
-
if (error.fault === 'duplicate') {
|
|
199
|
-
this.logger.info('hook-collation-overage', {
|
|
200
|
-
job_id: this.context.metadata.jid,
|
|
201
|
-
guid: this.context.metadata.guid,
|
|
202
|
-
});
|
|
203
|
-
return;
|
|
204
|
-
}
|
|
205
|
-
//unknown collation error
|
|
206
|
-
this.logger.error('hook-collation-error', { error });
|
|
207
|
-
}
|
|
208
|
-
else {
|
|
209
|
-
this.logger.error('hook-process-error', { error });
|
|
210
|
-
}
|
|
211
|
-
telemetry?.setActivityError(error.message);
|
|
212
|
-
throw error;
|
|
179
|
+
this.handleProcessError(error, telemetry, 'hook');
|
|
180
|
+
return;
|
|
213
181
|
}
|
|
214
182
|
finally {
|
|
215
183
|
telemetry?.endActivitySpan();
|
|
@@ -220,22 +188,18 @@ class Hook extends activity_1.Activity {
|
|
|
220
188
|
});
|
|
221
189
|
}
|
|
222
190
|
}
|
|
223
|
-
/**
|
|
224
|
-
* Static config check: does this activity have a hook or sleep config?
|
|
225
|
-
* Used for routing before context is loaded.
|
|
226
|
-
*/
|
|
227
191
|
isConfiguredAsHook() {
|
|
228
192
|
return !!this.config.sleep || !!this.config.hook?.topic;
|
|
229
193
|
}
|
|
230
|
-
/**
|
|
231
|
-
* does this activity use a time-hook or web-hook
|
|
232
|
-
*/
|
|
233
194
|
doesHook() {
|
|
195
|
+
if (this.config.hook?.topic) {
|
|
196
|
+
return true;
|
|
197
|
+
}
|
|
234
198
|
if (this.config.sleep) {
|
|
235
199
|
const duration = pipe_1.Pipe.resolve(this.config.sleep, this.context);
|
|
236
200
|
return !isNaN(duration) && Number(duration) > 0;
|
|
237
201
|
}
|
|
238
|
-
return
|
|
202
|
+
return false;
|
|
239
203
|
}
|
|
240
204
|
async doHook(telemetry) {
|
|
241
205
|
const transaction = this.store.transact();
|
|
@@ -252,7 +216,6 @@ class Hook extends activity_1.Activity {
|
|
|
252
216
|
this.adjacencyList = await this.filterAdjacent();
|
|
253
217
|
this.mapOutputData();
|
|
254
218
|
this.mapJobData();
|
|
255
|
-
//Category B: use Leg1 step protocol for crash-safe edge capture
|
|
256
219
|
await this.executeLeg1StepProtocol(this.adjacencyList.length - 1);
|
|
257
220
|
telemetry.mapActivityAttributes();
|
|
258
221
|
telemetry.setActivityAttributes({});
|
|
@@ -262,16 +225,20 @@ class Hook extends activity_1.Activity {
|
|
|
262
225
|
return rules?.[topic]?.[0];
|
|
263
226
|
}
|
|
264
227
|
async registerHook(transaction) {
|
|
228
|
+
let result;
|
|
265
229
|
if (this.config.hook?.topic) {
|
|
266
|
-
|
|
230
|
+
result = await this.engine.taskService.registerWebHook(this.config.hook.topic, this.context, this.resolveDad(), this.context.metadata.expire, transaction);
|
|
267
231
|
}
|
|
268
|
-
|
|
232
|
+
if (this.config.sleep) {
|
|
269
233
|
const duration = pipe_1.Pipe.resolve(this.config.sleep, this.context);
|
|
270
|
-
|
|
271
|
-
|
|
234
|
+
if (!isNaN(duration) && Number(duration) > 0) {
|
|
235
|
+
await this.engine.taskService.registerTimeHook(this.context.metadata.jid, this.context.metadata.gid, `${this.metadata.aid}${this.metadata.dad || ''}`, 'sleep', duration, this.metadata.dad || '', transaction);
|
|
236
|
+
if (!result)
|
|
237
|
+
result = this.context.metadata.jid;
|
|
238
|
+
}
|
|
272
239
|
}
|
|
240
|
+
return result;
|
|
273
241
|
}
|
|
274
|
-
//******** SIGNAL RE-ENTRY POINT ********//
|
|
275
242
|
async processWebHookEvent(status = stream_1.StreamStatus.SUCCESS, code = 200) {
|
|
276
243
|
this.logger.debug('hook-process-web-hook-event', {
|
|
277
244
|
topic: this.config.hook.topic,
|
|
@@ -290,8 +257,8 @@ class Hook extends activity_1.Activity {
|
|
|
290
257
|
await this.processEvent(status, code, 'hook');
|
|
291
258
|
if (code === 200) {
|
|
292
259
|
await taskService.deleteWebHookSignal(this.config.hook.topic, data);
|
|
293
|
-
}
|
|
294
|
-
}
|
|
260
|
+
}
|
|
261
|
+
}
|
|
295
262
|
}
|
|
296
263
|
async processTimeHookEvent(jobId) {
|
|
297
264
|
this.logger.debug('hook-process-time-hook-event', {
|
|
@@ -299,6 +266,19 @@ class Hook extends activity_1.Activity {
|
|
|
299
266
|
gid: this.context.metadata.gid,
|
|
300
267
|
aid: this.metadata.aid,
|
|
301
268
|
});
|
|
269
|
+
//if combined hook+sleep, clean up the webhook signal (timeout won the race)
|
|
270
|
+
if (this.config.hook?.topic) {
|
|
271
|
+
try {
|
|
272
|
+
const taskService = new task_1.TaskService(this.store, this.logger);
|
|
273
|
+
await taskService.deleteWebHookSignal(this.config.hook.topic, this.data);
|
|
274
|
+
}
|
|
275
|
+
catch (e) {
|
|
276
|
+
this.logger.debug('hook-timeout-signal-cleanup', {
|
|
277
|
+
topic: this.config.hook.topic,
|
|
278
|
+
error: e.message,
|
|
279
|
+
});
|
|
280
|
+
}
|
|
281
|
+
}
|
|
302
282
|
await this.processEvent(stream_1.StreamStatus.SUCCESS, 200, 'hook');
|
|
303
283
|
}
|
|
304
284
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { EngineService } from '../engine';
|
|
2
1
|
import { TelemetryService } from '../telemetry';
|
|
3
|
-
import {
|
|
4
|
-
import { JobInterruptOptions
|
|
2
|
+
import { InterruptActivity } from '../../types/activity';
|
|
3
|
+
import { JobInterruptOptions } from '../../types/job';
|
|
5
4
|
import { Activity } from './activity';
|
|
6
5
|
/**
|
|
7
6
|
* Terminates a flow by sending an interrupt signal. The `interrupt` activity
|
|
@@ -117,7 +116,6 @@ import { Activity } from './activity';
|
|
|
117
116
|
*/
|
|
118
117
|
declare class Interrupt extends Activity {
|
|
119
118
|
config: InterruptActivity;
|
|
120
|
-
constructor(config: ActivityType, data: ActivityData, metadata: ActivityMetadata, hook: ActivityData | null, engine: EngineService, context?: JobState);
|
|
121
119
|
process(): Promise<string>;
|
|
122
120
|
interruptSelf(telemetry: TelemetryService): Promise<string>;
|
|
123
121
|
interruptAnother(telemetry: TelemetryService): Promise<string>;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Interrupt = void 0;
|
|
4
|
-
const errors_1 = require("../../modules/errors");
|
|
5
4
|
const collator_1 = require("../collator");
|
|
6
5
|
const pipe_1 = require("../pipe");
|
|
7
6
|
const telemetry_1 = require("../telemetry");
|
|
@@ -119,10 +118,6 @@ const activity_1 = require("./activity");
|
|
|
119
118
|
* @see {@link InterruptActivity} for the TypeScript interface
|
|
120
119
|
*/
|
|
121
120
|
class Interrupt extends activity_1.Activity {
|
|
122
|
-
constructor(config, data, metadata, hook, engine, context) {
|
|
123
|
-
super(config, data, metadata, hook, engine, context);
|
|
124
|
-
}
|
|
125
|
-
//******** LEG 1 ENTRY ********//
|
|
126
121
|
async process() {
|
|
127
122
|
this.logger.debug('interrupt-process', {
|
|
128
123
|
jid: this.context.metadata.jid,
|
|
@@ -147,34 +142,8 @@ class Interrupt extends activity_1.Activity {
|
|
|
147
142
|
}
|
|
148
143
|
}
|
|
149
144
|
catch (error) {
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
return;
|
|
153
|
-
}
|
|
154
|
-
else if (error instanceof errors_1.GenerationalError) {
|
|
155
|
-
this.logger.info('process-event-generational-job-error', { error });
|
|
156
|
-
return;
|
|
157
|
-
}
|
|
158
|
-
else if (error instanceof errors_1.GetStateError) {
|
|
159
|
-
this.logger.error('interrupt-get-state-error', { error });
|
|
160
|
-
return;
|
|
161
|
-
}
|
|
162
|
-
else if (error instanceof errors_1.CollationError) {
|
|
163
|
-
if (error.fault === 'duplicate') {
|
|
164
|
-
this.logger.info('interrupt-collation-overage', {
|
|
165
|
-
job_id: this.context.metadata.jid,
|
|
166
|
-
guid: this.context.metadata.guid,
|
|
167
|
-
});
|
|
168
|
-
return;
|
|
169
|
-
}
|
|
170
|
-
//unknown collation error
|
|
171
|
-
this.logger.error('interrupt-collation-error', { error });
|
|
172
|
-
}
|
|
173
|
-
else {
|
|
174
|
-
this.logger.error('interrupt-process-error', { error });
|
|
175
|
-
}
|
|
176
|
-
telemetry?.setActivityError(error.message);
|
|
177
|
-
throw error;
|
|
145
|
+
this.handleProcessError(error, telemetry, 'interrupt');
|
|
146
|
+
return;
|
|
178
147
|
}
|
|
179
148
|
finally {
|
|
180
149
|
telemetry?.endActivitySpan();
|
|
@@ -189,7 +158,6 @@ class Interrupt extends activity_1.Activity {
|
|
|
189
158
|
if (this.config.job?.maps) {
|
|
190
159
|
this.mapJobData();
|
|
191
160
|
}
|
|
192
|
-
// Bundle state + Leg1 completion + semaphore in one transaction
|
|
193
161
|
telemetry.mapActivityAttributes();
|
|
194
162
|
const transaction = this.store.transact();
|
|
195
163
|
if (this.config.job?.maps) {
|
|
@@ -199,7 +167,7 @@ class Interrupt extends activity_1.Activity {
|
|
|
199
167
|
await this.setStatus(-1, transaction);
|
|
200
168
|
const txResponse = (await transaction.exec());
|
|
201
169
|
const jobStatus = this.resolveStatus(txResponse);
|
|
202
|
-
//
|
|
170
|
+
//interrupt fires AFTER proof commits (best-effort)
|
|
203
171
|
const messageId = await this.interrupt();
|
|
204
172
|
telemetry.setActivityAttributes({
|
|
205
173
|
'app.activity.mid': messageId,
|
|
@@ -208,15 +176,13 @@ class Interrupt extends activity_1.Activity {
|
|
|
208
176
|
return this.context.metadata.aid;
|
|
209
177
|
}
|
|
210
178
|
async interruptAnother(telemetry) {
|
|
211
|
-
//
|
|
179
|
+
//interrupt ANOTHER job (best-effort, fires before step protocol)
|
|
212
180
|
await this.interrupt();
|
|
213
|
-
// Apply updates to THIS job's state
|
|
214
181
|
this.adjacencyList = await this.filterAdjacent();
|
|
215
182
|
if (this.config.job?.maps || this.config.output?.maps) {
|
|
216
183
|
this.mapOutputData();
|
|
217
184
|
this.mapJobData();
|
|
218
185
|
}
|
|
219
|
-
//Category B: use Leg1 step protocol for crash-safe edge capture
|
|
220
186
|
await this.executeLeg1StepProtocol(this.adjacencyList.length - 1);
|
|
221
187
|
telemetry.mapActivityAttributes();
|
|
222
188
|
telemetry.setActivityAttributes({});
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { ActivityData, ActivityMetadata, ActivityType, SignalActivity } from '../../types/activity';
|
|
3
|
-
import { JobState } from '../../types/job';
|
|
1
|
+
import { SignalActivity } from '../../types/activity';
|
|
4
2
|
import { ProviderTransaction } from '../../types/provider';
|
|
5
3
|
import { Activity } from './activity';
|
|
6
4
|
/**
|
|
@@ -110,18 +108,10 @@ import { Activity } from './activity';
|
|
|
110
108
|
*/
|
|
111
109
|
declare class Signal extends Activity {
|
|
112
110
|
config: SignalActivity;
|
|
113
|
-
constructor(config: ActivityType, data: ActivityData, metadata: ActivityMetadata, hook: ActivityData | null, engine: EngineService, context?: JobState);
|
|
114
111
|
process(): Promise<string>;
|
|
115
112
|
mapSignalData(): Record<string, any>;
|
|
116
113
|
mapResolverData(): Record<string, any>;
|
|
117
|
-
/**
|
|
118
|
-
* The signal activity will hook one. Accepts an optional transaction
|
|
119
|
-
* so the hook publish can be bundled with the Leg1 completion marker.
|
|
120
|
-
*/
|
|
121
114
|
signalOne(transaction?: ProviderTransaction): Promise<string>;
|
|
122
|
-
/**
|
|
123
|
-
* Signals all paused jobs that share the same job key, resuming their execution.
|
|
124
|
-
*/
|
|
125
115
|
signalAll(): Promise<string[]>;
|
|
126
116
|
}
|
|
127
117
|
export { Signal };
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Signal = void 0;
|
|
4
|
-
const errors_1 = require("../../modules/errors");
|
|
5
4
|
const collator_1 = require("../collator");
|
|
6
5
|
const mapper_1 = require("../mapper");
|
|
7
6
|
const pipe_1 = require("../pipe");
|
|
@@ -113,10 +112,6 @@ const activity_1 = require("./activity");
|
|
|
113
112
|
* @see {@link SignalActivity} for the TypeScript interface
|
|
114
113
|
*/
|
|
115
114
|
class Signal extends activity_1.Activity {
|
|
116
|
-
constructor(config, data, metadata, hook, engine, context) {
|
|
117
|
-
super(config, data, metadata, hook, engine, context);
|
|
118
|
-
}
|
|
119
|
-
//******** LEG 1 ENTRY ********//
|
|
120
115
|
async process() {
|
|
121
116
|
this.logger.debug('signal-process', {
|
|
122
117
|
jid: this.context.metadata.jid,
|
|
@@ -125,7 +120,6 @@ class Signal extends activity_1.Activity {
|
|
|
125
120
|
});
|
|
126
121
|
let telemetry;
|
|
127
122
|
try {
|
|
128
|
-
//Category B: entry with step resume
|
|
129
123
|
await this.verifyLeg1Entry();
|
|
130
124
|
telemetry = new telemetry_1.TelemetryService(this.engine.appId, this.config, this.metadata, this.context);
|
|
131
125
|
telemetry.startActivitySpan(this.leg);
|
|
@@ -133,7 +127,7 @@ class Signal extends activity_1.Activity {
|
|
|
133
127
|
this.mapOutputData();
|
|
134
128
|
this.mapJobData();
|
|
135
129
|
//Step A: Bundle signal hook with Leg1 completion marker.
|
|
136
|
-
//
|
|
130
|
+
//signalOne is transactional; signalAll is best-effort.
|
|
137
131
|
if (!collator_1.CollatorService.isGuidStep1Done(this.guidLedger)) {
|
|
138
132
|
const txn1 = this.store.transact();
|
|
139
133
|
if (this.config.subtype === 'all') {
|
|
@@ -148,7 +142,6 @@ class Signal extends activity_1.Activity {
|
|
|
148
142
|
}
|
|
149
143
|
await collator_1.CollatorService.notarizeStep1(this, this.context.metadata.guid, txn1);
|
|
150
144
|
await txn1.exec();
|
|
151
|
-
//update in-memory guidLedger so executeLeg1StepProtocol skips Step A
|
|
152
145
|
this.guidLedger += collator_1.CollatorService.WEIGHTS.STEP1_WORK;
|
|
153
146
|
}
|
|
154
147
|
//Steps B and C: spawn children + semaphore + edge capture
|
|
@@ -158,34 +151,8 @@ class Signal extends activity_1.Activity {
|
|
|
158
151
|
return this.context.metadata.aid;
|
|
159
152
|
}
|
|
160
153
|
catch (error) {
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
return;
|
|
164
|
-
}
|
|
165
|
-
else if (error instanceof errors_1.GenerationalError) {
|
|
166
|
-
this.logger.info('process-event-generational-job-error', { error });
|
|
167
|
-
return;
|
|
168
|
-
}
|
|
169
|
-
else if (error instanceof errors_1.GetStateError) {
|
|
170
|
-
this.logger.error('signal-get-state-error', { error });
|
|
171
|
-
return;
|
|
172
|
-
}
|
|
173
|
-
else if (error instanceof errors_1.CollationError) {
|
|
174
|
-
if (error.fault === 'duplicate') {
|
|
175
|
-
this.logger.info('signal-collation-overage', {
|
|
176
|
-
job_id: this.context.metadata.jid,
|
|
177
|
-
guid: this.context.metadata.guid,
|
|
178
|
-
});
|
|
179
|
-
return;
|
|
180
|
-
}
|
|
181
|
-
//unknown collation error
|
|
182
|
-
this.logger.error('signal-collation-error', { error });
|
|
183
|
-
}
|
|
184
|
-
else {
|
|
185
|
-
this.logger.error('signal-process-error', { error });
|
|
186
|
-
}
|
|
187
|
-
telemetry?.setActivityError(error.message);
|
|
188
|
-
throw error;
|
|
154
|
+
this.handleProcessError(error, telemetry, 'signal');
|
|
155
|
+
return;
|
|
189
156
|
}
|
|
190
157
|
finally {
|
|
191
158
|
telemetry?.endActivitySpan();
|
|
@@ -208,10 +175,6 @@ class Signal extends activity_1.Activity {
|
|
|
208
175
|
return mapper.mapRules();
|
|
209
176
|
}
|
|
210
177
|
}
|
|
211
|
-
/**
|
|
212
|
-
* The signal activity will hook one. Accepts an optional transaction
|
|
213
|
-
* so the hook publish can be bundled with the Leg1 completion marker.
|
|
214
|
-
*/
|
|
215
178
|
async signalOne(transaction) {
|
|
216
179
|
const topic = pipe_1.Pipe.resolve(this.config.topic, this.context);
|
|
217
180
|
const signalInputData = this.mapSignalData();
|
|
@@ -219,23 +182,15 @@ class Signal extends activity_1.Activity {
|
|
|
219
182
|
const code = pipe_1.Pipe.resolve(this.config.code, this.context);
|
|
220
183
|
return await this.engine.signal(topic, signalInputData, status, code, transaction);
|
|
221
184
|
}
|
|
222
|
-
/**
|
|
223
|
-
* Signals all paused jobs that share the same job key, resuming their execution.
|
|
224
|
-
*/
|
|
225
185
|
async signalAll() {
|
|
226
|
-
//prep 1) generate `input signal data` (essentially the webhook payload)
|
|
227
186
|
const signalInputData = this.mapSignalData();
|
|
228
|
-
//prep 2) generate data that resolves the job key (per the YAML config)
|
|
229
187
|
const keyResolverData = this.mapResolverData();
|
|
230
188
|
if (this.config.scrub) {
|
|
231
|
-
//self-clean the indexes upon use if configured
|
|
232
189
|
keyResolverData.scrub = true;
|
|
233
190
|
}
|
|
234
|
-
//prep 3) jobKeys can contain multiple indexes (per the YAML config)
|
|
235
191
|
const key_name = pipe_1.Pipe.resolve(this.config.key_name, this.context);
|
|
236
192
|
const key_value = pipe_1.Pipe.resolve(this.config.key_value, this.context);
|
|
237
193
|
const indexQueryFacets = [`${key_name}:${key_value}`];
|
|
238
|
-
//execute: `signalAll` will now resume all paused jobs that share the same job key
|
|
239
194
|
return await this.engine.signalAll(this.config.topic, signalInputData, keyResolverData, indexQueryFacets);
|
|
240
195
|
}
|
|
241
196
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { ActivityData, ActivityMetadata, ActivityType, TriggerActivity } from '../../types/activity';
|
|
1
|
+
import { TriggerActivity } from '../../types/activity';
|
|
3
2
|
import { JobState, ExtensionType } from '../../types/job';
|
|
4
3
|
import { ProviderTransaction } from '../../types/provider';
|
|
5
4
|
import { Activity } from './activity';
|
|
@@ -60,7 +59,6 @@ import { Activity } from './activity';
|
|
|
60
59
|
*/
|
|
61
60
|
declare class Trigger extends Activity {
|
|
62
61
|
config: TriggerActivity;
|
|
63
|
-
constructor(config: ActivityType, data: ActivityData, metadata: ActivityMetadata, hook: ActivityData | null, engine: EngineService, context?: JobState);
|
|
64
62
|
process(options?: ExtensionType): Promise<string>;
|
|
65
63
|
/**
|
|
66
64
|
* `pending` flows will not transition from the trigger to adjacent children until resumed
|
|
@@ -66,9 +66,6 @@ const activity_1 = require("./activity");
|
|
|
66
66
|
* @see {@link TriggerActivity} for the TypeScript interface
|
|
67
67
|
*/
|
|
68
68
|
class Trigger extends activity_1.Activity {
|
|
69
|
-
constructor(config, data, metadata, hook, engine, context) {
|
|
70
|
-
super(config, data, metadata, hook, engine, context);
|
|
71
|
-
}
|
|
72
69
|
async process(options) {
|
|
73
70
|
this.logger.debug('trigger-process', {
|
|
74
71
|
subscribes: this.config.subscribes,
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { ActivityData, ActivityMetadata, ActivityType, WorkerActivity } from '../../types/activity';
|
|
3
|
-
import { JobState } from '../../types/job';
|
|
1
|
+
import { WorkerActivity } from '../../types/activity';
|
|
4
2
|
import { ProviderTransaction } from '../../types/provider';
|
|
5
3
|
import { Activity } from './activity';
|
|
6
4
|
/**
|
|
@@ -70,7 +68,7 @@ import { Activity } from './activity';
|
|
|
70
68
|
* ## Retry Policy
|
|
71
69
|
*
|
|
72
70
|
* Retry behavior is configured at the **worker level** (not in YAML) via
|
|
73
|
-
* the `
|
|
71
|
+
* the `retry` option. Failed callbacks are retried with exponential
|
|
74
72
|
* backoff until `maximumAttempts` is exhausted. The `maximumInterval` caps
|
|
75
73
|
* the delay between retries.
|
|
76
74
|
*
|
|
@@ -81,7 +79,7 @@ import { Activity } from './activity';
|
|
|
81
79
|
* workers: [{
|
|
82
80
|
* topic: 'work.backoff',
|
|
83
81
|
* connection,
|
|
84
|
-
*
|
|
82
|
+
* retry: {
|
|
85
83
|
* maximumAttempts: 5, // retry up to 5 times
|
|
86
84
|
* backoffCoefficient: 2, // exponential: 2^0, 2^1, 2^2, ... seconds
|
|
87
85
|
* maximumInterval: '30s', // cap delay at 30 seconds
|
|
@@ -112,7 +110,6 @@ import { Activity } from './activity';
|
|
|
112
110
|
*/
|
|
113
111
|
declare class Worker extends Activity {
|
|
114
112
|
config: WorkerActivity;
|
|
115
|
-
constructor(config: ActivityType, data: ActivityData, metadata: ActivityMetadata, hook: ActivityData | null, engine: EngineService, context?: JobState);
|
|
116
113
|
process(): Promise<string>;
|
|
117
114
|
execActivity(transaction: ProviderTransaction): Promise<string>;
|
|
118
115
|
}
|