-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.ts
49 lines (45 loc) · 1.14 KB
/
main.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import {
OrkesApiConfig,
orkesConductorClient,
ConductorClient,
WorkflowExecutor,
} from "@io-orkes/conductor-javascript";
import { createTaskRunner } from "./workers/workerUtil";
const config: Partial<OrkesApiConfig> = {
keyId: process.env.KEY,
keySecret: process.env.SECRET,
serverUrl: process.env.SERVER_URL,
};
async function runWorkflow(
client: ConductorClient,
workflowName: string,
workflowVersion: number
) {
const workflowExecutor = new WorkflowExecutor(client);
return workflowExecutor.executeWorkflow(
{
name: workflowName,
version: workflowVersion,
input: {
accountId: "1234",
amount: 1000,
},
},
workflowName,
1,
"myRequest"
);
}
async function main() {
const name = process.env.WORKFLOW_NAME;
const version = process.env.WORKFLOW_VERSION || 1;
if (!name || !version) {
throw new Error("Workflow name or version not provided");
}
const client = await orkesConductorClient(config);
const taskRunner = createTaskRunner(client);
taskRunner.startPolling();
await runWorkflow(client, name, Number(version));
taskRunner.stopPolling();
}
main();