fix(slurm): add default 30s timeout to HTTP client
Replaces http.DefaultClient with a client that has a 30s timeout to prevent indefinite hangs when the Slurm REST API is unresponsive. Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
@@ -24,6 +24,8 @@ func defaultClientConfig() *clientConfig {
|
||||
}
|
||||
}
|
||||
|
||||
const defaultHTTPTimeout = 30 * time.Second
|
||||
|
||||
// WithJWTKey specifies the path to the JWT key file.
|
||||
func WithJWTKey(path string) ClientOption {
|
||||
return func(c *clientConfig) error {
|
||||
@@ -89,11 +91,12 @@ func NewClientWithOpts(baseURL string, opts ...ClientOption) (*Client, error) {
|
||||
}
|
||||
|
||||
tr := NewJWTAuthTransport(cfg.username, key, transportOpts...)
|
||||
httpClient = tr.Client()
|
||||
httpClient = &http.Client{
|
||||
Transport: tr,
|
||||
Timeout: defaultHTTPTimeout,
|
||||
}
|
||||
} else if cfg.httpClient != nil {
|
||||
httpClient = cfg.httpClient
|
||||
} else {
|
||||
httpClient = http.DefaultClient
|
||||
}
|
||||
|
||||
return NewClient(baseURL, httpClient)
|
||||
|
||||
Reference in New Issue
Block a user