Skip to content

Commit

Permalink
Add support for specifying Redis Timeout (TykTechnologies#2166)
Browse files Browse the repository at this point in the history
Added new variable `storage.timeout`

Fix TykTechnologies#2165
  • Loading branch information
buger committed Mar 13, 2019
1 parent 2344343 commit 023290a
Show file tree
Hide file tree
Showing 20 changed files with 3,421 additions and 21 deletions.
3 changes: 3 additions & 0 deletions cli/lint/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ const confSchema = `{
"optimisation_max_idle": {
"type": "integer"
},
"timeout": {
"type": "integer"
},
"password": {
"type": "string"
},
Expand Down
1 change: 1 addition & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ type StorageOptionsConf struct {
Database int `json:"database"`
MaxIdle int `json:"optimisation_max_idle"`
MaxActive int `json:"optimisation_max_active"`
Timeout int `json:"timeout"`
EnableCluster bool `json:"enable_cluster"`
UseSSL bool `json:"use_ssl"`
SSLInsecureSkipVerify bool `json:"ssl_insecure_skip_verify"`
Expand Down
25 changes: 17 additions & 8 deletions storage/redis_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,15 +117,24 @@ func NewRedisClusterPool(isCache bool) *rediscluster.RedisCluster {
log.Info("--> Using clustered mode")
}

timeout := 5 * time.Second

if cfg.Timeout > 0 {
timeout = time.Duration(cfg.Timeout) * time.Second
}

poolConf := rediscluster.PoolConfig{
MaxIdle: maxIdle,
MaxActive: maxActive,
IdleTimeout: 240 * time.Second,
Database: cfg.Database,
Password: cfg.Password,
IsCluster: cfg.EnableCluster,
UseTLS: cfg.UseSSL,
TLSSkipVerify: cfg.SSLInsecureSkipVerify,
MaxIdle: maxIdle,
MaxActive: maxActive,
IdleTimeout: 240 * time.Second,
ConnectTimeout: timeout,
ReadTimeout: timeout,
WriteTimeout: timeout,
Database: cfg.Database,
Password: cfg.Password,
IsCluster: cfg.EnableCluster,
UseTLS: cfg.UseSSL,
TLSSkipVerify: cfg.SSLInsecureSkipVerify,
}

// If Redis port isn't set, use default one:
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

175 changes: 175 additions & 0 deletions vendor/github.com/gomodule/redigo/LICENSE

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

55 changes: 55 additions & 0 deletions vendor/github.com/gomodule/redigo/redis/commandinfo.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 023290a

Please sign in to comment.