New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add grpc.ForceCodec-like ServerOption based on encoding.Codec #3694
Comments
I believe |
Same use case as mentioned in the linked issue: #2189 I am trying to use https://github.com/mwitkow/grpc-proxy func ExampleRegisterService() {
// A gRPC server with the proxying codec enabled.
server := grpc.NewServer(grpc.CustomCodec(proxy.Codec()))
// Register a TestService with 4 of its methods explicitly.
proxy.RegisterService(server, director,
"mwitkow.testproto.TestService",
"PingEmpty", "Ping", "PingError", "PingList")
} |
I think we should keep this open to track adding a non-deprecated version of the API. The server-side use case seems just as appropriate as the client-side. |
Same issue here - I want to use a custom codec for a particular gRPC server. I have more than one server in the program and ideally I'd prefer not to register a global codec. Also, I wonder what is the reasoning for adding global registries for codec and compressor? Allowing a per-server configuration is much more flexible and there is no thread-safety issues (global registries are not thread safe at the moment). |
Sorry, more context: servers that I have should use different codecs for the same content type - global registry makes this hard to achieve. I can work this around, but it's not as clean as it could be with this issue resolved. |
I've opened a PR to add an option. Would be great to get some eyes on it. Thanks. |
I have a similar use case as @ash2k (several GRPC servers inside one program which must use different codecs for the same content type), really unfortunate to not have a non-deprecated way to set it on per-server basis. |
What version of gRPC are you using?
google.golang.org/grpc v1.29.1
What version of Go are you using (
go version
)?go1.14.3 darwin/amd64
What did you do?
Following up on #2189, the server side was missed, it is still using the deprecated
grpc.Codec
interface.What did you expect to see?
What did you see instead?
The text was updated successfully, but these errors were encountered: