Add client feature flag to support connect_with_connector in wasm32 targets #1594
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is an updated version of @boxdot's PR #693. The main purpose is to allow compiling tonic for wasm32-unknown-unknown with the connect_with_connector function, so you could use custom connectors in wasm.
Motivation
The main motivation is to allow using something like https://github.com/boxdot/tonic-ws-transport to use tonic in browsers over websockets. grpc-web has a limit on concurrent conections that are open and doesn't allow for client streaming. There is also a related issue for this, #491.
Solution
The connect_with_connector function, as well as the Endpoint and Channel structs, are gated behind the transport feature. Enabling this feature also enables things that are impossible to compile for wasm. This PR introduces a
client
feature that that enables everything necessary to make connect_with_connector work in wasm and disables anything that fails to compile for wasm.An alternative to adding a new
client
feature could also be to gate everything that doesn't compile for wasm behind a #[cfg()] attribute that is disabled for wasm.I could also add a test that checks whether compilation to wasm works with the client feature, so this won't break in the future.