From 08265afdd6da9b886806ce475591c9013ff8699b Mon Sep 17 00:00:00 2001 From: Takuya Noguchi Date: Fri, 27 Dec 2019 20:55:38 +0900 Subject: [PATCH] Fix deprecation warnings in Praefect also proxy.Codec comes to return encoding.Codec instead of grpc.Codec Signed-off-by: Takuya Noguchi --- internal/praefect/grpc-proxy/proxy/DOC.md | 8 ++++---- internal/praefect/grpc-proxy/proxy/codec.go | 12 ++++++------ internal/praefect/grpc-proxy/proxy/helper_test.go | 2 +- internal/praefect/helper_test.go | 2 +- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/internal/praefect/grpc-proxy/proxy/DOC.md b/internal/praefect/grpc-proxy/proxy/DOC.md index 85c411a104..e43d19fc38 100644 --- a/internal/praefect/grpc-proxy/proxy/DOC.md +++ b/internal/praefect/grpc-proxy/proxy/DOC.md @@ -19,18 +19,18 @@ See examples on documented functions. #### func Codec ```go -func Codec() grpc.Codec +func Codec() encoding.Codec ``` -Codec returns a proxying grpc.Codec with the default protobuf codec as parent. +Codec returns a proxying encoding.Codec with the default protobuf codec as parent. See CodecWithParent. #### func CodecWithParent ```go -func CodecWithParent(fallback grpc.Codec) grpc.Codec +func CodecWithParent(fallback encoding.Codec) encoding.Codec ``` -CodecWithParent returns a proxying grpc.Codec with a user provided codec as +CodecWithParent returns a proxying encoding.Codec with a user provided codec as parent. This codec is *crucial* to the functioning of the proxy. It allows the proxy diff --git a/internal/praefect/grpc-proxy/proxy/codec.go b/internal/praefect/grpc-proxy/proxy/codec.go index a6aa3dc1da..5856b475c0 100644 --- a/internal/praefect/grpc-proxy/proxy/codec.go +++ b/internal/praefect/grpc-proxy/proxy/codec.go @@ -8,28 +8,28 @@ import ( "fmt" "github.com/golang/protobuf/proto" - "google.golang.org/grpc" + "google.golang.org/grpc/encoding" ) -// Codec returns a proxying grpc.Codec with the default protobuf codec as parent. +// Codec returns a proxying encoding.Codec with the default protobuf codec as parent. // // See CodecWithParent. -func Codec() grpc.Codec { +func Codec() encoding.Codec { return CodecWithParent(&protoCodec{}) } -// CodecWithParent returns a proxying grpc.Codec with a user provided codec as parent. +// CodecWithParent returns a proxying encoding.Codec with a user provided codec as parent. // // This codec is *crucial* to the functioning of the proxy. It allows the proxy server to be oblivious // to the schema of the forwarded messages. It basically treats a gRPC message frame as raw bytes. // However, if the server handler, or the client caller are not proxy-internal functions it will fall back // to trying to decode the message using a fallback codec. -func CodecWithParent(fallback grpc.Codec) grpc.Codec { +func CodecWithParent(fallback encoding.Codec) encoding.Codec { return &rawCodec{fallback} } type rawCodec struct { - parentCodec grpc.Codec + parentCodec encoding.Codec } type frame struct { diff --git a/internal/praefect/grpc-proxy/proxy/helper_test.go b/internal/praefect/grpc-proxy/proxy/helper_test.go index c563556384..8999bd98ca 100644 --- a/internal/praefect/grpc-proxy/proxy/helper_test.go +++ b/internal/praefect/grpc-proxy/proxy/helper_test.go @@ -38,7 +38,7 @@ func newBackendPinger(tb testing.TB, ctx context.Context) (*grpc.ClientConn, *in grpc.WithInsecure(), grpc.WithBlock(), grpc.WithDefaultCallOptions( - grpc.CallCustomCodec(proxy.Codec()), + grpc.ForceCodec(proxy.Codec()), ), ) require.NoError(tb, err) diff --git a/internal/praefect/helper_test.go b/internal/praefect/helper_test.go index 16094ac6c0..2c5ec6a81d 100644 --- a/internal/praefect/helper_test.go +++ b/internal/praefect/helper_test.go @@ -292,7 +292,7 @@ func dialLocalPort(tb testing.TB, port int, backend bool) *grpc.ClientConn { if backend { opts = append( opts, - grpc.WithDefaultCallOptions(grpc.CallCustomCodec(proxy.Codec())), + grpc.WithDefaultCallOptions(grpc.ForceCodec(proxy.Codec())), ) } -- GitLab