Browse Source

update

master
dengbiao 1 month ago
parent
commit
f534e79ede
2 changed files with 29 additions and 26 deletions
  1. +26
    -23
      config/config.go
  2. +3
    -3
      pkg/rpc/rpc.go

+ 26
- 23
config/config.go View File

@@ -1,9 +1,13 @@
package config

import (
"context"
"egg_im/pkg/k8sutil"
"egg_im/pkg/logger"
"go.uber.org/zap"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"os"
"strconv"
)

const (
@@ -16,9 +20,8 @@ const (
)

var (
NameSpace string = "egg_im"
MySQL string = "root:Fnuo123com@@tcp(119.23.182.117:3306)/egg_im?charset=utf8&parseTime=true&loc=Local"
//MySQL string = "canal:canal@tcp(zhios123.rwlb.rds.aliyuncs.com:3306)/egg_im?charset=utf8&parseTime=true&loc=Local"
NameSpace string = "egg_im"
MySQL string = "root:Fnuo123com@@tcp(119.23.182.117:3306)/egg_im?charset=utf8&parseTime=true&loc=Local"
RedisIP string = "120.24.28.6:32572"
RedisPassword string = ""

@@ -28,26 +31,26 @@ var (
)

func Init() {
//k8sClient, err := k8sutil.GetK8sClient()
//if err != nil {
// panic(err)
//}
//configmap, err := k8sClient.CoreV1().ConfigMaps(NameSpace).Get(context.TODO(), "config", metav1.GetOptions{})
//if err != nil {
// panic(err)
//}
//
//MySQL = configmap.Data["mysql"]
//RedisIP = configmap.Data["redisIP"]
//RedisPassword = configmap.Data["redisPassword"]
//PushRoomSubscribeNum, _ = strconv.Atoi(configmap.Data["pushRoomSubscribeNum"])
//if PushRoomSubscribeNum == 0 {
// panic("PushRoomSubscribeNum == 0")
//}
//PushAllSubscribeNum, _ = strconv.Atoi(configmap.Data["pushAllSubscribeNum"])
//if PushRoomSubscribeNum == 0 {
// panic("PushAllSubscribeNum == 0")
//}
k8sClient, err := k8sutil.GetK8sClient()
if err != nil {
panic(err)
}
configmap, err := k8sClient.CoreV1().ConfigMaps(NameSpace).Get(context.TODO(), "config", metav1.GetOptions{})
if err != nil {
panic(err)
}
MySQL = configmap.Data["mysql"]
RedisIP = configmap.Data["redisIP"]
RedisPassword = configmap.Data["redisPassword"]
PushRoomSubscribeNum, _ = strconv.Atoi(configmap.Data["pushRoomSubscribeNum"])
if PushRoomSubscribeNum == 0 {
panic("PushRoomSubscribeNum == 0")
}
PushAllSubscribeNum, _ = strconv.Atoi(configmap.Data["pushAllSubscribeNum"])
if PushRoomSubscribeNum == 0 {
panic("PushAllSubscribeNum == 0")
}

LocalAddr = os.Getenv("POD_IP") + RPCListenAddr



+ 3
- 3
pkg/rpc/rpc.go View File

@@ -58,10 +58,10 @@ func initConnectIntClient() {
}

func initBusinessIntClient() {
conn, err := grpc.DialContext(context.TODO(), "im-rpc-business.izhyin.com:8000", grpc.WithInsecure(),
grpc.WithDefaultServiceConfig(fmt.Sprintf(`{"LoadBalancingPolicy": "%s"}`, roundrobin.Name)))
//conn, err := grpc.DialContext(context.TODO(), k8s.GetK8STarget("egg_im", "business", "8000"), grpc.WithInsecure(),
//conn, err := grpc.DialContext(context.TODO(), "127.0.0.1:8000", grpc.WithInsecure(),
// grpc.WithDefaultServiceConfig(fmt.Sprintf(`{"LoadBalancingPolicy": "%s"}`, roundrobin.Name)))
conn, err := grpc.DialContext(context.TODO(), k8s.GetK8STarget("egg_im", "business", "8000"), grpc.WithInsecure(),
grpc.WithDefaultServiceConfig(fmt.Sprintf(`{"LoadBalancingPolicy": "%s"}`, roundrobin.Name)))
if err != nil {
panic(err)
}


Loading…
Cancel
Save