From 064fbc7f1b3aaa7df453e8d499d6fdb446ea101f Mon Sep 17 00:00:00 2001 From: Mingwei Samuel Date: Tue, 22 Oct 2019 11:16:17 -0700 Subject: [PATCH] code cleanup --- src/req/regional_requester.rs | 8 ++---- src/req/requester_manager.rs | 50 ----------------------------------- 2 files changed, 2 insertions(+), 56 deletions(-) delete mode 100644 src/req/requester_manager.rs diff --git a/src/req/regional_requester.rs b/src/req/regional_requester.rs index 173ec87..e873659 100644 --- a/src/req/regional_requester.rs +++ b/src/req/regional_requester.rs @@ -38,15 +38,11 @@ impl RegionalRequester { pub fn get<'a, T: serde::de::DeserializeOwned>(self: Arc, config: &'a RiotApiConfig, client: &'a Client, - method_id: &'static str, region: Region, path: String, - query: Option) + method_id: &'static str, region: Region, path: String, query: Option) -> impl Future, reqwest::Error>> + 'a { async move { - let query = query.as_ref().map(|s| s.as_ref()); - - // let ref config = RiotApiConfig::with_key("asdf"); - // let ref client = Client::new(); + let query = query.as_deref(); let mut attempts: u8 = 0; for _ in 0..=config.retries { diff --git a/src/req/requester_manager.rs b/src/req/requester_manager.rs deleted file mode 100644 index 9fa7447..0000000 --- a/src/req/requester_manager.rs +++ /dev/null @@ -1,50 +0,0 @@ -use std::future::Future; - -use log::*; -use reqwest::Client; - -use crate::riot_api_config::RiotApiConfig; -use crate::consts::Region; -use crate::util::InsertOnlyCHashMap; - -use super::RegionalRequester; - -pub struct RequesterManager { - /// Configuration settings. - riot_api_config: RiotApiConfig, - /// Client for making requests. - client: Client, - - /// Per-region requesters. - regional_requesters: InsertOnlyCHashMap, -} - -impl RequesterManager { - pub fn new(riot_api_config: RiotApiConfig) -> Self { - // TODO configure client. - let client = Client::new(); - trace!("Creating client (TODO: configuration)."); - - Self { - riot_api_config: riot_api_config, - client: client, - regional_requesters: InsertOnlyCHashMap::new(), - } - } - - pub fn get_regional_requester(&self, region: Region) { - self.regional_requesters - .get_or_insert_with(region, || RegionalRequester::new()) - } - - // pub fn get( - // &self, method_id: &'static str, region: Region, path: &str, - // query: Option<&str>) -> dyn Future, reqwest::Error>> - // { - // // TODO: max concurrent requests? Or can configure client? - // let regional_requester = self.regional_requesters - // .get_or_insert_with(region, || RegionalRequester::new()); - // regional_requester - // .get(&self.riot_api_config, &self.client, method_id, region, path, query) - // } -}