Connect rust, java and the browser using rust grpc framework tonic, java grpc and grpc-web. We use a simple echo.proto(./rust/server/proto/echo.proto) definition to implement grpc server and clients in java and rust. Next, we use the same echo.proto definition to implement a browser client using grpc-web.
- Clone this repository to a ubuntu machine(This has been tested in buster and various flavors of ubuntu).
- Run ./compile.sh - from the root directory. This would compile rust and java client and server implementations.
- Navigate to ./envoy folder and run ./setup.sh - this would install envoy proxy server locally.
- Navigate to ./web folder and run ./setup.sh. This would install tomcat server locally and setup grpc-web app.
- Navigate back to the root folder and run "./run.sh" - this would run rust and java grpc servers, envoy proxy and tomcat webserver.
- Browse the grpc-web application at http://localhost:8080/client
Run a grpc server/client selectively
- From the project root folder, run "./run.sh rust server". This would launch the rust grpc server.
- We can "./run.sh rust client" - to run the rust client. Likewise, for java.
- We can pass on the GRPC_SERVER=[ip:port] - for target grpc server - while running the client.
Run the grpc-curl.sh script:
- Launch grpc-curl.sh script from these folders ./rust/server, ./java/server/ etc. We might need to pass on the GRPC_SERVER environmnt variable - if envoy proxy is not running.
Containerizing the rust and java grpc implementations and the envoy proxy:
- For grpc rust - the Dockerfile is: https://github.com/ratulb/grpc-rust-java-web/blob/main/rust/server/Dockerfile
- Commands for building - image and pushing to docker hub is located at: https://github.com/ratulb/grpc-rust-java-web/blob/main/rust/server/image-build.sh
- The rust and java grpc implementations can be launched as kubernetes ClusterIP services. The service yaml file is: https://github.com/ratulb/grpc-rust-java-web/blob/main/rust/server/rust-clusterip.yaml
- For java - Dockerfile, image build commands and service yaml file is located at: https://github.com/ratulb/grpc-rust-java-web/tree/main/java/server
- The NodePort service definition for envoy proxy is: https://github.com/ratulb/grpc-rust-java-web/blob/main/envoy/envoy-nodeport.yaml
Note: To quickly launch a kubernetetes cluster in a matter of minutes - have a look at https://github.com/ratulb/k8s-easy-install.