You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
769 B

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

package GRpcUtil
import (
"dsBaseRpc/Utils/ConfigUtil"
"fmt"
"github.com/0x5010/grpcp"
"google.golang.org/grpc"
)
/**
功能:获取连接
作者:黄海
时间2020-4-15
*/
func GetConnection() *grpc.ClientConn {
//连接的服务器地址
var address = "127.0.0.1:"+ConfigUtil.RpcServerPort
//建立链接
conn, err := grpcp.GetConn(address) // get conn with grpcp default pool
if err != nil {
fmt.Printf("did not connect: %v\n", err)
}
return conn
}
func GetRemoteConnection() *grpc.ClientConn {
//连接的服务器地址
var address = "10.10.6.200:"+ConfigUtil.RpcServerPort
//建立链接
conn, err := grpcp.GetConn(address) // get conn with grpcp default pool
if err != nil {
fmt.Printf("did not connect: %v\n", err)
}
return conn
}