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:
@@ -9,6 +9,7 @@ import (
|
||||
"net/http"
|
||||
"net/url"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -16,6 +17,8 @@ const (
|
||||
DefaultBaseURL = "http://localhost:6820/"
|
||||
// DefaultUserAgent is the default User-Agent header value.
|
||||
DefaultUserAgent = "slurm-go-sdk"
|
||||
// DefaultTimeout is the default HTTP request timeout.
|
||||
DefaultTimeout = 30 * time.Second
|
||||
)
|
||||
|
||||
// Client manages communication with the Slurm REST API.
|
||||
@@ -85,7 +88,7 @@ type Response struct {
|
||||
// http.DefaultClient is used.
|
||||
func NewClient(baseURL string, httpClient *http.Client) (*Client, error) {
|
||||
if httpClient == nil {
|
||||
httpClient = http.DefaultClient
|
||||
httpClient = &http.Client{Timeout: DefaultTimeout}
|
||||
}
|
||||
|
||||
parsedURL, err := url.Parse(baseURL)
|
||||
|
||||
Reference in New Issue
Block a user