MCPcopy
hub / github.com/cli/cli / fetchJobSessionURL

Function fetchJobSessionURL

pkg/cmd/agent-task/create/create.go:209–230  ·  view source on GitHub ↗

fetchJobSessionURL tries to return the agent session URL for a job. If the pull request is not yet available, ("", nil) is returned.

(ctx context.Context, client capi.CapiClient, repo ghrepo.Interface, job *capi.Job, bo backoff.BackOff)

Source from the content-addressed store, hash-verified

207// fetchJobSessionURL tries to return the agent session URL for a job. If the pull
208// request is not yet available, ("", nil) is returned.
209func fetchJobSessionURL(ctx context.Context, client capi.CapiClient, repo ghrepo.Interface, job *capi.Job, bo backoff.BackOff) (string, error) {
210 if job.PullRequest != nil && job.PullRequest.Number > 0 {
211 // Return the agent session URL if we happen to get it.
212 // Right now, this never happens.
213 return agentSessionWebURL(repo, job), nil
214 }
215
216 if bo == nil {
217 bo = backoff.NewExponentialBackOff(
218 backoff.WithMaxElapsedTime(10*time.Second),
219 backoff.WithInitialInterval(300*time.Millisecond),
220 backoff.WithMaxInterval(10*time.Second),
221 backoff.WithMultiplier(1.5),
222 )
223 }
224
225 jobWithPR, err := fetchJobWithBackoff(ctx, client, repo, job.ID, bo)
226 if jobWithPR != nil {
227 return agentSessionWebURL(repo, jobWithPR), nil
228 }
229 return "", err
230}
231
232// fetchJobWithBackoff polls the job resource until a PR number is present or the overall
233// timeout elapses. It returns the updated Job on success, (nil, nil) on timeout,

Callers 1

createRunFunction · 0.85

Calls 2

agentSessionWebURLFunction · 0.85
fetchJobWithBackoffFunction · 0.85

Tested by

no test coverage detected