Skip to content

Commit 3312663

Browse files
committed
Fix comment
1 parent 0599e67 commit 3312663

File tree

4 files changed

+17
-17
lines changed

4 files changed

+17
-17
lines changed

internal/wrappers/client.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ var cachedAccessToken string
7070
var cachedAccessTime time.Time
7171
var Domains = make(map[string]struct{})
7272

73-
func retryHTTPRequest(requestFunc func() (*http.Response, error), retries int, baseDelayInMillis time.Duration) (*http.Response, error) {
73+
func retryHTTPRequest(requestFunc func() (*http.Response, error), retries int, baseDelayInMilliSec time.Duration) (*http.Response, error) {
7474

7575
var resp *http.Response
7676
var err error
@@ -84,7 +84,7 @@ func retryHTTPRequest(requestFunc func() (*http.Response, error), retries int, b
8484
return resp, nil
8585
}
8686
_ = resp.Body.Close()
87-
time.Sleep(baseDelayInMillis * (1 << attempt))
87+
time.Sleep(baseDelayInMilliSec * (1 << attempt))
8888
}
8989
return resp, nil
9090
}

internal/wrappers/client_test.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"github.com/stretchr/testify/assert"
66
"net/http"
77
"testing"
8+
"time"
89
)
910

1011
type mockReadCloser struct{}
@@ -25,7 +26,7 @@ func TestRetryHTTPRequest_Success(t *testing.T) {
2526
}, nil
2627
}
2728

28-
resp, err := retryHTTPRequest(fn, retryAttempts, retryDelay)
29+
resp, err := retryHTTPRequest(fn, retryAttempts, retryDelay*time.Millisecond)
2930
assert.NoError(t, err)
3031
assert.NotNil(t, resp)
3132
assert.Equal(t, http.StatusOK, resp.StatusCode)
@@ -47,7 +48,7 @@ func TestRetryHTTPRequest_RetryOnBadGateway(t *testing.T) {
4748
}, nil
4849
}
4950

50-
resp, err := retryHTTPRequest(fn, retryAttempts, retryDelay)
51+
resp, err := retryHTTPRequest(fn, retryAttempts, retryDelay*time.Millisecond)
5152
assert.NoError(t, err)
5253
assert.NotNil(t, resp)
5354
assert.Equal(t, http.StatusOK, resp.StatusCode)
@@ -59,7 +60,7 @@ func TestRetryHTTPRequest_Fail(t *testing.T) {
5960
return nil, errors.New("network error")
6061
}
6162

62-
resp, err := retryHTTPRequest(fn, retryAttempts, retryDelay)
63+
resp, err := retryHTTPRequest(fn, retryAttempts, retryDelay*time.Millisecond)
6364
assert.Error(t, err)
6465
assert.Nil(t, resp)
6566
}
@@ -72,7 +73,7 @@ func TestRetryHTTPRequest_EndWithBadGateway(t *testing.T) {
7273
}, nil
7374
}
7475

75-
resp, err := retryHTTPRequest(fn, retryAttempts, retryDelay)
76+
resp, err := retryHTTPRequest(fn, retryAttempts, retryDelay*time.Millisecond)
7677
assert.NoError(t, err)
7778
assert.NotNil(t, resp)
7879
assert.Equal(t, http.StatusBadGateway, resp.StatusCode)
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
package wrappers
22

3-
import "time"
4-
53
const (
64
limitValue = "10000"
75
retryAttempts = 4
8-
retryDelay = 500 * time.Millisecond
6+
retryDelay = 500
97
)

internal/wrappers/projects-http.go

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"github.com/pkg/errors"
88
"github.com/spf13/viper"
99
"net/http"
10+
"time"
1011

