From ec8e3844a992e50684dc5648a02970056616022c Mon Sep 17 00:00:00 2001 From: Ben Kochie Date: Sun, 18 Aug 2024 06:13:10 +0200 Subject: [PATCH] Update grpc library use (#6826) Replace deprecated grpc Dial/DialContext with grpc.NewClient. Signed-off-by: SuperQ --- plugin/grpc/proxy.go | 2 +- test/grpc_test.go | 5 +---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/plugin/grpc/proxy.go b/plugin/grpc/proxy.go index 9a96e9504..f8322680b 100644 --- a/plugin/grpc/proxy.go +++ b/plugin/grpc/proxy.go @@ -37,7 +37,7 @@ func newProxy(addr string, tlsConfig *tls.Config) (*Proxy, error) { p.dialOpts = append(p.dialOpts, grpc.WithTransportCredentials(insecure.NewCredentials())) } - conn, err := grpc.Dial(p.addr, p.dialOpts...) + conn, err := grpc.NewClient(p.addr, p.dialOpts...) if err != nil { return nil, err } diff --git a/test/grpc_test.go b/test/grpc_test.go index 37504c930..157b4e397 100644 --- a/test/grpc_test.go +++ b/test/grpc_test.go @@ -3,7 +3,6 @@ package test import ( "context" "testing" - "time" "github.com/coredns/coredns/pb" @@ -23,9 +22,7 @@ func TestGrpc(t *testing.T) { } defer g.Stop() - ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) - defer cancel() - conn, err := grpc.DialContext(ctx, tcp, grpc.WithTransportCredentials(insecure.NewCredentials()), grpc.WithBlock()) + conn, err := grpc.NewClient(tcp, grpc.WithTransportCredentials(insecure.NewCredentials()), grpc.WithBlock()) if err != nil { t.Fatalf("Expected no error but got: %s", err) }