Add easy connect method in codegen

This commit is contained in:
Lucio Franco
2019-09-21 14:21:28 -06:00
parent 5ded741eb6
commit 922e480cec
8 changed files with 74 additions and 20 deletions
+1 -7
View File
@@ -1,5 +1,3 @@
use tonic::transport::Channel;
pub mod hello_world {
include!(concat!(env!("OUT_DIR"), "/helloworld.rs"));
}
@@ -8,11 +6,7 @@ use hello_world::{client::GreeterClient, HelloRequest};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let origin = vec![http::Uri::from_static("http://[::1]:50051").into()];
let svc = Channel::builder().balance_list(origin)?;
let mut client = GreeterClient::new(svc);
let mut client = GreeterClient::connect("http://[::1]:50051")?;
let request = tonic::Request::new(HelloRequest {
name: "hello".into(),