Struct: retry.RetryableConnectionError

import "../ibm-cos-sdk-go-v2/aws/retry"

Overview

IsErrorRetryable returns if the error is caused by and HTTP connection error, and should be retried.

Implemented Interfaces

types.AnalyticsFilter, v4.HTTPPresigner, s3.HTTPPresignerV4, retry.IsErrorRetryable, types.MetricsFilter, s3.PresignPost, arn.S3ObjectLambdaARN, types.SelectObjectContentEventStream

Method Summary collapse

Method Details

func (r RetryableConnectionError) IsErrorRetryable(err error) aws.Ternary



87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
// File 'aws/retry/retryable_error.go', line 87

func (r RetryableConnectionError) IsErrorRetryable(err error) aws.Ternary { if err == nil { return aws.UnknownTernary } var retryable bool var conErr interface{ ConnectionError() bool } var tempErr interface{ Temporary() bool } var timeoutErr interface{ Timeout() bool } var urlErr *url.Error var netOpErr *net.OpError var dnsError *net.DNSError if errors.As(err, &dnsError) { // NXDOMAIN errors should not be retried if dnsError.IsNotFound { return aws.BoolTernary(false) } // if !dnsError.Temporary(), error may or may not be temporary, // (i.e. !Temporary() =/=> !retryable) so we should fall through to // remaining checks if dnsError.Temporary() { return aws.BoolTernary(true) } } switch { case errors.As(err, &conErr) && conErr.ConnectionError(): retryable = true case strings.Contains(err.Error(), "use of closed network connection"): fallthrough case strings.Contains(err.Error(), "connection reset"): // The errors "connection reset" and "use of closed network connection" // are effectively the same. It appears to be the difference between // sync and async read of TCP RST in the stdlib's net.Conn read loop. // see #2737 retryable = true case errors.As(err, &urlErr): // Refused connections should be retried as the service may not yet be // running on the port. Go TCP dial considers refused connections as // not temporary. if strings.Contains(urlErr.Error(), "connection refused") { retryable = true } else { return r.IsErrorRetryable(errors.Unwrap(urlErr)) } case errors.As(err, &netOpErr): // Network dial, or temporary network errors are always retryable. if strings.EqualFold(netOpErr.Op, "dial") || netOpErr.Temporary() { retryable = true } else { return r.IsErrorRetryable(errors.Unwrap(netOpErr)) } case errors.As(err, &tempErr) && tempErr.Temporary(): // Fallback to the generic temporary check, with temporary errors // retryable. retryable = true case errors.As(err, &timeoutErr) && timeoutErr.Timeout(): // Fallback to the generic timeout check, with timeout errors // retryable. retryable = true default: return aws.UnknownTernary } return aws.BoolTernary(retryable) }