修复rpc启动
This commit is contained in:
@@ -3,6 +3,7 @@ package svc
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/smartwalle/alipay/v3"
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"github.com/zeromicro/go-zero/core/stores/redis"
|
||||
"github.com/zeromicro/go-zero/core/stores/sqlx"
|
||||
"github.com/zeromicro/go-zero/zrpc"
|
||||
@@ -44,8 +45,15 @@ func NewServiceContext(c config.Config) *ServiceContext {
|
||||
if err != nil {
|
||||
panic(fmt.Sprintf("加载支付宝公钥失败: %v", err))
|
||||
}
|
||||
var walletRpc user.WalletServiceClient
|
||||
|
||||
walletRpc := user.NewWalletServiceClient(zrpc.MustNewClient(c.UserRpc).Conn())
|
||||
// 捕获RPC初始化时的错误,但不影响服务启动
|
||||
userClient, err := zrpc.NewClient(c.UserRpc)
|
||||
if err != nil {
|
||||
logx.Errorf("Failed to connect to SecretRpc: %v", err)
|
||||
} else {
|
||||
walletRpc = user.NewWalletServiceClient(userClient.Conn())
|
||||
}
|
||||
return &ServiceContext{
|
||||
Config: c,
|
||||
Redis: rds,
|
||||
|
||||
Reference in New Issue
Block a user