From 0f80b196149a0fb75d84b61c8bbbeb9a71267129 Mon Sep 17 00:00:00 2001 From: Ilion Beyst Date: Wed, 1 Jun 2022 20:19:13 +0200 Subject: set up stub grpc client --- planetwars-client/src/main.rs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 planetwars-client/src/main.rs (limited to 'planetwars-client/src') diff --git a/planetwars-client/src/main.rs b/planetwars-client/src/main.rs new file mode 100644 index 0000000..9d9bdab --- /dev/null +++ b/planetwars-client/src/main.rs @@ -0,0 +1,21 @@ +pub mod pb { + tonic::include_proto!("grpc.planetwars.bot_api"); +} + +use pb::test_service_client::TestServiceClient; +use pb::{Hello, HelloResponse}; +use tonic::Response; + +#[tokio::main] +async fn main() { + let mut client = TestServiceClient::connect("http://localhost:50051") + .await + .unwrap(); + let response: Response = client + .greet(Hello { + hello_message: "robbe".to_string(), + }) + .await + .unwrap(); + println!("{}", response.get_ref().response); +} -- cgit v1.2.3