tweak redis conns

This commit is contained in:
Andre Medeiros 2022-07-13 15:02:38 -04:00
parent 624cebf8ef
commit a00e4405c7
4 changed files with 5 additions and 5 deletions

View file

@ -39,7 +39,7 @@ func APICmd(ctx context.Context) *cobra.Command {
}
defer db.Close()
redis, err := cmdutil.NewRedisClient(ctx)
redis, err := cmdutil.NewRedisClient(ctx, 16)
if err != nil {
return err
}

View file

@ -50,7 +50,7 @@ func SchedulerCmd(ctx context.Context) *cobra.Command {
}
defer db.Close()
redis, err := cmdutil.NewRedisClient(ctx)
redis, err := cmdutil.NewRedisClient(ctx, 2)
if err != nil {
return err
}

View file

@ -54,7 +54,7 @@ func WorkerCmd(ctx context.Context) *cobra.Command {
}
defer db.Close()
redis, err := cmdutil.NewRedisClient(ctx)
redis, err := cmdutil.NewRedisClient(ctx, poolSize)
if err != nil {
return err
}

View file

@ -35,12 +35,12 @@ func NewStatsdClient(tags ...string) (*statsd.Client, error) {
return statsd.New(os.Getenv("STATSD_URL"), statsd.WithTags(tags))
}
func NewRedisClient(ctx context.Context) (*redis.Client, error) {
func NewRedisClient(ctx context.Context, maxConns int) (*redis.Client, error) {
opt, err := redis.ParseURL(os.Getenv("REDIS_URL"))
if err != nil {
return nil, err
}
opt.PoolSize = 16
opt.PoolSize = maxConns
client := redis.NewClient(opt)
if err := client.Ping(ctx).Err(); err != nil {