MCPcopy Create free account
hub / github.com/flant/shell-operator / Shutdown

Method Shutdown

pkg/task/queue/queue_set.go:250–276  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

248// timeout and nil on a clean stop. Safe to call once; calling it on an
249// already-stopped set is a no-op.
250func (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}

Callers

nothing calls this directly

Calls 3

GetStatusTypeMethod · 0.80
StopMethod · 0.65
ListMethod · 0.45

Tested by

no test coverage detected