Upgrade to tokio 0.2 (#163)
This commit is contained in:
@@ -15,17 +15,18 @@ name = "server"
|
||||
path = "src/bin/server.rs"
|
||||
|
||||
[dependencies]
|
||||
tokio = "=0.2.0-alpha.6"
|
||||
tokio = { version = "0.2", features = ["rt-threaded", "time", "macros", "stream", "fs"] }
|
||||
tonic = { path = "../tonic", features = ["tls"] }
|
||||
prost = "0.5"
|
||||
prost-derive = "0.5"
|
||||
bytes = "0.4"
|
||||
http = "0.1"
|
||||
futures-core-preview = "=0.3.0-alpha.19"
|
||||
futures-util-preview = "=0.3.0-alpha.19"
|
||||
async-stream = "0.1.2"
|
||||
tower = "=0.3.0-alpha.2"
|
||||
http-body = "=0.2.0-alpha.3"
|
||||
http = "0.2"
|
||||
futures-core = "0.3"
|
||||
futures-util = "0.3"
|
||||
async-stream = "0.2"
|
||||
# tower = "=0.3.0-alpha.2"
|
||||
tower = { git = "https://github.com/tower-rs/tower" }
|
||||
http-body = "0.3"
|
||||
|
||||
console = "0.9"
|
||||
structopt = "0.2"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use crate::{pb::client::*, pb::*, test_assert, TestAssertion};
|
||||
use futures_util::{future, stream, SinkExt, StreamExt};
|
||||
use futures_util::{future, stream, StreamExt};
|
||||
use tokio::sync::mpsc;
|
||||
use tonic::transport::Channel;
|
||||
use tonic::{metadata::MetadataValue, Code, Request, Response, Status};
|
||||
@@ -148,8 +148,8 @@ pub async fn server_streaming(client: &mut TestClient, assertions: &mut Vec<Test
|
||||
}
|
||||
|
||||
pub async fn ping_pong(client: &mut TestClient, assertions: &mut Vec<TestAssertion>) {
|
||||
let (mut tx, rx) = mpsc::unbounded_channel();
|
||||
tx.try_send(make_ping_pong_request(0)).unwrap();
|
||||
let (tx, rx) = mpsc::unbounded_channel();
|
||||
tx.send(make_ping_pong_request(0)).unwrap();
|
||||
|
||||
let result = client.full_duplex_call(Request::new(rx)).await;
|
||||
|
||||
@@ -170,9 +170,7 @@ pub async fn ping_pong(client: &mut TestClient, assertions: &mut Vec<TestAsserti
|
||||
drop(tx);
|
||||
break;
|
||||
} else {
|
||||
tx.send(make_ping_pong_request(responses.len()))
|
||||
.await
|
||||
.unwrap();
|
||||
tx.send(make_ping_pong_request(responses.len())).unwrap();
|
||||
}
|
||||
}
|
||||
None => {
|
||||
|
||||
@@ -2,7 +2,7 @@ use crate::pb::{self, *};
|
||||
use async_stream::try_stream;
|
||||
use futures_util::{stream, StreamExt, TryStreamExt};
|
||||
use std::pin::Pin;
|
||||
use std::time::{Duration, Instant};
|
||||
use std::time::Duration;
|
||||
use tonic::{Code, Request, Response, Status};
|
||||
|
||||
pub use pb::server::{TestServiceServer, UnimplementedServiceServer};
|
||||
@@ -65,8 +65,7 @@ impl pb::server::TestService for TestService {
|
||||
|
||||
let stream = try_stream! {
|
||||
for param in response_parameters {
|
||||
let deadline = Instant::now() + Duration::from_micros(param.interval_us as u64);
|
||||
tokio::timer::delay(deadline).await;
|
||||
tokio::time::delay_for(Duration::from_micros(param.interval_us as u64)).await;
|
||||
|
||||
let payload = crate::server_payload(param.size as usize);
|
||||
yield StreamingOutputCallResponse { payload: Some(payload) };
|
||||
@@ -121,8 +120,7 @@ impl pb::server::TestService for TestService {
|
||||
}
|
||||
|
||||
for param in msg.response_parameters {
|
||||
let deadline = Instant::now() + Duration::from_micros(param.interval_us as u64);
|
||||
tokio::timer::delay(deadline).await;
|
||||
tokio::time::delay_for(Duration::from_micros(param.interval_us as u64)).await;
|
||||
|
||||
let payload = crate::server_payload(param.size as usize);
|
||||
yield StreamingOutputCallResponse { payload: Some(payload) };
|
||||
|
||||
Reference in New Issue
Block a user