mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-09-20 13:30:46 +02:00
The sentinel stores hardcoded a 30s read timeout and a 1m retry backoff. After a sentinel failover every request that picked a pooled connection to the old master sat there for 30s before the connection was retired, and the pool timeout derived from it (read timeout + 1s) queued the rest behind them. The other redis stores took the go-redis defaults with no way to tune anything. Read the dial, timeout and pool knobs from each redis store section instead, keeping the go-redis default for every key left unset.
41 lines
995 B
Go
41 lines
995 B
Go
package redis
|
|
|
|
import (
|
|
"github.com/redis/go-redis/v9"
|
|
"github.com/seaweedfs/seaweedfs/weed/filer"
|
|
"github.com/seaweedfs/seaweedfs/weed/filer/redis_conf"
|
|
"github.com/seaweedfs/seaweedfs/weed/util"
|
|
)
|
|
|
|
func init() {
|
|
filer.Stores = append(filer.Stores, &RedisStore{})
|
|
}
|
|
|
|
type RedisStore struct {
|
|
UniversalRedisStore
|
|
}
|
|
|
|
func (store *RedisStore) GetName() string {
|
|
return "redis"
|
|
}
|
|
|
|
func (store *RedisStore) Initialize(configuration util.Configuration, prefix string) (err error) {
|
|
return store.initialize(
|
|
configuration.GetString(prefix+"address"),
|
|
configuration.GetString(prefix+"password"),
|
|
configuration.GetInt(prefix+"database"),
|
|
redis_conf.Read(configuration, prefix),
|
|
)
|
|
}
|
|
|
|
func (store *RedisStore) initialize(hostPort string, password string, database int, settings redis_conf.Settings) (err error) {
|
|
options := &redis.Options{
|
|
Addr: hostPort,
|
|
Password: password,
|
|
DB: database,
|
|
}
|
|
settings.ApplyTo(options)
|
|
store.Client = redis.NewClient(options)
|
|
return
|
|
}
|