|
|
@@ -13,8 +13,6 @@ import (
|
|
|
grpc2 "google.golang.org/grpc"
|
|
|
)
|
|
|
|
|
|
-var connMap = make(map[string]*grpc2.ClientConn)
|
|
|
-
|
|
|
type DialOption struct {
|
|
|
Middlewares []middleware.Middleware
|
|
|
Timeout time.Duration
|
|
|
@@ -26,10 +24,6 @@ func GetDialInsecure(
|
|
|
clientName string,
|
|
|
endpointNameKey string, option *DialOption) (*grpc2.ClientConn, error) {
|
|
|
option = checkOption(option)
|
|
|
-
|
|
|
- if _, ok := connMap[clientName]; ok {
|
|
|
- return connMap[clientName], nil
|
|
|
- }
|
|
|
endpoint := grpc.WithEndpoint(endpointNameKey)
|
|
|
|
|
|
if r == nil {
|
|
|
@@ -46,17 +40,12 @@ func GetDialInsecure(
|
|
|
if err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
- connMap[clientName] = conn
|
|
|
return conn, nil
|
|
|
}
|
|
|
|
|
|
func GetDialSimple(clientName string, endpoint string, option *DialOption) (*grpc2.ClientConn, error) {
|
|
|
option = checkOption(option)
|
|
|
|
|
|
- if _, ok := connMap[clientName]; ok {
|
|
|
- return connMap[clientName], nil
|
|
|
- }
|
|
|
-
|
|
|
conn, err := grpc.DialInsecure(context.Background(),
|
|
|
grpc.WithEndpoint(endpoint),
|
|
|
grpc.WithMiddleware(option.Middlewares...),
|
|
|
@@ -66,7 +55,6 @@ func GetDialSimple(clientName string, endpoint string, option *DialOption) (*grp
|
|
|
if err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
- connMap[clientName] = conn
|
|
|
return conn, nil
|
|
|
}
|
|
|
|