Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merging to release-4-lts: [TT-9196] fix dashboard client timeout (#5176) #5229

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions cli/linter/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,9 @@
"connection_string": {
"type": "string"
},
"connection_timeout": {
"type": "integer"
},
"node_is_segmented": {
"type": "boolean"
},
Expand Down
3 changes: 3 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ type DBAppConfOptionsConfig struct {
// Set the URL to your Dashboard instance (or a load balanced instance). The URL needs to be formatted as: `http://dashboard_host:port`
ConnectionString string `json:"connection_string"`

// Set the timeout for your Dashboard connection. Defaults to 30 seconds. In seconds.
ConnectionTimeout int `json:"connection_timeout"`

// Set to `true` to enable filtering (sharding) of APIs.
NodeIsSegmented bool `json:"node_is_segmented"`

Expand Down
13 changes: 11 additions & 2 deletions gateway/dashboard_register.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,20 @@ var dashClient *http.Client

func (gw *Gateway) initialiseClient() *http.Client {
if dashClient == nil {
conf := gw.GetConfig()
timeout := conf.DBAppConfOptions.ConnectionTimeout

// I don't think this is the appropriate place for this. I recommend we look at
// something like https://github.com/mcuadros/go-defaults to normalize all our defaults.
if timeout < 1 {
timeout = 30
}

dashClient = &http.Client{
Timeout: 30 * time.Second,
Timeout: time.Duration(timeout) * time.Second,
}

if gw.GetConfig().HttpServerOptions.UseSSL {
if conf.HttpServerOptions.UseSSL {
// Setup HTTPS client
tlsConfig := &tls.Config{
InsecureSkipVerify: gw.GetConfig().HttpServerOptions.SSLInsecureSkipVerify,
Expand Down
Loading