Skip to content
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

Proto generation #206

Closed
wahmedswl opened this issue Jan 27, 2021 · 6 comments · Fixed by #475
Closed

Proto generation #206

wahmedswl opened this issue Jan 27, 2021 · 6 comments · Fixed by #475

Comments

@wahmedswl
Copy link

Hi, can we export proto from grpc server reflection?

Thanks

@jhump
Copy link
Contributor

jhump commented Jan 27, 2021

@wahmedswl, yes. Run grpcurl -h and then take a look at the -protoset-out. Note, however, that this exports a FileDescriptorSet that is written in the binary protobuf format. It does not produce proto sources.

Though you could use the packages in https://github.com/jhump/protoreflect to translate them into source files. You'd have to write some Go code to make that happen.

@wahmedswl
Copy link
Author

Nice, can this be integrated within grpcurl? This is something useful.

Thanks

@costela
Copy link

costela commented May 11, 2021

Alternatively, grpcurl could follow up on #57 and add a -recursive option to describe, so that the whole accessible "tree" of services and types would be described in a protobuf format (bonus points if we could filter out grpc.reflection.* and exclude the "x.Y is a service" comments 😉 ). This would probably miss a lot of corner-cases, but might be useful enough regardless?
Would an PR in this direction be considered? Or am I missing some obvious deal-breaker?

@jhump
Copy link
Contributor

jhump commented May 11, 2021

@costela, I'm not sure that would really work. The resulting source would not be compile-able unless it emitted, at a minimum, one file per referenced package. IMO, it would ideally be one file per actual input source file that defined the schema, which is how -protoset-out works.

So it needs to be special-cased to support multi-file export; it's not sufficient to just print the transitive closure of all elements independently as if in one file. I'm thinking that it would instead be a -proto-out option, where the resulting output will be a ZIP file, with possibly multiple proto source files inside.

@costela
Copy link

costela commented May 25, 2021

@jhump ah yes, that makes sense. I'm coming from the "easy" case of single package proto definitions, so it would be enough for us, but not for a lot of other people.

Just out of curiosity, why do you suggest zipping the output (as opposed to, e.g. --proto-out-dir)?

@Eitol
Copy link
Contributor

Eitol commented Jul 10, 2024

@costela @jhump @wahmedswl I have made a PR to support this functionality. Check: #475

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 a pull request may close this issue.

4 participants