@etohq/workflow-engine-redis 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +10 -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 +64 -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/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 +10 -0
- package/dist/models/workflow-execution.d.ts.map +1 -0
- package/dist/models/workflow-execution.js +33 -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 +83 -0
- package/dist/services/workflow-orchestrator.d.ts.map +1 -0
- package/dist/services/workflow-orchestrator.js +514 -0
- package/dist/services/workflow-orchestrator.js.map +1 -0
- package/dist/services/workflows-module.d.ts +54 -0
- package/dist/services/workflows-module.d.ts.map +1 -0
- package/dist/services/workflows-module.js +113 -0
- package/dist/services/workflows-module.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/types/index.d.ts +30 -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 +46 -0
- package/dist/utils/workflow-orchestrator-storage.d.ts.map +1 -0
- package/dist/utils/workflow-orchestrator-storage.js +262 -0
- package/dist/utils/workflow-orchestrator-storage.js.map +1 -0
- package/package.json +65 -0
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
var _a;
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.WorkflowsModuleService = void 0;
|
|
17
|
+
const types_1 = require("@etohq/framework/types");
|
|
18
|
+
const utils_1 = require("@etohq/framework/utils");
|
|
19
|
+
const _models_1 = require("../models");
|
|
20
|
+
class WorkflowsModuleService extends utils_1.ModulesSdkUtils.EtoService({ WorkflowExecution: _models_1.WorkflowExecution }) {
|
|
21
|
+
constructor({ baseRepository, workflowExecutionService, workflowOrchestratorService, redisDisconnectHandler, }, moduleDeclaration) {
|
|
22
|
+
// @ts-ignore
|
|
23
|
+
super(...arguments);
|
|
24
|
+
this.moduleDeclaration = moduleDeclaration;
|
|
25
|
+
this.__hooks = {
|
|
26
|
+
onApplicationShutdown: async () => {
|
|
27
|
+
await this.workflowOrchestratorService_.onApplicationShutdown();
|
|
28
|
+
await this.redisDisconnectHandler_();
|
|
29
|
+
},
|
|
30
|
+
onApplicationPrepareShutdown: async () => {
|
|
31
|
+
await this.workflowOrchestratorService_.onApplicationPrepareShutdown();
|
|
32
|
+
},
|
|
33
|
+
onApplicationStart: async () => {
|
|
34
|
+
await this.workflowOrchestratorService_.onApplicationStart();
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
this.baseRepository_ = baseRepository;
|
|
38
|
+
this.workflowExecutionService_ = workflowExecutionService;
|
|
39
|
+
this.workflowOrchestratorService_ = workflowOrchestratorService;
|
|
40
|
+
this.redisDisconnectHandler_ = redisDisconnectHandler;
|
|
41
|
+
}
|
|
42
|
+
async run(workflowIdOrWorkflow, options = {}, context = {}) {
|
|
43
|
+
const ret = await this.workflowOrchestratorService_.run(workflowIdOrWorkflow, options, context);
|
|
44
|
+
return ret;
|
|
45
|
+
}
|
|
46
|
+
async getRunningTransaction(workflowId, transactionId, context = {}) {
|
|
47
|
+
return await this.workflowOrchestratorService_.getRunningTransaction(workflowId, transactionId, context);
|
|
48
|
+
}
|
|
49
|
+
async setStepSuccess({ idempotencyKey, stepResponse, options, }, context = {}) {
|
|
50
|
+
return await this.workflowOrchestratorService_.setStepSuccess({
|
|
51
|
+
idempotencyKey,
|
|
52
|
+
stepResponse,
|
|
53
|
+
options,
|
|
54
|
+
}, context);
|
|
55
|
+
}
|
|
56
|
+
async setStepFailure({ idempotencyKey, stepResponse, options, }, context = {}) {
|
|
57
|
+
return await this.workflowOrchestratorService_.setStepFailure({
|
|
58
|
+
idempotencyKey,
|
|
59
|
+
stepResponse,
|
|
60
|
+
options,
|
|
61
|
+
}, context);
|
|
62
|
+
}
|
|
63
|
+
async subscribe(args, context = {}) {
|
|
64
|
+
return this.workflowOrchestratorService_.subscribe(args, context);
|
|
65
|
+
}
|
|
66
|
+
async unsubscribe(args, context = {}) {
|
|
67
|
+
return this.workflowOrchestratorService_.unsubscribe(args, context);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
exports.WorkflowsModuleService = WorkflowsModuleService;
|
|
71
|
+
__decorate([
|
|
72
|
+
(0, utils_1.InjectSharedContext)(),
|
|
73
|
+
__param(2, (0, utils_1.EtoContext)()),
|
|
74
|
+
__metadata("design:type", Function),
|
|
75
|
+
__metadata("design:paramtypes", [typeof (_a = typeof TWorkflow !== "undefined" && TWorkflow) === "function" ? _a : Object, Object, Object]),
|
|
76
|
+
__metadata("design:returntype", Promise)
|
|
77
|
+
], WorkflowsModuleService.prototype, "run", null);
|
|
78
|
+
__decorate([
|
|
79
|
+
(0, utils_1.InjectSharedContext)(),
|
|
80
|
+
__param(2, (0, utils_1.EtoContext)()),
|
|
81
|
+
__metadata("design:type", Function),
|
|
82
|
+
__metadata("design:paramtypes", [String, String, Object]),
|
|
83
|
+
__metadata("design:returntype", Promise)
|
|
84
|
+
], WorkflowsModuleService.prototype, "getRunningTransaction", null);
|
|
85
|
+
__decorate([
|
|
86
|
+
(0, utils_1.InjectSharedContext)(),
|
|
87
|
+
__param(1, (0, utils_1.EtoContext)()),
|
|
88
|
+
__metadata("design:type", Function),
|
|
89
|
+
__metadata("design:paramtypes", [Object, Object]),
|
|
90
|
+
__metadata("design:returntype", Promise)
|
|
91
|
+
], WorkflowsModuleService.prototype, "setStepSuccess", null);
|
|
92
|
+
__decorate([
|
|
93
|
+
(0, utils_1.InjectSharedContext)(),
|
|
94
|
+
__param(1, (0, utils_1.EtoContext)()),
|
|
95
|
+
__metadata("design:type", Function),
|
|
96
|
+
__metadata("design:paramtypes", [Object, Object]),
|
|
97
|
+
__metadata("design:returntype", Promise)
|
|
98
|
+
], WorkflowsModuleService.prototype, "setStepFailure", null);
|
|
99
|
+
__decorate([
|
|
100
|
+
(0, utils_1.InjectSharedContext)(),
|
|
101
|
+
__param(1, (0, utils_1.EtoContext)()),
|
|
102
|
+
__metadata("design:type", Function),
|
|
103
|
+
__metadata("design:paramtypes", [Object, Object]),
|
|
104
|
+
__metadata("design:returntype", Promise)
|
|
105
|
+
], WorkflowsModuleService.prototype, "subscribe", null);
|
|
106
|
+
__decorate([
|
|
107
|
+
(0, utils_1.InjectSharedContext)(),
|
|
108
|
+
__param(1, (0, utils_1.EtoContext)()),
|
|
109
|
+
__metadata("design:type", Function),
|
|
110
|
+
__metadata("design:paramtypes", [Object, Object]),
|
|
111
|
+
__metadata("design:returntype", Promise)
|
|
112
|
+
], WorkflowsModuleService.prototype, "unsubscribe", null);
|
|
113
|
+
//# sourceMappingURL=workflows-module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workflows-module.js","sourceRoot":"","sources":["../../src/services/workflows-module.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,kDAO+B;AAC/B,kDAI+B;AAK/B,qCAA2C;AAU3C,MAAa,sBAIX,SAAQ,uBAAe,CAAC,UAAU,CAEjC,EAAE,iBAAiB,EAAjB,2BAAiB,EAAE,CAAC;IAMvB,YACE,EACE,cAAc,EACd,wBAAwB,EACxB,2BAA2B,EAC3B,sBAAsB,GACD,EACJ,iBAA4C;QAE/D,aAAa;QACb,K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","../src/loaders/utils.ts","../src/migrations/Migration20231228143900.ts","../src/migrations/Migration20241206123341.ts","../src/models/index.ts","../src/models/workflow-execution.ts","../src/schema/index.ts","../src/services/index.ts","../src/services/workflow-orchestrator.ts","../src/services/workflows-module.ts","../src/types/index.ts","../src/utils/index.ts","../src/utils/workflow-orchestrator-storage.ts"],"version":"5.6.2"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Logger } from "@etohq/framework/types";
|
|
2
|
+
import { RedisOptions } from "ioredis";
|
|
3
|
+
export type InitializeModuleInjectableDependencies = {
|
|
4
|
+
logger?: Logger;
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* Module config type
|
|
8
|
+
*/
|
|
9
|
+
export type RedisWorkflowsOptions = {
|
|
10
|
+
/**
|
|
11
|
+
* Redis connection string
|
|
12
|
+
*/
|
|
13
|
+
url?: string;
|
|
14
|
+
/**
|
|
15
|
+
* Queue name used for retries and timeouts
|
|
16
|
+
*/
|
|
17
|
+
queueName?: string;
|
|
18
|
+
/**
|
|
19
|
+
* Redis client options
|
|
20
|
+
*/
|
|
21
|
+
options?: RedisOptions;
|
|
22
|
+
/**
|
|
23
|
+
* Optiona connection string and options to pub/sub
|
|
24
|
+
*/
|
|
25
|
+
pubsub?: {
|
|
26
|
+
url: string;
|
|
27
|
+
options?: RedisOptions;
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAA;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAEtC,MAAM,MAAM,sCAAsC,GAAG;IACnD,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB,CAAA;AAED;;GAEG;AACH,MAAM,MAAM,qBAAqB,GAAG;IAClC;;OAEG;IACH,GAAG,CAAC,EAAE,MAAM,CAAA;IAEZ;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAElB;;OAEG;IACH,OAAO,CAAC,EAAE,YAAY,CAAA;IAEtB;;OAEG;IACH,MAAM,CAAC,EAAE;QACP,GAAG,EAAE,MAAM,CAAA;QACX,OAAO,CAAC,EAAE,YAAY,CAAA;KACvB,CAAA;CACF,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,iCAAiC,CAAA"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./workflow-orchestrator-storage"), exports);
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,kEAA+C"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { DistributedTransactionType, IDistributedSchedulerStorage, IDistributedTransactionStorage, SchedulerOptions, TransactionCheckpoint, TransactionOptions, TransactionStep } from "@etohq/framework/orchestration";
|
|
2
|
+
import { Logger, ModulesSdkTypes } from "@etohq/framework/types";
|
|
3
|
+
import Redis from "ioredis";
|
|
4
|
+
export declare class RedisDistributedTransactionStorage implements IDistributedTransactionStorage, IDistributedSchedulerStorage {
|
|
5
|
+
private static TTL_AFTER_COMPLETED;
|
|
6
|
+
private workflowExecutionService_;
|
|
7
|
+
private logger_;
|
|
8
|
+
private workflowOrchestratorService_;
|
|
9
|
+
private redisClient;
|
|
10
|
+
private redisWorkerConnection;
|
|
11
|
+
private queueName;
|
|
12
|
+
private queue;
|
|
13
|
+
private worker;
|
|
14
|
+
constructor({ workflowExecutionService, redisConnection, redisWorkerConnection, redisQueueName, logger, }: {
|
|
15
|
+
workflowExecutionService: ModulesSdkTypes.IEtoInternalService<any>;
|
|
16
|
+
redisConnection: Redis;
|
|
17
|
+
redisWorkerConnection: Redis;
|
|
18
|
+
redisQueueName: string;
|
|
19
|
+
logger: Logger;
|
|
20
|
+
});
|
|
21
|
+
onApplicationPrepareShutdown(): Promise<void>;
|
|
22
|
+
onApplicationShutdown(): Promise<void>;
|
|
23
|
+
onApplicationStart(): Promise<void>;
|
|
24
|
+
setWorkflowOrchestratorService(workflowOrchestratorService: any): void;
|
|
25
|
+
private saveToDb;
|
|
26
|
+
private deleteFromDb;
|
|
27
|
+
private executeTransaction;
|
|
28
|
+
private executeScheduledJob;
|
|
29
|
+
get(key: string, options?: TransactionOptions): Promise<TransactionCheckpoint | undefined>;
|
|
30
|
+
list(): Promise<TransactionCheckpoint[]>;
|
|
31
|
+
save(key: string, data: TransactionCheckpoint, ttl?: number, options?: TransactionOptions): Promise<void>;
|
|
32
|
+
scheduleRetry(transaction: DistributedTransactionType, step: TransactionStep, timestamp: number, interval: number): Promise<void>;
|
|
33
|
+
clearRetry(transaction: DistributedTransactionType, step: TransactionStep): Promise<void>;
|
|
34
|
+
scheduleTransactionTimeout(transaction: DistributedTransactionType, _: number, interval: number): Promise<void>;
|
|
35
|
+
clearTransactionTimeout(transaction: DistributedTransactionType): Promise<void>;
|
|
36
|
+
scheduleStepTimeout(transaction: DistributedTransactionType, step: TransactionStep, timestamp: number, interval: number): Promise<void>;
|
|
37
|
+
clearStepTimeout(transaction: DistributedTransactionType, step: TransactionStep): Promise<void>;
|
|
38
|
+
private getJobId;
|
|
39
|
+
private removeJob;
|
|
40
|
+
schedule(jobDefinition: string | {
|
|
41
|
+
jobId: string;
|
|
42
|
+
}, schedulerOptions: SchedulerOptions): Promise<void>;
|
|
43
|
+
remove(jobId: string): Promise<void>;
|
|
44
|
+
removeAll(): Promise<void>;
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=workflow-orchestrator-storage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workflow-orchestrator-storage.d.ts","sourceRoot":"","sources":["../../src/utils/workflow-orchestrator-storage.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,0BAA0B,EAC1B,4BAA4B,EAC5B,8BAA8B,EAC9B,gBAAgB,EAChB,qBAAqB,EACrB,kBAAkB,EAClB,eAAe,EAChB,MAAM,gCAAgC,CAAA;AACvC,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AAQhE,OAAO,KAAK,MAAM,SAAS,CAAA;AAS3B,qBAAa,kCACX,YAAW,8BAA8B,EAAE,4BAA4B;IAEvE,OAAO,CAAC,MAAM,CAAC,mBAAmB,CAAS;IAC3C,OAAO,CAAC,yBAAyB,CAA0C;IAC3E,OAAO,CAAC,OAAO,CAAQ;IACvB,OAAO,CAAC,4BAA4B,CAA6B;IAEjE,OAAO,CAAC,WA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AAuB,CAC3B,WAAW,EAAE,0BAA0B,GACtC,OAAO,CAAC,IAAI,CAAC;IAIV,mBAAmB,CACvB,WAAW,EAAE,0BAA0B,EACvC,IAAI,EAAE,eAAe,EACrB,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,IAAI,CAAC;IAgBV,gBAAgB,CACpB,WAAW,EAAE,0BAA0B,EACvC,IAAI,EAAE,eAAe,GACpB,OAAO,CAAC,IAAI,CAAC;IAIhB,OAAO,CAAC,QAAQ;YAiBF,SAAS;IAcjB,QAAQ,CACZ,aAAa,EAAE,MAAM,GAAG;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,EACzC,gBAAgB,EAAE,gBAAgB,GACjC,OAAO,CAAC,IAAI,CAAC;IA6BV,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIpC,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC;CAMjC"}
|
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RedisDistributedTransactionStorage = void 0;
|
|
4
|
+
const orchestration_1 = require("@etohq/framework/orchestration");
|
|
5
|
+
const utils_1 = require("@etohq/framework/utils");
|
|
6
|
+
const bullmq_1 = require("bullmq");
|
|
7
|
+
var JobType;
|
|
8
|
+
(function (JobType) {
|
|
9
|
+
JobType["SCHEDULE"] = "schedule";
|
|
10
|
+
JobType["RETRY"] = "retry";
|
|
11
|
+
JobType["STEP_TIMEOUT"] = "step_timeout";
|
|
12
|
+
JobType["TRANSACTION_TIMEOUT"] = "transaction_timeout";
|
|
13
|
+
})(JobType || (JobType = {}));
|
|
14
|
+
class RedisDistributedTransactionStorage {
|
|
15
|
+
constructor({ workflowExecutionService, redisConnection, redisWorkerConnection, redisQueueName, logger, }) {
|
|
16
|
+
this.workflowExecutionService_ = workflowExecutionService;
|
|
17
|
+
this.logger_ = logger;
|
|
18
|
+
this.redisClient = redisConnection;
|
|
19
|
+
this.redisWorkerConnection = redisWorkerConnection;
|
|
20
|
+
this.queueName = redisQueueName;
|
|
21
|
+
this.queue = new bullmq_1.Queue(redisQueueName, { connection: this.redisClient });
|
|
22
|
+
}
|
|
23
|
+
async onApplicationPrepareShutdown() {
|
|
24
|
+
// Close worker gracefully, i.e. wait for the current jobs to finish
|
|
25
|
+
await this.worker?.close();
|
|
26
|
+
}
|
|
27
|
+
async onApplicationShutdown() {
|
|
28
|
+
await this.queue?.close();
|
|
29
|
+
}
|
|
30
|
+
async onApplicationStart() {
|
|
31
|
+
const allowedJobs = [
|
|
32
|
+
JobType.RETRY,
|
|
33
|
+
JobType.STEP_TIMEOUT,
|
|
34
|
+
JobType.TRANSACTION_TIMEOUT,
|
|
35
|
+
];
|
|
36
|
+
this.worker = new bullmq_1.Worker(this.queueName, async (job) => {
|
|
37
|
+
if (allowedJobs.includes(job.name)) {
|
|
38
|
+
await this.executeTransaction(job.data.workflowId, job.data.transactionId);
|
|
39
|
+
}
|
|
40
|
+
// Note: We might even want a separate worker with different concurrency settings in the future, but for now we keep it simple
|
|
41
|
+
if (job.name === JobType.SCHEDULE) {
|
|
42
|
+
await this.executeScheduledJob(job.data.jobId, job.data.schedulerOptions);
|
|
43
|
+
}
|
|
44
|
+
}, {
|
|
45
|
+
connection: this.redisWorkerConnection /*, runRetryDelay: 100000 for tests */,
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
setWorkflowOrchestratorService(workflowOrchestratorService) {
|
|
49
|
+
this.workflowOrchestratorService_ = workflowOrchestratorService;
|
|
50
|
+
}
|
|
51
|
+
async saveToDb(data) {
|
|
52
|
+
await this.workflowExecutionService_.upsert([
|
|
53
|
+
{
|
|
54
|
+
workflow_id: data.flow.modelId,
|
|
55
|
+
transaction_id: data.flow.transactionId,
|
|
56
|
+
execution: data.flow,
|
|
57
|
+
context: {
|
|
58
|
+
data: data.context,
|
|
59
|
+
errors: data.errors,
|
|
60
|
+
},
|
|
61
|
+
state: data.flow.state,
|
|
62
|
+
},
|
|
63
|
+
]);
|
|
64
|
+
}
|
|
65
|
+
async deleteFromDb(data) {
|
|
66
|
+
await this.workflowExecutionService_.delete([
|
|
67
|
+
{
|
|
68
|
+
workflow_id: data.flow.modelId,
|
|
69
|
+
transaction_id: data.flow.transactionId,
|
|
70
|
+
},
|
|
71
|
+
]);
|
|
72
|
+
}
|
|
73
|
+
async executeTransaction(workflowId, transactionId) {
|
|
74
|
+
return await this.workflowOrchestratorService_.run(workflowId, {
|
|
75
|
+
transactionId,
|
|
76
|
+
logOnError: true,
|
|
77
|
+
throwOnError: false,
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
async executeScheduledJob(jobId, schedulerOptions) {
|
|
81
|
+
try {
|
|
82
|
+
// TODO: In the case of concurrency being forbidden, we want to generate a predictable transaction ID and rely on the idempotency
|
|
83
|
+
// of the transaction to ensure that the transaction is only executed once.
|
|
84
|
+
return await this.workflowOrchestratorService_.run(jobId, {
|
|
85
|
+
logOnError: true,
|
|
86
|
+
throwOnError: false,
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
catch (e) {
|
|
90
|
+
if (e instanceof utils_1.EtoError && e.type === utils_1.EtoError.Types.NOT_FOUND) {
|
|
91
|
+
this.logger_?.warn(`Tried to execute a scheduled workflow with ID ${jobId} that does not exist, removing it from the scheduler.`);
|
|
92
|
+
await this.remove(jobId);
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
throw e;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
async get(key, options) {
|
|
99
|
+
const data = await this.redisClient.get(key);
|
|
100
|
+
if (data) {
|
|
101
|
+
return JSON.parse(data);
|
|
102
|
+
}
|
|
103
|
+
const { idempotent } = options ?? {};
|
|
104
|
+
if (!idempotent) {
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
const [_, workflowId, transactionId] = key.split(":");
|
|
108
|
+
const trx = await this.workflowExecutionService_
|
|
109
|
+
.retrieve({
|
|
110
|
+
workflow_id: workflowId,
|
|
111
|
+
transaction_id: transactionId,
|
|
112
|
+
}, {
|
|
113
|
+
select: ["execution", "context"],
|
|
114
|
+
})
|
|
115
|
+
.catch(() => undefined);
|
|
116
|
+
if (trx) {
|
|
117
|
+
return {
|
|
118
|
+
flow: trx.execution,
|
|
119
|
+
context: trx.context.data,
|
|
120
|
+
errors: trx.context.errors,
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
async list() {
|
|
126
|
+
const keys = await this.redisClient.keys(orchestration_1.DistributedTransaction.keyPrefix + ":*");
|
|
127
|
+
const transactions = [];
|
|
128
|
+
for (const key of keys) {
|
|
129
|
+
const data = await this.redisClient.get(key);
|
|
130
|
+
if (data) {
|
|
131
|
+
transactions.push(JSON.parse(data));
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
return transactions;
|
|
135
|
+
}
|
|
136
|
+
async save(key, data, ttl, options) {
|
|
137
|
+
/**
|
|
138
|
+
* Store the retention time only if the transaction is done, failed or reverted.
|
|
139
|
+
* From that moment, this tuple can be later on archived or deleted after the retention time.
|
|
140
|
+
*/
|
|
141
|
+
const hasFinished = [
|
|
142
|
+
utils_1.TransactionState.DONE,
|
|
143
|
+
utils_1.TransactionState.FAILED,
|
|
144
|
+
utils_1.TransactionState.REVERTED,
|
|
145
|
+
].includes(data.flow.state);
|
|
146
|
+
const { retentionTime, idempotent } = options ?? {};
|
|
147
|
+
if (hasFinished) {
|
|
148
|
+
Object.assign(data, {
|
|
149
|
+
retention_time: retentionTime,
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
const stringifiedData = JSON.stringify(data);
|
|
153
|
+
if (!hasFinished) {
|
|
154
|
+
if (ttl) {
|
|
155
|
+
await this.redisClient.set(key, stringifiedData, "EX", ttl);
|
|
156
|
+
}
|
|
157
|
+
else {
|
|
158
|
+
await this.redisClient.set(key, stringifiedData);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
if (hasFinished && !retentionTime && !idempotent) {
|
|
162
|
+
await this.deleteFromDb(data);
|
|
163
|
+
}
|
|
164
|
+
else {
|
|
165
|
+
await this.saveToDb(data);
|
|
166
|
+
}
|
|
167
|
+
if (hasFinished) {
|
|
168
|
+
await this.redisClient.set(key, stringifiedData, "EX", RedisDistributedTransactionStorage.TTL_AFTER_COMPLETED);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
async scheduleRetry(transaction, step, timestamp, interval) {
|
|
172
|
+
await this.queue.add(JobType.RETRY, {
|
|
173
|
+
workflowId: transaction.modelId,
|
|
174
|
+
transactionId: transaction.transactionId,
|
|
175
|
+
stepId: step.id,
|
|
176
|
+
}, {
|
|
177
|
+
delay: interval > 0 ? interval * 1000 : undefined,
|
|
178
|
+
jobId: this.getJobId(JobType.RETRY, transaction, step),
|
|
179
|
+
removeOnComplete: true,
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
async clearRetry(transaction, step) {
|
|
183
|
+
await this.removeJob(JobType.RETRY, transaction, step);
|
|
184
|
+
}
|
|
185
|
+
async scheduleTransactionTimeout(transaction, _, interval) {
|
|
186
|
+
await this.queue.add(JobType.TRANSACTION_TIMEOUT, {
|
|
187
|
+
workflowId: transaction.modelId,
|
|
188
|
+
transactionId: transaction.transactionId,
|
|
189
|
+
}, {
|
|
190
|
+
delay: interval * 1000,
|
|
191
|
+
jobId: this.getJobId(JobType.TRANSACTION_TIMEOUT, transaction),
|
|
192
|
+
removeOnComplete: true,
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
async clearTransactionTimeout(transaction) {
|
|
196
|
+
await this.removeJob(JobType.TRANSACTION_TIMEOUT, transaction);
|
|
197
|
+
}
|
|
198
|
+
async scheduleStepTimeout(transaction, step, timestamp, interval) {
|
|
199
|
+
await this.queue.add(JobType.STEP_TIMEOUT, {
|
|
200
|
+
workflowId: transaction.modelId,
|
|
201
|
+
transactionId: transaction.transactionId,
|
|
202
|
+
stepId: step.id,
|
|
203
|
+
}, {
|
|
204
|
+
delay: interval * 1000,
|
|
205
|
+
jobId: this.getJobId(JobType.STEP_TIMEOUT, transaction, step),
|
|
206
|
+
removeOnComplete: true,
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
async clearStepTimeout(transaction, step) {
|
|
210
|
+
await this.removeJob(JobType.STEP_TIMEOUT, transaction, step);
|
|
211
|
+
}
|
|
212
|
+
getJobId(type, transaction, step) {
|
|
213
|
+
const key = [type, transaction.modelId, transaction.transactionId];
|
|
214
|
+
if (step) {
|
|
215
|
+
key.push(step.id, step.attempts + "");
|
|
216
|
+
if (step.isCompensating()) {
|
|
217
|
+
key.push("compensate");
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
return key.join(":");
|
|
221
|
+
}
|
|
222
|
+
async removeJob(type, transaction, step) {
|
|
223
|
+
const jobId = this.getJobId(type, transaction, step);
|
|
224
|
+
const job = await this.queue.getJob(jobId);
|
|
225
|
+
if (job && job.attemptsStarted === 0) {
|
|
226
|
+
await job.remove();
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
/* Scheduler storage methods */
|
|
230
|
+
async schedule(jobDefinition, schedulerOptions) {
|
|
231
|
+
const jobId = typeof jobDefinition === "string" ? jobDefinition : jobDefinition.jobId;
|
|
232
|
+
// If it is the same key (eg. the same workflow name), the old one will get overridden.
|
|
233
|
+
await this.queue.add(JobType.SCHEDULE, {
|
|
234
|
+
jobId,
|
|
235
|
+
schedulerOptions,
|
|
236
|
+
}, {
|
|
237
|
+
repeat: {
|
|
238
|
+
pattern: schedulerOptions.cron,
|
|
239
|
+
limit: schedulerOptions.numberOfExecutions,
|
|
240
|
+
key: `${JobType.SCHEDULE}_${jobId}`,
|
|
241
|
+
},
|
|
242
|
+
removeOnComplete: {
|
|
243
|
+
age: 86400,
|
|
244
|
+
count: 1000,
|
|
245
|
+
},
|
|
246
|
+
removeOnFail: {
|
|
247
|
+
age: 604800,
|
|
248
|
+
count: 5000,
|
|
249
|
+
},
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
async remove(jobId) {
|
|
253
|
+
await this.queue.removeRepeatableByKey(`${JobType.SCHEDULE}_${jobId}`);
|
|
254
|
+
}
|
|
255
|
+
async removeAll() {
|
|
256
|
+
const repeatableJobs = await this.queue.getRepeatableJobs();
|
|
257
|
+
await (0, utils_1.promiseAll)(repeatableJobs.map((job) => this.queue.removeRepeatableByKey(job.key)));
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
exports.RedisDistributedTransactionStorage = RedisDistributedTransactionStorage;
|
|
261
|
+
RedisDistributedTransactionStorage.TTL_AFTER_COMPLETED = 60 * 2; // 2 minutes
|
|
262
|
+
//# 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,kEASuC;AAEvC,kDAI+B;AAE/B,mCAAsC;AAGtC,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,MAAa,kCAAkC;IAc7C,YAAY,EACV,wBAAwB,EACxB,eAAe,EACf,qBAAqB,EACrB,cAAc,EACd,MAAM,GAOP;QACC,IAAI,CAAC,yBAAyB,GAAG,wBAAwB,CAAA;QACzD,IAAI,CAAC,OAAO,GAAG,MAAM,CAAA;QACrB,IAAI,CAAC,WAAW,GAAG,eAAe,CAAA;QAClC,IAAI,CAAC,qBAAqB,GAAG,qBAAqB,CAAA;QAClD,IAAI,CAAC,SAAS,GAAG,cAAc,CAAA;QAC/B,IAAI,CAAC,KAAK,GAAG,IAAI,cAAK,CAAC,cAAc,EAAE,EAAE,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,iBAAiB,EAAE,CAAA;QAC3D,MAAM,IAAA,kBAAU,EACd,cAAc,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,qBAAqB,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CACvE,CAAA;IACH,CAAC;;AAxYH,gFAyYC;AAtYgB,sDAAmB,GAAG,EAAE,GAAG,CAAC,CAAA,CAAC,YAAY"}
|
package/package.json
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@etohq/workflow-engine-redis",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Eto Workflow Orchestrator module using Redis to track workflows executions",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist",
|
|
9
|
+
"!dist/**/__tests__",
|
|
10
|
+
"!dist/**/__mocks__",
|
|
11
|
+
"!dist/**/__fixtures__"
|
|
12
|
+
],
|
|
13
|
+
"engines": {
|
|
14
|
+
"node": ">=20"
|
|
15
|
+
},
|
|
16
|
+
"repository": {
|
|
17
|
+
"type": "git",
|
|
18
|
+
"url": "https://github.com/etohq/eto",
|
|
19
|
+
"directory": "packages/workflow-engine-redis"
|
|
20
|
+
},
|
|
21
|
+
"publishConfig": {
|
|
22
|
+
"access": "public"
|
|
23
|
+
},
|
|
24
|
+
"author": "Eto",
|
|
25
|
+
"license": "MIT",
|
|
26
|
+
"scripts": {
|
|
27
|
+
"watch": "tsc --build --watch",
|
|
28
|
+
"watch:test": "tsc --build tsconfig.spec.json --watch",
|
|
29
|
+
"resolve:aliases": "tsc --showConfig -p tsconfig.json > tsconfig.resolved.json && tsc-alias -p tsconfig.resolved.json && rimraf tsconfig.resolved.json", "build": "rimraf dist && tsc --build && npm run resolve:aliases",
|
|
30
|
+
"test": "jest --passWithNoTests --runInBand --bail --forceExit -- src",
|
|
31
|
+
"test:integration": "jest --forceExit -- integration-tests/**/__tests__/**/*.ts",
|
|
32
|
+
"migration:initial": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts eto-mikro-orm migration:create --initial",
|
|
33
|
+
"migration:create": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts eto-mikro-orm migration:create",
|
|
34
|
+
"migration:up": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts eto-mikro-orm migration:up",
|
|
35
|
+
"orm:cache:clear": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts eto-mikro-orm cache:clear"
|
|
36
|
+
},
|
|
37
|
+
"devDependencies": {
|
|
38
|
+
"@etohq/framework": "^1.0.0",
|
|
39
|
+
"@etohq/test-utils": "^1.0.0",
|
|
40
|
+
"@mikro-orm/cli": "5.9.7",
|
|
41
|
+
"@mikro-orm/core": "5.9.7",
|
|
42
|
+
"@mikro-orm/migrations": "5.9.7",
|
|
43
|
+
"@mikro-orm/postgresql": "5.9.7",
|
|
44
|
+
"@swc/core": "^1.7.28",
|
|
45
|
+
"@swc/jest": "^0.2.36",
|
|
46
|
+
"@types/jest": "^29.5.14",
|
|
47
|
+
"jest": "^29.7.0",
|
|
48
|
+
"rimraf": "^5.0.2",
|
|
49
|
+
"tsc-alias": "^1.8.6",
|
|
50
|
+
"typescript": "^5.6.2"
|
|
51
|
+
},
|
|
52
|
+
"dependencies": {
|
|
53
|
+
"awilix": "^8.0.1",
|
|
54
|
+
"bullmq": "5.13.0",
|
|
55
|
+
"ioredis": "^5.4.1",
|
|
56
|
+
"ulid": "^2.3.0"
|
|
57
|
+
},
|
|
58
|
+
"peerDependencies": {
|
|
59
|
+
"@etohq/framework": "^1.0.0",
|
|
60
|
+
"@mikro-orm/core": "5.9.7",
|
|
61
|
+
"@mikro-orm/migrations": "5.9.7",
|
|
62
|
+
"@mikro-orm/postgresql": "5.9.7",
|
|
63
|
+
"awilix": "^8.0.1"
|
|
64
|
+
}
|
|
65
|
+
}
|