@@ -14,6 +14,7 @@ import (
14
14
"github.com/deploymenttheory/go-api-http-client/apiintegrations/apihandler"
15
15
"github.com/deploymenttheory/go-api-http-client/authenticationhandler"
16
16
"github.com/deploymenttheory/go-api-http-client/concurrency"
17
+ "github.com/deploymenttheory/go-api-http-client/helpers"
17
18
18
19
"github.com/deploymenttheory/go-api-http-client/logger"
19
20
"github.com/deploymenttheory/go-api-http-client/redirecthandler"
@@ -94,10 +95,16 @@ type ConcurrencyConfig struct {
94
95
}
95
96
96
97
// 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
+
97
104
type 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
101
108
}
102
109
103
110
// RedirectConfig holds configuration related to redirect handling.
@@ -152,7 +159,7 @@ func BuildClient(config ClientConfig) (*Client, error) {
152
159
153
160
// Initialize the internal HTTP client
154
161
httpClient := & http.Client {
155
- Timeout : config .ClientOptions .Timeout .CustomTimeout ,
162
+ Timeout : config .ClientOptions .Timeout .CustomTimeout . Duration () ,
156
163
}
157
164
158
165
// Conditionally setup cookie jar
@@ -206,9 +213,9 @@ func BuildClient(config ClientConfig) (*Client, error) {
206
213
zap .Int ("Max Concurrent Requests" , config .ClientOptions .Concurrency .MaxConcurrentRequests ),
207
214
zap .Bool ("Follow Redirects" , config .ClientOptions .Redirect .FollowRedirects ),
208
215
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 () ),
212
219
)
213
220
214
221
return client , nil
0 commit comments