From b27bcf0280efe93fff464f067213981f550c98e8 Mon Sep 17 00:00:00 2001 From: yangyang <962032265@qq.com> Date: Mon, 1 Jul 2024 17:31:28 +0800 Subject: [PATCH] example(greet): update client --- examples/greeter/src/greeter/client.rs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/examples/greeter/src/greeter/client.rs b/examples/greeter/src/greeter/client.rs index f6fea892..4fa65e70 100644 --- a/examples/greeter/src/greeter/client.rs +++ b/examples/greeter/src/greeter/client.rs @@ -38,12 +38,18 @@ async fn main() { let builder = ClientBuilder::new().with_registry("nacos://127.0.0.1:8848".parse().unwrap()); let mut cli = GreeterClient::new(builder); + let mut mtdata = Metadata::default(); + mtdata = mtdata.insert("static_tag".to_string(), "red".to_string()); + let req = Request::from_parts( + mtdata.clone(), + GreeterRequest { + name: "message from client".to_string(), + }, + ); println!("# unary call"); let resp = cli - .greet(Request::new(GreeterRequest { - name: "message from client".to_string(), - })) + .greet(req) .await; let resp = match resp { Ok(resp) => resp, @@ -64,7 +70,9 @@ async fn main() { name: "msg3 from client streaming".to_string(), }, ]; - let req = futures_util::stream::iter(data); + let mut mtdata = Metadata::default(); + mtdata = mtdata.insert("client_streaming".to_string(), "true".to_string()); + let req = Request::from_parts(mtdata, futures_util::stream::iter(data)); let resp = cli.greet_client_stream(req).await; let client_streaming_resp = match resp { Ok(resp) => resp,