Shutdown stops every queue in the set and blocks until either all workers reach QueueStatusStop or ctx is canceled / deadlines. Returns ctx.Err() on timeout and nil on a clean stop. Safe to call once; calling it on an already-stopped set is a no-op.
(ctx context.Context)
| 248 | // timeout and nil on a clean stop. Safe to call once; calling it on an |
| 249 | // already-stopped set is a no-op. |
| 250 | func (tqs *TaskQueueSet) Shutdown(ctx context.Context) error { |
| 251 | if tqs.cancel != nil { |
| 252 | tqs.cancel() |
| 253 | } |
| 254 | |
| 255 | checkTick := time.NewTicker(50 * time.Millisecond) |
| 256 | defer checkTick.Stop() |
| 257 | |
| 258 | for { |
| 259 | stopped := true |
| 260 | for _, q := range tqs.Queues.List() { |
| 261 | if q.GetStatusType() != QueueStatusStop { |
| 262 | stopped = false |
| 263 | break |
| 264 | } |
| 265 | } |
| 266 | if stopped { |
| 267 | return nil |
| 268 | } |
| 269 | |
| 270 | select { |
| 271 | case <-ctx.Done(): |
| 272 | return ctx.Err() |
| 273 | case <-checkTick.C: |
| 274 | } |
| 275 | } |
| 276 | } |
nothing calls this directly
no test coverage detected