Skip to content

Commit b01ca14

Browse files
committed
only validate retry/concurrency settings if enabled
1 parent 74be6fe commit b01ca14

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

httpclient/config_validation.go

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -108,12 +108,10 @@ func validateClientConfig(config ClientConfig, populateDefaults bool) error {
108108
return errors.New("no http client api integration supplied, please see repo documentation for this client and go-api-http-client-integration and provide an implementation")
109109
}
110110

111-
if config.MaxRetryAttempts < 0 {
112-
return errors.New("max retry cannot be less than 0")
113-
}
114-
115-
if config.MaxConcurrentRequests < 1 {
116-
return errors.New("maximum concurrent requests cannot be less than 1")
111+
if config.EnableConcurrencyManagement {
112+
if config.MaxConcurrentRequests < 1 {
113+
return errors.New("maximum concurrent requests cannot be less than 1")
114+
}
117115
}
118116

119117
if config.CustomTimeout.Seconds() < 0 {
@@ -124,8 +122,15 @@ func validateClientConfig(config ClientConfig, populateDefaults bool) error {
124122
return errors.New("refresh buffer period cannot be less than 0 seconds")
125123
}
126124

127-
if config.TotalRetryDuration.Seconds() < 0 {
128-
return errors.New("total retry duration cannot be less than 0 seconds")
125+
if config.RetryEligiableRequests {
126+
if config.TotalRetryDuration.Seconds() < 0 {
127+
return errors.New("total retry duration cannot be less than 0 seconds")
128+
}
129+
130+
if config.MaxRetryAttempts < 0 {
131+
return errors.New("max retry cannot be less than 0")
132+
}
133+
129134
}
130135

131136
if config.FollowRedirects {

0 commit comments

Comments
 (0)