tonic
tonic copied to clipboard
gRPC-Web wasm browser client implementation in tonic-web
Feature Request
Crates
tonic-web
Motivation
Now that gRPC-Web support has been implemented and merged by @alce (#455), I think it's worth considering adding support for a gRPC-Web client implementation that works in browsers. This will allow users that are writing frontend apps in Rust to use gRPC natively via tonic without leaving the Rust ecosystem.
Proposal
I propose adding a new Client
type to tonic-web
that implements GrpcService
using the browser Fetch API via js-sys
/wasm-bindgen
. I have prototyped this implementation at https://github.com/titanous/grpc-web-client and am happy to work on a PR to merge in the implementation.
This would be behind a feature flag that is not enabled by default so that it can be used in projects that use wasm-bindgen to target browsers.
Alternatives
The alternative is to keep this implementation as a separate third-party crate, but I think that it would be better for the ecosystem to have an easy to find implementation available in tonic.
@titanous Is your implementation meant to replace https://github.com/grpc/grpc-web and https://github.com/improbable-eng/grpc-web?
@titanous Is your implementation meant to replace https://github.com/grpc/grpc-web and https://github.com/improbable-eng/grpc-web?
Only for Rust use, I don’t plan to export JS bindings.
Is it suitable to use the grpc-web-client prototype crate as an actual grpc web client today? I notice it points against branches of tonic that no longer exist.
It should work if you point it at the lastest tonic master. I am planning to send a PR that will integrate it into this repository soon.
Any way to get this effort going again? Seeing this merged into tonic would be awesome.
I too would like to see this implemented. I'm working on a full-stack rust app and using gRPC would be fantastic.
What's new?
I have only seen this alternative: https://github.com/devashishdxt/tonic-web-wasm-client :(