@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
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.executeLeg1StepProtocol = exports.executeStepProtocol = void 0;
|
|
4
|
+
const collator_1 = require("../../collator");
|
|
5
|
+
/**
|
|
6
|
+
* 3-step Leg2 protocol using GUID ledger for crash-safe resume.
|
|
7
|
+
* Each step bundles durable writes with its concluding digit
|
|
8
|
+
* update in a single transaction.
|
|
9
|
+
*/
|
|
10
|
+
async function executeStepProtocol(instance, delta, shouldFinalize) {
|
|
11
|
+
const msgGuid = instance.context.metadata.guid;
|
|
12
|
+
const threshold = instance.mapStatusThreshold();
|
|
13
|
+
const { id: appId } = await instance.engine.getVID();
|
|
14
|
+
//Step 1: Save work (skip if GUID 10B already set)
|
|
15
|
+
if (!collator_1.CollatorService.isGuidStep1Done(instance.guidLedger)) {
|
|
16
|
+
const txn1 = instance.store.transact();
|
|
17
|
+
await instance.setState(txn1);
|
|
18
|
+
await collator_1.CollatorService.notarizeStep1(instance, msgGuid, txn1);
|
|
19
|
+
await txn1.exec();
|
|
20
|
+
}
|
|
21
|
+
//Step 2: Spawn children + semaphore + edge capture
|
|
22
|
+
let thresholdHit = false;
|
|
23
|
+
if (!collator_1.CollatorService.isGuidStep2Done(instance.guidLedger)) {
|
|
24
|
+
const txn2 = instance.store.transact();
|
|
25
|
+
await collator_1.CollatorService.notarizeStep2(instance, msgGuid, txn2);
|
|
26
|
+
for (const child of instance.adjacencyList) {
|
|
27
|
+
await instance.engine.router?.publishMessage(null, child, txn2);
|
|
28
|
+
}
|
|
29
|
+
await instance.store.setStatusAndCollateGuid(delta, threshold, instance.context.metadata.jid, appId, msgGuid, collator_1.CollatorService.WEIGHTS.GUID_SNAPSHOT, txn2);
|
|
30
|
+
const results = (await txn2.exec());
|
|
31
|
+
thresholdHit = instance.resolveThresholdHit(results);
|
|
32
|
+
instance.logger.debug('step-protocol-step2-complete', {
|
|
33
|
+
jid: instance.context.metadata.jid,
|
|
34
|
+
aid: instance.metadata.aid,
|
|
35
|
+
delta,
|
|
36
|
+
threshold,
|
|
37
|
+
thresholdHit,
|
|
38
|
+
lastResult: results[results.length - 1],
|
|
39
|
+
resultCount: results.length,
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
thresholdHit = collator_1.CollatorService.isGuidJobClosed(instance.guidLedger);
|
|
44
|
+
}
|
|
45
|
+
//Step 3: Job completion tasks
|
|
46
|
+
const isErrorTerminal = !thresholdHit &&
|
|
47
|
+
instance.context.data?.done === true &&
|
|
48
|
+
!!instance.context.data?.$error;
|
|
49
|
+
const needsCompletion = thresholdHit ||
|
|
50
|
+
instance.shouldEmit() ||
|
|
51
|
+
instance.shouldPersistJob() ||
|
|
52
|
+
isErrorTerminal;
|
|
53
|
+
if (needsCompletion &&
|
|
54
|
+
!collator_1.CollatorService.isGuidStep3Done(instance.guidLedger)) {
|
|
55
|
+
const txn3 = instance.store.transact();
|
|
56
|
+
const options = thresholdHit || isErrorTerminal
|
|
57
|
+
? {}
|
|
58
|
+
: { emit: !instance.shouldPersistJob() };
|
|
59
|
+
await instance.engine.runJobCompletionTasks(instance.context, options, txn3);
|
|
60
|
+
await collator_1.CollatorService.notarizeStep3(instance, msgGuid, txn3);
|
|
61
|
+
const shouldFinalizeNow = thresholdHit || isErrorTerminal
|
|
62
|
+
? shouldFinalize
|
|
63
|
+
: instance.shouldPersistJob();
|
|
64
|
+
if (shouldFinalizeNow) {
|
|
65
|
+
await collator_1.CollatorService.notarizeFinalize(instance, txn3);
|
|
66
|
+
}
|
|
67
|
+
await txn3.exec();
|
|
68
|
+
}
|
|
69
|
+
else if (needsCompletion) {
|
|
70
|
+
instance.logger.debug('step-protocol-step3-skipped-already-done', {
|
|
71
|
+
jid: instance.context.metadata.jid,
|
|
72
|
+
aid: instance.metadata.aid,
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
instance.logger.debug('step-protocol-no-threshold', {
|
|
77
|
+
jid: instance.context.metadata.jid,
|
|
78
|
+
aid: instance.metadata.aid,
|
|
79
|
+
thresholdHit,
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
return thresholdHit;
|
|
83
|
+
}
|
|
84
|
+
exports.executeStepProtocol = executeStepProtocol;
|
|
85
|
+
/**
|
|
86
|
+
* 3-step Leg1 protocol for Category B activities
|
|
87
|
+
* (Leg1-only with children: Hook passthrough, Signal, Interrupt-another).
|
|
88
|
+
*
|
|
89
|
+
* Step A: setState + Leg1 completion + step1 marker
|
|
90
|
+
* Step B: publish children + semaphore + edge capture
|
|
91
|
+
* Step C: if edge → completion tasks + finalize
|
|
92
|
+
*/
|
|
93
|
+
async function executeLeg1StepProtocol(instance, delta) {
|
|
94
|
+
const msgGuid = instance.context.metadata.guid;
|
|
95
|
+
const threshold = instance.mapStatusThreshold();
|
|
96
|
+
const { id: appId } = await instance.engine.getVID();
|
|
97
|
+
//Step A: Save work + Leg1 completion marker
|
|
98
|
+
if (!collator_1.CollatorService.isGuidStep1Done(instance.guidLedger)) {
|
|
99
|
+
const txn1 = instance.store.transact();
|
|
100
|
+
await instance.setState(txn1);
|
|
101
|
+
if (instance.adjacentIndex === 0) {
|
|
102
|
+
await collator_1.CollatorService.notarizeLeg1Completion(instance, txn1);
|
|
103
|
+
}
|
|
104
|
+
await collator_1.CollatorService.notarizeStep1(instance, msgGuid, txn1);
|
|
105
|
+
await txn1.exec();
|
|
106
|
+
}
|
|
107
|
+
//Step B: Spawn children + semaphore + edge capture
|
|
108
|
+
let thresholdHit = false;
|
|
109
|
+
if (!collator_1.CollatorService.isGuidStep2Done(instance.guidLedger)) {
|
|
110
|
+
const txn2 = instance.store.transact();
|
|
111
|
+
await collator_1.CollatorService.notarizeStep2(instance, msgGuid, txn2);
|
|
112
|
+
for (const child of instance.adjacencyList) {
|
|
113
|
+
await instance.engine.router?.publishMessage(null, child, txn2);
|
|
114
|
+
}
|
|
115
|
+
await instance.store.setStatusAndCollateGuid(delta, threshold, instance.context.metadata.jid, appId, msgGuid, collator_1.CollatorService.WEIGHTS.GUID_SNAPSHOT, txn2);
|
|
116
|
+
const results = (await txn2.exec());
|
|
117
|
+
thresholdHit = instance.resolveThresholdHit(results);
|
|
118
|
+
instance.logger.debug('leg1-step-protocol-stepB-complete', {
|
|
119
|
+
jid: instance.context.metadata.jid,
|
|
120
|
+
aid: instance.metadata.aid,
|
|
121
|
+
delta,
|
|
122
|
+
threshold,
|
|
123
|
+
thresholdHit,
|
|
124
|
+
lastResult: results[results.length - 1],
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
else {
|
|
128
|
+
thresholdHit = collator_1.CollatorService.isGuidJobClosed(instance.guidLedger);
|
|
129
|
+
}
|
|
130
|
+
//Step C: Job completion tasks
|
|
131
|
+
const isErrorTerminal = !thresholdHit &&
|
|
132
|
+
instance.context.data?.done === true &&
|
|
133
|
+
!!instance.context.data?.$error;
|
|
134
|
+
const needsCompletion = thresholdHit ||
|
|
135
|
+
instance.shouldEmit() ||
|
|
136
|
+
instance.shouldPersistJob() ||
|
|
137
|
+
isErrorTerminal;
|
|
138
|
+
if (needsCompletion &&
|
|
139
|
+
!collator_1.CollatorService.isGuidStep3Done(instance.guidLedger)) {
|
|
140
|
+
const txn3 = instance.store.transact();
|
|
141
|
+
const options = thresholdHit || isErrorTerminal
|
|
142
|
+
? {}
|
|
143
|
+
: { emit: !instance.shouldPersistJob() };
|
|
144
|
+
await instance.engine.runJobCompletionTasks(instance.context, options, txn3);
|
|
145
|
+
await collator_1.CollatorService.notarizeStep3(instance, msgGuid, txn3);
|
|
146
|
+
await collator_1.CollatorService.notarizeFinalize(instance, txn3);
|
|
147
|
+
await txn3.exec();
|
|
148
|
+
}
|
|
149
|
+
return thresholdHit;
|
|
150
|
+
}
|
|
151
|
+
exports.executeLeg1StepProtocol = executeLeg1StepProtocol;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { EngineService } from '../../engine';
|
|
2
|
+
import { ILogger } from '../../logger';
|
|
3
|
+
import { StoreService } from '../../store';
|
|
4
|
+
import { ActivityData, ActivityLeg, ActivityMetadata, ActivityType } from '../../../types/activity';
|
|
5
|
+
import { JobState } from '../../../types/job';
|
|
6
|
+
import { ProviderClient, ProviderTransaction } from '../../../types/provider';
|
|
7
|
+
import { StringAnyType } from '../../../types/serializer';
|
|
8
|
+
import { StreamStatus } from '../../../types/stream';
|
|
9
|
+
interface StateContext {
|
|
10
|
+
config: ActivityType;
|
|
11
|
+
context: JobState;
|
|
12
|
+
metadata: ActivityMetadata;
|
|
13
|
+
store: StoreService<ProviderClient, ProviderTransaction>;
|
|
14
|
+
engine: EngineService;
|
|
15
|
+
logger: ILogger;
|
|
16
|
+
status: StreamStatus;
|
|
17
|
+
data: ActivityData;
|
|
18
|
+
leg: ActivityLeg;
|
|
19
|
+
getJobStatus(): number | null;
|
|
20
|
+
authorizeEntry(state: StringAnyType): string[];
|
|
21
|
+
resolveDad(): string;
|
|
22
|
+
getTriggerConfig(): Promise<ActivityType>;
|
|
23
|
+
bindJobMetadataPaths(): string[];
|
|
24
|
+
bindActivityMetadataPaths(): string[];
|
|
25
|
+
assertGenerationalId(jobGID: string, msgGID: string): void;
|
|
26
|
+
initDimensionalAddress(dad: string): void;
|
|
27
|
+
initSelf(context: StringAnyType): JobState;
|
|
28
|
+
initPolicies(context: JobState): void;
|
|
29
|
+
}
|
|
30
|
+
export declare function setState(instance: StateContext, transaction?: ProviderTransaction): Promise<string>;
|
|
31
|
+
export declare function getState(instance: StateContext): Promise<void>;
|
|
32
|
+
export declare function setStatus(instance: StateContext, amount: number, transaction?: ProviderTransaction): Promise<void | any>;
|
|
33
|
+
export declare function bindJobMetadata(instance: StateContext): void;
|
|
34
|
+
export declare function bindActivityMetadata(instance: StateContext): void;
|
|
35
|
+
export declare function bindJobState(instance: StateContext, state: StringAnyType): Promise<void>;
|
|
36
|
+
export declare function bindActivityState(instance: StateContext, state: StringAnyType): void;
|
|
37
|
+
export declare function bindDimensionalAddress(instance: StateContext, state: StringAnyType): void;
|
|
38
|
+
export declare function bindJobMetadataPaths(): string[];
|
|
39
|
+
export declare function bindActivityMetadataPaths(leg: ActivityLeg): string[];
|
|
40
|
+
export {};
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.bindActivityMetadataPaths = exports.bindJobMetadataPaths = exports.bindDimensionalAddress = exports.bindActivityState = exports.bindJobState = exports.bindActivityMetadata = exports.bindJobMetadata = exports.setStatus = exports.getState = exports.setState = void 0;
|
|
4
|
+
const utils_1 = require("../../../modules/utils");
|
|
5
|
+
const collator_1 = require("../../collator");
|
|
6
|
+
const serializer_1 = require("../../serializer");
|
|
7
|
+
const telemetry_1 = require("../../telemetry");
|
|
8
|
+
const stream_1 = require("../../../types/stream");
|
|
9
|
+
//─── persist full activity + job state ───────────────────────────────
|
|
10
|
+
async function setState(instance, transaction) {
|
|
11
|
+
const jobId = instance.context.metadata.jid;
|
|
12
|
+
bindJobMetadata(instance);
|
|
13
|
+
bindActivityMetadata(instance);
|
|
14
|
+
const state = {};
|
|
15
|
+
await bindJobState(instance, state);
|
|
16
|
+
const presets = instance.authorizeEntry(state);
|
|
17
|
+
bindDimensionalAddress(instance, state);
|
|
18
|
+
bindActivityState(instance, state);
|
|
19
|
+
const symbolNames = [
|
|
20
|
+
`$${instance.config.subscribes}`,
|
|
21
|
+
instance.metadata.aid,
|
|
22
|
+
...presets,
|
|
23
|
+
];
|
|
24
|
+
const dIds = collator_1.CollatorService.getDimensionsById([...instance.config.ancestors, instance.metadata.aid], instance.resolveDad());
|
|
25
|
+
return await instance.store.setState(state, instance.getJobStatus(), jobId, symbolNames, dIds, transaction);
|
|
26
|
+
}
|
|
27
|
+
exports.setState = setState;
|
|
28
|
+
//─── load state from store into context ──────────────────────────────
|
|
29
|
+
async function getState(instance) {
|
|
30
|
+
const gid = instance.context.metadata.gid;
|
|
31
|
+
const jobSymbolHashName = `$${instance.config.subscribes}`;
|
|
32
|
+
const consumes = {
|
|
33
|
+
[jobSymbolHashName]: serializer_1.MDATA_SYMBOLS.JOB.KEYS.map((key) => `metadata/${key}`),
|
|
34
|
+
};
|
|
35
|
+
for (let [activityId, paths] of Object.entries(instance.config.consumes)) {
|
|
36
|
+
if (activityId === '$job') {
|
|
37
|
+
for (const path of paths) {
|
|
38
|
+
consumes[jobSymbolHashName].push(path);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
if (activityId === '$self') {
|
|
43
|
+
activityId = instance.metadata.aid;
|
|
44
|
+
}
|
|
45
|
+
if (!consumes[activityId]) {
|
|
46
|
+
consumes[activityId] = [];
|
|
47
|
+
}
|
|
48
|
+
for (const path of paths) {
|
|
49
|
+
consumes[activityId].push(`${activityId}/${path}`);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
telemetry_1.TelemetryService.addTargetTelemetryPaths(consumes, instance.config, instance.metadata, instance.leg);
|
|
54
|
+
const { dad, jid } = instance.context.metadata;
|
|
55
|
+
const dIds = collator_1.CollatorService.getDimensionsById([...instance.config.ancestors, instance.metadata.aid], dad || '');
|
|
56
|
+
const [state, _status] = await instance.store.getState(jid, consumes, dIds);
|
|
57
|
+
instance.context = (0, utils_1.restoreHierarchy)(state);
|
|
58
|
+
instance.assertGenerationalId(instance.context?.metadata?.gid, gid);
|
|
59
|
+
instance.initDimensionalAddress(dad);
|
|
60
|
+
instance.initSelf(instance.context);
|
|
61
|
+
instance.initPolicies(instance.context);
|
|
62
|
+
}
|
|
63
|
+
exports.getState = getState;
|
|
64
|
+
//─── semaphore status update ─────────────────────────────────────────
|
|
65
|
+
async function setStatus(instance, amount, transaction) {
|
|
66
|
+
const { id: appId } = await instance.engine.getVID();
|
|
67
|
+
return await instance.store.setStatus(amount, instance.context.metadata.jid, appId, transaction);
|
|
68
|
+
}
|
|
69
|
+
exports.setStatus = setStatus;
|
|
70
|
+
//─── metadata binding ────────────────────────────────────────────────
|
|
71
|
+
function bindJobMetadata(instance) {
|
|
72
|
+
instance.context.metadata.ju = (0, utils_1.formatISODate)(new Date());
|
|
73
|
+
}
|
|
74
|
+
exports.bindJobMetadata = bindJobMetadata;
|
|
75
|
+
function bindActivityMetadata(instance) {
|
|
76
|
+
const self = instance.context['$self'];
|
|
77
|
+
if (!self.output.metadata) {
|
|
78
|
+
self.output.metadata = {};
|
|
79
|
+
}
|
|
80
|
+
if (instance.status === stream_1.StreamStatus.ERROR) {
|
|
81
|
+
self.output.metadata.err = JSON.stringify(instance.data);
|
|
82
|
+
}
|
|
83
|
+
const ts = (0, utils_1.formatISODate)(new Date());
|
|
84
|
+
self.output.metadata.ac = ts;
|
|
85
|
+
self.output.metadata.au = ts;
|
|
86
|
+
self.output.metadata.atp = instance.config.type;
|
|
87
|
+
if (instance.config.subtype) {
|
|
88
|
+
self.output.metadata.stp = instance.config.subtype;
|
|
89
|
+
}
|
|
90
|
+
self.output.metadata.aid = instance.metadata.aid;
|
|
91
|
+
}
|
|
92
|
+
exports.bindActivityMetadata = bindActivityMetadata;
|
|
93
|
+
//─── state path resolution ───────────────────────────────────────────
|
|
94
|
+
async function bindJobState(instance, state) {
|
|
95
|
+
const triggerConfig = await instance.getTriggerConfig();
|
|
96
|
+
const PRODUCES = [
|
|
97
|
+
...(triggerConfig.PRODUCES || []),
|
|
98
|
+
...instance.bindJobMetadataPaths(),
|
|
99
|
+
];
|
|
100
|
+
for (const path of PRODUCES) {
|
|
101
|
+
const value = (0, utils_1.getValueByPath)(instance.context, path);
|
|
102
|
+
if (value !== undefined) {
|
|
103
|
+
state[path] = value;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
for (const key in instance.context?.data ?? {}) {
|
|
107
|
+
if (key.startsWith('-') || key.startsWith('_')) {
|
|
108
|
+
state[key] = instance.context.data[key];
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
telemetry_1.TelemetryService.bindJobTelemetryToState(state, instance.config, instance.context);
|
|
112
|
+
}
|
|
113
|
+
exports.bindJobState = bindJobState;
|
|
114
|
+
function bindActivityState(instance, state) {
|
|
115
|
+
const produces = [
|
|
116
|
+
...instance.config.produces,
|
|
117
|
+
...instance.bindActivityMetadataPaths(),
|
|
118
|
+
];
|
|
119
|
+
for (const path of produces) {
|
|
120
|
+
const prefixedPath = `${instance.metadata.aid}/${path}`;
|
|
121
|
+
const value = (0, utils_1.getValueByPath)(instance.context, prefixedPath);
|
|
122
|
+
if (value !== undefined) {
|
|
123
|
+
state[prefixedPath] = value;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
telemetry_1.TelemetryService.bindActivityTelemetryToState(state, instance.config, instance.metadata, instance.context, instance.leg);
|
|
127
|
+
}
|
|
128
|
+
exports.bindActivityState = bindActivityState;
|
|
129
|
+
function bindDimensionalAddress(instance, state) {
|
|
130
|
+
const dad = instance.resolveDad();
|
|
131
|
+
state[`${instance.metadata.aid}/output/metadata/dad`] = dad;
|
|
132
|
+
}
|
|
133
|
+
exports.bindDimensionalAddress = bindDimensionalAddress;
|
|
134
|
+
//─── default metadata path resolvers (overridden by Trigger) ─────────
|
|
135
|
+
function bindJobMetadataPaths() {
|
|
136
|
+
return serializer_1.MDATA_SYMBOLS.JOB_UPDATE.KEYS.map((key) => `metadata/${key}`);
|
|
137
|
+
}
|
|
138
|
+
exports.bindJobMetadataPaths = bindJobMetadataPaths;
|
|
139
|
+
function bindActivityMetadataPaths(leg) {
|
|
140
|
+
const keys_to_save = leg === 1 ? 'ACTIVITY' : 'ACTIVITY_UPDATE';
|
|
141
|
+
return serializer_1.MDATA_SYMBOLS[keys_to_save].KEYS.map((key) => `output/metadata/${key}`);
|
|
142
|
+
}
|
|
143
|
+
exports.bindActivityMetadataPaths = bindActivityMetadataPaths;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { EngineService } from '../../engine';
|
|
2
|
+
import { StoreService } from '../../store';
|
|
3
|
+
import { ActivityMetadata, ActivityType } from '../../../types/activity';
|
|
4
|
+
import { JobState, JobStatus } from '../../../types/job';
|
|
5
|
+
import { ProviderClient, ProviderTransaction, TransactionResultList } from '../../../types/provider';
|
|
6
|
+
import { StreamCode, StreamData } from '../../../types/stream';
|
|
7
|
+
interface TransitionContext {
|
|
8
|
+
config: ActivityType;
|
|
9
|
+
context: JobState;
|
|
10
|
+
metadata: ActivityMetadata;
|
|
11
|
+
store: StoreService<ProviderClient, ProviderTransaction>;
|
|
12
|
+
engine: EngineService;
|
|
13
|
+
code: StreamCode;
|
|
14
|
+
resolveAdjacentDad(): string;
|
|
15
|
+
}
|
|
16
|
+
export declare function filterAdjacent(instance: TransitionContext): Promise<StreamData[]>;
|
|
17
|
+
export declare function resolveThresholdHit(results: TransactionResultList): boolean;
|
|
18
|
+
export declare function resolveStatus(multiResponse: TransactionResultList): number;
|
|
19
|
+
export declare function shouldEmit(instance: TransitionContext): boolean;
|
|
20
|
+
export declare function shouldPersistJob(instance: TransitionContext): boolean;
|
|
21
|
+
export declare function isJobComplete(jobStatus: JobStatus): boolean;
|
|
22
|
+
export declare function jobWasInterrupted(jobStatus: JobStatus): boolean;
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.jobWasInterrupted = exports.isJobComplete = exports.shouldPersistJob = exports.shouldEmit = exports.resolveStatus = exports.resolveThresholdHit = exports.filterAdjacent = void 0;
|
|
4
|
+
const utils_1 = require("../../../modules/utils");
|
|
5
|
+
const mapper_1 = require("../../mapper");
|
|
6
|
+
const pipe_1 = require("../../pipe");
|
|
7
|
+
const stream_1 = require("../../../types/stream");
|
|
8
|
+
async function filterAdjacent(instance) {
|
|
9
|
+
const adjacencyList = [];
|
|
10
|
+
const transitions = await instance.store.getTransitions(await instance.engine.getVID());
|
|
11
|
+
const transition = transitions[`.${instance.metadata.aid}`];
|
|
12
|
+
const adjacentDad = instance.resolveAdjacentDad();
|
|
13
|
+
if (transition) {
|
|
14
|
+
for (const toActivityId in transition) {
|
|
15
|
+
const transitionRule = transition[toActivityId];
|
|
16
|
+
if (mapper_1.MapperService.evaluate(transitionRule, instance.context, instance.code)) {
|
|
17
|
+
adjacencyList.push({
|
|
18
|
+
metadata: {
|
|
19
|
+
guid: (0, utils_1.guid)(),
|
|
20
|
+
jid: instance.context.metadata.jid,
|
|
21
|
+
gid: instance.context.metadata.gid,
|
|
22
|
+
dad: adjacentDad,
|
|
23
|
+
aid: toActivityId,
|
|
24
|
+
spn: instance.context['$self'].output.metadata?.l2s,
|
|
25
|
+
trc: instance.context.metadata.trc,
|
|
26
|
+
},
|
|
27
|
+
type: stream_1.StreamDataType.TRANSITION,
|
|
28
|
+
data: {},
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return adjacencyList;
|
|
34
|
+
}
|
|
35
|
+
exports.filterAdjacent = filterAdjacent;
|
|
36
|
+
function resolveThresholdHit(results) {
|
|
37
|
+
const last = results[results.length - 1];
|
|
38
|
+
const value = Array.isArray(last) ? last[1] : last;
|
|
39
|
+
return Number(value) === 1;
|
|
40
|
+
}
|
|
41
|
+
exports.resolveThresholdHit = resolveThresholdHit;
|
|
42
|
+
function resolveStatus(multiResponse) {
|
|
43
|
+
const activityStatus = multiResponse[multiResponse.length - 1];
|
|
44
|
+
if (Array.isArray(activityStatus)) {
|
|
45
|
+
return Number(activityStatus[1]);
|
|
46
|
+
}
|
|
47
|
+
return Number(activityStatus);
|
|
48
|
+
}
|
|
49
|
+
exports.resolveStatus = resolveStatus;
|
|
50
|
+
function shouldEmit(instance) {
|
|
51
|
+
if (instance.config.emit) {
|
|
52
|
+
return pipe_1.Pipe.resolve(instance.config.emit, instance.context) === true;
|
|
53
|
+
}
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
exports.shouldEmit = shouldEmit;
|
|
57
|
+
function shouldPersistJob(instance) {
|
|
58
|
+
if (instance.config.persist !== undefined) {
|
|
59
|
+
return pipe_1.Pipe.resolve(instance.config.persist, instance.context) === true;
|
|
60
|
+
}
|
|
61
|
+
return false;
|
|
62
|
+
}
|
|
63
|
+
exports.shouldPersistJob = shouldPersistJob;
|
|
64
|
+
function isJobComplete(jobStatus) {
|
|
65
|
+
return jobStatus <= 0;
|
|
66
|
+
}
|
|
67
|
+
exports.isJobComplete = isJobComplete;
|
|
68
|
+
function jobWasInterrupted(jobStatus) {
|
|
69
|
+
return jobStatus < -100000000;
|
|
70
|
+
}
|
|
71
|
+
exports.jobWasInterrupted = jobWasInterrupted;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { EngineService } from '../../engine';
|
|
2
|
+
import { StoreService } from '../../store';
|
|
3
|
+
import { ActivityLeg, ActivityMetadata, ActivityType } from '../../../types/activity';
|
|
4
|
+
import { ProviderClient, ProviderTransaction } from '../../../types/provider';
|
|
5
|
+
import { JobState } from '../../../types/job';
|
|
6
|
+
interface VerifyContext {
|
|
7
|
+
config: ActivityType;
|
|
8
|
+
context: JobState;
|
|
9
|
+
metadata: ActivityMetadata;
|
|
10
|
+
store: StoreService<ProviderClient, ProviderTransaction>;
|
|
11
|
+
engine: EngineService;
|
|
12
|
+
adjacentIndex: number;
|
|
13
|
+
guidLedger: number;
|
|
14
|
+
setLeg(leg: ActivityLeg): void;
|
|
15
|
+
getState(): Promise<void>;
|
|
16
|
+
setStatus(amount: number, txn?: ProviderTransaction): Promise<void | any>;
|
|
17
|
+
mapStatusThreshold(): number;
|
|
18
|
+
}
|
|
19
|
+
export declare function verifyEntry(instance: VerifyContext): Promise<void>;
|
|
20
|
+
export declare function verifyReentry(instance: VerifyContext): Promise<number>;
|
|
21
|
+
export declare function verifyLeg1Entry(instance: VerifyContext): Promise<boolean>;
|
|
22
|
+
export {};
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.verifyLeg1Entry = exports.verifyReentry = exports.verifyEntry = void 0;
|
|
4
|
+
const errors_1 = require("../../../modules/errors");
|
|
5
|
+
const collator_1 = require("../../collator");
|
|
6
|
+
async function verifyEntry(instance) {
|
|
7
|
+
instance.setLeg(1);
|
|
8
|
+
await instance.getState();
|
|
9
|
+
const threshold = instance.mapStatusThreshold();
|
|
10
|
+
try {
|
|
11
|
+
collator_1.CollatorService.assertJobActive(instance.context.metadata.js, instance.context.metadata.jid, instance.metadata.aid, threshold);
|
|
12
|
+
}
|
|
13
|
+
catch (error) {
|
|
14
|
+
await collator_1.CollatorService.notarizeEntry(instance);
|
|
15
|
+
if (threshold > 0) {
|
|
16
|
+
if (instance.context.metadata.js <= threshold) {
|
|
17
|
+
const status = await instance.setStatus(-threshold);
|
|
18
|
+
if (Number(status) === 0) {
|
|
19
|
+
const txn = instance.store.transact();
|
|
20
|
+
await instance.engine.runJobCompletionTasks(instance.context, {}, txn);
|
|
21
|
+
await txn.exec();
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
throw error;
|
|
27
|
+
}
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
await collator_1.CollatorService.notarizeEntry(instance);
|
|
31
|
+
}
|
|
32
|
+
exports.verifyEntry = verifyEntry;
|
|
33
|
+
async function verifyReentry(instance) {
|
|
34
|
+
const msgGuid = instance.context.metadata.guid;
|
|
35
|
+
instance.setLeg(2);
|
|
36
|
+
await instance.getState();
|
|
37
|
+
instance.context.metadata.guid = msgGuid;
|
|
38
|
+
collator_1.CollatorService.assertJobActive(instance.context.metadata.js, instance.context.metadata.jid, instance.metadata.aid);
|
|
39
|
+
const [activityLedger, guidLedger] = await collator_1.CollatorService.notarizeLeg2Entry(instance, msgGuid);
|
|
40
|
+
instance.guidLedger = guidLedger;
|
|
41
|
+
return activityLedger;
|
|
42
|
+
}
|
|
43
|
+
exports.verifyReentry = verifyReentry;
|
|
44
|
+
async function verifyLeg1Entry(instance) {
|
|
45
|
+
const msgGuid = instance.context.metadata.guid;
|
|
46
|
+
instance.setLeg(1);
|
|
47
|
+
await instance.getState();
|
|
48
|
+
instance.context.metadata.guid = msgGuid;
|
|
49
|
+
const threshold = instance.mapStatusThreshold();
|
|
50
|
+
try {
|
|
51
|
+
collator_1.CollatorService.assertJobActive(instance.context.metadata.js, instance.context.metadata.jid, instance.metadata.aid, threshold);
|
|
52
|
+
}
|
|
53
|
+
catch (error) {
|
|
54
|
+
if (error instanceof errors_1.InactiveJobError && threshold > 0) {
|
|
55
|
+
await collator_1.CollatorService.notarizeEntry(instance);
|
|
56
|
+
if (instance.context.metadata.js === threshold) {
|
|
57
|
+
const status = await instance.setStatus(-threshold);
|
|
58
|
+
if (Number(status) === 0) {
|
|
59
|
+
await instance.engine.runJobCompletionTasks(instance.context);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
throw error;
|
|
64
|
+
}
|
|
65
|
+
try {
|
|
66
|
+
await collator_1.CollatorService.notarizeEntry(instance);
|
|
67
|
+
return false;
|
|
68
|
+
}
|
|
69
|
+
catch (error) {
|
|
70
|
+
if (error instanceof errors_1.CollationError && error.fault === 'duplicate') {
|
|
71
|
+
if (instance.config.cycle) {
|
|
72
|
+
const [activityLedger, guidLedger] = await collator_1.CollatorService.notarizeLeg2Entry(instance, msgGuid);
|
|
73
|
+
instance.adjacentIndex =
|
|
74
|
+
collator_1.CollatorService.getDimensionalIndex(activityLedger);
|
|
75
|
+
instance.guidLedger = guidLedger;
|
|
76
|
+
return false;
|
|
77
|
+
}
|
|
78
|
+
const guidValue = await instance.store.collateSynthetic(instance.context.metadata.jid, msgGuid, 0);
|
|
79
|
+
instance.guidLedger = guidValue;
|
|
80
|
+
return true;
|
|
81
|
+
}
|
|
82
|
+
throw error;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
exports.verifyLeg1Entry = verifyLeg1Entry;
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { ActivityData, ActivityMetadata, AwaitActivity, ActivityType } from '../../types/activity';
|
|
1
|
+
import { AwaitActivity } from '../../types/activity';
|
|
3
2
|
import { ProviderTransaction } from '../../types/provider';
|
|
4
|
-
import { JobState } from '../../types/job';
|
|
5
3
|
import { Activity } from './activity';
|
|
6
4
|
/**
|
|
7
5
|
* Invokes another graph (sub-flow) and optionally waits for its completion.
|
|
@@ -106,7 +104,6 @@ import { Activity } from './activity';
|
|
|
106
104
|
*/
|
|
107
105
|
declare class Await extends Activity {
|
|
108
106
|
config: AwaitActivity;
|
|
109
|
-
constructor(config: ActivityType, data: ActivityData, metadata: ActivityMetadata, hook: ActivityData | null, engine: EngineService, context?: JobState);
|
|
110
107
|
process(): Promise<string>;
|
|
111
108
|
execActivity(transaction: ProviderTransaction): Promise<string>;
|
|
112
109
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Await = 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 pipe_1 = require("../pipe");
|
|
@@ -110,10 +109,6 @@ const activity_1 = require("./activity");
|
|
|
110
109
|
* @see {@link AwaitActivity} for the TypeScript interface
|
|
111
110
|
*/
|
|
112
111
|
class Await extends activity_1.Activity {
|
|
113
|
-
constructor(config, data, metadata, hook, engine, context) {
|
|
114
|
-
super(config, data, metadata, hook, engine, context);
|
|
115
|
-
}
|
|
116
|
-
//******** INITIAL ENTRY POINT (A) ********//
|
|
117
112
|
async process() {
|
|
118
113
|
this.logger.debug('await-process', {
|
|
119
114
|
jid: this.context.metadata.jid,
|
|
@@ -126,15 +121,12 @@ class Await extends activity_1.Activity {
|
|
|
126
121
|
telemetry = new telemetry_1.TelemetryService(this.engine.appId, this.config, this.metadata, this.context);
|
|
127
122
|
telemetry.startActivitySpan(this.leg);
|
|
128
123
|
this.mapInputData();
|
|
129
|
-
//save state and mark Leg1 complete
|
|
130
124
|
const transaction = this.store.transact();
|
|
131
|
-
//todo: await this.registerTimeout();
|
|
132
125
|
const messageId = await this.execActivity(transaction);
|
|
133
126
|
await collator_1.CollatorService.notarizeLeg1Completion(this, transaction);
|
|
134
127
|
await this.setState(transaction);
|
|
135
128
|
await this.setStatus(0, transaction);
|
|
136
129
|
const multiResponse = (await transaction.exec());
|
|
137
|
-
//telemetry
|
|
138
130
|
telemetry.mapActivityAttributes();
|
|
139
131
|
const jobStatus = this.resolveStatus(multiResponse);
|
|
140
132
|
telemetry.setActivityAttributes({
|
|
@@ -144,34 +136,8 @@ class Await extends activity_1.Activity {
|
|
|
144
136
|
return this.context.metadata.aid;
|
|
145
137
|
}
|
|
146
138
|
catch (error) {
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
return;
|
|
150
|
-
}
|
|
151
|
-
else if (error instanceof errors_1.GenerationalError) {
|
|
152
|
-
this.logger.info('process-event-generational-job-error', { error });
|
|
153
|
-
return;
|
|
154
|
-
}
|
|
155
|
-
else if (error instanceof errors_1.GetStateError) {
|
|
156
|
-
this.logger.error('await-get-state-error', { error });
|
|
157
|
-
return;
|
|
158
|
-
}
|
|
159
|
-
else if (error instanceof errors_1.CollationError) {
|
|
160
|
-
if (error.fault === 'duplicate') {
|
|
161
|
-
this.logger.info('await-collation-overage', {
|
|
162
|
-
job_id: this.context.metadata.jid,
|
|
163
|
-
guid: this.context.metadata.guid,
|
|
164
|
-
});
|
|
165
|
-
return;
|
|
166
|
-
}
|
|
167
|
-
//unknown collation error
|
|
168
|
-
this.logger.error('await-collation-error', { error });
|
|
169
|
-
}
|
|
170
|
-
else {
|
|
171
|
-
this.logger.error('await-process-error', { error });
|
|
172
|
-
}
|
|
173
|
-
telemetry?.setActivityError(error.message);
|
|
174
|
-
throw error;
|
|
139
|
+
this.handleProcessError(error, telemetry, 'await');
|
|
140
|
+
return;
|
|
175
141
|
}
|
|
176
142
|
finally {
|
|
177
143
|
telemetry?.endActivitySpan();
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { ActivityData, ActivityMetadata, ActivityType, CycleActivity } from '../../types/activity';
|
|
1
|
+
import { CycleActivity } from '../../types/activity';
|
|
3
2
|
import { ProviderTransaction } from '../../types/provider';
|
|
4
|
-
import { JobState } from '../../types/job';
|
|
5
3
|
import { Activity } from './activity';
|
|
6
4
|
/**
|
|
7
5
|
* Re-executes an ancestor activity in a new dimensional thread, enabling
|
|
@@ -87,15 +85,7 @@ import { Activity } from './activity';
|
|
|
87
85
|
*/
|
|
88
86
|
declare class Cycle extends Activity {
|
|
89
87
|
config: CycleActivity;
|
|
90
|
-
constructor(config: ActivityType, data: ActivityData, metadata: ActivityMetadata, hook: ActivityData | null, engine: EngineService, context?: JobState);
|
|
91
88
|
process(): Promise<string>;
|
|
92
|
-
/**
|
|
93
|
-
* Trigger the target ancestor to execute in a cycle,
|
|
94
|
-
* without violating the constraints of the DAG. Immutable
|
|
95
|
-
* `individual activity state` will execute in a new dimensional
|
|
96
|
-
* thread while `shared job state` can change. This
|
|
97
|
-
* pattern allows for retries without violating the DAG.
|
|
98
|
-
*/
|
|
99
89
|
cycleAncestorActivity(transaction: ProviderTransaction): Promise<string>;
|
|
100
90
|
}
|
|
101
91
|
export { Cycle };
|