Repository navigation
Expand file tree
/
Copy path10-schedule.js
More file actions
60 lines (50 loc) · 1.43 KB
/
Copy path10-schedule.js
File metadata and controls
60 lines (50 loc) · 1.43 KB
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
50
51
52
53
54
55
56
57
58
59
60
const workflow_es = require("workflow-es");
const workflow_mongo = require("workflow-es-mongodb");
class SayHello extends workflow_es.StepBody {
run(context) {
console.log("Hello");
return workflow_es.ExecutionResult.next();
}
}
class PrintMessage extends workflow_es.StepBody {
run(context) {
console.log(this.message);
return workflow_es.ExecutionResult.next();
}
}
class DoSomething extends workflow_es.StepBody {
run(context) {
console.log("Doing something...");
return workflow_es.ExecutionResult.next();
}
}
class SayGoodbye extends workflow_es.StepBody {
run(context) {
console.log("Bye");
return workflow_es.ExecutionResult.next();
}
}
class Schedule_Workflow {
constructor() {
this.id = "schedule-sample";
this.version = 1;
}
build(builder) {
builder
.startWith(SayHello)
.schedule((data) => 20000).do((then) => then
.startWith(PrintMessage)
.input((step, data) => step.message = "firing")
.then(DoSomething))
.then(SayGoodbye);
}
}
async function main() {
var config = workflow_es.configureWorkflow();
var host = config.getHost();
host.registerWorkflow(Schedule_Workflow);
await host.start();
let id = await host.startWorkflow("schedule-sample", 1);
console.log("Started workflow: " + id);
}
main();