test
parent
a08010b83d
commit
4892847915
|
@ -1,6 +1,7 @@
|
||||||
package rpc
|
package rpc
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
|
@ -9,6 +10,10 @@ import (
|
||||||
// GetServiceConn 获取服务的连接
|
// GetServiceConn 获取服务的连接
|
||||||
func GetServiceConn(serviceName string) *grpc.ClientConn {
|
func GetServiceConn(serviceName string) *grpc.ClientConn {
|
||||||
target := strings.ToUpper(os.Getenv("SERVICE_" + serviceName))
|
target := strings.ToUpper(os.Getenv("SERVICE_" + serviceName))
|
||||||
cli, _ := grpc.Dial(target, grpc.WithInsecure())
|
cli, err := grpc.Dial(target, grpc.WithInsecure())
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println("target: " + target + " err: " + err.Error())
|
||||||
|
return nil
|
||||||
|
}
|
||||||
return cli
|
return cli
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue