Skip to content

Commit

Permalink
Added optional no-adjust-timeout flag to control timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
Ice3man543 committed Dec 3, 2022
1 parent 2dd6824 commit 1d25b06
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion client.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ type Options struct {
CheckRetry CheckRetry
// Custom Backoff policy
Backoff Backoff
// NoAdjustTimeout disables automatic adjustment of HTTP request timeout
NoAdjustTimeout bool
// Custom http client
HttpClient *http.Client
}
Expand Down Expand Up @@ -110,7 +112,7 @@ func NewClient(options Options) *Client {
}

// if necessary adjusts per-request timeout proportionally to general timeout (30%)
if options.Timeout > time.Second*15 {
if options.Timeout > time.Second*15 && options.RetryMax > 1 && !options.NoAdjustTimeout {
httpclient.Timeout = time.Duration(options.Timeout.Seconds()*0.3) * time.Second
}

Expand Down

0 comments on commit 1d25b06

Please sign in to comment.