-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprocessor.js
More file actions
56 lines (41 loc) · 1.42 KB
/
Copy pathprocessor.js
File metadata and controls
56 lines (41 loc) · 1.42 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
const {Scheduler} = require('../dist/')
const moment = require('moment')
let scheduler = new Scheduler()
scheduler.addTask({
task: async (my) =>
console.log(`task1 uuid:${my.uuid} run!`),
callback: async (my, result)=>
console.log(`task1 uuid:${my.uuid} callback run!`)
})
scheduler.addTask({
task: async (my) =>
console.log(`task2 uuid:${my.uuid} run!`),
callback: async (my, result)=>
console.log(`task2 uuid:${my.uuid} callback run!`),
delay: 5000
})
scheduler.addTask({
task: async (my) =>
console.log(`task4 uuid:${my.uuid} run!`),
callback: async (my, result)=> {
console.log(`task4 uuid:${my.uuid} callback run!`)
scheduler.addTask({
task: async (my) =>
console.log(`task5 uuid:${my.uuid} run!`),
callback: async (my, result)=>
console.log(`task5 uuid:${my.uuid} callback run!`),
schedule: moment().add(5, 'second').valueOf()
})
},
schedule: moment().add(5, 'second').valueOf()
})
let taskHandler =
scheduler.addTask({
task: async (my) =>
console.log(`task3 uuid:${my.uuid} run!`),
callback: async (my, result)=> {
console.log(`task3 uuid:${my.uuid} callback run!`)
console.log(`task3 uuid:${my.uuid} callback isStopped: ${my.isStopped}`)
}
})
taskHandler.isStopped = true