gRPC应用实践
Posted carsonzhu
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了gRPC应用实践相关的知识,希望对你有一定的参考价值。
What is RPC?
Remote Procedure Call is a high-level model for client-server communication. Assume there are two computers, computer A(on local) and computer B(on some network). Computer B provides some API’s, let’s say it has some procedures which can be run and these procedures can be run on computer B itself.
What is gRPC?
gRPC is a high performance, open source universal RPC Framework. In simple words, it enables the server and client applications to communicate transparently and build connected systems. GRPC is developed and open sourced by Google.
Linux server (C++) Setup
gRPC C++ - Build from source
(1) Pre-requisites
$ sudo apt-get install build-essential autoconf libtool pkg-config # If you plan to build from source and run tests, install the following as well: $ sudo apt-get install libgflags-dev libgtest-dev $ sudo apt-get install clang-5.0 libc++-dev
(2) Clone the repository (including submodules)
$ git clone -b $(curl -L https://grpc.io/release) https://github.com/grpc/grpc $ cd grpc $ git submodule update --init
(3) Building with CMake
$ sudo mkdir -p cmake/build # Check if the cmake version > 3.6, otherwise install the latest version follow below steps:
$ cd cmake/build $ sudo apt-get install golang $ sudo cmake ../.. -DBUILD_SHARED_LIBS=ON $ sudo make # Copy all needed libs, dlls and executables to the specified folder $ sudo ln -sf ~/min-projects/grpc/cmake/build/* /usr/bin/ $ sudo cp -f /home/mzhu/min-projects/grpc/cmake/build/*.so /usr/local/lib $ sudo cp -f /home/mzhu/min-projects/grpc/cmake/build/*.a /usr/local/lib $ sudo cp -f /home/ mzhu /min-projects/grpc/libs/opt/pkgconfig/*.pc /usr/lib/pkgconfig/ # Add the line “/usr/local/lib” into the file “/etc/ld.so.conf” $ sudo gedit /etc/ld.so.conf # Refresh shared library cache $ sudo ldconfig
(4) Install protoc along with the C++ runtime
$ cd ~/min-projects/grpc/third_party/protobuf/ $ ./autogen.sh $ ./configure $ sudo make $ sudo make install
(5) Run an example to verify the environment
以上是关于gRPC应用实践的主要内容,如果未能解决你的问题,请参考以下文章