diff options
author | Takuya Noguchi <takninnovationresearch@gmail.com> | 2019-12-27 14:55:38 +0300 |
---|---|---|
committer | Takuya Noguchi <takninnovationresearch@gmail.com> | 2020-02-21 15:45:49 +0300 |
commit | 08265afdd6da9b886806ce475591c9013ff8699b (patch) | |
tree | 17ceee13da78dae31994495b2817124a377b5a3a | |
parent | 443e3578520f7fb92f42a96d3fc77b0ad1381820 (diff) |
Fix deprecation warnings in Praefect2228-fix-deprecation-warnings-in-praefect
also proxy.Codec comes to return encoding.Codec instead of grpc.Codec
Signed-off-by: Takuya Noguchi <takninnovationresearch@gmail.com>
-rw-r--r-- | internal/praefect/grpc-proxy/proxy/DOC.md | 8 | ||||
-rw-r--r-- | internal/praefect/grpc-proxy/proxy/codec.go | 12 | ||||
-rw-r--r-- | internal/praefect/grpc-proxy/proxy/helper_test.go | 2 | ||||
-rw-r--r-- | 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 85c411a10..e43d19fc3 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 a6aa3dc1d..5856b475c 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 c56355638..8999bd98c 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 16094ac6c..2c5ec6a81 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())), ) } |