Skip to content

Conversation

simonferquel
Copy link

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.

@simonferquel
Copy link
Author

@awalterschulze I have no idea how to create a test for this one though...

g.P("s.RegisterService(_named", servName, "ServiceDesc(name), srv)")
g.P("}")
g.P()
g.P("func Register", servName, "Server(s *", grpcPkg, ".Server, srv ", serverType, ") {")
Copy link
Member

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.

Copy link
Author

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.

Copy link
Member

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.

Copy link
Member

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.

Copy link
Author

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.

g.P("}")
g.P()

if genSend {
Copy link
Member

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?

@awalterschulze
Copy link
Member

I would test this be at least having a proto file which each type of grpc service.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants