~vpzom/lotide

eb570ccfee42c1b0e10bc2b6d2e022bf2eba2be8 — Colin Reeder 13 days ago a2b6f67 ratelimit
Remove logging from ratelimit, increase rate to a more reasonable number
2 files changed, 1 insertions(+), 5 deletions(-)

M src/main.rs
M src/ratelimit.rs
M src/main.rs => src/main.rs +1 -1
@@ 937,7 937,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
        host_url_apub,
        http_client: hyper::Client::builder().build(hyper_tls::HttpsConnector::new()),
        apub_proxy_rewrites,
        api_ratelimit: ratelimit::RatelimitBucket::new(1),
        api_ratelimit: ratelimit::RatelimitBucket::new(300),
    });

    let worker_trigger = worker::start_worker(base_context.clone());

M src/ratelimit.rs => src/ratelimit.rs +0 -4
@@ 22,7 22,6 @@ impl<K: Eq + std::hash::Hash + std::fmt::Debug> RatelimitBucket<K> {
        let inner = self.inner.read().await;
        let seconds_into = now.duration_since(inner.divider_time).as_secs();
        if seconds_into >= 60 {
            println!("new minute");
            std::mem::drop(inner);
            let mut inner = self.inner.write().await;



@@ 53,7 52,6 @@ impl<K: Eq + std::hash::Hash + std::fmt::Debug> RatelimitBucket<K> {
    }

    async fn try_for_current(&self, seconds_into: u64, inner: &Inner<K>, key: K) -> bool {
        println!("key={:?}", key);
        let prev_count = if let Some(last_minute) = &inner.last_minute {
            if let Some(prev_count) = last_minute.get(&key) {
                (u64::from(prev_count.load(std::sync::atomic::Ordering::Relaxed))


@@ 73,8 71,6 @@ impl<K: Eq + std::hash::Hash + std::fmt::Debug> RatelimitBucket<K> {
                .or_default()
                .fetch_add(1, std::sync::atomic::Ordering::SeqCst);

        println!("count={:?}", count);

        count < self.cap
    }
}