-
-
Notifications
You must be signed in to change notification settings - Fork 286
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
proto3 & grpc #127
Comments
|
@eiennohito Uh, that is nice :) I can see this from the docs:
What is the deal with that. Seems to compile when I import a proto2 message type that uses enum into a proto3 file with a grpc service? Does it only mean that I cannot use an enum directly in another proto3 message, but otherwise fine if I import a message with proto2 that uses an enum defined in its own file? |
Probably so. By the way, I have already talked about the topic you have raised in #40. |
@ahjohannessen would the solution suggested at #40 would work for you? That is, add field-level option that tells the generator not to wrap a value in an option. Something like:
This would apply to any field in proto2, and for proto3 this is relevant only to messages since primitives are not boxed. |
@thesamet In a pure scala environment I suppose that would be fine - however it is not so much an issue as I can define messages in proto2 and use those with services generated in proto3. However, what I think is more interesting to investigate is the generated service code with respect to being able to use a scalaz Task instead of a scala Future plus making the code more Scala / FP like. |
Furthermore, being able to bridge between scalaz-stream I suppose that requires some sort of pluggability in the code generator? |
Perhaps the scalaz-stream suggestion should go into its own separate github issue, with more details? It seems like the discussion here is diverging to two paths (scalaz-streams, and option boxing), so if there's interest in #40 let's continue there? |
Yep, agree 👍 |
As I understand it everything is suddenly an optional field in proto3, perhaps for reasons that are understandable considering languages such as Java and C#.
However, if messages are used to communicate via gRPC in a Scala setting then it becomes very cumbersome to ensure required fields on messages, because suddenly you also need to pattern match wrt.
Option
even when you know that field is required.Would it make sense to build in required as some sort of extension to ScalaPB when using
proto3
that causes the code generator to generate non-optional fields on case classes? I can see that falls a bit apart when used in a mixed setting.Secondly, if the above is a bad idea, would it work if one defines messages that need that sort of semantics in a proto file that uses syntax v2 and then defines gRPC in a different proto that uses syntax v3 and imports the one with syntax v2?
The text was updated successfully, but these errors were encountered: