chore: Reorganize examples and interop crates (#180)

* chore: Reorganize examples and interop crates

* fix interop tests
This commit is contained in:
Lucio Franco
2019-12-12 11:53:15 -05:00
committed by GitHub
parent f096a238ac
commit d9a481baef
69 changed files with 25 additions and 22 deletions
+39
View File
@@ -0,0 +1,39 @@
pub mod hello_world {
tonic::include_proto!("helloworld");
}
pub mod echo {
tonic::include_proto!("grpc.examples.echo");
}
use echo::{echo_client::EchoClient, EchoRequest};
use hello_world::{greeter_client::GreeterClient, HelloRequest};
use tonic::transport::Endpoint;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let channel = Endpoint::from_static("http://[::1]:50051")
.connect()
.await?;
let mut greeter_client = GreeterClient::new(channel.clone());
let mut echo_client = EchoClient::new(channel);
let request = tonic::Request::new(HelloRequest {
name: "Tonic".into(),
});
let response = greeter_client.say_hello(request).await?;
println!("GREETER RESPONSE={:?}", response);
let request = tonic::Request::new(EchoRequest {
message: "hello".into(),
});
let response = echo_client.unary_echo(request).await?;
println!("ECHO RESPONSE={:?}", response);
Ok(())
}