Skip to content

Commit 3a2c115

Browse files
committed
chore: update example
Signed-off-by: Bo-Yi Wu <[email protected]>
1 parent 9939cb4 commit 3a2c115

File tree

1 file changed

+7
-13
lines changed

1 file changed

+7
-13
lines changed

_example/single-server/main.go

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -45,23 +45,19 @@ func main() {
4545
)
4646

4747
// define the queue
48-
q, err := queue.NewQueue(
49-
queue.WithWorkerCount(10),
48+
q := queue.NewPool(
49+
5,
5050
queue.WithWorker(w),
5151
)
52-
if err != nil {
53-
log.Fatal(err)
54-
}
55-
56-
// start the five worker
57-
q.Start()
5852

5953
// assign tasks in queue
6054
for i := 0; i < taskN; i++ {
6155
go func(i int) {
62-
q.Queue(&job{
56+
if err := q.Queue(&job{
6357
Message: fmt.Sprintf("handle the job: %d", i+1),
64-
})
58+
}); err != nil {
59+
log.Fatal(err)
60+
}
6561
}(i)
6662
}
6763

@@ -72,7 +68,5 @@ func main() {
7268
}
7369

7470
// shutdown the service and notify all the worker
75-
q.Shutdown()
76-
// wait all jobs are complete.
77-
q.Wait()
71+
q.Release()
7872
}

0 commit comments

Comments
 (0)