-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
46 lines (38 loc) · 817 Bytes
/
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
package main
import (
"fmt"
"time"
"github.com/idugan100/jobqueue/jobqueue"
)
type myjob struct{}
func (m myjob) Run() jobqueue.JobResult {
time.Sleep(5 * time.Second)
_, err := fmt.Println("hello world!")
if err != nil {
return jobqueue.JobResult{Successful: false, ErrorMessage: err.Error()}
}
return jobqueue.JobResult{Successful: true}
}
type quickjob struct{}
func (q quickjob) Run() jobqueue.JobResult {
_, err := fmt.Println("hello world!")
if err != nil {
return jobqueue.JobResult{Successful: false, ErrorMessage: err.Error()}
}
return jobqueue.JobResult{Successful: true}
}
func main() {
m := myjob{}
qj := quickjob{}
q := jobqueue.NewQueue()
for range 1 {
q.AddJob(m)
}
for range 2 {
q.AddJob(qj)
}
fmt.Println("hi1")
fmt.Println("hi2")
fmt.Println("hi3")
q.Stop()
}