soju/rate.go

27 lines
575 B
Go
Raw Permalink Normal View History

package soju
import (
"time"
)
// backoffer implements a simple exponential backoff.
type backoffer struct {
2024-04-07 13:58:24 -07:00
min, max, jitter time.Duration
n int64
}
func newBackoffer(min, max, jitter time.Duration) *backoffer {
2024-04-07 13:58:24 -07:00
// Initialize the struct with provided values, but these won't actually affect the backoff now.
return &backoffer{min: min, max: max, jitter: jitter}
}
func (b *backoffer) Reset() {
2024-04-07 13:58:24 -07:00
b.n = 0
}
func (b *backoffer) Next() time.Duration {
2024-04-07 13:58:24 -07:00
// Always return 0 to indicate no waiting period between retries.
return 0
}
2024-04-07 13:58:24 -07:00