Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // DefaultBackoff duration 2 secs DefaultBackoff = 2 // LinearBackoff duration starts from 1 second LinearBackoff = 1 // ExponetialFactor 1.5 per retry attempts ExponetialFactor = 1.5 )
var ( // ErrRetryMaxLimit : ErrMsg after max retry failure ErrRetryMaxLimit = errors.New("Retry Limit Exceed!") // DefaultRetryCount : the number of retry attempts DefaultRetryCount int = 5 )
Functions ¶
func IsContextError ¶
IsContextError verifies the error codes with context based error codes.
func IsRetriable ¶
IsRetriable verifies the error codes with the defined retriable codes.
func RetryClientConnection ¶
func RetryClientConnection(factory ClientConnFactory, retryOption *RetryOption) (*grpc.ClientConn, error)
RetryClientConnection function will retry gRPC connection for max retry count using the ClientConnFactory.
Types ¶
type Backoff ¶
type Backoff struct {
Strategy BackoffStrategy
}
Backoff struct defines the backoff strategy type
func (*Backoff) ApplyBackoffDuration ¶
ApplyBackoffDuration will decide a backoff strategy for a retry attempt.
type BackoffStrategy ¶
type BackoffStrategy int
BackoffStrategy type
const ( Default BackoffStrategy = iota // BackoffStrategy constants Jitter Linear Exponetial )
type ClientConnFactory ¶
type ClientConnFactory func(address string) (*grpc.ClientConn, error)
ClientConnFactory is the abstract connection factory function to retry multiple times.
type ConnState ¶
type ConnState connectivity.State
ConnState : Connectivity State of gRPC connection [Idle,Connecting,Ready,TransientFailure,Shutdown]
type RetryOption ¶
RetryOption struct defines the configuration for retry behavior for the gRPC connection failure,
Retry: The number of retry attempts for gRPC connection retry. Address: The target address of the server used for retry. Backoff: The backoff strategy applies delays for each retry attempt. Codes: A list of codes retriable codes that get matched with the error codes.
func (*RetryOption) RetryBackoff ¶
func (r *RetryOption) RetryBackoff(attempt int) error
RetryBackoff will apply the backoff strategy to provides a delay to each retry attempt.