MCPcopy Index your code
hub / github.com/cloudfoundry/cli / waitForJob

Method waitForJob

cf/net/gateway.go:332–358  ·  view source on GitHub ↗
(jobURL, accessToken string, timeout time.Duration)

Source from the content-addressed store, hash-verified

330}
331
332func (gateway Gateway) waitForJob(jobURL, accessToken string, timeout time.Duration) error {
333 startTime := gateway.Clock()
334 for true {
335 if gateway.Clock().Sub(startTime) > timeout && timeout != 0 {
336 return errors.NewAsyncTimeoutError(jobURL)
337 }
338 var request *Request
339 request, err := gateway.NewRequest("GET", jobURL, accessToken, nil)
340 response := &JobResource{}
341 _, err = gateway.PerformRequestForJSONResponse(request, response)
342 if err != nil {
343 return err
344 }
345
346 switch response.Entity.Status {
347 case JobFinished:
348 return nil
349 case JobFailed:
350 return errors.New(response.Entity.ErrorDetails.Description)
351 }
352
353 accessToken = request.HTTPReq.Header.Get("Authorization")
354
355 time.Sleep(gateway.PollingThrottle)
356 }
357 return nil
358}
359
360func (gateway Gateway) doRequestHandlingAuth(request *Request) (*http.Response, error) {
361 httpReq := request.HTTPReq

Calls 5

NewRequestMethod · 0.95
NewAsyncTimeoutErrorFunction · 0.92
NewFunction · 0.92
GetMethod · 0.65

Tested by

no test coverage detected