grpc rust 项目基本使用

1. 安装依赖(rust 基本依赖就不说了,需要配置环境变量)

protoc
参考:
https://github.com/google/protobuf/releases/tag/v3.5.1
2. 参考项目
https://github.com/rongfengliang/grpc-rustdemo
3. 项目运行&&构建
a. 项目clone

git clone https://github.com/rongfengliang/grpc-rustdemo

b.依赖包下载

cargo  update && cargo build

c. 构建

client:
cd src/bin
cargo build --bin client --release
server:
cd src/bin
cargo build --bin server --release

d. 运行(因为项目代码使用了docker-compose 需要进行本地host,也可以修改代码)

cd target/release
先运行server  后运行client

备注: host 修改
127.0.0.1 rpcserver
4. docker  构建(docker-compose)
docker-compose build
具体dockerfile docker-compose.yml 可以参考源码,都是比较简单的
5. 参考资料
https://github.com/rongfengliang/grpc-rustdemo
原文地址:https://www.cnblogs.com/rongfengliang/p/8527043.html