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
+12
-11
@@ -15,23 +15,24 @@ name = "server"
|
||||
path = "src/bin/server.rs"
|
||||
|
||||
[dependencies]
|
||||
tokio = { version = "0.2", features = ["rt-threaded", "time", "macros", "stream", "fs"] }
|
||||
tokio = { version = "1.0", features = ["rt-multi-thread", "time", "macros", "fs"] }
|
||||
tokio-stream = "0.1"
|
||||
async-stream = "0.3"
|
||||
tonic = { path = "../tonic", features = ["tls"] }
|
||||
prost = "0.6"
|
||||
prost-derive = "0.6"
|
||||
bytes = "0.5"
|
||||
prost = "0.7"
|
||||
prost-derive = "0.7"
|
||||
bytes = "1.0"
|
||||
http = "0.2"
|
||||
futures-core = "0.3"
|
||||
futures-util = "0.3"
|
||||
async-stream = "0.2"
|
||||
tower = "0.3"
|
||||
http-body = "0.3"
|
||||
hyper = "0.13"
|
||||
console = "0.9"
|
||||
tower = { version = "0.4" }
|
||||
http-body = "0.4"
|
||||
hyper = "0.14"
|
||||
console = "0.14"
|
||||
structopt = "0.3"
|
||||
tracing = "0.1"
|
||||
tracing-subscriber = "0.2.0-alpha"
|
||||
tracing-log = "0.1.0"
|
||||
tracing-subscriber = "0.2"
|
||||
tracing-log = "0.1"
|
||||
|
||||
[build-dependencies]
|
||||
tonic-build = { path = "../tonic-build", features = ["prost"] }
|
||||
|
||||
@@ -154,7 +154,11 @@ pub async fn ping_pong(client: &mut TestClient, assertions: &mut Vec<TestAsserti
|
||||
let (tx, rx) = mpsc::unbounded_channel();
|
||||
tx.send(make_ping_pong_request(0)).unwrap();
|
||||
|
||||
let result = client.full_duplex_call(Request::new(rx)).await;
|
||||
let result = client
|
||||
.full_duplex_call(Request::new(
|
||||
tokio_stream::wrappers::UnboundedReceiverStream::new(rx),
|
||||
))
|
||||
.await;
|
||||
|
||||
assertions.push(test_assert!(
|
||||
"call must be successful",
|
||||
|
||||
+1
-4
@@ -68,10 +68,7 @@ pub enum TestAssertion {
|
||||
|
||||
impl TestAssertion {
|
||||
pub fn is_failed(&self) -> bool {
|
||||
match self {
|
||||
TestAssertion::Failed { .. } => true,
|
||||
_ => false,
|
||||
}
|
||||
matches!(self, TestAssertion::Failed { .. })
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -72,7 +72,7 @@ impl pb::test_service_server::TestService for TestService {
|
||||
|
||||
let stream = try_stream! {
|
||||
for param in response_parameters {
|
||||
tokio::time::delay_for(Duration::from_micros(param.interval_us as u64)).await;
|
||||
tokio::time::sleep(Duration::from_micros(param.interval_us as u64)).await;
|
||||
|
||||
let payload = crate::server_payload(param.size as usize);
|
||||
yield StreamingOutputCallResponse { payload: Some(payload) };
|
||||
@@ -90,7 +90,7 @@ impl pb::test_service_server::TestService for TestService {
|
||||
) -> Result<StreamingInputCallResponse> {
|
||||
let mut stream = req.into_inner();
|
||||
|
||||
let mut aggregated_payload_size = 0 as i32;
|
||||
let mut aggregated_payload_size = 0;
|
||||
while let Some(msg) = stream.try_next().await? {
|
||||
aggregated_payload_size += msg.payload.unwrap().body.len() as i32;
|
||||
}
|
||||
@@ -127,7 +127,7 @@ impl pb::test_service_server::TestService for TestService {
|
||||
}
|
||||
|
||||
for param in msg.response_parameters {
|
||||
tokio::time::delay_for(Duration::from_micros(param.interval_us as u64)).await;
|
||||
tokio::time::sleep(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