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
+32
View File
@@ -0,0 +1,32 @@
pub mod pb {
tonic::include_proto!("/grpc.examples.echo");
}
use pb::{echo_client::EchoClient, EchoRequest};
use tonic::transport::{Certificate, Channel, ClientTlsConfig};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let pem = tokio::fs::read("tonic-examples/data/tls/ca.pem").await?;
let ca = Certificate::from_pem(pem);
let tls = ClientTlsConfig::with_rustls()
.ca_certificate(ca)
.domain_name("example.com");
let channel = Channel::from_static("http://[::1]:50051")
.tls_config(tls)
.connect()
.await?;
let mut client = EchoClient::new(channel);
let request = tonic::Request::new(EchoRequest {
message: "hello".into(),
});
let response = client.unary_echo(request).await?;
println!("RESPONSE={:?}", response);
Ok(())
}