feat: 设置rpc timeout

This commit is contained in:
wolter 2024-11-08 11:47:30 +08:00
parent 76f7b9e15c
commit 9c125f5562
3 changed files with 7 additions and 0 deletions

View File

@ -5,6 +5,7 @@ Cache:
- Host: 47.97.27.195:6379
Pass: lansexiongdi@666
Nacos:
Timeout: 5000
Endpoints:
- 120.55.12.245:10001
Sys:

View File

@ -31,6 +31,7 @@ type Rpc struct {
}
type Nacos struct {
Timeout int64
Endpoints []string
}

View File

@ -18,8 +18,13 @@ type ServiceContext struct {
}
func NewServiceContext(c config.Config) *ServiceContext {
var timeOut int64 = 2000
if c.Nacos.Timeout > 2000 {
timeOut = c.Nacos.Timeout
}
client := transferClient.NewTransfer(zrpc.MustNewClient(zrpc.RpcClientConf{
Endpoints: c.Nacos.Endpoints,
Timeout: timeOut,
}))
sqlConn := sqlx.NewMysql(c.DB.Master.DataSource)