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

[FEATURE-REQUEST] Way to disable transport feature for tonic_build #42

Closed
stan-irl opened this issue Nov 24, 2022 · 2 comments
Closed

Comments

@stan-irl
Copy link
Contributor

Hi!

I want to compile my generated rust protos to wasm-unknown-unknown but the generate ::connect() method doesn't compile to wasm. The connect method can be omitted by disabling the transport feature of tonic_build as documented here and I've tested that this works as expected by using tonic_build directly.

@neoeinstein do you have any idea how I can disable this? Is it possible in the current implementation of protoc-gen-tonic?

@neoeinstein
Copy link
Owner

At the current moment, no, unfortunately, because I cannot conditionally enable a dependency's features at runtime. (Though I could duplicate a protoc-gen-tonic-no-transport, I'd like to avoid the overhead of a completely distinct executable.) However, this PR has been merged into tonic-build, which should allow us to expose an argument to include the batteries-included transport or not at runtime (and without needing a completely distinct executable).

If you wanted to give this a test, you could pull down the repository, add a [patch] block to the Cargo.toml pointing at tonic's default branch, and see if what would be necessary to get it to compile and expose the option.

Once a new version of Tonic releases with this new functionality, I'd be happy to merge in a PR for this, or update it myself when I have the next opportunity.

@stan-irl
Copy link
Contributor Author

ok sure. i will have a go

bors bot added a commit that referenced this issue Feb 24, 2023
43: [protoc-gen-tonic] Add option to disable transport generation r=neoeinstein a=stan-irl

## Background
- #42
- Currently, transport is always generated for tonic grpc services which is a problem for consumers who want to compile for wasm. The latest version `tonic-build="0.8.4"` allows us to disable this 

## Changes
- Update tonic-build to v0.8.4
- Add `tonic_opt` option `no_transport`
- Migrate from deprecated `generate` APIs to `tonic_build::CodeGenBuilder`
- Update `prost-build` ti 0.11.4 in all crates
  - This was required for cargo crate resolution to succeed 
- Update README

## Tests
-[x] `cargo test` - everything is passing
-[x] Used this package to regenerate my own protos
  - [x] Confirmed that the `connect()` function wasnt generated
  - Just an FYI that there is now `#[allow(clippy::derive_partial_eq_without_eq)]` macros in the generated code 



Co-authored-by: Stan Tsouvallas <stan.tsouvallas@irl.com>
Co-authored-by: Marcus Griep <marcus@griep.us>
@stan-irl stan-irl closed this as completed May 3, 2023
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

No branches or pull requests

2 participants