1112
errorConstants "github.com/checkmarx/ast-cli/internal/constants/errors"
1213
commonParams "github.com/checkmarx/ast-cli/internal/params"
@@ -32,7 +33,7 @@ func (p *ProjectsHTTPWrapper) Create(model *Project) (*ProjectResponseModel, *Er
3233
fn := func() (*http.Response, error) {
3334
return SendHTTPRequest(http.MethodPost, p.path, bytes.NewBuffer(jsonBytes), true, clientTimeout)
3435
}
35-
resp, err := retryHTTPRequest(fn, retryAttempts, retryDelay)
36+
resp, err := retryHTTPRequest(fn, retryAttempts, retryDelay*time.Millisecond)
3637
if err != nil {
3738
return nil, nil, err
3839
}
@@ -54,7 +55,7 @@ func (p *ProjectsHTTPWrapper) Update(projectID string, model *Project) error {
5455
fn := func() (*http.Response, error) {
5556
return SendHTTPRequest(http.MethodPut, fmt.Sprintf("%s/%s", p.path, projectID), bytes.NewBuffer(jsonBytes), true, clientTimeout)
5657
}
57-
resp, err := retryHTTPRequest(fn, retryAttempts, retryDelay)
58+
resp, err := retryHTTPRequest(fn, retryAttempts, retryDelay*time.Millisecond)
5859
if err != nil {
5960
return err
6061
}
@@ -87,7 +88,7 @@ func (p *ProjectsHTTPWrapper) UpdateConfiguration(projectID string, configuratio
8788
fn := func() (*http.Response, error) {
8889
return SendHTTPRequestWithQueryParams(http.MethodPatch, "api/configuration/project", params, bytes.NewBuffer(jsonBytes), clientTimeout)
8990
}
90-
resp, err := retryHTTPRequest(fn, retryAttempts, retryDelay)
91+
resp, err := retryHTTPRequest(fn, retryAttempts, retryDelay*time.Millisecond)
9192
if err != nil {
9293
return nil, err
9394
}
@@ -111,7 +112,7 @@ func (p *ProjectsHTTPWrapper) Get(params map[string]string) (
111112
fn := func() (*http.Response, error) {
112113
return SendHTTPRequestWithQueryParams(http.MethodGet, p.path, params, nil, clientTimeout)
113114
}
114-
resp, err := retryHTTPRequest(fn, retryAttempts, retryDelay)
115+
resp, err := retryHTTPRequest(fn, retryAttempts, retryDelay*time.Millisecond)
115116
if err != nil {
116117
return nil, nil, err
117118
}
@@ -152,7 +153,7 @@ func (p *ProjectsHTTPWrapper) GetByID(projectID string) (
152153
fn := func() (*http.Response, error) {
153154
return SendHTTPRequest(http.MethodGet, p.path+"/"+projectID, http.NoBody, true, clientTimeout)
154155
}
155-
resp, err := retryHTTPRequest(fn, retryAttempts, retryDelay)
156+
resp, err := retryHTTPRequest(fn, retryAttempts, retryDelay*time.Millisecond)
156157
if err != nil {
157158
return nil, nil, err
158159
}
@@ -199,7 +200,7 @@ func (p *ProjectsHTTPWrapper) GetBranchesByID(projectID string, params map[strin
199200
fn := func() (*http.Response, error) {
200201
return SendHTTPRequestWithQueryParams(http.MethodGet, p.path+request, params, nil, clientTimeout)
201202
}
202-
resp, err := retryHTTPRequest(fn, retryAttempts, retryDelay)
203+
resp, err := retryHTTPRequest(fn, retryAttempts, retryDelay*time.Millisecond)
203204
if err != nil {
204205
return nil, nil, err
205206
}
@@ -237,7 +238,7 @@ func (p *ProjectsHTTPWrapper) Delete(projectID string) (*ErrorModel, error) {
237238
fn := func() (*http.Response, error) {
238239
return SendHTTPRequest(http.MethodDelete, p.path+"/"+projectID, http.NoBody, true, clientTimeout)
239240
}
240-
resp, err := retryHTTPRequest(fn, retryAttempts, retryDelay)
241+
resp, err := retryHTTPRequest(fn, retryAttempts, retryDelay*time.Millisecond)
241242
if err != nil {
242243
return nil, err
243244
}
@@ -258,7 +259,7 @@ func (p *ProjectsHTTPWrapper) Tags() (
258259
fn := func() (*http.Response, error) {
259260
return SendHTTPRequest(http.MethodGet, p.path+"/tags", http.NoBody, true, clientTimeout)
260261
}
261-
resp, err := retryHTTPRequest(fn, retryAttempts, retryDelay)
262+
resp, err := retryHTTPRequest(fn, retryAttempts, retryDelay*time.Millisecond)
262263
if err != nil {
263264
return nil, nil, err
264265
}

0 commit comments

Comments
 (0)