Documentation ¶
Index ¶
- Variables
- func Interceptor(callOpts ...grpc.CallOption) grpc.UnaryClientInterceptor
- func WithAttemptHeader(enable bool) grpc.CallOption
- func WithBackoff(f BackoffFunc) grpc.CallOption
- func WithCodes(codes ...codes.Code) grpc.CallOption
- func WithDefaultInterceptor() grpc.DialOption
- func WithMax(maxRetryCount int) grpc.CallOption
- func WithPerCallTimeout(to time.Duration) grpc.CallOption
- type BackoffFunc
- func BackoffExponentialWithJitter(base time.Duration, cap time.Duration) BackoffFunc
- func BackoffLinearWithJitter(waitBetween time.Duration, jitterFraction float64) BackoffFunc
- func DefaultBackoff() BackoffFunc
- func DefaultExponentialJitterBackoff() BackoffFunc
- func DefaultLinearJitterBackoff() BackoffFunc
Constants ¶
This section is empty.
Variables ¶
var ( // TODO(seukyaso): Consider adding some non-zero default retry options DefaultRetriableCodes = []codes.Code{codes.ResourceExhausted, codes.Unavailable} )
Functions ¶
func Interceptor ¶
func Interceptor(callOpts ...grpc.CallOption) grpc.UnaryClientInterceptor
Interceptor returns retry interceptor, that can be parametrized by specific call options. Without any option, it uses default options, that basically retries nothing. Default retry quantity is 0, backoff function is nil, retry codes are DefaultRetriableCodes, AttemptHeader is false, and perCallTimeout is 0.
func WithAttemptHeader ¶
func WithAttemptHeader(enable bool) grpc.CallOption
WithAttemptHeader adds retry attempt number to context outgoing metadata, with key "x-retry-attempt".
func WithBackoff ¶
func WithBackoff(f BackoffFunc) grpc.CallOption
WithBackoff sets up interceptor with custom defined backoff function
func WithCodes ¶
func WithCodes(codes ...codes.Code) grpc.CallOption
WithCodes overrides the whole retriable codes list.
func WithDefaultInterceptor ¶
func WithDefaultInterceptor() grpc.DialOption
WithDefaultInterceptor returns interceptor that DOESN'T retry anything. Its possible to change its behaviour with call options.
func WithMax ¶
func WithMax(maxRetryCount int) grpc.CallOption
WithMax option sets quantity of retry attempts. It handles negative maxRetryCount as INFINITE retries.
func WithPerCallTimeout ¶
func WithPerCallTimeout(to time.Duration) grpc.CallOption
WithPerCallTimeout adds timeout for retry calls.
Types ¶
type BackoffFunc ¶
func BackoffExponentialWithJitter ¶
func BackoffExponentialWithJitter(base time.Duration, cap time.Duration) BackoffFunc
func BackoffLinearWithJitter ¶
func BackoffLinearWithJitter(waitBetween time.Duration, jitterFraction float64) BackoffFunc
func DefaultBackoff ¶
func DefaultBackoff() BackoffFunc
DefaultBackoff uses exponential backoff with jitter, with base = 50ms, and maximum timeout = 1 minute.
func DefaultExponentialJitterBackoff ¶
func DefaultExponentialJitterBackoff() BackoffFunc
WithDefaultExponentialJitterBackoff same as WithDefaultBackoff
func DefaultLinearJitterBackoff ¶
func DefaultLinearJitterBackoff() BackoffFunc
DefaultLinearJitterBackoff uses linear backoff with base = 50ms, and jitter = +-10%