-
Notifications
You must be signed in to change notification settings - Fork 60
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
Add redis sentinel support #161
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -151,12 +151,14 @@ func (cfg *Memcache) validateAndLog() error { | |
} | ||
|
||
type Redis struct { | ||
Host string `mapstructure:"host"` | ||
Port int `mapstructure:"port"` | ||
Password string `mapstructure:"password"` | ||
Db int `mapstructure:"db"` | ||
ExpirationMinutes int `mapstructure:"expiration"` | ||
TLS RedisTLS `mapstructure:"tls"` | ||
Host string `mapstructure:"host"` | ||
Port int `mapstructure:"port"` | ||
Password string `mapstructure:"password"` | ||
Db int `mapstructure:"db"` | ||
ExpirationMinutes int `mapstructure:"expiration"` | ||
TLS RedisTLS `mapstructure:"tls"` | ||
SentinelHostsPorts []string `mapstructure:"sentinel_hosts_ports"` | ||
SentinelMasterName string `mapstructure:"sentinel_mastername"` | ||
} | ||
|
||
type RedisTLS struct { | ||
|
@@ -165,8 +167,13 @@ type RedisTLS struct { | |
} | ||
|
||
func (cfg *Redis) validateAndLog() error { | ||
log.Infof("config.backend.redis.host: %s", cfg.Host) | ||
log.Infof("config.backend.redis.port: %d", cfg.Port) | ||
if cfg.Host != "" && len(cfg.SentinelHostsPorts) > 0 { | ||
log.Infof("config.backend.redis.sentinel_hosts_ports: %s. Note that redis 'host' will be ignore if 'sentinel_hosts_ports' is define", cfg.SentinelHostsPorts) | ||
log.Infof("config.backend.redis.sentinel_mastername: %s.", cfg.SentinelMasterName) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @cyrinux thank you for your addresing our feedback. When we want to configure Redis in Sentinel mode, is If we do, then I believe an extra Thoughts? |
||
} else { | ||
log.Infof("config.backend.redis.host: %s", cfg.Host) | ||
log.Infof("config.backend.redis.port: %d", cfg.Port) | ||
} | ||
log.Infof("config.backend.redis.db: %d", cfg.Db) | ||
if cfg.ExpirationMinutes > 0 { | ||
log.Infof("config.backend.redis.expiration: %d. Note that this configuration option is being deprecated in favor of config.request_limits.max_ttl_seconds", cfg.ExpirationMinutes) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In practice,
logrus.FatalLevel
stops execution. Under this scenario, we would only see the first entry in the logs:There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought the same but without those three items the test fail.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's because the test function disables the
logrus
exit functions, so we can have as manylog.Fatalf
calls without interrupting the test:There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch, thanks @sebmil-daily