GRPC chat system with Rust + Grpc-web
Using Tonic (Rust grpc framework) as backend system. Grpc-web as the frontend code.
protos
: defineprotobuf
messages and services.backend
: usetonic
as chat backend system.frontend
: grpc-web talk to backend. Insert js intoindex.html
for demo.
I am using docker holding server with envoy
.
- Make sure the
envoy.yaml
is correct setting and running. - Do
cargo run --bin server
to launch server with developing mode. (Please feel free try release mode)
Move into
cd frontend
folder.Generate protobuf related js files (in codebase, both
_pb.js
already generated):- protoc -I=../protos chat.proto
--js_out=import_style=commonjs:./ --grpc-web_out=import_style=commonjs,mode=grpcwebtext:./
Compile JS library, please refer here
npm install
npx webpack client.js
Open
index.html
page in your browser.(You may got domain issue when visiting page, disable security to access
chromium --disable-web-security --disable-gpu --user-data-dir=./chrometest
).