Skip to content

Commit

Permalink
feat: [PIPE-22866]: Add V2 runner task status endpoint to client (#33)
Browse files Browse the repository at this point in the history
* Rename method
* Add runner task status V2 API to client
  • Loading branch information
vcalasansh authored and Harness committed Dec 9, 2024
1 parent 7f9e37c commit 8a9d1e1
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions delegate/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const (
taskPollEndpoint = "/api/agent/delegates/%s/task-events?accountId=%s"
taskAcquireEndpoint = "/api/agent/v2/delegates/%s/tasks/%s/acquire?accountId=%s&delegateInstanceId=%s"
taskStatusEndpoint = "/api/agent/v2/tasks/%s/delegates/%s?accountId=%s"
taskStatusEndpointV2 = "/api/executions/%s/task-response?runnerId=%s&accountId=%s"
runnerTaskStatusEndpoint = "/api/executions/%s/response?accountId=%s&delegateId=%s"
delegateCapacityEndpoint = "/api/agent/delegates/register-delegate-capacity/%s?accountId=%s"
)
Expand Down Expand Up @@ -227,6 +228,22 @@ func (p *HTTPClient) SendStatus(ctx context.Context, delegateID, taskID string,
return err
}

// SendStatusV2 updates the status of a task submitted via Harness Runner (V2 Task Status endpoint)
func (p *HTTPClient) SendStatusV2(ctx context.Context, runnerID, taskID string, r *client.RunnerTaskResponse) error {
path := fmt.Sprintf(taskStatusEndpointV2, taskID, runnerID, p.AccountID)
req := r
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
}

func (p *HTTPClient) SendRunnerStatus(ctx context.Context, delegateID, taskID string, r *client.RunnerTaskResponse) error {
path := fmt.Sprintf(runnerTaskStatusEndpoint, taskID, p.AccountID, delegateID)
req := r
Expand Down

0 comments on commit 8a9d1e1

Please sign in to comment.