use std::sync::Arc;
use std::time::Duration;
use clock_kit::Clock;
use crate::error::Result;
use crate::store::Store;
#[derive(Clone)]
pub struct CollectCtx {
pub clock: Arc<dyn Clock + Send + Sync>,
pub store: Arc<Store>,
pub pages: u32,
pub window_days: u32,
}
impl std::fmt::Debug for CollectCtx {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("CollectCtx")
.field("pages", &self.pages)
.field("window_days", &self.window_days)
.finish_non_exhaustive()
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct CollectReport {
pub source: &'static str,
pub items: usize,
pub pages: usize,
}
pub trait TrendSource {
fn name(&self) -> &'static str;
fn collect(&self, ctx: &CollectCtx)
-> impl std::future::Future<Output = Result<CollectReport>>;
}
pub const SEARCH_PACING: Duration = Duration::from_millis(2_200);
#[cfg(test)]
mod tests {
#![allow(clippy::unwrap_used, clippy::expect_used, clippy::panic)]
use super::*;
#[test]
fn pacing_meets_github_search_budget() {
assert!(SEARCH_PACING >= Duration::from_secs(2));
}
}