use crate::errors::CrawlError;
use std::time::Duration;
use tokio::time::Instant;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct LoadSnapshot {
pub at: Instant,
pub overloaded: bool,
}
#[async_trait::async_trait]
pub trait LoadSignal: Send + Sync + 'static {
fn name(&self) -> &str;
fn overload_threshold(&self) -> f32;
async fn start(&self) -> Result<(), CrawlError> {
Ok(())
}
async fn stop(&self) -> Result<(), CrawlError> {
Ok(())
}
fn sample(&self, window: Duration) -> Vec<LoadSnapshot>;
}