podman
52 строки · 1.7 Кб
1/*
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 backoff26
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.32BaseDelay time.Duration33// Multiplier is the factor with which to multiply backoffs after a34// failed retry. Should ideally be greater than 1.35Multiplier float6436// Jitter is the factor with which backoffs are randomized.37Jitter float6438// MaxDelay is the upper bound of backoff delay.39MaxDelay time.Duration40}
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{48BaseDelay: 1.0 * time.Second,49Multiplier: 1.6,50Jitter: 0.2,51MaxDelay: 120 * time.Second,52}
53