Upgrade to reqwest 0.10, tokio 0.2, release 0.2.0

pull/5/head v0.2.0
Mingwei Samuel 2019-12-30 21:35:23 -08:00
parent b4c0432286
commit cf23db7361
6 changed files with 17 additions and 28 deletions

View File

@ -1,6 +1,6 @@
[package] [package]
name = "riven" name = "riven"
version = "0.1.3" version = "0.2.0"
authors = ["Mingwei Samuel <mingwei.samuel@gmail.com>"] authors = ["Mingwei Samuel <mingwei.samuel@gmail.com>"]
repository = "https://github.com/MingweiSamuel/Riven" repository = "https://github.com/MingweiSamuel/Riven"
description = "Riot Games API Library" description = "Riot Games API Library"
@ -26,13 +26,13 @@ nightly = [ "parking_lot/nightly" ]
log = "0.4" log = "0.4"
num_enum = "0.4" num_enum = "0.4"
parking_lot = "0.9" 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 } scan_fmt = { version = "0.2", default-features = false }
serde = { version = "1.0", features = [ "derive" ] } serde = { version = "1.0", features = [ "derive" ] }
serde_repr = "0.1" serde_repr = "0.1"
strum = "0.16" strum = "0.16"
strum_macros = "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" url = "2.1"
[dev-dependencies] [dev-dependencies]
@ -40,5 +40,4 @@ colored = "1.8"
env_logger = "0.7" env_logger = "0.7"
fake_instant = "0.4" fake_instant = "0.4"
lazy_static = "1.4" lazy_static = "1.4"
tokio = "0.2.0-alpha.6" tokio = "0.2"
futures-util-preview = "0.3.0-alpha.19"

View File

@ -27,8 +27,8 @@ Data structs and endpoints are automatically generated from the
use riven::RiotApi; use riven::RiotApi;
use riven::consts::Region; use riven::consts::Region;
// Riven Enter tokio async runtime. // Enter tokio async runtime.
let rt = tokio::runtime::Runtime::new().unwrap(); let mut rt = tokio::runtime::Runtime::new().unwrap();
rt.block_on(async { rt.block_on(async {
// Create RiotApi instance from key string. // Create RiotApi instance from key string.
let api_key = "RGAPI-01234567-89ab-cdef-0123-456789abcdef"; let api_key = "RGAPI-01234567-89ab-cdef-0123-456789abcdef";

View File

@ -3,7 +3,7 @@ use std::sync::Arc;
use log; use log;
use reqwest::{ Client, StatusCode, Url }; use reqwest::{ Client, StatusCode, Url };
use tokio::timer::delay_for; use tokio::time::delay_for;
use crate::Result; use crate::Result;
use crate::RiotApiError; use crate::RiotApiError;

View File

@ -7,7 +7,7 @@ macro_rules! async_tests {
env_logger::init(); env_logger::init();
std::process::exit({ std::process::exit({
let rt = tokio::runtime::Runtime::new() let mut rt = tokio::runtime::Runtime::new()
.expect("Failed to create runtime."); .expect("Failed to create runtime.");
let (_, errs) = rt.block_on(async { let (_, errs) = rt.block_on(async {
@ -23,9 +23,10 @@ macro_rules! async_tests {
}.await; }.await;
result result
}; };
let $name = tokio::executor::Executor::spawn_with_handle( // let $name = tokio_executor::Executor::spawn_with_handle(
&mut tokio::executor::DefaultExecutor::current(), $name) // &mut tokio_executor::DefaultExecutor::current(), $name)
.expect("Failed to spawn."); // .expect("Failed to spawn.");
let $name = tokio::spawn($name);
)* )*
$( $(
let $name = $name.await; let $name = $name.await;

View File

@ -3,7 +3,7 @@
mod async_tests; mod async_tests;
mod testutils; mod testutils;
use testutils::{ RIOT_API, future_start }; use testutils::RIOT_API;
use colored::*; use colored::*;
@ -24,11 +24,13 @@ async_tests!{
let sl = ll.entries[..50].iter() let sl = ll.entries[..50].iter()
.map(|entry| RIOT_API.summoner_v4().get_by_summoner_id(REGION, &entry.summoner_id)) .map(|entry| RIOT_API.summoner_v4().get_by_summoner_id(REGION, &entry.summoner_id))
.map(future_start) .map(tokio::spawn)
.collect::<Vec<_>>(); .collect::<Vec<_>>();
for (i, s) in sl.into_iter().enumerate() { 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); println!("{}: {}", i + 1, summoner.name);
} }

View File

@ -1,10 +1,6 @@
#![allow(dead_code)] #![allow(dead_code)]
use std::future::Future;
use futures_util::future::RemoteHandle;
use lazy_static::lazy_static; use lazy_static::lazy_static;
use tokio::executor::{ DefaultExecutor, Executor };
use riven::{ RiotApi, RiotApiConfig }; use riven::{ RiotApi, RiotApiConfig };
@ -18,15 +14,6 @@ lazy_static! {
}; };
} }
pub fn future_start<Fut>(future: Fut) -> RemoteHandle<<Fut as Future>::Output>
where
Fut: Future + Send + 'static,
<Fut as Future>::Output: Send,
{
Executor::spawn_with_handle(&mut DefaultExecutor::current(), future)
.expect("Failed to spawn.")
}
pub mod ids { pub mod ids {
pub const SUMMONER_ID_LUGNUTSK: &'static str = "SBM8Ubipo4ge2yj7bhEzL7yvV0C9Oc1XA2l6v5okGMA_nCw"; pub const SUMMONER_ID_LUGNUTSK: &'static str = "SBM8Ubipo4ge2yj7bhEzL7yvV0C9Oc1XA2l6v5okGMA_nCw";
pub const SUMMONER_ID_MA5TERY: &'static str = "IbC4uyFEEW3ZkZw6FZF4bViw3P1EynclAcI6-p-vCpI99Ec"; pub const SUMMONER_ID_MA5TERY: &'static str = "IbC4uyFEEW3ZkZw6FZF4bViw3P1EynclAcI6-p-vCpI99Ec";