-
Notifications
You must be signed in to change notification settings - Fork 10
/
main.go
60 lines (48 loc) · 1.05 KB
/
main.go
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
package main
import (
"strconv"
"time"
"github.com/deepaksinghvi/cdule/pkg/cdule"
"github.com/deepaksinghvi/cdule/pkg/utils"
log "github.com/sirupsen/logrus"
)
/*
TODO This TestJob schedule in main program is for the development debugging.
*/
func main() {
c := cdule.Cdule{}
c.NewCduleWithWorker("worker1")
myJob := TestJob{}
jobData := make(map[string]string)
jobData["one"] = "1"
jobData["two"] = "2"
jobData["three"] = "3"
_, err := cdule.NewJob(&myJob, jobData).Build(utils.EveryMinute)
if nil != err {
log.Error(err)
}
time.Sleep(5 * time.Minute)
c.StopWatcher()
}
var testJobData map[string]string
type TestJob struct {
Job cdule.Job
}
func (m TestJob) Execute(jobData map[string]string) {
log.Info("Execute(): In TestJob")
for k, v := range jobData {
valNum, err := strconv.Atoi(v)
if nil == err {
jobData[k] = strconv.Itoa(valNum + 1)
} else {
log.Error(err)
}
}
testJobData = jobData
}
func (m TestJob) JobName() string {
return "job.TestJob"
}
func (m TestJob) GetJobData() map[string]string {
return testJobData
}