MCPcopy
hub / github.com/redis/go-redis / shutdownWorkers

Method shutdownWorkers

maintnotifications/handoff_worker.go:330–354  ·  view source on GitHub ↗

shutdownWorkers gracefully shuts down the worker manager, waiting for workers to complete

(ctx context.Context)

Source from the content-addressed store, hash-verified

328
329// shutdownWorkers gracefully shuts down the worker manager, waiting for workers to complete
330func (hwm *handoffWorkerManager) shutdownWorkers(ctx context.Context) error {
331 hwm.shutdownOnce.Do(func() {
332 close(hwm.shutdown)
333 // workers will exit when they finish their current request
334
335 // Shutdown circuit breaker manager cleanup goroutine
336 if hwm.circuitBreakerManager != nil {
337 hwm.circuitBreakerManager.Shutdown()
338 }
339 })
340
341 // Wait for workers to complete
342 done := make(chan struct{})
343 go func() {
344 hwm.workerWg.Wait()
345 close(done)
346 }()
347
348 select {
349 case <-done:
350 return nil
351 case <-ctx.Done():
352 return ctx.Err()
353 }
354}
355
356// performConnectionHandoff performs the actual connection handoff
357// When error is returned, the connection handoff should be retried if err is not ErrMaxHandoffRetriesReached

Callers 1

ShutdownMethod · 0.80

Calls 4

WaitMethod · 0.80
DoMethod · 0.65
ShutdownMethod · 0.65
ErrMethod · 0.65

Tested by

no test coverage detected