Back to godoc.org

Package netutil

v0.3.3
Latest Go to latest

The latest major version is .

Published: Jan 20, 2020 | License: MIT | Module: github.com/bilibili/kratos

Index

Variables

var DefaultBackoffConfig = BackoffConfig{
	MaxDelay:  120 * time.Second,
	BaseDelay: 1.0 * time.Second,
	Factor:    1.6,
	Jitter:    0.2,
}

DefaultBackoffConfig uses values specified for backoff in common.

type Backoff

type Backoff interface {
	// Backoff returns the amount of time to wait before the next retry given
	// the number of consecutive failures.
	Backoff(retries int) time.Duration
}

Backoff defines the methodology for backing off after a call failure.

type BackoffConfig

type BackoffConfig struct {
	// MaxDelay is the upper bound of backoff delay.
	MaxDelay time.Duration

	// baseDelay is the amount of time to wait before retrying after the first
	// failure.
	BaseDelay time.Duration

	// factor is applied to the backoff after each retry.
	Factor float64

	// jitter provides a range to randomize backoff delays.
	Jitter float64
}

BackoffConfig defines the parameters for the default backoff strategy.

func (*BackoffConfig) Backoff

func (bc *BackoffConfig) Backoff(retries int) time.Duration

Backoff returns the amount of time to wait before the next retry given the number of consecutive failures.

Package Files

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier