#grpc #protobuf #rpc #tls #http2

grpcio

The rust language implementation of gRPC, base on the gRPC c core library

19 releases

✓ Uses Rust 2018 edition

0.5.0-alpha.4 Aug 12, 2019
0.5.0-alpha.3 Jul 24, 2019
0.5.0-alpha.1 Apr 10, 2019
0.4.4 Feb 20, 2019
0.1.0 Jul 27, 2017

#11 in Network programming

Download history 1898/week @ 2019-04-29 2264/week @ 2019-05-06 2014/week @ 2019-05-13 2076/week @ 2019-05-20 1778/week @ 2019-05-27 1809/week @ 2019-06-03 1657/week @ 2019-06-10 7236/week @ 2019-06-17 3556/week @ 2019-06-24 2518/week @ 2019-07-01 2602/week @ 2019-07-08 2739/week @ 2019-07-15 2366/week @ 2019-07-22 3180/week @ 2019-07-29 2478/week @ 2019-08-05

11,820 downloads per month
Used in 27 crates (15 directly)

Apache-2.0

26MB
558K SLoC

C++ 273K SLoC // 0.2% comments C 117K SLoC // 0.2% comments Perl 60K SLoC // 0.1% comments Go 31K SLoC // 0.1% comments Python 27K SLoC // 0.2% comments Visual Studio Project 18K SLoC Rust 11K SLoC // 0.1% comments Assembly 10K SLoC // 0.1% comments Shell 3.5K SLoC // 0.5% comments Ada 1.5K SLoC // 0.2% comments Pascal 1K SLoC // 0.2% comments Visual Studio Solution 1K SLoC C# 1K SLoC // 0.4% comments Automake 868 SLoC // 0.2% comments Objective-C++ 607 SLoC // 0.1% comments Scons 576 SLoC // 0.2% comments Batch 565 SLoC // 0.0% comments XSL 181 SLoC SQL 159 SLoC Xcode Config 65 SLoC // 0.7% comments Ruby 38 SLoC // 0.5% comments Alex 19 SLoC PHP 9 SLoC // 0.6% comments D 5 SLoC

gRPC-rs

gRPC-rs is a Rust wrapper of gRPC Core. gRPC is a high performance, open source universal RPC framework that puts mobile and HTTP/2 first.

Crates.io docs.rs Build Status

Status

This project is still under development. The following features with the check marks are supported:

  • Basic asynchronous unary/steaming call
  • SSL
  • Generic call
  • Connection level compression
  • Interoperability test
  • QPS benchmark
  • Custom metadata
  • Health check
  • Reflection
  • Authentication
  • Load balance

Prerequisites

  • CMake >= 3.8.0
  • Rust >= 1.19.0
  • binutils >= 2.22
  • LLVM and Clang >= 3.9 if you need to generate bindings at compile time.
  • By default, the secure feature is provided by boringssl, which requires Go (>=1.7) to build. You can also use openssl instead by enabling openssl feature.

For Linux and MacOS, you also need to install gcc (or clang) too.

Bindings are pre-generated for x86_64 Linux. For other platforms, bindings are generated at compile time.

For Windows, you also need to install following software:

  • Active State Perl
  • yasm
  • Visual Studio 2015+

Build

$ ./scripts/reset-submodule.cmd # if you just cloned the repository
$ cargo build

Error linking OpenSSL

If you're getting linker errors when building your project using gRPC-rs, head down to the openssl feature section for a possible fix.

Usage

To generate the sources from proto files:

Option 1 - Manual Generation

  1. Install the protobuf compiler:
$ cargo install protobuf-codegen
  1. Install the gRPC compiler:
$ cargo install grpcio-compiler
  1. Generate the sources:
$ protoc --rust_out=. --grpc_out=. --plugin=protoc-gen-grpc=`which grpc_rust_plugin` example.proto

Option 2 - Programmatic Generation

Programmatic generation can be used to generate Rust modules from proto files via your build.rs by using protoc-grpcio.

For more information and examples see README.

To include this project as a dependency:

[dependencies]
grpcio = "0.4"

Feature secure

secure feature enables support for TLS encryption and some authentication mechanism. When you do not need it, for example when working in intranet, you can disable it by using the following configuration:

[dependencies]
grpcio = { version = "0.4", default-features = false, features = ["protobuf-codec"] }

Feature openssl

gRPC-rs comes vendored with gRPC Core, which by default uses BoringSSL instead of OpenSSL. This may cause linking issues due to symbol clashes and/or missing symbols when another one of your dependencies uses OpenSSL. To resolve this, you can tell gRPC-rs to use OpenSSL too by specifying "openssl" in your Cargo.toml's features list for gprcio. E.g.:

[dependencies]
grpcio = { version = "0.4.4", features = ["openssl"] }

Performance

See benchmark to find out how to run a benchmark by yourself.

Cross Compile

See cross_compile

Contributing

Make sure to format and test the code before sending a PR.

If the content in grpc-sys/grpc is updated, you may need to regenerate bindings:

$ ./scripts/generate-bindings.sh

Dependencies