We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 9939cb4 commit 3a2c115Copy full SHA for 3a2c115
_example/single-server/main.go
@@ -45,23 +45,19 @@ func main() {
45
)
46
47
// define the queue
48
- q, err := queue.NewQueue(
49
- queue.WithWorkerCount(10),
+ q := queue.NewPool(
+ 5,
50
queue.WithWorker(w),
51
52
- if err != nil {
53
- log.Fatal(err)
54
- }
55
-
56
- // start the five worker
57
- q.Start()
58
59
// assign tasks in queue
60
for i := 0; i < taskN; i++ {
61
go func(i int) {
62
- q.Queue(&job{
+ if err := q.Queue(&job{
63
Message: fmt.Sprintf("handle the job: %d", i+1),
64
- })
+ }); err != nil {
+ log.Fatal(err)
+ }
65
}(i)
66
}
67
@@ -72,7 +68,5 @@ func main() {
72
68
73
69
74
70
// shutdown the service and notify all the worker
75
- q.Shutdown()
76
- // wait all jobs are complete.
77
- q.Wait()
71
+ q.Release()
78
0 commit comments