From cf23db736138701bee2b35455cd54345cacdf38e Mon Sep 17 00:00:00 2001 From: Mingwei Samuel Date: Mon, 30 Dec 2019 21:35:23 -0800 Subject: [PATCH] Upgrade to reqwest 0.10, tokio 0.2, release 0.2.0 --- Cargo.toml | 9 ++++----- README.md | 4 ++-- src/req/regional_requester.rs | 2 +- tests/async_tests.rs | 9 +++++---- tests/tests_tr.rs | 8 +++++--- tests/testutils.rs | 13 ------------- 6 files changed, 17 insertions(+), 28 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 46e5109..dc0c97f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "riven" -version = "0.1.3" +version = "0.2.0" authors = ["Mingwei Samuel "] repository = "https://github.com/MingweiSamuel/Riven" description = "Riot Games API Library" @@ -26,13 +26,13 @@ nightly = [ "parking_lot/nightly" ] log = "0.4" num_enum = "0.4" parking_lot = "0.9" -reqwest = { version = "0.10.0-alpha.2", features = [ "gzip", "json" ] } +reqwest = { version = "0.10", features = [ "gzip", "json" ] } scan_fmt = { version = "0.2", default-features = false } serde = { version = "1.0", features = [ "derive" ] } serde_repr = "0.1" strum = "0.16" strum_macros = "0.16" -tokio = { version = "0.2.0-alpha.6", default-features = false, features = [ "timer" ] } +tokio = { version = "0.2", default-features = false, features = [ "time" ] } url = "2.1" [dev-dependencies] @@ -40,5 +40,4 @@ colored = "1.8" env_logger = "0.7" fake_instant = "0.4" lazy_static = "1.4" -tokio = "0.2.0-alpha.6" -futures-util-preview = "0.3.0-alpha.19" +tokio = "0.2" diff --git a/README.md b/README.md index 9a94e3f..b241289 100644 --- a/README.md +++ b/README.md @@ -27,8 +27,8 @@ Data structs and endpoints are automatically generated from the use riven::RiotApi; use riven::consts::Region; -// Riven Enter tokio async runtime. -let rt = tokio::runtime::Runtime::new().unwrap(); +// Enter tokio async runtime. +let mut rt = tokio::runtime::Runtime::new().unwrap(); rt.block_on(async { // Create RiotApi instance from key string. let api_key = "RGAPI-01234567-89ab-cdef-0123-456789abcdef"; diff --git a/src/req/regional_requester.rs b/src/req/regional_requester.rs index 2c87dff..b9ad5ef 100644 --- a/src/req/regional_requester.rs +++ b/src/req/regional_requester.rs @@ -3,7 +3,7 @@ use std::sync::Arc; use log; use reqwest::{ Client, StatusCode, Url }; -use tokio::timer::delay_for; +use tokio::time::delay_for; use crate::Result; use crate::RiotApiError; diff --git a/tests/async_tests.rs b/tests/async_tests.rs index f626cd4..cc56a2e 100644 --- a/tests/async_tests.rs +++ b/tests/async_tests.rs @@ -7,7 +7,7 @@ macro_rules! async_tests { env_logger::init(); std::process::exit({ - let rt = tokio::runtime::Runtime::new() + let mut rt = tokio::runtime::Runtime::new() .expect("Failed to create runtime."); let (_, errs) = rt.block_on(async { @@ -23,9 +23,10 @@ macro_rules! async_tests { }.await; result }; - let $name = tokio::executor::Executor::spawn_with_handle( - &mut tokio::executor::DefaultExecutor::current(), $name) - .expect("Failed to spawn."); + // let $name = tokio_executor::Executor::spawn_with_handle( + // &mut tokio_executor::DefaultExecutor::current(), $name) + // .expect("Failed to spawn."); + let $name = tokio::spawn($name); )* $( let $name = $name.await; diff --git a/tests/tests_tr.rs b/tests/tests_tr.rs index ca6c26b..0fd3bd0 100644 --- a/tests/tests_tr.rs +++ b/tests/tests_tr.rs @@ -3,7 +3,7 @@ mod async_tests; mod testutils; -use testutils::{ RIOT_API, future_start }; +use testutils::RIOT_API; use colored::*; @@ -24,11 +24,13 @@ async_tests!{ let sl = ll.entries[..50].iter() .map(|entry| RIOT_API.summoner_v4().get_by_summoner_id(REGION, &entry.summoner_id)) - .map(future_start) + .map(tokio::spawn) .collect::>(); for (i, s) in sl.into_iter().enumerate() { - let summoner: Summoner = s.await.map_err(|e| e.to_string())?; + let summoner: Summoner = s.await + .expect("tokio::spawn join error") + .map_err(|e| e.to_string())?; println!("{}: {}", i + 1, summoner.name); } diff --git a/tests/testutils.rs b/tests/testutils.rs index 2d2741f..35269a6 100644 --- a/tests/testutils.rs +++ b/tests/testutils.rs @@ -1,10 +1,6 @@ #![allow(dead_code)] -use std::future::Future; - -use futures_util::future::RemoteHandle; use lazy_static::lazy_static; -use tokio::executor::{ DefaultExecutor, Executor }; use riven::{ RiotApi, RiotApiConfig }; @@ -18,15 +14,6 @@ lazy_static! { }; } -pub fn future_start(future: Fut) -> RemoteHandle<::Output> -where - Fut: Future + Send + 'static, - ::Output: Send, -{ - Executor::spawn_with_handle(&mut DefaultExecutor::current(), future) - .expect("Failed to spawn.") -} - pub mod ids { pub const SUMMONER_ID_LUGNUTSK: &'static str = "SBM8Ubipo4ge2yj7bhEzL7yvV0C9Oc1XA2l6v5okGMA_nCw"; pub const SUMMONER_ID_MA5TERY: &'static str = "IbC4uyFEEW3ZkZw6FZF4bViw3P1EynclAcI6-p-vCpI99Ec";