|
@@ -3,7 +3,6 @@ package mdb
|
|
|
import (
|
|
|
"context"
|
|
|
"crypto/tls"
|
|
|
- "fmt"
|
|
|
"github.com/go-redis/redis/v8"
|
|
|
mhayaMongo "github.com/mhaya/components/mongo"
|
|
|
clog "github.com/mhaya/logger"
|
|
@@ -40,38 +39,34 @@ func (p *ActorDB) OnInit() {
|
|
|
if MDB == nil {
|
|
|
clog.Panic("game_db_id not found")
|
|
|
}
|
|
|
+
|
|
|
redisConfig := cprofile.GetConfig("redis")
|
|
|
tlsEnable := redisConfig.GetInt("tls")
|
|
|
+
|
|
|
if tlsEnable == 1 {
|
|
|
tlsConfig := &tls.Config{
|
|
|
MinVersion: tls.VersionTLS12,
|
|
|
PreferServerCipherSuites: true,
|
|
|
}
|
|
|
+
|
|
|
RDB = redis.NewUniversalClient(&redis.UniversalOptions{
|
|
|
Addrs: strings.Split(redisConfig.GetString("address"), ","),
|
|
|
Password: redisConfig.GetString("password"),
|
|
|
DB: redisConfig.GetInt("db"),
|
|
|
TLSConfig: tlsConfig,
|
|
|
})
|
|
|
- clog.Debugf("redis Addrs str: ", redisConfig.GetString("address"), ",")
|
|
|
- split := strings.Split(redisConfig.GetString("address"), ",")
|
|
|
- for i := 0; i < len(split); i++ {
|
|
|
- if i > 0 {
|
|
|
- fmt.Print(", ")
|
|
|
- }
|
|
|
- clog.Debugf("addr : %s", split[i])
|
|
|
- }
|
|
|
-
|
|
|
- err := RDB.Set(context.Background(), "test", 0, 0).Err()
|
|
|
- clog.Errorf("redis client error %v:", err)
|
|
|
} else {
|
|
|
RDB = redis.NewUniversalClient(&redis.UniversalOptions{
|
|
|
Addrs: strings.Split(redisConfig.GetString("address"), ","),
|
|
|
Password: redisConfig.GetString("password"),
|
|
|
DB: redisConfig.GetInt("db"),
|
|
|
})
|
|
|
- err := RDB.Set(context.Background(), "test", 0, 0).Err()
|
|
|
- clog.Errorf("redis client error %v:", err)
|
|
|
+ }
|
|
|
+
|
|
|
+ clog.Debug("redis address :" + redisConfig.GetString("address"))
|
|
|
+ err := RDB.Set(context.Background(), "test", 0, 0).Err()
|
|
|
+ if err != nil {
|
|
|
+ clog.Errorf("redis client error: %v", err)
|
|
|
}
|
|
|
|
|
|
if p.App().NodeId() == "m-center" {
|