Skip to content
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
4 changes: 2 additions & 2 deletions internal/job/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ const (
// Machinery server configuration.
const (
DefaultResultsExpireIn = 86400
DefaultRedisMaxIdle = 5
DefaultRedisMaxActive = 20
DefaultRedisMaxIdle = 30
DefaultRedisMaxActive = 50
DefaultRedisIdleTimeout = 30
DefaultRedisReadTimeout = 60
DefaultRedisWriteTimeout = 60
Expand Down
2 changes: 1 addition & 1 deletion manager/config/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ const (

const (
// DefaultRedisPoolSize is default pool size for redis.
DefaultRedisPoolSize = 20
DefaultRedisPoolSize = 40

// DefaultRedisPoolTimeout is default pool timeout for redis.
DefaultRedisPoolTimeout = 10 * time.Second
Expand Down
2 changes: 2 additions & 0 deletions manager/database/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ func New(cfg *config.Config) (*Database, error) {
Password: cfg.Database.Redis.Password,
SentinelUsername: cfg.Database.Redis.SentinelUsername,
SentinelPassword: cfg.Database.Redis.SentinelPassword,
PoolSize: cfg.Database.Redis.PoolSize,
PoolTimeout: cfg.Database.Redis.PoolTimeout,
})
if err != nil {
return nil, err
Expand Down
2 changes: 2 additions & 0 deletions pkg/redis/redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ func NewRedis(cfg *redis.UniversalOptions) (redis.UniversalClient, error) {
Password: cfg.Password,
SentinelUsername: cfg.SentinelUsername,
SentinelPassword: cfg.SentinelPassword,
PoolSize: cfg.PoolSize,
PoolTimeout: cfg.PoolTimeout,
})

if err := client.Ping(context.Background()).Err(); err != nil {
Expand Down
12 changes: 10 additions & 2 deletions scheduler/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,12 @@ type RedisConfig struct {
// SentinelPassword is sentinel server password.
SentinelPassword string `yaml:"sentinelPassword" mapstructure:"sentinelPassword"`

// PoolSize is the maximum number of idle connections in the pool.
PoolSize int `yaml:"poolSize" mapstructure:"poolSize"`

// PoolTimeout is the maximum amount of time a connection may be idle before being closed.
PoolTimeout time.Duration `yaml:"poolTimeout" mapstructure:"poolTimeout"`

// BrokerDB is broker database name.
BrokerDB int `yaml:"brokerDB" mapstructure:"brokerDB"`

Expand Down Expand Up @@ -334,8 +340,10 @@ func New() *Config {
},
Database: DatabaseConfig{
Redis: RedisConfig{
BrokerDB: DefaultRedisBrokerDB,
BackendDB: DefaultRedisBackendDB,
BrokerDB: DefaultRedisBrokerDB,
BackendDB: DefaultRedisBackendDB,
PoolSize: DefaultRedisPoolSize,
PoolTimeout: DefaultRedisPoolTimeout,
},
},
DynConfig: DynConfig{
Expand Down
16 changes: 9 additions & 7 deletions scheduler/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,15 @@ func TestConfig_Load(t *testing.T) {
},
Database: DatabaseConfig{
Redis: RedisConfig{
Host: "127.0.0.1",
Password: "foo",
Addrs: []string{"foo", "bar"},
MasterName: "baz",
Port: 6379,
BrokerDB: DefaultRedisBrokerDB,
BackendDB: DefaultRedisBackendDB,
Host: "127.0.0.1",
Password: "foo",
Addrs: []string{"foo", "bar"},
MasterName: "baz",
Port: 6379,
BrokerDB: DefaultRedisBrokerDB,
BackendDB: DefaultRedisBackendDB,
PoolSize: 10,
PoolTimeout: 1 * time.Second,
},
},
DynConfig: DynConfig{
Expand Down
6 changes: 6 additions & 0 deletions scheduler/config/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ const (

// DefaultRedisBackendDB is default db for redis backend.
DefaultRedisBackendDB = 2

// DefaultRedisPoolSize is default pool size for redis.
DefaultRedisPoolSize = 20

// DefaultRedisPoolTimeout is default pool timeout for redis.
DefaultRedisPoolTimeout = 10 * time.Second
)

const (
Expand Down
2 changes: 2 additions & 0 deletions scheduler/config/testdata/scheduler.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ database:
password: foo
brokerDB: 1
backendDB: 2
poolSize: 10
poolTimeout: 1s

dynConfig:
refreshInterval: 10s
Expand Down
2 changes: 2 additions & 0 deletions scheduler/scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@ func New(ctx context.Context, cfg *config.Config, d dfpath.Dfpath) (*Server, err
Password: cfg.Database.Redis.Password,
SentinelUsername: cfg.Database.Redis.SentinelUsername,
SentinelPassword: cfg.Database.Redis.SentinelPassword,
PoolSize: cfg.Database.Redis.PoolSize,
PoolTimeout: cfg.Database.Redis.PoolTimeout,
})
if err != nil {
return nil, err
Expand Down