feature/11-update_master_to_beta_release_commits #12
3 changed files with 17 additions and 17 deletions
|
@ -653,19 +653,23 @@ func Parse(rd io.Reader) (*Configuration, error) {
|
||||||
return config, nil
|
return config, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type RedisOptions = redis.UniversalOptions
|
||||||
|
|
||||||
|
type RedisTLSOptions struct {
|
||||||
|
Certificate string `yaml:"certificate,omitempty"`
|
||||||
|
Key string `yaml:"key,omitempty"`
|
||||||
|
ClientCAs []string `yaml:"clientcas,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
type Redis struct {
|
type Redis struct {
|
||||||
redis.UniversalOptions `yaml:",inline"`
|
Options RedisOptions `yaml:",inline"`
|
||||||
TLS struct {
|
TLS RedisTLSOptions `yaml:"tls,omitempty"`
|
||||||
Certificate string `yaml:"certificate,omitempty"`
|
|
||||||
Key string `yaml:"key,omitempty"`
|
|
||||||
ClientCAs []string `yaml:"clientcas,omitempty"`
|
|
||||||
} `yaml:"tls,omitempty"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c Redis) MarshalYAML() (interface{}, error) {
|
func (c Redis) MarshalYAML() (interface{}, error) {
|
||||||
fields := make(map[string]interface{})
|
fields := make(map[string]interface{})
|
||||||
|
|
||||||
val := reflect.ValueOf(c.UniversalOptions)
|
val := reflect.ValueOf(c.Options)
|
||||||
typ := val.Type()
|
typ := val.Type()
|
||||||
|
|
||||||
for i := 0; i < val.NumField(); i++ {
|
for i := 0; i < val.NumField(); i++ {
|
||||||
|
@ -695,7 +699,7 @@ func (c *Redis) UnmarshalYAML(unmarshal func(interface{}) error) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
val := reflect.ValueOf(&c.UniversalOptions).Elem()
|
val := reflect.ValueOf(&c.Options).Elem()
|
||||||
typ := val.Type()
|
typ := val.Type()
|
||||||
|
|
||||||
for i := 0; i < typ.NumField(); i++ {
|
for i := 0; i < typ.NumField(); i++ {
|
||||||
|
|
|
@ -132,7 +132,7 @@ var configStruct = Configuration{
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Redis: Redis{
|
Redis: Redis{
|
||||||
UniversalOptions: redis.UniversalOptions{
|
Options: redis.UniversalOptions{
|
||||||
Addrs: []string{"localhost:6379"},
|
Addrs: []string{"localhost:6379"},
|
||||||
Username: "alice",
|
Username: "alice",
|
||||||
Password: "123456",
|
Password: "123456",
|
||||||
|
@ -144,11 +144,7 @@ var configStruct = Configuration{
|
||||||
ReadTimeout: time.Millisecond * 10,
|
ReadTimeout: time.Millisecond * 10,
|
||||||
WriteTimeout: time.Millisecond * 10,
|
WriteTimeout: time.Millisecond * 10,
|
||||||
},
|
},
|
||||||
TLS: struct {
|
TLS: RedisTLSOptions{
|
||||||
Certificate string `yaml:"certificate,omitempty"`
|
|
||||||
Key string `yaml:"key,omitempty"`
|
|
||||||
ClientCAs []string `yaml:"clientcas,omitempty"`
|
|
||||||
}{
|
|
||||||
Certificate: "/foo/cert.crt",
|
Certificate: "/foo/cert.crt",
|
||||||
Key: "/foo/key.pem",
|
Key: "/foo/key.pem",
|
||||||
ClientCAs: []string{"/path/to/ca.pem"},
|
ClientCAs: []string{"/path/to/ca.pem"},
|
||||||
|
|
|
@ -489,7 +489,7 @@ func (app *App) configureEvents(configuration *configuration.Configuration) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (app *App) configureRedis(cfg *configuration.Configuration) {
|
func (app *App) configureRedis(cfg *configuration.Configuration) {
|
||||||
if len(cfg.Redis.Addrs) == 0 {
|
if len(cfg.Redis.Options.Addrs) == 0 {
|
||||||
dcontext.GetLogger(app).Infof("redis not configured")
|
dcontext.GetLogger(app).Infof("redis not configured")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -520,10 +520,10 @@ func (app *App) configureRedis(cfg *configuration.Configuration) {
|
||||||
tlsConf.ClientAuth = tls.RequireAndVerifyClientCert
|
tlsConf.ClientAuth = tls.RequireAndVerifyClientCert
|
||||||
tlsConf.ClientCAs = pool
|
tlsConf.ClientCAs = pool
|
||||||
}
|
}
|
||||||
cfg.Redis.UniversalOptions.TLSConfig = tlsConf
|
cfg.Redis.Options.TLSConfig = tlsConf
|
||||||
}
|
}
|
||||||
|
|
||||||
app.redis = app.createPool(cfg.Redis.UniversalOptions)
|
app.redis = app.createPool(cfg.Redis.Options)
|
||||||
|
|
||||||
// Enable metrics instrumentation.
|
// Enable metrics instrumentation.
|
||||||
if err := redisotel.InstrumentMetrics(app.redis); err != nil {
|
if err := redisotel.InstrumentMetrics(app.redis); err != nil {
|
||||||
|
|
Loading…
Reference in a new issue