Skip to content

Commit 507d67f

Browse files
Configure the retry behaviour
Co-authored-by: Lawrence Gripper <[email protected]>
1 parent 9f135a1 commit 507d67f

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

client/service/client.go

+13-1
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,10 @@ func (c *DBApiClientConfig) Setup() {
7878
if c.TimeoutSeconds == 0 {
7979
c.TimeoutSeconds = 60
8080
}
81+
// Set up a retryable HTTP Client to handle cases where the service returns
82+
// a transient error on initial creation
83+
retryDelayDuration := 10 * time.Second
84+
retryMaximumDuration := 5 * time.Minute
8185
c.client = retryablehttp.Client{
8286
HTTPClient: &http.Client{
8387
Timeout: time.Duration(time.Duration(c.TimeoutSeconds) * time.Second),
@@ -88,7 +92,15 @@ func (c *DBApiClientConfig) Setup() {
8892
},
8993
},
9094
CheckRetry: checkHTTPRetry,
91-
// TODO - default is exponential backoff - do we want that, or linear backoff?????????????????????
95+
// Using a linear retry rather than the default exponential retry
96+
// as the creation condition is normally passed after 30-40 seconds
97+
// Setting the retry interval to 10 seconds. Setting RetryWaitMin and RetryWaitMax
98+
// to the same value removes jitter (which would be useful in a high-volume traffic scenario
99+
// but wouldn't add much here)
100+
Backoff: retryablehttp.LinearJitterBackoff,
101+
RetryWaitMin: retryDelayDuration,
102+
RetryWaitMax: retryDelayDuration,
103+
RetryMax: int(retryMaximumDuration / retryDelayDuration),
92104
}
93105
}
94106

0 commit comments

Comments
 (0)