@acmekit/workflow-engine-redis 2.13.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/README.md +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +11 -0
- package/dist/index.js.map +1 -0
- package/dist/loaders/index.d.ts +3 -0
- package/dist/loaders/index.d.ts.map +1 -0
- package/dist/loaders/index.js +11 -0
- package/dist/loaders/index.js.map +1 -0
- package/dist/loaders/redis.d.ts +4 -0
- package/dist/loaders/redis.d.ts.map +1 -0
- package/dist/loaders/redis.js +113 -0
- package/dist/loaders/redis.js.map +1 -0
- package/dist/loaders/utils.d.ts +6 -0
- package/dist/loaders/utils.d.ts.map +1 -0
- package/dist/loaders/utils.js +11 -0
- package/dist/loaders/utils.js.map +1 -0
- package/dist/migrations/Migration20231228143900.d.ts +6 -0
- package/dist/migrations/Migration20231228143900.d.ts.map +1 -0
- package/dist/migrations/Migration20231228143900.js +40 -0
- package/dist/migrations/Migration20231228143900.js.map +1 -0
- package/dist/migrations/Migration20241206123341.d.ts +5 -0
- package/dist/migrations/Migration20241206123341.d.ts.map +1 -0
- package/dist/migrations/Migration20241206123341.js +19 -0
- package/dist/migrations/Migration20241206123341.js.map +1 -0
- package/dist/migrations/Migration20250120111059.d.ts +6 -0
- package/dist/migrations/Migration20250120111059.d.ts.map +1 -0
- package/dist/migrations/Migration20250120111059.js +14 -0
- package/dist/migrations/Migration20250120111059.js.map +1 -0
- package/dist/migrations/Migration20250128174354.d.ts +6 -0
- package/dist/migrations/Migration20250128174354.d.ts.map +1 -0
- package/dist/migrations/Migration20250128174354.js +24 -0
- package/dist/migrations/Migration20250128174354.js.map +1 -0
- package/dist/migrations/Migration20250505101505.d.ts +6 -0
- package/dist/migrations/Migration20250505101505.d.ts.map +1 -0
- package/dist/migrations/Migration20250505101505.js +40 -0
- package/dist/migrations/Migration20250505101505.js.map +1 -0
- package/dist/migrations/Migration20250819110923.d.ts +6 -0
- package/dist/migrations/Migration20250819110923.d.ts.map +1 -0
- package/dist/migrations/Migration20250819110923.js +14 -0
- package/dist/migrations/Migration20250819110923.js.map +1 -0
- package/dist/migrations/Migration20250819110924.d.ts +6 -0
- package/dist/migrations/Migration20250819110924.d.ts.map +1 -0
- package/dist/migrations/Migration20250819110924.js +16 -0
- package/dist/migrations/Migration20250819110924.js.map +1 -0
- package/dist/migrations/Migration20250908080326.d.ts +6 -0
- package/dist/migrations/Migration20250908080326.d.ts.map +1 -0
- package/dist/migrations/Migration20250908080326.js +20 -0
- package/dist/migrations/Migration20250908080326.js.map +1 -0
- package/dist/models/index.d.ts +2 -0
- package/dist/models/index.d.ts.map +1 -0
- package/dist/models/index.js +6 -0
- package/dist/models/index.js.map +1 -0
- package/dist/models/workflow-execution.d.ts +12 -0
- package/dist/models/workflow-execution.d.ts.map +1 -0
- package/dist/models/workflow-execution.js +60 -0
- package/dist/models/workflow-execution.js.map +1 -0
- package/dist/schema/index.d.ts +3 -0
- package/dist/schema/index.d.ts.map +1 -0
- package/dist/schema/index.js +26 -0
- package/dist/schema/index.js.map +1 -0
- package/dist/services/index.d.ts +3 -0
- package/dist/services/index.d.ts.map +1 -0
- package/dist/services/index.js +19 -0
- package/dist/services/index.js.map +1 -0
- package/dist/services/workflow-orchestrator.d.ts +101 -0
- package/dist/services/workflow-orchestrator.d.ts.map +1 -0
- package/dist/services/workflow-orchestrator.js +660 -0
- package/dist/services/workflow-orchestrator.js.map +1 -0
- package/dist/services/workflows-module.d.ts +165 -0
- package/dist/services/workflows-module.d.ts.map +1 -0
- package/dist/services/workflows-module.js +212 -0
- package/dist/services/workflows-module.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/types/index.d.ts +138 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +3 -0
- package/dist/types/index.js.map +1 -0
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +18 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/workflow-orchestrator-storage.d.ts +72 -0
- package/dist/utils/workflow-orchestrator-storage.d.ts.map +1 -0
- package/dist/utils/workflow-orchestrator-storage.js +621 -0
- package/dist/utils/workflow-orchestrator-storage.js.map +1 -0
- package/package.json +50 -0
|
@@ -0,0 +1,621 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
3
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
4
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
5
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
6
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
7
|
+
};
|
|
8
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
9
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
10
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
11
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
12
|
+
};
|
|
13
|
+
var _RedisDistributedTransactionStorage_instances, _RedisDistributedTransactionStorage_isWorkerMode, _RedisDistributedTransactionStorage_getLockKey, _RedisDistributedTransactionStorage_acquireLock, _RedisDistributedTransactionStorage_releaseLock, _RedisDistributedTransactionStorage_preventRaceConditionExecutionIfNecessary;
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.RedisDistributedTransactionStorage = void 0;
|
|
16
|
+
const core_1 = require("@acmekit/framework/mikro-orm/core");
|
|
17
|
+
const orchestration_1 = require("@acmekit/framework/orchestration");
|
|
18
|
+
const utils_1 = require("@acmekit/framework/utils");
|
|
19
|
+
const bullmq_1 = require("bullmq");
|
|
20
|
+
var JobType;
|
|
21
|
+
(function (JobType) {
|
|
22
|
+
JobType["SCHEDULE"] = "schedule";
|
|
23
|
+
JobType["RETRY"] = "retry";
|
|
24
|
+
JobType["STEP_TIMEOUT"] = "step_timeout";
|
|
25
|
+
JobType["TRANSACTION_TIMEOUT"] = "transaction_timeout";
|
|
26
|
+
})(JobType || (JobType = {}));
|
|
27
|
+
const THIRTY_MINUTES_IN_MS = 1000 * 60 * 30;
|
|
28
|
+
const REPEATABLE_CLEARER_JOB_ID = "clear-expired-executions";
|
|
29
|
+
const doneStates = new Set([
|
|
30
|
+
utils_1.TransactionStepState.DONE,
|
|
31
|
+
utils_1.TransactionStepState.REVERTED,
|
|
32
|
+
utils_1.TransactionStepState.FAILED,
|
|
33
|
+
utils_1.TransactionStepState.SKIPPED,
|
|
34
|
+
utils_1.TransactionStepState.SKIPPED_FAILURE,
|
|
35
|
+
utils_1.TransactionStepState.TIMEOUT,
|
|
36
|
+
]);
|
|
37
|
+
const finishedStates = new Set([
|
|
38
|
+
utils_1.TransactionState.DONE,
|
|
39
|
+
utils_1.TransactionState.FAILED,
|
|
40
|
+
utils_1.TransactionState.REVERTED,
|
|
41
|
+
]);
|
|
42
|
+
const failedStates = new Set([
|
|
43
|
+
utils_1.TransactionState.FAILED,
|
|
44
|
+
utils_1.TransactionState.REVERTED,
|
|
45
|
+
]);
|
|
46
|
+
class RedisDistributedTransactionStorage {
|
|
47
|
+
constructor({ workflowExecutionService, redisConnection, redisWorkerConnection, redisQueueName, redisJobQueueName, redisMainQueueOptions, redisMainWorkerOptions, redisJobQueueOptions, redisJobWorkerOptions, redisCleanerQueueOptions, redisCleanerWorkerOptions, logger, isWorkerMode, }) {
|
|
48
|
+
_RedisDistributedTransactionStorage_instances.add(this);
|
|
49
|
+
_RedisDistributedTransactionStorage_isWorkerMode.set(this, false);
|
|
50
|
+
this.workflowExecutionService_ = workflowExecutionService;
|
|
51
|
+
this.logger_ = logger;
|
|
52
|
+
this.redisClient = redisConnection;
|
|
53
|
+
this.redisWorkerConnection = redisWorkerConnection;
|
|
54
|
+
this.cleanerQueueName = "workflows-cleaner";
|
|
55
|
+
this.queueName = redisQueueName;
|
|
56
|
+
this.jobQueueName = redisJobQueueName;
|
|
57
|
+
// Store per-queue options
|
|
58
|
+
this.mainQueueOptions_ = redisMainQueueOptions ?? {};
|
|
59
|
+
this.mainWorkerOptions_ = redisMainWorkerOptions ?? {};
|
|
60
|
+
this.jobQueueOptions_ = redisJobQueueOptions ?? {};
|
|
61
|
+
this.jobWorkerOptions_ = redisJobWorkerOptions ?? {};
|
|
62
|
+
this.cleanerQueueOptions_ = redisCleanerQueueOptions ?? {};
|
|
63
|
+
this.cleanerWorkerOptions_ = redisCleanerWorkerOptions ?? {};
|
|
64
|
+
// Create queues with their respective options
|
|
65
|
+
this.queue = new bullmq_1.Queue(redisQueueName, {
|
|
66
|
+
...this.mainQueueOptions_,
|
|
67
|
+
connection: this.redisClient,
|
|
68
|
+
});
|
|
69
|
+
this.jobQueue = isWorkerMode
|
|
70
|
+
? new bullmq_1.Queue(redisJobQueueName, {
|
|
71
|
+
...this.jobQueueOptions_,
|
|
72
|
+
connection: this.redisClient,
|
|
73
|
+
})
|
|
74
|
+
: undefined;
|
|
75
|
+
this.cleanerQueue_ = isWorkerMode
|
|
76
|
+
? new bullmq_1.Queue(this.cleanerQueueName, {
|
|
77
|
+
...this.cleanerQueueOptions_,
|
|
78
|
+
connection: this.redisClient,
|
|
79
|
+
})
|
|
80
|
+
: undefined;
|
|
81
|
+
__classPrivateFieldSet(this, _RedisDistributedTransactionStorage_isWorkerMode, isWorkerMode, "f");
|
|
82
|
+
}
|
|
83
|
+
async onApplicationPrepareShutdown() {
|
|
84
|
+
// Close worker gracefully, i.e. wait for the current jobs to finish
|
|
85
|
+
await this.worker?.close();
|
|
86
|
+
await this.jobWorker?.close();
|
|
87
|
+
await this.cleanerWorker_?.close();
|
|
88
|
+
}
|
|
89
|
+
async onApplicationShutdown() {
|
|
90
|
+
await this.queue?.close();
|
|
91
|
+
await this.jobQueue?.close();
|
|
92
|
+
await this.cleanerQueue_?.close();
|
|
93
|
+
}
|
|
94
|
+
async onApplicationStart() {
|
|
95
|
+
await this.ensureRedisConnection();
|
|
96
|
+
const allowedJobs = [
|
|
97
|
+
JobType.RETRY,
|
|
98
|
+
JobType.STEP_TIMEOUT,
|
|
99
|
+
JobType.TRANSACTION_TIMEOUT,
|
|
100
|
+
];
|
|
101
|
+
// Per-worker options with their respective configurations
|
|
102
|
+
const mainWorkerOptions = {
|
|
103
|
+
...this.mainWorkerOptions_,
|
|
104
|
+
connection: this.redisWorkerConnection,
|
|
105
|
+
};
|
|
106
|
+
const jobWorkerOptions = {
|
|
107
|
+
...this.jobWorkerOptions_,
|
|
108
|
+
connection: this.redisWorkerConnection,
|
|
109
|
+
};
|
|
110
|
+
const cleanerWorkerOptions = {
|
|
111
|
+
...this.cleanerWorkerOptions_,
|
|
112
|
+
connection: this.redisWorkerConnection,
|
|
113
|
+
};
|
|
114
|
+
// TODO: Remove this once we have released to all clients (Added: v2.6+)
|
|
115
|
+
// Remove all repeatable jobs from the old queue since now we have a queue dedicated to scheduled jobs
|
|
116
|
+
await this.removeAllRepeatableJobs(this.queue);
|
|
117
|
+
if (__classPrivateFieldGet(this, _RedisDistributedTransactionStorage_isWorkerMode, "f")) {
|
|
118
|
+
this.worker = new bullmq_1.Worker(this.queueName, async (job) => {
|
|
119
|
+
this.logger_.debug(`executing job ${job.name} from queue ${this.queueName} with the following data: ${JSON.stringify(job.data)}`);
|
|
120
|
+
if (allowedJobs.includes(job.name)) {
|
|
121
|
+
try {
|
|
122
|
+
await this.executeTransaction(job.data.workflowId, job.data.transactionId, job.data.transactionMetadata);
|
|
123
|
+
}
|
|
124
|
+
catch (error) {
|
|
125
|
+
if (!orchestration_1.SkipExecutionError.isSkipExecutionError(error)) {
|
|
126
|
+
throw error;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
if (job.name === JobType.SCHEDULE) {
|
|
131
|
+
// Remove repeatable job from the old queue since now we have a queue dedicated to scheduled jobs
|
|
132
|
+
await this.remove(job.data.jobId);
|
|
133
|
+
}
|
|
134
|
+
}, mainWorkerOptions);
|
|
135
|
+
this.jobWorker = new bullmq_1.Worker(this.jobQueueName, async (job) => {
|
|
136
|
+
this.logger_.debug(`executing scheduled job ${job.data.jobId} from queue ${this.jobQueueName} with the following options: ${JSON.stringify(job.data.schedulerOptions)}`);
|
|
137
|
+
return await this.executeScheduledJob(job.data.jobId, job.data.schedulerOptions);
|
|
138
|
+
}, jobWorkerOptions);
|
|
139
|
+
this.cleanerWorker_ = new bullmq_1.Worker(this.cleanerQueueName, async () => {
|
|
140
|
+
await this.clearExpiredExecutions();
|
|
141
|
+
}, cleanerWorkerOptions);
|
|
142
|
+
await this.cleanerQueue_?.add("cleaner", {}, {
|
|
143
|
+
repeat: {
|
|
144
|
+
every: THIRTY_MINUTES_IN_MS,
|
|
145
|
+
},
|
|
146
|
+
jobId: REPEATABLE_CLEARER_JOB_ID,
|
|
147
|
+
removeOnComplete: true,
|
|
148
|
+
removeOnFail: true,
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
setWorkflowOrchestratorService(workflowOrchestratorService) {
|
|
153
|
+
this.workflowOrchestratorService_ = workflowOrchestratorService;
|
|
154
|
+
}
|
|
155
|
+
async ensureRedisConnection() {
|
|
156
|
+
const reconnectTasks = [];
|
|
157
|
+
if (this.redisClient.status !== "ready") {
|
|
158
|
+
this.logger_.warn(`[Workflow-engine-redis] Redis connection is not ready (status: ${this.redisClient.status}). Attempting to reconnect...`);
|
|
159
|
+
reconnectTasks.push(this.redisClient
|
|
160
|
+
.connect()
|
|
161
|
+
.then(() => {
|
|
162
|
+
this.logger_.info("[Workflow-engine-redis] Redis connection reestablished successfully");
|
|
163
|
+
})
|
|
164
|
+
.catch((error) => {
|
|
165
|
+
this.logger_.error("[Workflow-engine-redis] Failed to reconnect to Redis", error);
|
|
166
|
+
throw new utils_1.AcmeKitError(utils_1.AcmeKitError.Types.DB_ERROR, `Redis connection failed: ${error.message}`);
|
|
167
|
+
}));
|
|
168
|
+
}
|
|
169
|
+
if (this.redisWorkerConnection.status !== "ready") {
|
|
170
|
+
this.logger_.warn(`[Workflow-engine-redis] Redis worker connection is not ready (status: ${this.redisWorkerConnection.status}). Attempting to reconnect...`);
|
|
171
|
+
reconnectTasks.push(this.redisWorkerConnection
|
|
172
|
+
.connect()
|
|
173
|
+
.then(() => {
|
|
174
|
+
this.logger_.info("[Workflow-engine-redis] Redis worker connection reestablished successfully");
|
|
175
|
+
})
|
|
176
|
+
.catch((error) => {
|
|
177
|
+
this.logger_.error("[Workflow-engine-redis] Failed to reconnect to Redis worker connection", error);
|
|
178
|
+
throw new utils_1.AcmeKitError(utils_1.AcmeKitError.Types.DB_ERROR, `Redis worker connection failed: ${error.message}`);
|
|
179
|
+
}));
|
|
180
|
+
}
|
|
181
|
+
if (reconnectTasks.length > 0) {
|
|
182
|
+
await (0, utils_1.promiseAll)(reconnectTasks);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
async saveToDb(data, retentionTime) {
|
|
186
|
+
const isNotStarted = data.flow.state === utils_1.TransactionState.NOT_STARTED;
|
|
187
|
+
const asyncVersion = data.flow._v;
|
|
188
|
+
const isFinished = finishedStates.has(data.flow.state);
|
|
189
|
+
const isWaitingToCompensate = data.flow.state === utils_1.TransactionState.WAITING_TO_COMPENSATE;
|
|
190
|
+
const isFlowInvoking = data.flow.state === utils_1.TransactionState.INVOKING;
|
|
191
|
+
const stepsArray = Object.values(data.flow.steps);
|
|
192
|
+
let currentStep;
|
|
193
|
+
const targetStates = isFlowInvoking
|
|
194
|
+
? new Set([
|
|
195
|
+
utils_1.TransactionStepState.INVOKING,
|
|
196
|
+
utils_1.TransactionStepState.DONE,
|
|
197
|
+
utils_1.TransactionStepState.FAILED,
|
|
198
|
+
])
|
|
199
|
+
: new Set([utils_1.TransactionStepState.COMPENSATING]);
|
|
200
|
+
for (let i = stepsArray.length - 1; i >= 0; i--) {
|
|
201
|
+
const step = stepsArray[i];
|
|
202
|
+
if (step.id === "_root") {
|
|
203
|
+
break;
|
|
204
|
+
}
|
|
205
|
+
const isTargetState = targetStates.has(step.invoke?.state);
|
|
206
|
+
if (isTargetState && !currentStep) {
|
|
207
|
+
currentStep = step;
|
|
208
|
+
break;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
let shouldStoreCurrentSteps = false;
|
|
212
|
+
if (currentStep) {
|
|
213
|
+
for (const step of stepsArray) {
|
|
214
|
+
if (step.id === "_root") {
|
|
215
|
+
continue;
|
|
216
|
+
}
|
|
217
|
+
if (step.depth === currentStep.depth &&
|
|
218
|
+
step?.definition?.store === true) {
|
|
219
|
+
shouldStoreCurrentSteps = true;
|
|
220
|
+
break;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
if (!(isNotStarted || isFinished || isWaitingToCompensate) &&
|
|
225
|
+
!shouldStoreCurrentSteps &&
|
|
226
|
+
!asyncVersion) {
|
|
227
|
+
return;
|
|
228
|
+
}
|
|
229
|
+
await this.workflowExecutionService_.upsert([
|
|
230
|
+
{
|
|
231
|
+
workflow_id: data.flow.modelId,
|
|
232
|
+
transaction_id: data.flow.transactionId,
|
|
233
|
+
run_id: data.flow.runId,
|
|
234
|
+
execution: data.flow,
|
|
235
|
+
context: {
|
|
236
|
+
data: data.context,
|
|
237
|
+
errors: data.errors,
|
|
238
|
+
},
|
|
239
|
+
state: data.flow.state,
|
|
240
|
+
retention_time: retentionTime,
|
|
241
|
+
},
|
|
242
|
+
]);
|
|
243
|
+
}
|
|
244
|
+
async deleteFromDb(data) {
|
|
245
|
+
await this.workflowExecutionService_.delete([
|
|
246
|
+
{
|
|
247
|
+
run_id: data.flow.runId,
|
|
248
|
+
},
|
|
249
|
+
]);
|
|
250
|
+
}
|
|
251
|
+
async executeTransaction(workflowId, transactionId, transactionMetadata = {}) {
|
|
252
|
+
return await this.workflowOrchestratorService_.run(workflowId, {
|
|
253
|
+
transactionId,
|
|
254
|
+
logOnError: true,
|
|
255
|
+
throwOnError: false,
|
|
256
|
+
context: {
|
|
257
|
+
eventGroupId: transactionMetadata.eventGroupId,
|
|
258
|
+
parentStepIdempotencyKey: transactionMetadata.parentStepIdempotencyKey,
|
|
259
|
+
preventReleaseEvents: transactionMetadata.preventReleaseEvents,
|
|
260
|
+
},
|
|
261
|
+
});
|
|
262
|
+
}
|
|
263
|
+
async executeScheduledJob(jobId, schedulerOptions) {
|
|
264
|
+
try {
|
|
265
|
+
// TODO: In the case of concurrency being forbidden, we want to generate a predictable transaction ID and rely on the idempotency
|
|
266
|
+
// of the transaction to ensure that the transaction is only executed once.
|
|
267
|
+
await this.workflowOrchestratorService_.run(jobId, {
|
|
268
|
+
logOnError: true,
|
|
269
|
+
});
|
|
270
|
+
}
|
|
271
|
+
catch (e) {
|
|
272
|
+
if (e instanceof utils_1.AcmeKitError && e.type === utils_1.AcmeKitError.Types.NOT_FOUND) {
|
|
273
|
+
this.logger_?.warn(`Tried to execute a scheduled workflow with ID ${jobId} that does not exist, removing it from the scheduler.`);
|
|
274
|
+
await this.remove(jobId);
|
|
275
|
+
return;
|
|
276
|
+
}
|
|
277
|
+
throw e;
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
async get(key, options) {
|
|
281
|
+
const [_, workflowId, transactionId] = key.split(":");
|
|
282
|
+
const [trx, rawData] = await (0, utils_1.promiseAll)([
|
|
283
|
+
this.workflowExecutionService_
|
|
284
|
+
.list({
|
|
285
|
+
workflow_id: workflowId,
|
|
286
|
+
transaction_id: transactionId,
|
|
287
|
+
}, {
|
|
288
|
+
select: ["execution", "context"],
|
|
289
|
+
order: {
|
|
290
|
+
id: "desc",
|
|
291
|
+
},
|
|
292
|
+
take: 1,
|
|
293
|
+
})
|
|
294
|
+
.then((trx) => trx[0])
|
|
295
|
+
.catch(() => undefined),
|
|
296
|
+
options?._cachedRawData !== undefined
|
|
297
|
+
? Promise.resolve(options._cachedRawData)
|
|
298
|
+
: this.redisClient.get(key),
|
|
299
|
+
]);
|
|
300
|
+
if (trx) {
|
|
301
|
+
let flow, errors;
|
|
302
|
+
if (rawData) {
|
|
303
|
+
const data = JSON.parse(rawData);
|
|
304
|
+
flow = data.flow;
|
|
305
|
+
errors = data.errors;
|
|
306
|
+
}
|
|
307
|
+
const { idempotent } = options ?? {};
|
|
308
|
+
const execution = trx.execution;
|
|
309
|
+
if (!idempotent) {
|
|
310
|
+
const isFailedOrReverted = failedStates.has(execution.state);
|
|
311
|
+
const isDone = execution.state === utils_1.TransactionState.DONE;
|
|
312
|
+
const isCancellingAndFailedOrReverted = options?.isCancelling && isFailedOrReverted;
|
|
313
|
+
const isNotCancellingAndDoneOrFailedOrReverted = !options?.isCancelling && (isDone || isFailedOrReverted);
|
|
314
|
+
if (isCancellingAndFailedOrReverted ||
|
|
315
|
+
isNotCancellingAndDoneOrFailedOrReverted) {
|
|
316
|
+
return;
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
return new orchestration_1.TransactionCheckpoint(flow ?? trx.execution, trx.context?.data, errors ?? trx.context?.errors);
|
|
320
|
+
}
|
|
321
|
+
return;
|
|
322
|
+
}
|
|
323
|
+
async save(key, data, ttl, options) {
|
|
324
|
+
/**
|
|
325
|
+
* Store the retention time only if the transaction is done, failed or reverted.
|
|
326
|
+
*/
|
|
327
|
+
const { retentionTime } = options ?? {};
|
|
328
|
+
let lockAcquired = false;
|
|
329
|
+
let storedData;
|
|
330
|
+
if (data.flow._v) {
|
|
331
|
+
lockAcquired = await __classPrivateFieldGet(this, _RedisDistributedTransactionStorage_instances, "m", _RedisDistributedTransactionStorage_acquireLock).call(this, key);
|
|
332
|
+
if (!lockAcquired) {
|
|
333
|
+
throw new Error("Lock not acquired");
|
|
334
|
+
}
|
|
335
|
+
storedData = await this.get(key, {
|
|
336
|
+
isCancelling: !!data.flow.cancelledAt,
|
|
337
|
+
});
|
|
338
|
+
orchestration_1.TransactionCheckpoint.mergeCheckpoints(data, storedData);
|
|
339
|
+
}
|
|
340
|
+
try {
|
|
341
|
+
const hasFinished = finishedStates.has(data.flow.state);
|
|
342
|
+
await __classPrivateFieldGet(this, _RedisDistributedTransactionStorage_instances, "m", _RedisDistributedTransactionStorage_preventRaceConditionExecutionIfNecessary).call(this, {
|
|
343
|
+
data: data,
|
|
344
|
+
key,
|
|
345
|
+
options,
|
|
346
|
+
storedData,
|
|
347
|
+
});
|
|
348
|
+
// Only set if not exists
|
|
349
|
+
const shouldSetNX = data.flow.state === utils_1.TransactionState.NOT_STARTED &&
|
|
350
|
+
!data.flow.transactionId.startsWith("auto-");
|
|
351
|
+
if (retentionTime) {
|
|
352
|
+
Object.assign(data, {
|
|
353
|
+
retention_time: retentionTime,
|
|
354
|
+
});
|
|
355
|
+
}
|
|
356
|
+
const execPipeline = () => {
|
|
357
|
+
const stringifiedData = JSON.stringify({
|
|
358
|
+
errors: data.errors,
|
|
359
|
+
flow: data.flow,
|
|
360
|
+
});
|
|
361
|
+
const pipeline = this.redisClient.pipeline();
|
|
362
|
+
if (!hasFinished) {
|
|
363
|
+
if (ttl) {
|
|
364
|
+
if (shouldSetNX) {
|
|
365
|
+
pipeline.set(key, stringifiedData, "EX", ttl, "NX");
|
|
366
|
+
}
|
|
367
|
+
else {
|
|
368
|
+
pipeline.set(key, stringifiedData, "EX", ttl);
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
else {
|
|
372
|
+
if (shouldSetNX) {
|
|
373
|
+
pipeline.set(key, stringifiedData, "NX");
|
|
374
|
+
}
|
|
375
|
+
else {
|
|
376
|
+
pipeline.set(key, stringifiedData);
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
else {
|
|
381
|
+
pipeline.unlink(key);
|
|
382
|
+
}
|
|
383
|
+
return pipeline.exec().then((result) => {
|
|
384
|
+
if (!shouldSetNX) {
|
|
385
|
+
return result;
|
|
386
|
+
}
|
|
387
|
+
const actionResult = result?.pop();
|
|
388
|
+
const isOk = !!actionResult?.pop();
|
|
389
|
+
if (!isOk) {
|
|
390
|
+
throw new orchestration_1.SkipExecutionError("Transaction already started for transactionId: " +
|
|
391
|
+
data.flow.transactionId);
|
|
392
|
+
}
|
|
393
|
+
return result;
|
|
394
|
+
});
|
|
395
|
+
};
|
|
396
|
+
// Parallelize DB and Redis operations for better performance
|
|
397
|
+
if (hasFinished && !retentionTime) {
|
|
398
|
+
if (!data.flow.metadata?.parentStepIdempotencyKey) {
|
|
399
|
+
await (0, utils_1.promiseAll)([this.deleteFromDb(data), execPipeline()]);
|
|
400
|
+
}
|
|
401
|
+
else {
|
|
402
|
+
await (0, utils_1.promiseAll)([this.saveToDb(data, retentionTime), execPipeline()]);
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
else {
|
|
406
|
+
await (0, utils_1.promiseAll)([this.saveToDb(data, retentionTime), execPipeline()]);
|
|
407
|
+
}
|
|
408
|
+
return data;
|
|
409
|
+
}
|
|
410
|
+
finally {
|
|
411
|
+
if (lockAcquired) {
|
|
412
|
+
await __classPrivateFieldGet(this, _RedisDistributedTransactionStorage_instances, "m", _RedisDistributedTransactionStorage_releaseLock).call(this, key);
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
async scheduleRetry(transaction, step, timestamp, interval) {
|
|
417
|
+
await this.queue.add(JobType.RETRY, {
|
|
418
|
+
workflowId: transaction.modelId,
|
|
419
|
+
transactionId: transaction.transactionId,
|
|
420
|
+
transactionMetadata: transaction.getFlow().metadata,
|
|
421
|
+
stepId: step.id,
|
|
422
|
+
}, {
|
|
423
|
+
delay: interval > 0 ? interval * 1000 : undefined,
|
|
424
|
+
jobId: this.getJobId(JobType.RETRY, transaction, step, interval),
|
|
425
|
+
removeOnComplete: true,
|
|
426
|
+
});
|
|
427
|
+
}
|
|
428
|
+
async clearRetry(transaction, step) {
|
|
429
|
+
// Pass retry interval to ensure we remove the correct job (with -retry suffix if interval > 0)
|
|
430
|
+
const interval = step.definition.retryInterval || 0;
|
|
431
|
+
await this.removeJob(JobType.RETRY, transaction, step, interval);
|
|
432
|
+
}
|
|
433
|
+
async scheduleTransactionTimeout(transaction, _, interval) {
|
|
434
|
+
await this.queue.add(JobType.TRANSACTION_TIMEOUT, {
|
|
435
|
+
workflowId: transaction.modelId,
|
|
436
|
+
transactionId: transaction.transactionId,
|
|
437
|
+
transactionMetadata: transaction.getFlow().metadata,
|
|
438
|
+
}, {
|
|
439
|
+
delay: interval * 1000,
|
|
440
|
+
jobId: this.getJobId(JobType.TRANSACTION_TIMEOUT, transaction),
|
|
441
|
+
removeOnComplete: true,
|
|
442
|
+
});
|
|
443
|
+
}
|
|
444
|
+
async clearTransactionTimeout(transaction) {
|
|
445
|
+
await this.removeJob(JobType.TRANSACTION_TIMEOUT, transaction);
|
|
446
|
+
}
|
|
447
|
+
async scheduleStepTimeout(transaction, step, timestamp, interval) {
|
|
448
|
+
await this.queue.add(JobType.STEP_TIMEOUT, {
|
|
449
|
+
workflowId: transaction.modelId,
|
|
450
|
+
transactionId: transaction.transactionId,
|
|
451
|
+
transactionMetadata: transaction.getFlow().metadata,
|
|
452
|
+
stepId: step.id,
|
|
453
|
+
}, {
|
|
454
|
+
delay: interval * 1000,
|
|
455
|
+
jobId: this.getJobId(JobType.STEP_TIMEOUT, transaction, step),
|
|
456
|
+
removeOnComplete: true,
|
|
457
|
+
});
|
|
458
|
+
}
|
|
459
|
+
async clearStepTimeout(transaction, step) {
|
|
460
|
+
await this.removeJob(JobType.STEP_TIMEOUT, transaction, step);
|
|
461
|
+
}
|
|
462
|
+
getJobId(type, transaction, step, interval) {
|
|
463
|
+
const key = [type, transaction.modelId, transaction.transactionId];
|
|
464
|
+
if (step) {
|
|
465
|
+
key.push(step.id, step.attempts + "");
|
|
466
|
+
// Add suffix for retry scheduling (interval > 0) to avoid collision with async execution (interval = 0)
|
|
467
|
+
if (type === JobType.RETRY && (0, utils_1.isDefined)(interval) && interval > 0) {
|
|
468
|
+
key.push("retry");
|
|
469
|
+
}
|
|
470
|
+
if (step.isCompensating()) {
|
|
471
|
+
key.push("compensate");
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
return key.join(":");
|
|
475
|
+
}
|
|
476
|
+
async removeJob(type, transaction, step, interval) {
|
|
477
|
+
const jobId = this.getJobId(type, transaction, step, interval);
|
|
478
|
+
if (type === JobType.SCHEDULE) {
|
|
479
|
+
const job = await this.jobQueue?.getJob(jobId);
|
|
480
|
+
if (job) {
|
|
481
|
+
await job.remove();
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
else {
|
|
485
|
+
const job = await this.queue.getJob(jobId);
|
|
486
|
+
if (job && job.attemptsStarted === 0) {
|
|
487
|
+
await job.remove();
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
/* Scheduler storage methods */
|
|
492
|
+
async schedule(jobDefinition, schedulerOptions) {
|
|
493
|
+
const jobId = typeof jobDefinition === "string" ? jobDefinition : jobDefinition.jobId;
|
|
494
|
+
if ("cron" in schedulerOptions && "interval" in schedulerOptions) {
|
|
495
|
+
throw new Error(`Unable to register a job with both scheduler options interval and cron.`);
|
|
496
|
+
}
|
|
497
|
+
const repeatOptions = {
|
|
498
|
+
limit: schedulerOptions.numberOfExecutions,
|
|
499
|
+
key: `${JobType.SCHEDULE}_${jobId}`,
|
|
500
|
+
};
|
|
501
|
+
if ("cron" in schedulerOptions) {
|
|
502
|
+
repeatOptions.pattern = schedulerOptions.cron;
|
|
503
|
+
}
|
|
504
|
+
else {
|
|
505
|
+
repeatOptions.every = schedulerOptions.interval;
|
|
506
|
+
}
|
|
507
|
+
// If it is the same key (eg. the same workflow name), the old one will get overridden.
|
|
508
|
+
await this.jobQueue?.add(JobType.SCHEDULE, {
|
|
509
|
+
jobId,
|
|
510
|
+
schedulerOptions,
|
|
511
|
+
}, {
|
|
512
|
+
repeat: repeatOptions,
|
|
513
|
+
removeOnComplete: {
|
|
514
|
+
age: 86400,
|
|
515
|
+
count: 1000,
|
|
516
|
+
},
|
|
517
|
+
removeOnFail: {
|
|
518
|
+
age: 604800,
|
|
519
|
+
count: 5000,
|
|
520
|
+
},
|
|
521
|
+
});
|
|
522
|
+
}
|
|
523
|
+
async remove(jobId) {
|
|
524
|
+
await this.jobQueue?.removeRepeatableByKey(`${JobType.SCHEDULE}_${jobId}`);
|
|
525
|
+
}
|
|
526
|
+
async removeAll() {
|
|
527
|
+
return await this.removeAllRepeatableJobs(this.jobQueue);
|
|
528
|
+
}
|
|
529
|
+
async removeAllRepeatableJobs(queue) {
|
|
530
|
+
const repeatableJobs = (await queue.getRepeatableJobs()) ?? [];
|
|
531
|
+
await (0, utils_1.promiseAll)(repeatableJobs.map((job) => queue.removeRepeatableByKey(job.key)));
|
|
532
|
+
}
|
|
533
|
+
async clearExpiredExecutions() {
|
|
534
|
+
await this.workflowExecutionService_.delete({
|
|
535
|
+
retention_time: {
|
|
536
|
+
$ne: null,
|
|
537
|
+
},
|
|
538
|
+
updated_at: {
|
|
539
|
+
$lte: (0, core_1.raw)((_alias) => `CURRENT_TIMESTAMP - (INTERVAL '1 second' * "retention_time")`),
|
|
540
|
+
},
|
|
541
|
+
state: {
|
|
542
|
+
$in: [
|
|
543
|
+
utils_1.TransactionState.DONE,
|
|
544
|
+
utils_1.TransactionState.FAILED,
|
|
545
|
+
utils_1.TransactionState.REVERTED,
|
|
546
|
+
],
|
|
547
|
+
},
|
|
548
|
+
});
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
exports.RedisDistributedTransactionStorage = RedisDistributedTransactionStorage;
|
|
552
|
+
_RedisDistributedTransactionStorage_isWorkerMode = new WeakMap(), _RedisDistributedTransactionStorage_instances = new WeakSet(), _RedisDistributedTransactionStorage_getLockKey = function _RedisDistributedTransactionStorage_getLockKey(key) {
|
|
553
|
+
return `${key}:lock`;
|
|
554
|
+
}, _RedisDistributedTransactionStorage_acquireLock = async function _RedisDistributedTransactionStorage_acquireLock(key, ttlSeconds = 2) {
|
|
555
|
+
const lockKey = __classPrivateFieldGet(this, _RedisDistributedTransactionStorage_instances, "m", _RedisDistributedTransactionStorage_getLockKey).call(this, key);
|
|
556
|
+
const result = await this.redisClient.set(lockKey, 1, "EX", ttlSeconds, "NX");
|
|
557
|
+
return result === "OK";
|
|
558
|
+
}, _RedisDistributedTransactionStorage_releaseLock = async function _RedisDistributedTransactionStorage_releaseLock(key) {
|
|
559
|
+
const lockKey = __classPrivateFieldGet(this, _RedisDistributedTransactionStorage_instances, "m", _RedisDistributedTransactionStorage_getLockKey).call(this, key);
|
|
560
|
+
await this.redisClient.del(lockKey);
|
|
561
|
+
}, _RedisDistributedTransactionStorage_preventRaceConditionExecutionIfNecessary = async function _RedisDistributedTransactionStorage_preventRaceConditionExecutionIfNecessary({ data, key, options, storedData, }) {
|
|
562
|
+
const isInitialCheckpoint = [utils_1.TransactionState.NOT_STARTED].includes(data.flow.state);
|
|
563
|
+
/**
|
|
564
|
+
* In case many execution can succeed simultaneously, we need to ensure that the latest
|
|
565
|
+
* execution does continue if a previous execution is considered finished
|
|
566
|
+
*/
|
|
567
|
+
const currentFlow = data.flow;
|
|
568
|
+
let data_ = storedData ?? {};
|
|
569
|
+
if (!storedData) {
|
|
570
|
+
const rawData = await this.redisClient.get(key);
|
|
571
|
+
if (rawData) {
|
|
572
|
+
data_ = JSON.parse(rawData);
|
|
573
|
+
}
|
|
574
|
+
else {
|
|
575
|
+
// Pass cached raw data to avoid redundant Redis fetch
|
|
576
|
+
const getOptions = {
|
|
577
|
+
...options,
|
|
578
|
+
isCancelling: !!data.flow.cancelledAt,
|
|
579
|
+
_cachedRawData: rawData,
|
|
580
|
+
};
|
|
581
|
+
data_ =
|
|
582
|
+
(await this.get(key, getOptions)) ??
|
|
583
|
+
{ flow: {} };
|
|
584
|
+
}
|
|
585
|
+
}
|
|
586
|
+
const { flow: latestUpdatedFlow } = data_;
|
|
587
|
+
if (options?.stepId) {
|
|
588
|
+
const stepId = options.stepId;
|
|
589
|
+
const currentStep = data.flow.steps[stepId];
|
|
590
|
+
const latestStep = latestUpdatedFlow.steps?.[stepId];
|
|
591
|
+
if (latestStep && currentStep) {
|
|
592
|
+
const isCompensating = data.flow.state === utils_1.TransactionState.COMPENSATING;
|
|
593
|
+
const latestState = isCompensating
|
|
594
|
+
? latestStep.compensate?.state
|
|
595
|
+
: latestStep.invoke?.state;
|
|
596
|
+
const shouldSkip = doneStates.has(latestState);
|
|
597
|
+
if (shouldSkip) {
|
|
598
|
+
throw new orchestration_1.SkipStepAlreadyFinishedError(`Step ${stepId} already finished by another execution`);
|
|
599
|
+
}
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
if (!isInitialCheckpoint &&
|
|
603
|
+
!(0, utils_1.isPresent)(latestUpdatedFlow) &&
|
|
604
|
+
!data.flow.metadata?.parentStepIdempotencyKey) {
|
|
605
|
+
/**
|
|
606
|
+
* the initial checkpoint expect no other checkpoint to have been stored.
|
|
607
|
+
* In case it is not the initial one and another checkpoint is trying to
|
|
608
|
+
* find if a concurrent execution has finished, we skip the execution.
|
|
609
|
+
* The already finished execution would have deleted the checkpoint already.
|
|
610
|
+
*/
|
|
611
|
+
throw new orchestration_1.SkipExecutionError("Already finished by another execution");
|
|
612
|
+
}
|
|
613
|
+
// Ensure that the latest execution was not cancelled, otherwise we skip the execution
|
|
614
|
+
const latestTransactionCancelledAt = latestUpdatedFlow.cancelledAt;
|
|
615
|
+
const currentTransactionCancelledAt = currentFlow.cancelledAt;
|
|
616
|
+
if (!!latestTransactionCancelledAt &&
|
|
617
|
+
currentTransactionCancelledAt == null) {
|
|
618
|
+
throw new orchestration_1.SkipCancelledExecutionError("Workflow execution has been cancelled during the execution");
|
|
619
|
+
}
|
|
620
|
+
};
|
|
621
|
+
//# sourceMappingURL=workflow-orchestrator-storage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workflow-orchestrator-storage.js","sourceRoot":"","sources":["../../src/utils/workflow-orchestrator-storage.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,4DAAuD;AACvD,oEAcyC;AAEzC,oDAOiC;AAEjC,mCAAkF;AAGlF,IAAK,OAKJ;AALD,WAAK,OAAO;IACV,gCAAqB,CAAA;IACrB,0BAAe,CAAA;IACf,wCAA6B,CAAA;IAC7B,sDAA2C,CAAA;AAC7C,CAAC,EALI,OAAO,KAAP,OAAO,QAKX;AAED,MAAM,oBAAoB,GAAG,IAAI,GAAG,EAAE,GAAG,EAAE,CAAA;AAC3C,MAAM,yBAAyB,GAAG,0BAA0B,CAAA;AAE5D,MAAM,UAAU,GAAG,IAAI,GAAG,CAAC;IACzB,4BAAoB,CAAC,IAAI;IACzB,4BAAoB,CAAC,QAAQ;IAC7B,4BAAoB,CAAC,MAAM;IAC3B,4BAAoB,CAAC,OAAO;IAC5B,4BAAoB,CAAC,eAAe;IACpC,4BAAoB,CAAC,OAAO;CAC7B,CAAC,CAAA;AAEF,MAAM,cAAc,GAAG,IAAI,GAAG,CAAC;IAC7B,wBAAgB,CAAC,IAAI;IACrB,wBAAgB,CAAC,MAAM;IACvB,wBAAgB,CAAC,QAAQ;CAC1B,CAAC,CAAA;AAEF,MAAM,YAAY,GAAG,IAAI,GAAG,CAAC;IAC3B,wBAAgB,CAAC,MAAM;IACvB,wBAAgB,CAAC,QAAQ;CAC1B,CAAC,CAAA;AACF,MAAa,kCAAkC;IA6B7C,YAAY,EACV,wBAAwB,EACxB,eAAe,EACf,qBAAqB,EACrB,cAAc,EACd,iBAAiB,EACjB,qBAAqB,EACrB,sBAAsB,EACtB,oBAAoB,EACpB,qBAAqB,EACrB,wBAAwB,EACxB,yBAAyB,EACzB,MAAM,EACN,YAAY,GAeb;;QA9BD,2DAAyB,KAAK,EAAA;QA+B5B,IAAI,CAAC,yBAAyB,GAAG,wBAAwB,CAAA;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