soju/rate.go
2024-04-07 14:58:24 -06:00

27 lines
575 B
Go

package soju
import (
"time"
)
// backoffer implements a simple exponential backoff.
type backoffer struct {
min, max, jitter time.Duration
n int64
}
func newBackoffer(min, max, jitter time.Duration) *backoffer {
// 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() {
b.n = 0
}
func (b *backoffer) Next() time.Duration {
// Always return 0 to indicate no waiting period between retries.
return 0
}