#grpc #bindings #tls #rpc #wrapper #client #rpc-framework

sys grpcio-sys

FFI bindings to gRPC c core library

38 releases

0.13.0+1.56.2-patched Aug 25, 2023
0.12.1+1.46.5-patched Feb 14, 2023
0.12.0+1.46.5-patched Nov 4, 2022
0.10.3+1.44.0-patched Jun 28, 2022
0.1.0 Jul 27, 2017

#32 in #rpc-framework

Download history 3821/week @ 2023-12-11 2835/week @ 2023-12-18 1693/week @ 2023-12-25 3139/week @ 2024-01-01 4513/week @ 2024-01-08 4487/week @ 2024-01-15 4128/week @ 2024-01-22 3421/week @ 2024-01-29 3382/week @ 2024-02-05 3495/week @ 2024-02-12 3394/week @ 2024-02-19 3717/week @ 2024-02-26 2467/week @ 2024-03-04 2763/week @ 2024-03-11 2910/week @ 2024-03-18 2873/week @ 2024-03-25

11,146 downloads per month
Used in grpcio

Apache-2.0

26MB
530K SLoC

C++ 323K SLoC // 0.1% comments C 81K SLoC // 0.1% comments Python 41K SLoC // 0.2% comments Bazel 30K SLoC // 0.1% comments Go 19K SLoC // 0.1% comments M4 10K SLoC // 0.2% comments Shell 7.5K SLoC // 0.5% comments Rust 5K SLoC // 0.0% comments Bitbake 4.5K SLoC // 0.1% comments Forge Config 2.5K SLoC // 0.6% comments Swift 2K SLoC // 0.0% comments Lua 1.5K SLoC // 0.1% comments Batch 861 SLoC // 0.0% comments Ruby 560 SLoC // 0.2% comments PHP 335 SLoC // 0.8% comments XSL 186 SLoC C# 181 SLoC // 0.3% comments Perl 155 SLoC // 0.1% comments Automake 128 SLoC // 0.2% comments Java 120 SLoC // 0.4% comments Cython 95 SLoC // 0.1% comments PowerShell 93 SLoC // 0.2% comments Pan 44 SLoC // 0.1% comments Alex 20 SLoC AWK 18 SLoC // 0.3% comments NuGet Config 7 SLoC

Contains (JAR file, 55KB) gradle-wrapper.jar, (obscure autoconf code, 25KB) configure.ac, (obscure autoconf code, 1KB) configure.ac

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 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, client side is fully supported, server side load report is not implemented yet.

Prerequisites

  • CMake >= 3.8.0
  • Rust >= 1.36.0
  • binutils >= 2.22
  • LLVM and Clang >= 3.9 if you need to generate bindings at compile time.

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

Bindings are pre-generated for x86_64/arm64 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

$ cargo xtask submodule # 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.13"

Feature boringssl

boringssl 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.13", default-features = false, features = ["protobuf-codec"] }

Feature prost-codec and protobuf-codec

gRPC-rs uses protobuf crate by default. If you want to use prost instead, you can enable prost-codec feature. You probably only want to enable only one of the two features. Though grpcio is completely fine with both features enabled at the same time, grpcio-compiler will not going to work as expected.

Feature openssl and openssl-vendored

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, which requires openssl (>=1.0.2). E.g.:

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

Feature openssl-vendored is the same as feature openssl except it will build openssl from bundled sources.

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:

$ cargo xtask bindgen

Dependencies

~4–7MB
~119K SLoC