fix(redis): shorten dial/read/write timeouts and cap retries
This commit is contained in:
@@ -14,15 +14,16 @@ func NewClient(url string) (*redis.Client, error) {
|
||||
return nil, fmt.Errorf("разбор URL: %w", err)
|
||||
}
|
||||
|
||||
opt.DialTimeout = 5 * time.Second
|
||||
opt.ReadTimeout = 3 * time.Second
|
||||
opt.WriteTimeout = 3 * time.Second
|
||||
opt.MaxRetries = 2
|
||||
opt.DialTimeout = 700 * time.Millisecond
|
||||
opt.ReadTimeout = 700 * time.Millisecond
|
||||
opt.WriteTimeout = 700 * time.Millisecond
|
||||
opt.MaxRetries = 1
|
||||
opt.PoolSize = 10
|
||||
opt.ConnMaxIdleTime = time.Minute
|
||||
|
||||
client := redis.NewClient(opt)
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)
|
||||
defer cancel()
|
||||
if err := client.Ping(ctx).Err(); err != nil {
|
||||
_ = client.Close()
|
||||
|
||||
Reference in New Issue
Block a user