项目作者: nfultz

项目描述 :
gRPC clients and servers in R
高级语言: C++
项目地址: git://github.com/nfultz/grpc.git
创建时间: 2017-08-29T14:47:11Z
项目社区:https://github.com/nfultz/grpc

开源协议:

下载


grpc

An R library for GRPC a high-performance, open-source universal RPC framework.

Installation - Debian

Pre-requisites

The following is copied from gRPC C++ - Building from source

  1. sudo apt-get install build-essential autoconf libtool pkg-config
  2. ## If you plan to build from source and run tests, install the following as well:
  3. sudo apt-get install libgflags-dev libgtest-dev
  4. sudo apt-get install clang libc++-dev

Download and Install grpc

  1. export GRPC_INSTALL_DIR=$HOME/.local
  2. mkdir -p $GRPC_INSTALL_DIR
  3. export PATH="$GRPC_INSTALL_DIR/bin:$PATH"
  4. sudo apt install -y cmake
  5. LATEST_VER=$(curl -L "https://api.github.com/repos/grpc/grpc/releases/latest" | grep -Po '"tag_name": "\K.*?(?=")')
  6. git clone --recurse-submodules -b $LATEST_VER https://github.com/grpc/grpc grpc_base
  7. cd grpc_base
  8. mkdir -p cmake/build
  9. pushd cmake/build
  10. cmake -DgRPC_INSTALL=ON \
  11. -DgRPC_BUILD_TESTS=OFF \
  12. -DCMAKE_INSTALL_PREFIX=$GRPC_INSTALL_DIR \
  13. ../..
  14. make -j4
  15. sudo make install
  16. popd
  17. mkdir -p third_party/abseil-cpp/cmake/build
  18. pushd third_party/abseil-cpp/cmake/build
  19. cmake -DCMAKE_INSTALL_PREFIX=$GRPC_INSTALL_DIR \
  20. -DCMAKE_POSITION_INDEPENDENT_CODE=TRUE \
  21. ../..
  22. make -j4
  23. sudo make install
  24. popd

Original

Build Status

Easily create gRPC clients and servers from protobuf descriptions to build distributed services.

Copyright 2015 Google Inc, 2017 Neal Fultz

Dependencies

  • grpc
  • protobuf
  • RProtoBuf

See install for my installation notes…

Examples

There are runnable examples in the demo/ folder.

Hello, World!

To start a HelloWorld server:

  1. R -e 'demo("helloserver", "grpc")'

Or with much more detailed logging:

  1. R -e 'library(futile.logger); flog.threshold(TRACE); demo("helloserver", "grpc")'

To run a client against a running HelloWorld server:

  1. R -e 'demo("helloclient", "grpc")'

Both are cross compatible with the Node, Python and C++ Greeter examples provided by the grpc library.

Health check

This server implements the above service along with the standard GRPC Health Checking Protocol:

  1. R -e 'demo("health-check-server", "grpc")'

The client runs a health-check then calls the Hello, World! method once:

  1. R -e 'demo("health-check-client", "grpc")'

Please check the sources of the server to see how to bundle services defined in multiple proto files.

Live scoring

There’s a simple trained on the iris dataset and making that available for scoring via a gRPC service:

  1. R -e 'demo("iris-server", "grpc")'

An example client to this service from R:

  1. R -e 'demo("iris-client", "grpc")'

Todo

  • Streaming services
  • Authentication and Encryption
  • Error handling
  • Docs

Contributing