grpc

2018/05/29 15:02
阅读数 122

更多请参考:https://grpc.io/docs/quickstart
一、准备工作
1. grpc编译安装
>yum install -y gcc-c++ autoconf libtool
>yum groupinstall -y "Development Tools"
>git clone https://github.com/grpc/grpc
>cd grpc
>git submodule update --init
># 最好是放到/etc/profile
GRPC_PATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
export PATH=$PATH:$GRPC_PATH/bins/opt:$GRPC_PATH/bins/opt/protobuf
export CPATH=$GRPC_PATH/include:$GRPC_PATH/third_party/protobuf/src
export LIBRARY_PATH=$GRPC_PATH/libs/opt:$GRPC_PATH/libs/opt/protobuf
export PKG_CONFIG_PATH=$GRPC_PATH/libs/opt/pkgconfig:$GRPC_PATH/third_party/protobuf
export LD_LIBRARY_PATH=$GRPC_PATH/libs/opt
>make
>make install

2. 验证protobuf是否安装成功
>protoc --version
二、c++
>cd $GRPC_PATH/examples/cpp/helloworld
>make
>./greeter_server &
>./greeter_client
三、go
>go get google.golang.org/grpc
>go get github.com/golang/protobuf/protoc-gen-go
>export PATH=$PATH:$GOPATH/bin
>cd $GOPATH/src/google.golang.org/grpc/examples/
>protoc -I helloworld/ helloworld/helloworld.proto --go_out=plugins=grpc:helloworld
>cd helloworld/greeter_client
>go install
>cd ../greeter_server
>go install
>cd $GOPATH/bin
>./greeter_server &
>./greeter_client
四、java
>git clone https://github.com/grpc/grpc-java.git
>cd grpc-java/examples
>./gradlew installDist
>./build/install/examples/bin/hello-world-server &
>./build/install/examples/bin/hello-world-client

展开阅读全文
打赏
0
0 收藏
分享
加载中
更多评论
打赏
0 评论
0 收藏
0
分享
返回顶部
顶部