From 860e5d483cd952ec833c40312a2141bb3e4ef579 Mon Sep 17 00:00:00 2001 From: Joram Wilander Date: Mon, 29 May 2017 15:46:35 -0400 Subject: PLT-6341/PLT-6342 Update gorp to mattermost fork and add connection timeout setting (#6410) * Update gorp to mattermost fork and add connection timeout setting * Add go dependency * Rename from connection timeout to query timeout * Properly add gorp dependency --- model/config.go | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'model/config.go') diff --git a/model/config.go b/model/config.go index 8c1814792..311a34610 100644 --- a/model/config.go +++ b/model/config.go @@ -6,6 +6,7 @@ package model import ( "encoding/json" "io" + "net/http" "net/url" ) @@ -195,6 +196,7 @@ type SqlSettings struct { MaxOpenConns int Trace bool AtRestEncryptKey string + QueryTimeout *int } type LogSettings struct { @@ -480,6 +482,11 @@ func (o *Config) SetDefaults() { o.SqlSettings.AtRestEncryptKey = NewRandomString(32) } + if o.SqlSettings.QueryTimeout == nil { + o.SqlSettings.QueryTimeout = new(int) + *o.SqlSettings.QueryTimeout = 30 + } + if o.FileSettings.AmazonS3Endpoint == "" { // Defaults to "s3.amazonaws.com" o.FileSettings.AmazonS3Endpoint = "s3.amazonaws.com" @@ -1322,6 +1329,10 @@ func (o *Config) IsValid() *AppError { return NewLocAppError("Config.IsValid", "model.config.is_valid.sql_idle.app_error", nil, "") } + if *o.SqlSettings.QueryTimeout <= 0 { + return NewAppError("Config.IsValid", "model.config.is_valid.sql_query_timeout.app_error", nil, "", http.StatusBadRequest) + } + if len(o.SqlSettings.DataSource) == 0 { return NewLocAppError("Config.IsValid", "model.config.is_valid.sql_data_src.app_error", nil, "") } -- cgit v1.2.3-1-g7c22