MCPcopy Create free account
hub / github.com/coder/coder / next

Method next

enterprise/coderd/x/chatd/chatd.go:653–668  ·  view source on GitHub ↗

next returns the delay before the next dial and sets giveUp once attempts exceed relayMaxRetries. Adapts the math from retry.Retrier.Wait (github.com/coder/retry/retrier.go) without blocking: the library's Wait returns 0 on the first call and sets Delay to Floor only after the sleep, so we clamp to

()

Source from the content-addressed store, hash-verified

651// Delay to Floor only after the sleep, so we clamp to Floor up
652// front.
653func (s *relayRetryState) next() (delay time.Duration, giveUp bool) {
654 s.attempts++
655 if s.attempts > relayMaxRetries {
656 return 0, true
657 }
658 r := s.retrier
659 d := time.Duration(float64(r.Delay) * r.Rate)
660 if d > r.Ceil {
661 d = r.Ceil
662 }
663 if d < r.Floor {
664 d = r.Floor
665 }
666 r.Delay = d
667 return d, false
668}
669
670// reset returns the state to the floor delay and zero attempts.
671// Called after a successful dial or a relay target change.

Callers 3

localStorageMockFunction · 0.80
quietHoursDisplayFunction · 0.80

Calls 1

DurationMethod · 0.80

Tested by

no test coverage detected