Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix examples #8

Merged
merged 3 commits into from
Jan 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ Cargo.lock
.vscode
.idea
*.o
example/protocols/*.rs
!example/protocols/mod.rs
9 changes: 0 additions & 9 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,3 @@ byteorder = "1.3.2"
default = ["protobuf-codec"]
protobuf-codec = ["protobuf"]

[[example]]
name = "client"
path = "examples/client.rs"

[dev-dependencies]
log = "0.4.6"
simple-logging = "2.0.2"
nix = "0.15.0"

19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,22 @@ To generate the sources from proto files:
```
$ protoc --rust_out=. --ttrpc_out=. --plugin=protoc-gen-ttrpc=`which ttrpc_rust_plugin` example.proto
```

# Run Examples
1. Go to the directory

`$ cd ttrpc-rust/example`

2. Start the server

`$ cargo run --example server unix:///tmp/1`

3. Start a client

`$ cargo run --example client /tmp/1`

# Notes

The version of protobuf-codegen which you are using to generate codes should be exactly same with the version of protobuf library.

The reason is that [files generated by protobuf-codegen are compatible only with the same version of runtime](https://github.com/stepancheg/rust-protobuf/commit/2ab4d50c27c4dd7803b64ce1a43e2c134532c7a6)
34 changes: 34 additions & 0 deletions example/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[package]
name = "ttrpc-example"
version = "0.1.0"
authors = ["Hui Zhu <teawater@antfin.com>"]
edition = "2018"
license = "Apache-2.0"
keywords = ["ttrpc", "protobuf", "rpc"]
readme = "README.md"
repository = "https://github.com/alipay/ttrpc-rust"
homepage = "https://github.com/alipay/ttrpc-rust"
description = "An example of ttrpc."

[dependencies]
protobuf = "2.8.0"
bytes = "0.4.11"
libc = "0.2.59"
byteorder = "1.3.2"
log = "0.4.6"
simple-logging = "2.0.2"
nix = "0.15.0"
ttrpc = { path = "../" }


[[example]]
name = "client"
path = "./client.rs"

[[example]]
name = "server"
path = "./server.rs"

[build-dependencies]
protoc-rust = "2.8.0"
cmd_lib = "0.7.8"
8 changes: 8 additions & 0 deletions example/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
use cmd_lib::run_cmd;

fn main() {
run_cmd! {
cd protocols;
./hack/update-generated-proto.sh;
};
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
10 changes: 0 additions & 10 deletions examples/protocols/Cargo.toml

This file was deleted.

Loading