feat: 设置rpc timeout
This commit is contained in:
parent
76f7b9e15c
commit
9c125f5562
|
|
@ -5,6 +5,7 @@ Cache:
|
||||||
- Host: 47.97.27.195:6379
|
- Host: 47.97.27.195:6379
|
||||||
Pass: lansexiongdi@666
|
Pass: lansexiongdi@666
|
||||||
Nacos:
|
Nacos:
|
||||||
|
Timeout: 5000
|
||||||
Endpoints:
|
Endpoints:
|
||||||
- 120.55.12.245:10001
|
- 120.55.12.245:10001
|
||||||
Sys:
|
Sys:
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,7 @@ type Rpc struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type Nacos struct {
|
type Nacos struct {
|
||||||
|
Timeout int64
|
||||||
Endpoints []string
|
Endpoints []string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,8 +18,13 @@ type ServiceContext struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewServiceContext(c config.Config) *ServiceContext {
|
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{
|
client := transferClient.NewTransfer(zrpc.MustNewClient(zrpc.RpcClientConf{
|
||||||
Endpoints: c.Nacos.Endpoints,
|
Endpoints: c.Nacos.Endpoints,
|
||||||
|
Timeout: timeOut,
|
||||||
}))
|
}))
|
||||||
|
|
||||||
sqlConn := sqlx.NewMysql(c.DB.Master.DataSource)
|
sqlConn := sqlx.NewMysql(c.DB.Master.DataSource)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue