-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
49 lines (45 loc) · 2.11 KB
/
main.js
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
const { createAndRegisterWorkflow } = require("./workflow/workflowCreator")
const { createTaskManager } = require("./worker/workerUtil")
const {
executeWorkflowSync,
executeWorkflowAsync,
} = require("./workflow/workflowUtil")
const { getWorkflowExecutionUrl } = require("./client/apiUtil")
async function main() {
const wf = await createAndRegisterWorkflow();
const taskManager = await createTaskManager();
taskManager.startPolling();
await runSync();
await runAsync();
await taskManager.stopPolling();
process.exit(0);
}
async function runSync() {
const workflowRun = await executeWorkflowSync();
if (workflowRun.status != 'COMPLETED') {
throw new Error(`workflow not completed, workflowId: ${workflowRun.workflowId}`);
}
console.log();
console.log("=======================================================================================");
console.log("Workflow Execution Completed");
console.log(`Workflow Id: ${workflowRun.workflowId}`);
console.log(`Workflow Status: ${workflowRun.status}`);
console.log(`Workflow Output: ${workflowRun.output}`);
console.log(`Workflow Execution Flow UI: ${getWorkflowExecutionUrl(workflowRun.workflowId)}`);
console.log("=======================================================================================");
}
async function runAsync() {
const workflowStatus = await executeWorkflowAsync();
if (workflowStatus.status != 'COMPLETED') {
throw new Error(`workflow not completed, workflowId: ${workflowStatus.workflowId}`);
}
console.log();
console.log("=======================================================================================");
console.log("Workflow Execution Completed");
console.log(`Workflow Id: ${workflowStatus.workflowId}`);
console.log(`Workflow Status: ${workflowStatus.status}`);
console.log(`Workflow Output: ${workflowStatus.output}`);
console.log(`Workflow Execution Flow UI: ${getWorkflowExecutionUrl(workflowStatus.workflowId)}`);
console.log("=======================================================================================");
}
main()