retry

package
v1.0.0-alpha3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 20, 2018 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package retry provides retransmission capabilities to fabric-sdk-go

Index

Constants

View Source
const (
	// DefaultAttempts number of retry attempts made by default
	DefaultAttempts = 3
	// DefaultInitialBackoff default initial backoff
	DefaultInitialBackoff = 500 * time.Millisecond
	// DefaultMaxBackoff default maximum backoff
	DefaultMaxBackoff = 60 * time.Second
	// DefaultBackoffFactor default backoff factor
	DefaultBackoffFactor = 2.0
)

Variables

ChannelClientRetryableCodes are the suggested codes that should be treated as transient by fabric-sdk-go/api/apitxn.ChannelClient

View Source
var DefaultOpts = Opts{
	Attempts:       DefaultAttempts,
	InitialBackoff: DefaultInitialBackoff,
	MaxBackoff:     DefaultMaxBackoff,
	BackoffFactor:  DefaultBackoffFactor,
	RetryableCodes: DefaultRetryableCodes,
}

DefaultOpts default retry options

DefaultRetryableCodes these are the error codes, grouped by source of error, that are considered to be transient error conditions by default

Functions

This section is empty.

Types

type Handler

type Handler interface {
	Required(err error) bool
}

Handler retry handler interface decides whether a retry is required for the given error

func New

func New(opts Opts) Handler

New retry Handler with the given opts

func WithAttempts

func WithAttempts(attempts int) Handler

WithAttempts new retry Handler with given attempts. Other opts are set to default.

func WithDefaults

func WithDefaults() Handler

WithDefaults new retry Handler with default opts

type Opts

type Opts struct {
	// Attempts the number retry attempts
	Attempts int
	// InitialBackoff the backoff interval for the first retry attempt
	InitialBackoff time.Duration
	// MaxBackoff the maximum backoff interval for any retry attempt
	MaxBackoff time.Duration
	// BackoffFactor the factor by which the InitialBackoff is exponentially
	// incremented for consecutive retry attempts.
	// For example, a backoff factor of 2.5 will result in a backoff of
	// InitialBackoff * 2.5 * 2.5 on the second attempt.
	BackoffFactor float64
	// RetryableCodes defines the status codes, mapped by group, returned by fabric-sdk-go
	// that warrant a retry. This will default to retry.DefaultRetryableCodes.
	RetryableCodes map[status.Group][]status.Code
}

Opts defines the retry parameters

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL