Implement lab 3 level 4 failover and idempotency

This commit is contained in:
2026-10-29 23:35:04 +03:00
parent 0ab3a341aa
commit a2cb1ad2ae
338 changed files with 37821 additions and 22 deletions
+31
View File
@@ -0,0 +1,31 @@
package database
import (
"context"
"time"
"github.com/redis/go-redis/v9"
)
func NewRedis(ctx context.Context, addr string) (*redis.Client, error) {
options := &redis.Options{
Addr: addr,
DialTimeout: 3 * time.Second,
ReadTimeout: 3 * time.Second,
WriteTimeout: 2 * time.Second,
PoolSize: 10,
PoolTimeout: 2 * time.Second,
ContextTimeoutEnabled: true,
}
client := redis.NewClient(options)
if err := client.Ping(ctx).Err(); err != nil {
_ = client.Close()
return nil, err
}
return client, nil
}