-
Notifications
You must be signed in to change notification settings - Fork 810
Added support for named instances with a grpnamed plugin #292
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
base: master
Are you sure you want to change the base?
Added support for named instances with a grpnamed plugin #292
Conversation
Signed-off-by: Simon Ferquel <[email protected]>
@awalterschulze I have no idea how to create a test for this one though... |
protoc-gen-gogo/grpcnamed/grpc.go
Outdated
g.P("s.RegisterService(_named", servName, "ServiceDesc(name), srv)") | ||
g.P("}") | ||
g.P() | ||
g.P("func Register", servName, "Server(s *", grpcPkg, ".Server, srv ", serverType, ") {") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought that this plugin would only generate the RegisterNamed functions and that you won't need to generate the other Register functions, since they will be generated by the original grpc plugin.
This plugin should only need to do the extra code generation, which means it should require much less code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem is that if I do it as a plugin, I can't be sure that the grpc plugin is enabled as well. So I decided to implement the whole thing. But the non-named version can be easily removed (they are only passing default named values to the NewNamed<..> functions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think its ok to assume that the grpc plugin was also used. minor Documentation and a golang Compiler error should be enough to help most users.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do the same with the marshal plugin which assumes that the size plugin was also enabled.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made the grpcnamed plugin additive to grpc output. In parallel I've made a concurrent PR with named instance generation enabled trough a protobuf extension.
I kind of prefer the plugin based thing, as it does not require to mess with protoc import paths.
Signed-off-by: Simon Ferquel <[email protected]>
g.P("}") | ||
g.P() | ||
|
||
if genSend { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you still need all of this?
I would test this be at least having a proto file which each type of grpc service. |
This is a followup of #291 using a separate grpcnamed plugin.
Code generation is a bit modified to be able to host multiple named instances of the same grpc server interface.