Skip to content

Commit

Permalink
Merge pull request #1153 from favonia/cleanup-duration
Browse files Browse the repository at this point in the history
remove unnecessary time.Duration(...)
  • Loading branch information
jacobbednarz committed Dec 22, 2022
2 parents 75edb98 + d796af7 commit 717f161
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions cloudflare.go
Expand Up @@ -65,8 +65,8 @@ func newClient(opts ...Option) (*API, error) {
rateLimiter: rate.NewLimiter(rate.Limit(4), 1), // 4rps equates to default api limit (1200 req/5 min)
retryPolicy: RetryPolicy{
MaxRetries: 3,
MinRetryDelay: time.Duration(1) * time.Second,
MaxRetryDelay: time.Duration(30) * time.Second,
MinRetryDelay: 1 * time.Second,
MaxRetryDelay: 30 * time.Second,
},
logger: silentLogger,
}
Expand Down
4 changes: 2 additions & 2 deletions cloudflare_experimental.go
Expand Up @@ -98,13 +98,13 @@ func NewExperimental(config *ClientParams) (*Client, error) {
if c.RetryPolicy.MinRetryDelay > 0 {
retryClient.RetryWaitMin = c.RetryPolicy.MinRetryDelay
} else {
retryClient.RetryWaitMin = time.Duration(1) * time.Second
retryClient.RetryWaitMin = 1 * time.Second
}

if c.RetryPolicy.MaxRetryDelay > 0 {
retryClient.RetryWaitMax = c.RetryPolicy.MaxRetryDelay
} else {
retryClient.RetryWaitMax = time.Duration(30) * time.Second
retryClient.RetryWaitMax = 30 * time.Second
}

retryClient.Logger = silentRetryLogger
Expand Down
6 changes: 3 additions & 3 deletions cloudflare_test.go
Expand Up @@ -495,18 +495,18 @@ func TestContextTimeout(t *testing.T) {
defer teardown()

handler := func(w http.ResponseWriter, r *http.Request) {
time.Sleep(time.Second * time.Duration(3))
time.Sleep(3 * time.Second)
}

mux.HandleFunc("/timeout", handler)

ctx, cancel := context.WithTimeout(context.Background(), time.Second*time.Duration(1))
ctx, cancel := context.WithTimeout(context.Background(), time.Second)
defer cancel()

start := time.Now()
_, err := client.makeRequestContext(ctx, http.MethodHead, "/timeout", nil)
assert.ErrorIs(t, err, context.DeadlineExceeded)
assert.WithinDuration(t, start, time.Now(), time.Second*2,
assert.WithinDuration(t, start, time.Now(), 2*time.Second,
"makeRequestContext took too much time with an expiring context")
}

Expand Down

0 comments on commit 717f161

Please sign in to comment.