Skip to content

Commit

Permalink
(feat) internal/civisibility: change http default values and reduce t…
Browse files Browse the repository at this point in the history
…est time.
  • Loading branch information
tonyredondo committed Jan 31, 2025
1 parent 2641e5d commit c38f1af
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions internal/civisibility/utils/net/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ import (

const (
// DefaultMaxRetries is the default number of retries for a request.
DefaultMaxRetries int = 5
DefaultMaxRetries int = 3
// DefaultBackoff is the default backoff time for a request.
DefaultBackoff time.Duration = 150 * time.Millisecond
DefaultBackoff time.Duration = 100 * time.Millisecond
)

type (
Expand Down
2 changes: 1 addition & 1 deletion internal/civisibility/utils/net/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ func decompressData(data []byte) ([]byte, error) {

// exponentialBackoff performs an exponential backoff with retries.
func exponentialBackoff(retryCount int, initialDelay time.Duration) {
maxDelay := 30 * time.Second
maxDelay := 10 * time.Second
delay := initialDelay * (1 << uint(retryCount)) // Exponential backoff
if delay > maxDelay {
delay = maxDelay
Expand Down
4 changes: 2 additions & 2 deletions internal/civisibility/utils/net/http_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -786,9 +786,9 @@ func TestSendRequestWithInvalidRetryAfterHeader(t *testing.T) {

func TestExponentialBackoffWithMaxDelay(t *testing.T) {
start := time.Now()
exponentialBackoff(10, 1*time.Second) // Should be limited to maxDelay (30s)
exponentialBackoff(10, 1*time.Second) // Should be limited to maxDelay (10s)
duration := time.Since(start)
assert.LessOrEqual(t, duration, 31*time.Second)
assert.LessOrEqual(t, duration, 11*time.Second)
}

func TestSendRequestWithContextTimeout(t *testing.T) {
Expand Down

0 comments on commit c38f1af

Please sign in to comment.