Skip to content

Commit b9333f0

Browse files
committed
Replace deprecated grpc.Dial with grpc.NewClient
grpc.Dial and grpc.DialWithContext were deprecated and mention their replacement as grpc.NewClient. https://pkg.go.dev/google.golang.org/[email protected]#Dial One consequence of this change is that the target address needs to have "unix:" or "unix://" prepended to the absolute path for NewClient to create a connection properly. Signed-off-by: Michael Shen <[email protected]>
1 parent a7a91e5 commit b9333f0

File tree

1 file changed

+2
-9
lines changed

1 file changed

+2
-9
lines changed

pkg/connection/connection.go

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,16 @@
11
package connection
22

33
import (
4-
"context"
54
"fmt"
6-
"net"
75

86
"google.golang.org/grpc"
97
"google.golang.org/grpc/credentials/insecure"
108
)
119

1210
// New returns a grpc client connection for a given unix socket file path
1311
func New(addr string) (*grpc.ClientConn, error) {
14-
dialer := func(ctx context.Context, addr string) (net.Conn, error) {
15-
var d net.Dialer
16-
return d.DialContext(ctx, "unix", addr)
17-
}
18-
19-
conn, err := grpc.Dial(
20-
addr, grpc.WithContextDialer(dialer),
12+
conn, err := grpc.NewClient(
13+
"unix://"+addr,
2114
grpc.WithTransportCredentials(insecure.NewCredentials()),
2215
)
2316
if err != nil {

0 commit comments

Comments
 (0)