blob: 0787d0b50ce94ff9d96ce810eff90ad64bfba775 [file] [log] [blame]
Devmalya Pauldd23a992019-11-14 07:06:31 +00001/*
2 *
3 * Copyright 2019 gRPC authors.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 */
18
19// Package backoff provides configuration options for backoff.
20//
21// More details can be found at:
22// https://github.com/grpc/grpc/blob/master/doc/connection-backoff.md.
23//
24// All APIs in this package are experimental.
25package backoff
26
27import "time"
28
29// Config defines the configuration options for backoff.
30type Config struct {
31 // BaseDelay is the amount of time to backoff after the first failure.
32 BaseDelay time.Duration
33 // Multiplier is the factor with which to multiply backoffs after a
34 // failed retry. Should ideally be greater than 1.
35 Multiplier float64
36 // Jitter is the factor with which backoffs are randomized.
37 Jitter float64
38 // MaxDelay is the upper bound of backoff delay.
39 MaxDelay time.Duration
40}
41
42// DefaultConfig is a backoff configuration with the default values specfied
43// at https://github.com/grpc/grpc/blob/master/doc/connection-backoff.md.
44//
45// This should be useful for callers who want to configure backoff with
46// non-default values only for a subset of the options.
47var DefaultConfig = Config{
48 BaseDelay: 1.0 * time.Second,
49 Multiplier: 1.6,
50 Jitter: 0.2,
51 MaxDelay: 120 * time.Second,
52}