File tree 2 files changed +16
-9
lines changed
2 files changed +16
-9
lines changed Original file line number Diff line number Diff line change @@ -219,12 +219,19 @@ func WithInstrumentation(registry prometheus.Registerer) ClientOption {
219
219
// NewClient creates a new client.
220
220
func NewClient (options ... ClientOption ) * Client {
221
221
client := & Client {
222
- endpoint : Endpoint ,
223
- tokenValid : true ,
224
- httpClient : & http.Client {},
225
- retryBackoffFunc : ExponentialBackoff (2 , time .Second ),
226
- retryMaxRetries : 5 ,
227
- pollBackoffFunc : ConstantBackoff (500 * time .Millisecond ),
222
+ endpoint : Endpoint ,
223
+ tokenValid : true ,
224
+ httpClient : & http.Client {},
225
+
226
+ retryBackoffFunc : ExponentialBackoffWithOpts (ExponentialBackoffOpts {
227
+ Base : time .Second ,
228
+ Multiplier : 2 ,
229
+ Cap : time .Minute ,
230
+ Jitter : true ,
231
+ }),
232
+ retryMaxRetries : 5 ,
233
+
234
+ pollBackoffFunc : ConstantBackoff (500 * time .Millisecond ),
228
235
}
229
236
230
237
for _ , option := range options {
Original file line number Diff line number Diff line change @@ -5,9 +5,9 @@ The Hetzner Cloud API reference is available at https://docs.hetzner.cloud.
5
5
6
6
# Retry mechanism
7
7
8
- The [Client.Do] method will retry failed requests that match certain criteria. The default
9
- retry interval is defined by an exponential backoff algorithm truncated to 60s. The
10
- default maximal number of retries is 5.
8
+ The [Client.Do] method will retry failed requests that match certain criteria. The
9
+ default retry interval is defined by an exponential backoff algorithm truncated to 60s
10
+ with jitter. The default maximal number of retries is 5.
11
11
12
12
The following rules defines when a request can be retried:
13
13
You can’t perform that action at this time.
0 commit comments