use tokio::sync::broadcast;

#[derive(Clone)]
pub struct RtrNotifier {
    tx: broadcast::Sender<()>,
}

impl RtrNotifier {
    pub fn new(tx: broadcast::Sender<()>) -> Self {
        Self { tx }
    }

    pub fn notify_cache_updated(&self) -> usize {
        self.tx.send(()).unwrap_or_default()
    }

    pub fn listener_count(&self) -> usize {
        self.tx.receiver_count()
    }
}
