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(),
+2 -5
View File
@@ -2,7 +2,7 @@ use futures::TryStreamExt;
use route_guide::{Point, RouteNote};
use std::time::{Duration, Instant};
use tokio::timer::Interval;
use tonic::{transport::Channel, Request};
use tonic::Request;
mod route_guide {
include!(concat!(env!("OUT_DIR"), "/routeguide.rs"));
@@ -12,10 +12,7 @@ use route_guide::client::RouteGuideClient;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let origin = http::Uri::from_static("http://[::1]:10000");
let svc = Channel::builder().build(origin)?;
let mut client = RouteGuideClient::new(svc);
let mut client = RouteGuideClient::connect("http://[::1]:10000")?;
let start = Instant::now();