@@ -105,7 +105,7 @@ func validateClientConfig(config ClientConfig, populateDefaults bool) error {
105105
106106 // TODO adjust these strings to have links to documentation & centralise them
107107 if config .Integration == nil {
108- return errors .New ("no http client api integration supplied, please see documentation for go-api-http-client-integration and provide an implementation" )
108+ 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
111111 if config .MaxRetryAttempts < 0 {
@@ -137,47 +137,16 @@ func validateClientConfig(config ClientConfig, populateDefaults bool) error {
137137 return nil
138138}
139139
140- // SetDefaultValuesClientConfig sets default values for the client configuration.
140+ // SetDefaultValuesClientConfig sets default values for the client configuration. Ensuring that all fields have a valid or minimum value.
141141func SetDefaultValuesClientConfig (config * ClientConfig ) {
142-
143- if ! config .HideSensitiveData {
144- config .HideSensitiveData = DefaultHideSensitiveData
145- }
146-
147- if config .MaxRetryAttempts == 0 {
148- config .MaxRetryAttempts = DefaultMaxRetryAttempts
149- }
150-
151- if config .MaxConcurrentRequests == 0 {
152- config .MaxRetryAttempts = DefaultMaxConcurrentRequests
153- }
154-
155- if ! config .EnableDynamicRateLimiting {
156- config .EnableDynamicRateLimiting = DefaultEnableDynamicRateLimiting
157- }
158-
159- if config .CustomTimeout == 0 {
160- config .CustomTimeout = DefaultCustomTimeout
161- }
162-
163- if config .TokenRefreshBufferPeriod == 0 {
164- config .TokenRefreshBufferPeriod = DefaultTokenRefreshBufferPeriod
165- }
166-
167- if config .TotalRetryDuration == 0 {
168- config .TotalRetryDuration = DefaultTotalRetryDuration
169- }
170-
171- if ! config .FollowRedirects {
172- config .FollowRedirects = DefaultFollowRedirects
173- }
174-
175- if config .MaxRedirects == 0 {
176- config .MaxRedirects = DefaultMaxRedirects
177- }
178-
179- if ! config .EnableConcurrencyManagement {
180- config .EnableConcurrencyManagement = DefaultEnableConcurrencyManagement
181- }
182-
142+ setDefaultBool (& config .HideSensitiveData , DefaultHideSensitiveData )
143+ setDefaultInt (& config .MaxRetryAttempts , DefaultMaxRetryAttempts , 1 )
144+ setDefaultInt (& config .MaxConcurrentRequests , DefaultMaxConcurrentRequests , 1 )
145+ setDefaultBool (& config .EnableDynamicRateLimiting , DefaultEnableDynamicRateLimiting )
146+ setDefaultDuration (& config .CustomTimeout , DefaultCustomTimeout )
147+ setDefaultDuration (& config .TokenRefreshBufferPeriod , DefaultTokenRefreshBufferPeriod )
148+ setDefaultDuration (& config .TotalRetryDuration , DefaultTotalRetryDuration )
149+ setDefaultBool (& config .FollowRedirects , DefaultFollowRedirects )
150+ setDefaultInt (& config .MaxRedirects , DefaultMaxRedirects , 0 )
151+ setDefaultBool (& config .EnableConcurrencyManagement , DefaultEnableConcurrencyManagement )
183152}
0 commit comments