Upgrade to Tokio 1.0.0 ecosystem (#530)
* Upgrade Tonic to Tokio 1.0 Work in progress for updating Tonic to Tokio 1.0. Since tower has not been released to crates.io, a git dependency is taken instead. * Upgrade Tonic to Tokio 1.0 phase 2 * tonic: remove tower-* deps * Apply suggestions from code review Co-authored-by: Ed Marshall <[email protected]> Co-authored-by: Lucio Franco <[email protected]>
This commit is contained in:
co-authored by
Ed Marshall
Lucio Franco
parent
fe4d5b9d9a
commit
fdda5ae26a
@@ -18,42 +18,42 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let e1 = Endpoint::from_static("http://[::1]:50051");
|
||||
let e2 = Endpoint::from_static("http://[::1]:50052");
|
||||
|
||||
let (channel, mut rx) = Channel::balance_channel(10);
|
||||
let (channel, rx) = Channel::balance_channel(10);
|
||||
let mut client = EchoClient::new(channel);
|
||||
|
||||
let done = Arc::new(AtomicBool::new(false));
|
||||
let demo_done = done.clone();
|
||||
tokio::spawn(async move {
|
||||
tokio::time::delay_for(tokio::time::Duration::from_secs(5)).await;
|
||||
tokio::time::sleep(tokio::time::Duration::from_secs(5)).await;
|
||||
println!("Added first endpoint");
|
||||
let change = Change::Insert("1", e1);
|
||||
let res = rx.send(change).await;
|
||||
println!("{:?}", res);
|
||||
tokio::time::delay_for(tokio::time::Duration::from_secs(5)).await;
|
||||
tokio::time::sleep(tokio::time::Duration::from_secs(5)).await;
|
||||
println!("Added second endpoint");
|
||||
let change = Change::Insert("2", e2);
|
||||
let res = rx.send(change).await;
|
||||
println!("{:?}", res);
|
||||
tokio::time::delay_for(tokio::time::Duration::from_secs(5)).await;
|
||||
tokio::time::sleep(tokio::time::Duration::from_secs(5)).await;
|
||||
println!("Removed first endpoint");
|
||||
let change = Change::Remove("1");
|
||||
let res = rx.send(change).await;
|
||||
println!("{:?}", res);
|
||||
|
||||
tokio::time::delay_for(tokio::time::Duration::from_secs(5)).await;
|
||||
tokio::time::sleep(tokio::time::Duration::from_secs(5)).await;
|
||||
println!("Removed second endpoint");
|
||||
let change = Change::Remove("2");
|
||||
let res = rx.send(change).await;
|
||||
println!("{:?}", res);
|
||||
|
||||
tokio::time::delay_for(tokio::time::Duration::from_secs(5)).await;
|
||||
tokio::time::sleep(tokio::time::Duration::from_secs(5)).await;
|
||||
println!("Added third endpoint");
|
||||
let e3 = Endpoint::from_static("http://[::1]:50051");
|
||||
let change = Change::Insert("3", e3);
|
||||
let res = rx.send(change).await;
|
||||
println!("{:?}", res);
|
||||
|
||||
tokio::time::delay_for(tokio::time::Duration::from_secs(5)).await;
|
||||
tokio::time::sleep(tokio::time::Duration::from_secs(5)).await;
|
||||
println!("Removed third endpoint");
|
||||
let change = Change::Remove("3");
|
||||
let res = rx.send(change).await;
|
||||
@@ -62,7 +62,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
});
|
||||
|
||||
while !done.load(SeqCst) {
|
||||
tokio::time::delay_for(tokio::time::Duration::from_millis(500)).await;
|
||||
tokio::time::sleep(tokio::time::Duration::from_millis(500)).await;
|
||||
let request = tonic::Request::new(EchoRequest {
|
||||
message: "hello".into(),
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user