Documentation ¶
Index ¶
Constants ¶
View Source
const (
Stop = -1
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BackOff ¶
BackOff 接口定义
func NewExponential ¶
func NewExponential(opts ...ExponentialOption) BackOff
type ConstantBackOff ¶
func NewConstant ¶
func NewConstant(d time.Duration) *ConstantBackOff
func (*ConstantBackOff) Next ¶
func (b *ConstantBackOff) Next() time.Duration
func (*ConstantBackOff) Reset ¶
func (b *ConstantBackOff) Reset()
type ExponentialBackOff ¶
type ExponentialBackOff struct {
// contains filtered or unexported fields
}
https://aws.amazon.com/cn/blogs/architecture/exponential-backoff-and-jitter/ https://www.baeldung.com/resilience4j-backoff-jitter https://github.com/grpc/grpc-go/blob/master/internal/backoff/backoff.go https://github.com/jpillora/backoff/blob/master/backoff.go https://github.com/rfyiamcool/backoff
float64(b.Min) * math.Pow(b.Factor, b.Attempts) wait_interval = base * multiplier^n
func (*ExponentialBackOff) Next ¶
func (e *ExponentialBackOff) Next() time.Duration
func (*ExponentialBackOff) Reset ¶
func (e *ExponentialBackOff) Reset()
type ExponentialOption ¶
type ExponentialOption func(b *ExponentialBackOff)
func WithFactor ¶
func WithFactor(v float64) ExponentialOption
func WithJitter ¶
func WithJitter(v bool) ExponentialOption
func WithMax ¶
func WithMax(d time.Duration) ExponentialOption
func WithMin ¶
func WithMin(d time.Duration) ExponentialOption
type StopBackOff ¶
type StopBackOff struct { }
func (*StopBackOff) Next ¶
func (b *StopBackOff) Next() time.Duration
func (*StopBackOff) Reset ¶
func (b *StopBackOff) Reset()
type ZeroBackOff ¶
type ZeroBackOff struct { }
func (*ZeroBackOff) Next ¶
func (b *ZeroBackOff) Next() time.Duration
func (*ZeroBackOff) Reset ¶
func (b *ZeroBackOff) Reset()
Click to show internal directories.
Click to hide internal directories.