Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deps: tokio 1.0 and hyper 0.14 #176

Merged
merged 2 commits into from
Jan 4, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ smallvec = { version = "1.5.1", default-features = false }
thiserror = "1.0.22"

# used for tests and HTTP/hyper
# the features are used only for tests but enabled because `dev-depedencies` are leaked into dependencies.
tokio = { version = "0.2.24", features = ["stream", "rt-threaded", "macros"], optional = true }
# the features are used only for tests but enabled because `dev-dependencies` are leaked into dependencies.
tokio = { version = "1.0", features = ["net", "rt-multi-thread", "macros"], optional = true }

# HTTP-related dependencies
hyper = { version = "0.13.9", features = ["stream"], optional = true }
hyper = { version = "0.14", features = ["stream", "client", "server", "http1", "http2","http1", "http2", "tcp"], optional = true }
niklasad1 marked this conversation as resolved.
Show resolved Hide resolved
unicase = { version = "2.6.0", optional = true }

# WS-related dependencies
Expand Down
2 changes: 1 addition & 1 deletion src/http/transport/background.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ impl BackgroundHttp {

// Because hyper can only be polled through tokio, we spawn it in a background thread.
thread::Builder::new().name("jsonrpsee-hyper-server".to_string()).spawn(move || {
let mut runtime = match tokio::runtime::Builder::new().basic_scheduler().enable_all().build() {
let runtime = match tokio::runtime::Builder::new_current_thread().enable_all().build() {
Ok(r) => r,
Err(err) => {
log::error!("Failed to initialize tokio runtime in HTTP JSON-RPC server: {}", err);
Expand Down
6 changes: 3 additions & 3 deletions test-utils/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ edition = "2018"
[dependencies]
async-std = "1.8.0"
futures = "0.3.8"
hyper = "0.13.9"
hyper = "0.14"
log = "0.4.11"
serde = { version = "1.0.118", default-features = false, features = ["derive"] }
serde_json = "1.0.60"
soketto = "0.4.2"
tokio = { version = "0.2.24", features = ["dns", "stream", "tcp", "rt-threaded", "macros"] }
tokio-util = { version = "0.3.1", features = ["compat"] }
tokio = { version = "1.0", features = ["net", "rt-multi-thread", "macros", "time"] }
tokio-util = { version = "0.6", features = ["compat"] }
4 changes: 2 additions & 2 deletions test-utils/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use soketto::handshake::{server::Response, Server};
use std::net::SocketAddr;
use std::time::Duration;
use tokio::net::TcpStream;
use tokio_util::compat::{Compat, Tokio02AsyncReadCompatExt};
use tokio_util::compat::{Compat, TokioAsyncReadCompatExt};

pub use hyper::{Body, HeaderMap, StatusCode, Uri};

Expand Down Expand Up @@ -183,7 +183,7 @@ async fn connection_task(socket: async_std::net::TcpStream, mode: ServerMode, mu
loop {
let next_ws = ws_stream.next().fuse();
let next_exit = exit.next().fuse();
let time_out = tokio::time::delay_for(Duration::from_secs(1)).fuse();
let time_out = tokio::time::sleep(Duration::from_secs(1)).fuse();
futures::pin_mut!(time_out, next_exit, next_ws);

futures::select! {
Expand Down
8 changes: 4 additions & 4 deletions tests/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ use futures::future::FutureExt;

pub fn websocket_server(server_started: Sender<SocketAddr>) {
std::thread::spawn(move || {
let mut rt = tokio::runtime::Runtime::new().unwrap();
let rt = tokio::runtime::Runtime::new().unwrap();

let server = rt.block_on(WsServer::new("127.0.0.1:0")).unwrap();
let mut sub_hello =
Expand All @@ -54,7 +54,7 @@ pub fn websocket_server(server_started: Sender<SocketAddr>) {
}
.fuse();

let timeout = tokio::time::delay_for(Duration::from_millis(100)).fuse();
let timeout = tokio::time::sleep(Duration::from_millis(100)).fuse();
futures::pin_mut!(hello_fut, timeout);
futures::select! {
_ = hello_fut => (),
Expand All @@ -70,7 +70,7 @@ pub fn websocket_server(server_started: Sender<SocketAddr>) {

pub fn websocket_server_with_wait_period(server_started: Sender<SocketAddr>, wait: Receiver<()>) {
std::thread::spawn(move || {
let mut rt = tokio::runtime::Runtime::new().unwrap();
let rt = tokio::runtime::Runtime::new().unwrap();

let server = rt.block_on(WsServer::new("127.0.0.1:0")).unwrap();
let mut respond = server.register_method("say_hello".to_owned()).unwrap();
Expand All @@ -88,7 +88,7 @@ pub fn websocket_server_with_wait_period(server_started: Sender<SocketAddr>, wai

pub fn http_server(server_started: Sender<SocketAddr>) {
std::thread::spawn(move || {
let mut rt = tokio::runtime::Runtime::new().unwrap();
let rt = tokio::runtime::Runtime::new().unwrap();

let server = rt.block_on(HttpServer::new("127.0.0.1:0", HttpConfig::default())).unwrap();
server_started.send(*server.local_addr()).unwrap();
Expand Down