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 ¶
View Source
var ChannelClientRetryableCodes = map[status.Group][]status.Code{ status.EndorserClientStatus: []status.Code{ status.ConnectionFailed, status.EndorsementMismatch, }, status.EndorserServerStatus: []status.Code{ status.Code(common.Status_SERVICE_UNAVAILABLE), status.Code(common.Status_INTERNAL_SERVER_ERROR), }, status.OrdererClientStatus: []status.Code{ status.ConnectionFailed, }, status.OrdererServerStatus: []status.Code{ status.Code(common.Status_SERVICE_UNAVAILABLE), status.Code(common.Status_INTERNAL_SERVER_ERROR), }, status.EventServerStatus: []status.Code{ status.Code(pb.TxValidationCode_DUPLICATE_TXID), status.Code(pb.TxValidationCode_ENDORSEMENT_POLICY_FAILURE), status.Code(pb.TxValidationCode_MVCC_READ_CONFLICT), status.Code(pb.TxValidationCode_PHANTOM_READ_CONFLICT), }, status.GRPCTransportStatus: []status.Code{ status.Code(grpcCodes.Unavailable), }, }
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
View Source
var DefaultRetryableCodes = map[status.Group][]status.Code{ status.EndorserClientStatus: []status.Code{ status.EndorsementMismatch, }, status.EndorserServerStatus: []status.Code{ status.Code(common.Status_SERVICE_UNAVAILABLE), status.Code(common.Status_INTERNAL_SERVER_ERROR), }, status.OrdererServerStatus: []status.Code{ status.Code(common.Status_SERVICE_UNAVAILABLE), status.Code(common.Status_INTERNAL_SERVER_ERROR), }, status.EventServerStatus: []status.Code{ status.Code(pb.TxValidationCode_DUPLICATE_TXID), status.Code(pb.TxValidationCode_ENDORSEMENT_POLICY_FAILURE), status.Code(pb.TxValidationCode_MVCC_READ_CONFLICT), status.Code(pb.TxValidationCode_PHANTOM_READ_CONFLICT), }, status.GRPCTransportStatus: []status.Code{ status.Code(grpcCodes.Unavailable), }, }
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 ¶
Handler retry handler interface decides whether a retry is required for the given error
func WithAttempts ¶
WithAttempts new retry Handler with given attempts. Other opts are set to default.
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
Click to show internal directories.
Click to hide internal directories.