Skip to content

Latest commit

 

History

History
111 lines (78 loc) · 3.03 KB

README.md

File metadata and controls

111 lines (78 loc) · 3.03 KB

grpc-rust

Build Status License crates.io

Rust implementation of gRPC protocol, under development.

Some development questions in FAQ.

Current status

It basially works. See grpc-examples/src/bin/greeter_{client,server}.rs. It can be tested for example with go client:

# start greeter server implemented in rust
$ cargo run --bin greeter_server

# ... or start greeter server implemented in go
$ go get -u google.golang.org/grpc/examples/helloworld/greeter_client
$ greeter_server

# start greeter client implemented in rust
$ cargo run --bin greeter_client rust
> message: "Hello rust"

# ... or start greeter client implemented in go
$ go get -u google.golang.org/grpc/examples/helloworld/greeter_client
$ greeter_client rust
> 2016/08/19 05:44:45 Greeting: Hello rust

Client and server are implemented asynchronously.

How to generate rust code

There are several ways to generate rust code from .proto files

Invoke protoc programmatically with protoc-rust crate

(Recommended)

Have a look at readme in protoc-rust-grpc crate.

Invoke protoc programmatically with protoc crate

Have a look at readme in protoc crate.

With protoc command and protoc-gen-rust-grpc plugin

Install compiler plugin

cargo install protobuf
cargo install grpc-compiler

These commands install protoc-gen-rust and protoc-gen-rust-grpc to ~/.cargo/bin, which should be added to $PATH.

Compile your proto & gRPC to Rust:

cd $YOURPROJECT
mkdir -p src
protoc --rust_out=src *.proto
protoc --rust-grpc_out=src *.proto

Use compiled protos in your project:

In Cargo.toml:

[dependencies]
grpc            = "0.*"
protobuf        = "1.*"
futures         = "0.1"
futures-cpupool = "0.1"

In lib.rs or main.rs (or any other submodule):

extern crate protobuf;
extern crate grpc;
extern crate futures;
extern crate futures_cpupool;

pub mod myproto;
pub mod myproto_grpc;

TODO

  • Fix performance
  • More tests
  • In particular, add more compatibility tests, they live in interop directory
  • Fix all TODO in sources

Related projects

  • grpc-rs — alternative implementation of gRPC in Rust, a wrapper to C++ implementation
  • httpbis — implementation of HTTP/2, which is used by this implementation of gRPC
  • rust-protobuf — implementation of Google Protocol Buffers