worker: Configurable timeout for RequestJob
This is backwards compatible, as long as the timeout is 0 (never timeout), which is the default. In case of the dbjobqueue the underlying timeout is due to context.Canceled, context.DeadlineExceeded, or net.Error with Timeout() true. For the fsjobqueue only the first two are considered.
This commit is contained in:
parent
9075dbc61d
commit
d25ae71fef
19 changed files with 171 additions and 74 deletions
|
|
@ -5,6 +5,7 @@ import (
|
|||
"context"
|
||||
"crypto/tls"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"net"
|
||||
|
|
@ -45,6 +46,8 @@ type Job interface {
|
|||
UploadArtifact(name string, reader io.Reader) error
|
||||
}
|
||||
|
||||
var ErrClientRequestJobTimeout = errors.New("Dequeue timed out, retry")
|
||||
|
||||
type job struct {
|
||||
client *Client
|
||||
id uuid.UUID
|
||||
|
|
@ -185,6 +188,9 @@ func (c *Client) RequestJob(types []string, arch string) (Job, error) {
|
|||
}
|
||||
defer response.Body.Close()
|
||||
|
||||
if response.StatusCode == http.StatusNoContent {
|
||||
return nil, ErrClientRequestJobTimeout
|
||||
}
|
||||
if response.StatusCode != http.StatusCreated {
|
||||
return nil, errorFromResponse(response, "error requesting job")
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue