stefandanaita / grpc-build

Easy gRPC compilation for Rust
https://docs.rs/grpc-build
MIT License
17 stars 13 forks source link

Is this possible? #38

Open frederikhors opened 1 year ago

frederikhors commented 1 year ago

@stefandanaita thanks for your work.

Do you think this can help me with https://github.com/hyperium/tonic/issues/1386?

stefandanaita commented 1 year ago

I don't think it helps given your current setup, but it would probably be a good idea to separate your contracts from the workspace members, in which case you would be able to use grpc-build to improve your ergonomics.

frederikhors commented 1 year ago

I don't understand what you mean.

Do yo mean to have proto dir with:

instead of:

?

stefandanaita commented 1 year ago

Hmm, not exactly. I've looked at your dir structure in the tonic issue you linked above and it looks like you have separate cargo workspaces for all your protos, including the common.proto.

I was suggesting this structure

- Cargo.toml (workspace)
- src
  - protos
    - Cargo.toml
    - build.rs
    - src
      - common.proto
      - players
        - players.proto
      - teams
        - teams.proto
  - other application code workspaces, if needed at all

If you do it this way, importing the common protos into your teams or players becomes a matter of import "<replace with package name in common.proto>/common.proto";

Unless you have a specific reason for which you need the protos to be separate into different cargo workspaces, the one workspace approach makes it much simpler and easier to iterate on.