From 535d61daa3fc85869eb822953871521a08c63e36 Mon Sep 17 00:00:00 2001
From: liujiandao <274878379@qq.com>
Date: 星期三, 08 十一月 2023 14:18:11 +0800
Subject: [PATCH] 字段添加

---
 conf/config.go |   48 +++++++++++++++++++-----------------------------
 1 files changed, 19 insertions(+), 29 deletions(-)

diff --git a/conf/config.go b/conf/config.go
index 06955ee..ccb00c6 100644
--- a/conf/config.go
+++ b/conf/config.go
@@ -25,33 +25,28 @@
 	webConf struct {
 		Host      string // 鏈満ip鍦板潃
 		Port      string // 绔彛鍙�
-		APPort    string // 鏈満浣滀负鐨凣rpc鏈嶅姟绔殑绔彛鍙�
-		AlHost    string // 绠楁硶鏈嶅姟ip鍦板潃
-		AlPort    string // 绠楁硶鏈嶅姟绔彛鍙�
 		NodeId    string // 涓昏处鎴风敤鎴峰悕
 		OssType   string // 瀵硅薄瀛樺偍绫诲瀷
 		JWTSecret string
-	}
-
-	nsqConf struct {
-		NsqdAddr       string
-		NsqlookupdAddr string
+		GrpcPort  string //grpc绔彛鍙�
 	}
 
 	localConf struct {
 		StorePath string // 鏈湴鏂囦欢瀛樺偍璺緞
 	}
+
+	grpcServerConf struct {
+		ApsAddr string //aps鏈嶅姟grpc鍦板潃
+	}
 )
 
 var (
-	WebConf   = &webConf{}
-	LogConf   = &logx.Conf{}
-	DbConf    = &mysqlx.Conf{}
-	NsqConf   = &nsqConf{}
-	LocalConf = &localConf{}
-	NodeId    string
-	GrpcPort  string
-	Viper     *viper.Viper
+	WebConf        = &webConf{}
+	LogConf        = &logx.Conf{}
+	DbConf         = &mysqlx.Conf{}
+	LocalConf      = &localConf{}
+	Viper          *viper.Viper
+	GrpcServerConf = &grpcServerConf{}
 )
 
 func Init() error {
@@ -66,25 +61,21 @@
 	}
 	read2Conf(Viper)
 
-	GrpcPort = os.Getenv("GRPC_PORT") // 鍙粰grpc绠楁硶鏈嶅姟浣跨敤锛屾湰鏈嶅姟涓嶇敤
 	nodeId := os.Getenv("NODE_ID")    // 涓昏处鎴风敤鎴峰悕
 	host := os.Getenv("HOST")         // 鏈満IP鍦板潃
-	algHost := os.Getenv("AL_HOST")   // 绠楁硶鏈嶅姟鐨処P鍦板潃
-	nsqdAddr := os.Getenv("NSQD_ADDR")
-	if len(GrpcPort) == 0 { // 濡傛灉gprcPort涓虹┖锛岄偅涔堢敤閰嶇疆鐨凙PPort
-		GrpcPort = WebConf.APPort
+	GrpcPort := os.Getenv("WMS_GRPC") // 鍙澶栨彁渚沢rpc鏈嶅姟锛屾湰鏈嶅姟涓嶇敤
+	apsAddr := os.Getenv("APS_GRPC")
+	if len(GrpcPort) > 0 {
+		WebConf.GrpcPort = GrpcPort
 	}
 	if len(nodeId) > 0 {
 		WebConf.NodeId = nodeId
 	}
-	if len(algHost) > 0 {
-		WebConf.AlHost = algHost
-	}
 	if len(host) > 0 {
 		WebConf.Host = host
 	}
-	if len(nsqdAddr) > 0 {
-		NsqConf.NsqdAddr = nsqdAddr
+	if len(apsAddr) > 0 {
+		GrpcServerConf.ApsAddr = apsAddr
 	}
 
 	DBHost := os.Getenv("DB_HOST")
@@ -107,8 +98,8 @@
 	_ = v.UnmarshalKey("web", WebConf)
 	_ = v.UnmarshalKey("log", LogConf)
 	_ = v.UnmarshalKey("db", DbConf)
-	_ = v.UnmarshalKey("nsq", NsqConf)
 	_ = v.UnmarshalKey("local", LocalConf)
+	_ = v.UnmarshalKey("grpcServer", GrpcServerConf)
 	showConfig()
 }
 
@@ -117,8 +108,7 @@
 	log.Printf("   WebConf:                %+v", WebConf)
 	log.Printf("   LogConf:                %+v", LogConf)
 	log.Printf("   DbConf:                 %+v", DbConf)
-	log.Printf("   NsqConf:                %+v", NsqConf)
-	log.Printf("   GrpcPort:               %+v", GrpcPort)
 	log.Printf("   LocalConf:               %+v", LocalConf)
+	log.Printf("   GrpcServerConf:               %+v", GrpcServerConf)
 	log.Println("......................................................")
 }

--
Gitblit v1.8.0