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

feat: add full proto name to generated structs #25

Merged

Conversation

tl-helge-hoff
Copy link
Contributor

@tl-helge-hoff tl-helge-hoff commented Jun 24, 2022

Big refactoring of how to use grpc-build. There's now a builder pattern to set up the tonic/prost configuration, and the building is more manual compared to relying only on tonic as we did before

Also:

  • Added grpc-build-derive to hold the proc-macro generating NamedMessage
  • Added grpc-build-core
  • put grpc-build in its own lib.
  • remove Cargo.lock

e.g:

// Under the package test.helloworld.
Struct MyMessage {
  my_field String;
}
// We now add an impl:
impl NamedMessage for MyMessage {
    const NAME: &'static str = "test.helloworld.MyMessage";
}

@conradludgate
Copy link
Collaborator

Seems ok, I'm gonna need to test it a bit more to be fully happy with it

@conradludgate
Copy link
Collaborator

Ok, this is currently a breaking change (even if it doesn't seem like one).

Most users have grpc-build as part of their build-dependencies, but after the code is generated, it still relies on the macros to exist in the normal dependencies. Requiring users to have grpc-build-derive in their regular depedencies.

@conradludgate
Copy link
Collaborator

Also, our personal use of grpc-build makes use of the type_attribute feature to add serde support to our messages. Turns out that prost-build uses a hashmap internally for attribute support so it's strictly overriding.

I'll think about this more to hopefully find a solution

@conradludgate
Copy link
Collaborator

Currently this is still a breaking change (going from FnOnce to Fn). Not sure what I want to do about that. Cloning and reusing the pre-made config results in annotations being added on the impl which is wrong.

I tried just implementing all of them in mod.rs but that results in

impl google::protobuf::Empty {
    fn ... {}
}

which doesn't work (prost by default won't build those in).

@stefandanaita stefandanaita merged commit ff46bb7 into stefandanaita:master Jul 7, 2022
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.

None yet

3 participants