Skip to content

Commit 4e02bf5

Browse files
improve duration calculation
1 parent 25a7d66 commit 4e02bf5

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

internal/resilient/http-resilient-client.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,10 @@ func (c *resilientHttpClient) backoff(step uint16) {
5252
func (c *resilientHttpClient) doWithRetry(r *http.Request) (*http.Response, error) {
5353
var resp *http.Response
5454
var err error
55-
start := time.Now().UnixNano() / 1e6
55+
start := time.Now()
5656
for i := uint16(0); i <= uint16(c.maxRetry); i++ {
57-
now := time.Now().UnixNano() / 1e6
58-
if c.maxTimeout.Milliseconds() <= now-start {
57+
now := time.Now()
58+
if now.Sub(start) >= c.maxTimeout {
5959
return nil, context.DeadlineExceeded
6060
}
6161
resp, err = c.client.Do(r)

0 commit comments

Comments
 (0)