@@ -18,8 +18,6 @@ const (
18
18
19
19
// internal offset we use to detect if the offset has never been stored locally
20
20
offsetNotStored int64 = - 3
21
-
22
- consumerDrainTimeout = time .Second
23
21
)
24
22
25
23
// Backoff is used for adding backoff capabilities to the restarting
@@ -404,42 +402,22 @@ func (p *PartitionTable) markRecovered(ctx context.Context) error {
404
402
}
405
403
406
404
func (p * PartitionTable ) drainConsumer (cons sarama.PartitionConsumer ) error {
407
- timeoutCtx , cancel := context .WithTimeout (context .Background (), consumerDrainTimeout )
408
- defer cancel ()
409
-
410
405
errg , _ := multierr .NewErrGroup (context .Background ())
411
406
412
407
// drain errors channel
413
408
errg .Go (func () error {
414
409
var errs * multierror.Error
415
-
416
- for {
417
- select {
418
- case <- timeoutCtx .Done ():
419
- p .log .Printf ("draining errors channel timed out" )
420
- return errs
421
- case err , ok := <- cons .Errors ():
422
- if ! ok {
423
- return errs
424
- }
425
- errs = multierror .Append (errs , err )
426
- }
410
+ for err := range cons .Errors () {
411
+ errs = multierror .Append (errs , err )
427
412
}
413
+ return errs
428
414
})
429
415
430
416
// drain message channel
431
417
errg .Go (func () error {
432
- for {
433
- select {
434
- case <- timeoutCtx .Done ():
435
- p .log .Printf ("draining messages channel timed out" )
436
- return nil
437
- case _ , ok := <- cons .Messages ():
438
- if ! ok {
439
- return nil
440
- }
441
- }
418
+ for range cons .Messages () {
442
419
}
420
+ return nil
443
421
})
444
422
445
423
return errg .Wait ().ErrorOrNil ()
0 commit comments