diff --git a/internal/praefect/grpc-proxy/proxy/DOC.md b/internal/praefect/grpc-proxy/proxy/DOC.md index 85c411a104dba65bb3a5ea3b4159dd34e33a93fd..e43d19fc38231324a1ed1d8661280aba943b420b 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 a6aa3dc1dabb4bf794bfb8d829c70c31d3d608b7..5856b475c0c83dcb56b224414712a5cfd1505191 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 c563556384c6f7e955aed7a0f4beed775194c4ee..8999bd98ca0acc14fed57300c717820ca8ff106c 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 16094ac6c00a63f91d736836a6830c71dd9a2ef6..2c5ec6a81d408fb1e171ddd96169bdd2e24a93d2 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())), ) }