Skip to content

Commit

Permalink
example(greet): update client
Browse files Browse the repository at this point in the history
  • Loading branch information
yang20150702 committed Jul 1, 2024
1 parent 466f80e commit b27bcf0
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions examples/greeter/src/greeter/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down

0 comments on commit b27bcf0

Please sign in to comment.