Shutdown stops all queues.
()
| 132 | |
| 133 | // Shutdown stops all queues. |
| 134 | func (q *queue) Shutdown() { |
| 135 | q.logger.Info("Shutting down queue %q...", q.name) |
| 136 | defer func() { |
| 137 | q.routineGroup.Wait() |
| 138 | }() |
| 139 | |
| 140 | if !atomic.CompareAndSwapInt32(&q.stopFlag, 0, 1) { |
| 141 | return |
| 142 | } |
| 143 | |
| 144 | q.stopOnce.Do(func() { |
| 145 | q.cancel() |
| 146 | if q.metric.BusyWorkers() > 0 { |
| 147 | q.logger.Info("shutdown all tasks in queue %q: %d workers", q.name, q.metric.BusyWorkers()) |
| 148 | } |
| 149 | |
| 150 | if err := q.scheduler.Shutdown(); err != nil { |
| 151 | q.logger.Error("failed to shutdown scheduler in queue %q: %w", q.name, err) |
| 152 | } |
| 153 | close(q.quit) |
| 154 | }) |
| 155 | |
| 156 | } |
| 157 | |
| 158 | // BusyWorkers returns the numbers of workers in the running process. |
| 159 | func (q *queue) BusyWorkers() int { |