MCPcopy
hub / github.com/segmentio/kafka-go / sleep

Function sleep

dialer.go:418–435  ·  view source on GitHub ↗
(ctx context.Context, duration time.Duration)

Source from the content-addressed store, hash-verified

416}
417
418func sleep(ctx context.Context, duration time.Duration) bool {
419 if duration == 0 {
420 select {
421 default:
422 return true
423 case <-ctx.Done():
424 return false
425 }
426 }
427 timer := time.NewTimer(duration)
428 defer timer.Stop()
429 select {
430 case <-timer.C:
431 return true
432 case <-ctx.Done():
433 return false
434 }
435}
436
437func backoff(attempt int, min time.Duration, max time.Duration) time.Duration {
438 d := time.Duration(attempt*attempt) * min

Callers 3

LookupPartitionMethod · 0.85
runMethod · 0.85

Calls 1

DoneMethod · 0.80

Tested by

no test coverage detected