Nest server and client in their own mods

This commit is contained in:
Lucio Franco
2019-09-06 17:52:41 -04:00
parent 9d44b02e1a
commit 8b548f2ea4
8 changed files with 77 additions and 30 deletions
+3 -1
View File
@@ -8,12 +8,14 @@ mod route_guide {
include!(concat!(env!("OUT_DIR"), "/routeguide.rs"));
}
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 = route_guide::RouteGuideClient::new(svc);
let mut client = RouteGuideClient::new(svc);
let start = Instant::now();
+3 -3
View File
@@ -14,7 +14,7 @@ pub mod routeguide {
include!(concat!(env!("OUT_DIR"), "/routeguide.rs"));
}
use routeguide::{Feature, Point, Rectangle, RouteNote, RouteSummary};
use routeguide::{server, Feature, Point, Rectangle, RouteNote, RouteSummary};
#[derive(Debug)]
pub struct RouteGuide {
@@ -28,7 +28,7 @@ struct State {
}
#[tonic::async_trait]
impl routeguide::RouteGuide for RouteGuide {
impl server::RouteGuide for RouteGuide {
async fn get_feature(&self, request: Request<Point>) -> Result<Response<Feature>, Status> {
println!("GetFeature = {:?}", request);
@@ -168,7 +168,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
},
};
let svc = routeguide::RouteGuideServer::new(route_guide);
let svc = server::RouteGuideServer::new(route_guide);
Server::builder().serve(addr, svc).await?;