From 2d105529b4478ebe82cd532ae8a110e067578184 Mon Sep 17 00:00:00 2001 From: Mingwei Samuel Date: Thu, 17 Oct 2019 16:31:06 -0700 Subject: [PATCH] cleaning up unuseds --- src/lib.rs | 6 ++---- src/req/rate_limit.rs | 1 - src/req/regional_requester.rs | 11 ----------- src/req/requester_manager.rs | 4 ++-- src/req/token_bucket.rs | 13 ++++--------- src/util/insert_only_chashmap.rs | 16 ++++++++-------- 6 files changed, 16 insertions(+), 35 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 1b0bdd2..0e807eb 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,5 +1,3 @@ -#![allow(dead_code)] // TODO REMOVE - pub mod consts; mod riot_api_config; @@ -16,12 +14,12 @@ mod tests { use tokio::runtime::Runtime; use super::*; - const api_key: &'static str = "RGAPI-nothinghereowo"; + const API_KEY: &'static str = "RGAPI-nothinghereowo"; #[test] fn it_works() { let rt = Runtime::new().unwrap(); - let riot_api = RiotApi::with_key(api_key); + let riot_api = RiotApi::with_key(API_KEY); // https://na1.api.riotgames.com/lol/champion-mastery/v4/scores/by-summoner/SBM8Ubipo4ge2yj7bhEzL7yvV0C9Oc1XA2l6v5okGMA_nCw let my_future = riot_api.get::("asdf", consts::Region::NA, diff --git a/src/req/rate_limit.rs b/src/req/rate_limit.rs index d75dbca..d7516b3 100644 --- a/src/req/rate_limit.rs +++ b/src/req/rate_limit.rs @@ -19,7 +19,6 @@ pub struct RateLimit { // Buckets for this rate limit (synchronized). // Almost always read, written only when rate limit rates are updated // from API response. - // TODO: Question of writer starvation. buckets: RwLock>, // Set to when we can retry if a retry-after header is received. retry_after: Option, diff --git a/src/req/regional_requester.rs b/src/req/regional_requester.rs index 5d36c68..b4f9df9 100644 --- a/src/req/regional_requester.rs +++ b/src/req/regional_requester.rs @@ -106,12 +106,6 @@ impl<'a> RegionalRequester<'a> { panic!("FAILED AFTER {} ATTEMPTS!", attempts); } - pub fn get2(&'a self, method_id: &'a str, region: &'a Region<'_>, relative_url: &'a str, - query: &'a [(&'a str, &'a str)]) -> impl Future, reqwest::Error>> + 'a - { - self.get(method_id, region, relative_url, query) - } - fn is_none_status_code(status: &StatusCode) -> bool { Self::NONE_STATUS_CODES.contains(&status.as_u16()) } @@ -120,9 +114,4 @@ impl<'a> RegionalRequester<'a> { #[cfg(test)] mod tests { use super::*; - - fn send_sync() { - fn is_send_sync() {} - is_send_sync::(); - } } diff --git a/src/req/requester_manager.rs b/src/req/requester_manager.rs index b6b8320..54e1fa3 100644 --- a/src/req/requester_manager.rs +++ b/src/req/requester_manager.rs @@ -21,7 +21,7 @@ pub struct RequesterManager<'a> { impl<'a> RequesterManager<'a> { pub fn new(riot_api_config: RiotApiConfig<'a>) -> Self { - // TODO client. + // TODO configure client. let client = Client::new(); Self { riot_api_config: riot_api_config, @@ -34,7 +34,7 @@ impl<'a> RequesterManager<'a> { &'a self, method_id: &'a str, region: &'a Region<'a>, relative_url: &'_ str, query: &[(&'_ str, &'_ str)]) -> Result, reqwest::Error> { - // TODO: max concurrent requests? + // TODO: max concurrent requests? Or can configure client? let regional_requester = self.regional_requesters .get_or_insert_with(region, || RegionalRequester::new(&self.riot_api_config, &self.client)); regional_requester.get(method_id, region, relative_url, query).await diff --git a/src/req/token_bucket.rs b/src/req/token_bucket.rs index acf0805..4d203cd 100644 --- a/src/req/token_bucket.rs +++ b/src/req/token_bucket.rs @@ -97,13 +97,8 @@ impl TokenBucket for VectorTokenBucket { mod tests { use super::*; - fn send_sync() { - fn is_send_sync() {} - is_send_sync::(); - } - - #[test] - fn it_works() { - assert_eq!(2 + 2, 4); - } + // #[test] + // fn it_works() { + // assert_eq!(2 + 2, 4); + // } } diff --git a/src/util/insert_only_chashmap.rs b/src/util/insert_only_chashmap.rs index bc51796..9a496aa 100644 --- a/src/util/insert_only_chashmap.rs +++ b/src/util/insert_only_chashmap.rs @@ -17,14 +17,14 @@ impl InsertOnlyCHashMap { } } - #[inline] - pub fn get(&self, key: &Q) -> Option> - where - K: Borrow, - Q: Hash + Eq, - { - self.base.lock().get(key).map(|v| Arc::clone(v)) - } + // #[inline] + // pub fn get(&self, key: &Q) -> Option> + // where + // K: Borrow, + // Q: Hash + Eq, + // { + // self.base.lock().get(key).map(|v| Arc::clone(v)) + // } #[inline] pub fn get_or_insert_with V>(&self, key: K, default: F) -> Arc