Commit 12834dc
committed
refactor: refactor queue management and improve task handling
- Add the `log` package to imports
- Remove `github.com/appleboy/graceful` from imports
- Alias `github.com/golang-queue/rabbitmq` as `rabbitmq` in imports
- Reduce `taskN` from 10000 to 100
- Remove the use of `graceful.NewManager()`
- Remove `rabbitmq.WithExchangeType(*exchangeType)` from the worker configuration
- Remove the `time.Sleep(500 * time.Millisecond)` call in the worker function
- Change queue initialization to use `queue.NewQueue` with a worker count of 5
- Add error handling for queue initialization
- Add code to start the queue with five workers
- Replace `graceful` job management with direct task assignment to the queue
- Add a loop to wait until all tasks are done, printing messages and sleeping for 50 milliseconds between each
Signed-off-by: appleboy <appleboy.tw@gmail.com>1 parent 6c0e5ed commit 12834dc
1 file changed
+28
-30
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| 26 | + | |
26 | 27 | | |
27 | 28 | | |
28 | | - | |
29 | 29 | | |
30 | 30 | | |
31 | | - | |
| 31 | + | |
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
| |||
56 | 56 | | |
57 | 57 | | |
58 | 58 | | |
59 | | - | |
| 59 | + | |
60 | 60 | | |
61 | 61 | | |
62 | | - | |
63 | | - | |
64 | 62 | | |
65 | 63 | | |
66 | 64 | | |
67 | 65 | | |
68 | 66 | | |
69 | | - | |
70 | 67 | | |
71 | 68 | | |
72 | 69 | | |
73 | 70 | | |
74 | 71 | | |
75 | 72 | | |
76 | 73 | | |
77 | | - | |
78 | 74 | | |
79 | 75 | | |
80 | 76 | | |
| 77 | + | |
81 | 78 | | |
82 | | - | |
83 | | - | |
| 79 | + | |
| 80 | + | |
84 | 81 | | |
85 | 82 | | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
86 | 86 | | |
87 | | - | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | | - | |
93 | | - | |
94 | | - | |
95 | | - | |
96 | | - | |
97 | | - | |
98 | | - | |
99 | | - | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
100 | 97 | | |
101 | | - | |
102 | | - | |
| 98 | + | |
| 99 | + | |
103 | 100 | | |
104 | | - | |
105 | | - | |
106 | | - | |
107 | | - | |
108 | | - | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
109 | 106 | | |
110 | | - | |
| 107 | + | |
| 108 | + | |
111 | 109 | | |
112 | 110 | | |
0 commit comments