Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove unnecessary time.Duration(...) #1153

Merged
merged 1 commit into from Dec 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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