Allow Actions Github Client HTTP timeout to be configurable
This commit is contained in:
parent
168c90057b
commit
8aa523c453
|
|
@ -13,6 +13,7 @@ import (
|
|||
"math/rand"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"os"
|
||||
"strconv"
|
||||
"sync"
|
||||
"time"
|
||||
|
|
@ -209,7 +210,17 @@ func NewClient(githubConfigURL string, creds *ActionsAuth, options ...ClientOpti
|
|||
retryClient.RetryMax = ac.retryMax
|
||||
retryClient.RetryWaitMax = ac.retryWaitMax
|
||||
|
||||
retryClient.HTTPClient.Timeout = 90 * time.Second // timeout must be > 1m to accommodate long polling
|
||||
ts, found := os.LookupEnv("ACTIONS_HTTP_CLIENT_TIMEOUT_SECONDS")
|
||||
if !found {
|
||||
// Default to 5 minutes
|
||||
// timeout must be > 1m to accommodate long polling
|
||||
ts = "300"
|
||||
}
|
||||
timeout, err := strconv.ParseInt(ts, 10, 64)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to convert ACTIONS_HTTP_CLIENT_TIMEOUT_SECONDS to int64: %v", err)
|
||||
}
|
||||
retryClient.HTTPClient.Timeout = time.Duration(timeout) * time.Second
|
||||
|
||||
transport, ok := retryClient.HTTPClient.Transport.(*http.Transport)
|
||||
if !ok {
|
||||
|
|
|
|||
Loading…
Reference in New Issue