@@ -14,6 +14,7 @@ import (
1414 "github.com/deploymenttheory/go-api-http-client/apiintegrations/apihandler"
1515 "github.com/deploymenttheory/go-api-http-client/authenticationhandler"
1616 "github.com/deploymenttheory/go-api-http-client/concurrency"
17+ "github.com/deploymenttheory/go-api-http-client/helpers"
1718
1819 "github.com/deploymenttheory/go-api-http-client/logger"
1920 "github.com/deploymenttheory/go-api-http-client/redirecthandler"
@@ -94,10 +95,16 @@ type ConcurrencyConfig struct {
9495}
9596
9697// TimeoutConfig holds custom timeout settings.
98+ // type TimeoutConfig struct {
99+ // CustomTimeout time.Duration // Custom timeout for the HTTP client
100+ // TokenRefreshBufferPeriod time.Duration // Buffer period before token expiry to attempt token refresh
101+ // TotalRetryDuration time.Duration // Total duration to attempt retries
102+ // }
103+
97104type TimeoutConfig struct {
98- CustomTimeout time. Duration // Custom timeout for the HTTP client
99- TokenRefreshBufferPeriod time. Duration // Buffer period before token expiry to attempt token refresh
100- TotalRetryDuration time. Duration // Total duration to attempt retries
105+ CustomTimeout helpers. JSONDuration // Custom timeout for the HTTP client
106+ TokenRefreshBufferPeriod helpers. JSONDuration // Buffer period before token expiry to attempt token refresh
107+ TotalRetryDuration helpers. JSONDuration // Total duration to attempt retries
101108}
102109
103110// RedirectConfig holds configuration related to redirect handling.
@@ -152,7 +159,7 @@ func BuildClient(config ClientConfig) (*Client, error) {
152159
153160 // Initialize the internal HTTP client
154161 httpClient := & http.Client {
155- Timeout : config .ClientOptions .Timeout .CustomTimeout ,
162+ Timeout : config .ClientOptions .Timeout .CustomTimeout . Duration () ,
156163 }
157164
158165 // Conditionally setup cookie jar
@@ -206,9 +213,9 @@ func BuildClient(config ClientConfig) (*Client, error) {
206213 zap .Int ("Max Concurrent Requests" , config .ClientOptions .Concurrency .MaxConcurrentRequests ),
207214 zap .Bool ("Follow Redirects" , config .ClientOptions .Redirect .FollowRedirects ),
208215 zap .Int ("Max Redirects" , config .ClientOptions .Redirect .MaxRedirects ),
209- zap .Duration ("Token Refresh Buffer Period" , config .ClientOptions .Timeout .TokenRefreshBufferPeriod ),
210- zap .Duration ("Total Retry Duration" , config .ClientOptions .Timeout .TotalRetryDuration ),
211- zap .Duration ("Custom Timeout" , config .ClientOptions .Timeout .CustomTimeout ),
216+ zap .Duration ("Token Refresh Buffer Period" , config .ClientOptions .Timeout .TokenRefreshBufferPeriod . Duration () ),
217+ zap .Duration ("Total Retry Duration" , config .ClientOptions .Timeout .TotalRetryDuration . Duration () ),
218+ zap .Duration ("Custom Timeout" , config .ClientOptions .Timeout .CustomTimeout . Duration () ),
212219 )
213220
214221 return client , nil
0 commit comments