WH01243 4 years ago
parent
commit
9c6652d112

+ 1 - 1
rpc/userlib/internal/config/config.go

@@ -11,4 +11,4 @@ type Config struct {
 	FileSystemConf zrpc.RpcClientConf
 }
 
-var  con
+var   Configs Config

+ 1 - 1
rpc/userlib/internal/logic/docdownloadlogic.go

@@ -40,7 +40,7 @@ func (l *DocDownloadLogic) DocDownload(in *userlib.UserCollectRequest) (*userlib
 			DocPageSize:     int(in.DocPageSize),
 			DocSummary:      in.DocSummary,
 			DocSourceUserId: in.SourceUserId,
-		}, int(in.Cost),)
+		}, int(in.Cost),config.Configs.FileSystemConf.Etcd.Hosts,config.Configs.FileSystemConf.Etcd.Key)
 	log.Printf("用户文档收藏,userId:[%s],docId:[%s] 是否成功:[%v]", in.UserId, in.DocId, b)
 	return &userlib.UserCollectResponse{
 		Code:    200,

+ 6 - 7
rpc/userlib/userlib.go

@@ -17,21 +17,20 @@ import (
 )
 
 var configFile = flag.String("f", "etc/userlib.yaml", "the config file")
-var c config.Config
 func main() {
 	flag.Parse()
 
 
-	conf.MustLoad(*configFile, &c)
-	if c.JyDocsMysqlDB.DataSourceName != "" {
-		jyDocsRpcUtil.InitDB(c.JyDocsMysqlDB.DataSourceName, c.JyDocsMysqlDB.DriverName, c.JyDocsMysqlDB.MaxOpenConn, c.JyDocsMysqlDB.MaxIdleConn)
-		ctx := svc.NewServiceContext(c)
+	conf.MustLoad(*configFile, &config.Configs)
+	if config.Configs.JyDocsMysqlDB.DataSourceName != "" {
+		jyDocsRpcUtil.InitDB(config.Configs.JyDocsMysqlDB.DataSourceName, config.Configs.JyDocsMysqlDB.DriverName, config.Configs.JyDocsMysqlDB.MaxOpenConn, config.Configs.JyDocsMysqlDB.MaxIdleConn)
+		ctx := svc.NewServiceContext(config.Configs)
 		srv := server.NewUserLibServer(ctx)
-		s := zrpc.MustNewServer(c.RpcServerConf, func(grpcServer *grpc.Server) {
+		s := zrpc.MustNewServer(config.Configs.RpcServerConf, func(grpcServer *grpc.Server) {
 			userlib.RegisterUserLibServer(grpcServer, srv)
 		})
 		defer s.Stop()
-		fmt.Printf("Starting rpc server at %s...\n", c.ListenOn)
+		fmt.Printf("Starting rpc server at %s...\n", config.Configs.ListenOn)
 		s.Start()
 	} else {
 		log.Fatal("【jy_docs】 read config error!")

+ 0 - 1
services/userlib/userDocService.go

@@ -6,7 +6,6 @@ import (
 	"app.yhyue.com/moapp/jy_docs/services/model"
 	docRpcUtil "app.yhyue.com/moapp/jy_docs/services/util"
 	"context"
-	"github.com/olivere/elastic/v7/config"
 	"github.com/tal-tech/go-zero/core/discov"
 	"github.com/tal-tech/go-zero/zrpc"
 	"gorm.io/gorm"