Skip to content

Commit

Permalink
only validate retry/concurrency settings if enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
thejoeker12 committed Jun 22, 2024
1 parent 74be6fe commit b01ca14
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions httpclient/config_validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,10 @@ func validateClientConfig(config ClientConfig, populateDefaults bool) error {
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")
}

if config.MaxRetryAttempts < 0 {
return errors.New("max retry cannot be less than 0")
}

if config.MaxConcurrentRequests < 1 {
return errors.New("maximum concurrent requests cannot be less than 1")
if config.EnableConcurrencyManagement {
if config.MaxConcurrentRequests < 1 {
return errors.New("maximum concurrent requests cannot be less than 1")
}
}

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

if config.TotalRetryDuration.Seconds() < 0 {
return errors.New("total retry duration cannot be less than 0 seconds")
if config.RetryEligiableRequests {
if config.TotalRetryDuration.Seconds() < 0 {
return errors.New("total retry duration cannot be less than 0 seconds")
}

if config.MaxRetryAttempts < 0 {
return errors.New("max retry cannot be less than 0")
}

}

if config.FollowRedirects {
Expand Down

0 comments on commit b01ca14

Please sign in to comment.