mirror of
https://github.com/duanhf2012/origin.git
synced 2026-02-14 15:54:42 +08:00
增加动态调用rpc并增加rpc调用超时时间
This commit is contained in:
@@ -500,7 +500,7 @@ func GetNodeName(nodeid int) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func DynamicCall(address string, serviceMethod string, args interface{}, reply interface{}) error {
|
func DynamicCall(address string, serviceMethod string, args interface{}, reply interface{}) error {
|
||||||
rpcClient, err := rpc.Dial("tcp", address)
|
rpcClient, err := rpc.DialTimeOut("tcp", address, time.Second*1)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -291,7 +291,16 @@ func Dial(network, address string) (*Client, error) {
|
|||||||
}
|
}
|
||||||
tcpconn, _ := conn.(*net.TCPConn)
|
tcpconn, _ := conn.(*net.TCPConn)
|
||||||
tcpconn.SetNoDelay(true)
|
tcpconn.SetNoDelay(true)
|
||||||
|
return NewClient(conn), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func DialTimeOut(network, address string, timeout time.Duration) (*Client, error) {
|
||||||
|
conn, err := net.DialTimeout(network, address, timeout)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
tcpconn, _ := conn.(*net.TCPConn)
|
||||||
|
tcpconn.SetNoDelay(true)
|
||||||
return NewClient(conn), nil
|
return NewClient(conn), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user