pub mod downstream;
pub mod error;
pub mod job_declarator;
pub mod proxy_config;
pub mod status;
pub mod template_receiver;
pub mod upstream_sv2;
use std::{sync::atomic::AtomicBool, time::Duration};
pub static IS_NEW_TEMPLATE_HANDLED: AtomicBool = AtomicBool::new(true);
#[derive(Debug)]
pub struct PoolChangerTrigger {
timeout: Duration,
task: Option<tokio::task::JoinHandle<()>>,
}
impl PoolChangerTrigger {
pub fn new(timeout: Duration) -> Self {
Self {
timeout,
task: None,
}
}
pub fn start(&mut self, sender: status::Sender) {
let timeout = self.timeout;
let task = tokio::task::spawn(async move {
tokio::time::sleep(timeout).await;
let _ = sender
.send(status::Status {
state: status::State::UpstreamRogue,
})
.await;
});
self.task = Some(task);
}
pub fn stop(&mut self) {
if let Some(task) = self.task.take() {
task.abort();
}
}
}