Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: expose new redis config #429

Merged
merged 2 commits into from
Sep 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions configs/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ redis_address: "localhost:6379"
redis_max_idle: 500
redis_pool_size: 10000
redis_idle_timeout: 0
redis_max_conn_age: 0
redis_max_retries: 3
redis_min_retry_backoff: "8ms"
redis_max_retry_backoff: "512ms"
Expand Down
1 change: 1 addition & 0 deletions internal/app/server/open_saves_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ func getOpenSavesServer(ctx context.Context, t *testing.T, cloud string) (*openS
Address: r.Addr(),
PoolSize: 10000,
IdleTimeout: 0,
MaxConnAge: 0,
},
}
impl, err := newOpenSavesServer(ctx, cfg)
Expand Down
3 changes: 2 additions & 1 deletion internal/pkg/cache/redis/redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,14 @@ func NewRedis(address string) *Redis {
return NewRedisWithConfig(cfg)
}

// NewRedis creates a new Redis instance.
// NewRedisWithConfig creates a new Redis instance with configurable options.
func NewRedisWithConfig(cfg *config.RedisConfig) *Redis {
o := &redis.Options{
Addr: cfg.Address,
MinIdleConns: cfg.MinIdleConns,
PoolSize: cfg.PoolSize,
IdleTimeout: cfg.IdleTimeout,
MaxConnAge: cfg.MaxConnAge,
}

c := redis.NewClient(o)
Expand Down
1 change: 1 addition & 0 deletions internal/pkg/config/loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ func Load(path string) (*ServiceConfig, error) {
MaxRetries: viper.GetInt(RedisMaxRetries),
MinRetyBackoff: viper.GetDuration(RedisMinRetryBackoff),
MaxRetryBackoff: viper.GetDuration(RedisMaxRetryBackoff),
MaxConnAge: viper.GetDuration(RedisMaxConnAge),
MinIdleConns: viper.GetInt(RedisMinIdleConns),
PoolSize: viper.GetInt(RedisPoolSize),
IdleTimeout: time.Duration(viper.GetUint(RedisIdleTimeout)) * time.Second,
Expand Down
2 changes: 2 additions & 0 deletions internal/pkg/config/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const (
RedisMinIdleConns = "redis_min_idle_conns"
RedisPoolSize = "redis_pool_size"
RedisIdleTimeout = "redis_idle_timeout"
RedisMaxConnAge = "redis_max_conn_age"
RedisMaxRetries = "redis_max_retries"
RedisMinRetryBackoff = "redis_min_retry_backoff"
RedisMaxRetryBackoff = "redis_max_retry_backoff"
Expand Down Expand Up @@ -92,6 +93,7 @@ type RedisConfig struct {
MinIdleConns int
PoolSize int
IdleTimeout time.Duration
MaxConnAge time.Duration
}

// BlobConfig has Open Saves blob related configurations.
Expand Down