test
parent
a08010b83d
commit
4892847915
|
@ -1,6 +1,7 @@
|
|||
package rpc
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"google.golang.org/grpc"
|
||||
"os"
|
||||
"strings"
|
||||
|
@ -9,6 +10,10 @@ import (
|
|||
// GetServiceConn 获取服务的连接
|
||||
func GetServiceConn(serviceName string) *grpc.ClientConn {
|
||||
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
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue