feat: slow threshold customizable in redis (#1187)

This commit is contained in:
Kevin Wan
2021-11-01 08:20:35 +08:00
committed by GitHub
parent 8be0f77d96
commit f13e6f1149
6 changed files with 48 additions and 54 deletions

View File

@@ -1,11 +1,6 @@
package redis
import (
"errors"
"time"
"github.com/tal-tech/go-zero/core/conf"
)
import "errors"
var (
// ErrEmptyHost is an error that indicates no redis host is set.
@@ -19,11 +14,10 @@ var (
type (
// A RedisConf is a redis config.
RedisConf struct {
Host string
Type string `json:",default=node,options=node|cluster"`
Pass string `json:",optional"`
Tls bool `json:",default=false,options=true|false"`
SlowThreshold time.Duration `json:",default=100ms"`
Host string
Type string `json:",default=node,options=node|cluster"`
Pass string `json:",optional"`
Tls bool `json:",default=false,options=true|false"`
}
// A RedisKeyConf is a redis config with key.
@@ -42,9 +36,6 @@ func (rc RedisConf) NewRedis() *Redis {
if len(rc.Pass) > 0 {
opts = append(opts, WithPass(rc.Pass))
}
if rc.SlowThreshold > 0 {
opts = append(opts, WithSlowThreshold(conf.CheckedDuration(rc.SlowThreshold)))
}
if rc.Tls {
opts = append(opts, WithTLS())
}