Skip to content

Commit

Permalink
feat: [CI-11274]: Added retries sending step status
Browse files Browse the repository at this point in the history
  • Loading branch information
devkimittal committed Feb 8, 2024
1 parent d7ab998 commit d736476
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions delegate/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@ const (
)

var (
registerTimeout = 30 * time.Second
taskEventsTimeout = 60 * time.Second
registerTimeout = 30 * time.Second
taskEventsTimeout = 60 * time.Second
sendStatusRetryTimes = 5
)

// defaultClient is the default http.Client.
Expand Down Expand Up @@ -191,7 +192,15 @@ func (p *HTTPClient) Acquire(ctx context.Context, delegateID, taskID string) (*c
func (p *HTTPClient) SendStatus(ctx context.Context, delegateID, taskID string, r *client.TaskResponse) error {
path := fmt.Sprintf(taskStatusEndpoint, taskID, delegateID, p.AccountID)
req := r
_, err := p.retry(ctx, path, "POST", req, nil, createBackoff(ctx, taskEventsTimeout), true) //nolint: bodyclose
retryNumber := 0
var err error
for retryNumber < sendStatusRetryTimes {
_, err = p.retry(ctx, path, "POST", req, nil, createBackoff(ctx, taskEventsTimeout), true) //nolint: bodyclose
if err == nil {
return nil
}
retryNumber++
}
return err
}

Expand Down

0 comments on commit d736476

Please sign in to comment.