2016-04-30 02:21:46 +00:00
|
|
|
package grpc
|
|
|
|
|
2017-01-30 23:06:28 +00:00
|
|
|
import "time"
|
2016-04-30 02:21:46 +00:00
|
|
|
|
|
|
|
// DefaultBackoffConfig uses values specified for backoff in
|
|
|
|
// https://github.com/grpc/grpc/blob/master/doc/connection-backoff.md.
|
|
|
|
var (
|
|
|
|
DefaultBackoffConfig = BackoffConfig{
|
|
|
|
MaxDelay: 120 * time.Second,
|
|
|
|
baseDelay: 1.0 * time.Second,
|
|
|
|
factor: 1.6,
|
|
|
|
jitter: 0.2,
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
2016-09-07 18:27:11 +00:00
|
|
|
// BackoffConfig defines the parameters for the default gRPC backoff strategy.
|
2016-04-30 02:21:46 +00:00
|
|
|
type BackoffConfig struct {
|
|
|
|
// MaxDelay is the upper bound of backoff delay.
|
|
|
|
MaxDelay time.Duration
|
|
|
|
|
|
|
|
// TODO(stevvooe): The following fields are not exported, as allowing
|
2016-09-07 18:27:11 +00:00
|
|
|
// changes would violate the current gRPC specification for backoff. If
|
|
|
|
// gRPC decides to allow more interesting backoff strategies, these fields
|
2016-04-30 02:21:46 +00:00
|
|
|
// may be opened up in the future.
|
|
|
|
|
|
|
|
// 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
|
|
|
|
}
|