Open
Description
I have an experimental implementation of a Connector
which allows to tunnel gRPC communication over a WebSocket. This makes it possible to implement a gRPC-over-WebSocket server and more importantly also a client. With small patches of h2 and tower-buffer the client also runs in wasm32.
- Implementation incl. examples: https://github.com/boxdot/tonic-ws-transport
- Patch of
tonic
: boxdot@b06a97d - Patch of
h2
: boxdot/h2@0383865 - Path of
tower-buffer
: boxdot/tower@1091340
If you find this useful and my approach as suitable, I would like to discuss how to move forward from here.
Feature Request
Crates
- tonic (transport module)
- h2
- tower-buffer
Motivation
Run gRPC in browser.
Proposal
(High level)
- Expose the client parts that are independent of TCP and work in wasm as a separate feature.
- Use this new feature and the new
tonic-ws-transport
crate to enable implementations of wasm clients.
I am not sure if this should become a separate feature of tonic
crate though, or we could do it differently. Due to this bug in cargo (rust-lang/cargo#2524), we might run into problems if we choose conditional compilation based on wasm32
target arch.
Notes:
- Implementation and patches are based on
tokio
0.2 branch. - Conditional compilation of dependency feature based on target doesn't work rust-lang/cargo#2524
- Examples are not part of the experimental crate due to another cargo bug: Incorrect dev-dependency feature resolution rust-lang/cargo#1796