fix: update Redis configuration to use SSL and adjust related settings
This commit is contained in:
parent
02d8a509ff
commit
987ac2fe4a
@ -6,7 +6,7 @@ type Redis struct {
|
||||
DB int `mapstructure:"db"`
|
||||
Username string `mapstructure:"username"`
|
||||
Password string `mapstructure:"password"`
|
||||
SslMode string `mapstructure:"ssl-mode"`
|
||||
SSL bool `mapstructure:"ssl"`
|
||||
Debug bool `mapstructure:"debug"`
|
||||
MaxIdleConnectionsInSecond int `mapstructure:"max-idle-connections-in-second"`
|
||||
MaxOpenConnectionsInSecond int `mapstructure:"max-open-connections-in-second"`
|
||||
|
||||
2
env/staging.yaml
vendored
2
env/staging.yaml
vendored
@ -36,7 +36,7 @@ redis:
|
||||
username: red-d04c8k49c44c739ga8dg
|
||||
password: ItPzniHv94yr8vY4HTrhCfKoibqBh61T
|
||||
db: 5
|
||||
ssl: false
|
||||
ssl: true
|
||||
max-idle-connections-in-second: 600
|
||||
max-open-connections-in-second: 600
|
||||
connection-max-life-time-in-second: 600
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package redisaccessor
|
||||
|
||||
import (
|
||||
"crypto/tls"
|
||||
"fmt"
|
||||
"legalgo-BE-go/config"
|
||||
|
||||
@ -16,11 +17,19 @@ func Get() *redis.Client {
|
||||
func New(cfg *config.Config) *redis.Client {
|
||||
addr := fmt.Sprintf("%s:%s", cfg.Redis.Host, cfg.Redis.Port)
|
||||
|
||||
redisClient = redis.NewClient(&redis.Options{
|
||||
options := &redis.Options{
|
||||
Addr: addr,
|
||||
Password: cfg.Redis.Password,
|
||||
DB: cfg.Redis.DB,
|
||||
})
|
||||
}
|
||||
|
||||
if cfg.Redis.Username != "" {
|
||||
options.Username = cfg.Redis.Username
|
||||
}
|
||||
if cfg.Redis.SSL {
|
||||
options.TLSConfig = &tls.Config{}
|
||||
}
|
||||
|
||||
redisClient = redis.NewClient(options)
|
||||
return redisClient
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user