| 1 |
|
| 2 |
|
| 3 |
mod backup; |
| 4 |
mod ca_bundle; |
| 5 |
mod cors; |
| 6 |
mod dns; |
| 7 |
mod health; |
| 8 |
mod meta_alert; |
| 9 |
mod prune; |
| 10 |
mod routes; |
| 11 |
mod scan_pipeline; |
| 12 |
mod synckit_fleet; |
| 13 |
mod systemd; |
| 14 |
mod test_suite; |
| 15 |
mod tls; |
| 16 |
mod whois; |
| 17 |
|
| 18 |
use tokio_util::sync::CancellationToken; |
| 19 |
|
| 20 |
use pom::config::{Config, TargetConfig}; |
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
pub(crate) struct CheckInterval { |
| 32 |
interval: tokio::time::Interval, |
| 33 |
cancel: CancellationToken, |
| 34 |
startup_tick_pending: bool, |
| 35 |
} |
| 36 |
|
| 37 |
impl CheckInterval { |
| 38 |
pub(crate) fn new(interval_secs: u64, cancel: CancellationToken) -> Self { |
| 39 |
let mut interval = tokio::time::interval(std::time::Duration::from_secs(interval_secs)); |
| 40 |
interval.set_missed_tick_behavior(tokio::time::MissedTickBehavior::Delay); |
| 41 |
Self { |
| 42 |
interval, |
| 43 |
cancel, |
| 44 |
startup_tick_pending: true, |
| 45 |
} |
| 46 |
} |
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
pub(crate) async fn next(&mut self) -> bool { |
| 54 |
if self.startup_tick_pending { |
| 55 |
self.startup_tick_pending = false; |
| 56 |
self.interval.tick().await; |
| 57 |
} |
| 58 |
tokio::select! { |
| 59 |
() = self.cancel.cancelled() => false, |
| 60 |
_ = self.interval.tick() => true, |
| 61 |
} |
| 62 |
} |
| 63 |
} |
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
pub(crate) fn configured_targets( |
| 71 |
config: &Config, |
| 72 |
) -> impl Iterator<Item = (String, TargetConfig)> + use<'_> { |
| 73 |
config.target_names().into_iter().map(|name| { |
| 74 |
let target = config |
| 75 |
.get_target(&name) |
| 76 |
.expect("name came from target_names") |
| 77 |
.clone(); |
| 78 |
(name, target) |
| 79 |
}) |
| 80 |
} |
| 81 |
|
| 82 |
pub(crate) use backup::spawn_backup_tasks; |
| 83 |
pub(crate) use ca_bundle::spawn_ca_bundle_tasks; |
| 84 |
pub(crate) use cors::spawn_cors_tasks; |
| 85 |
pub(crate) use dns::spawn_dns_tasks; |
| 86 |
pub(crate) use health::spawn_health_tasks; |
| 87 |
pub(crate) use meta_alert::spawn_meta_alert_task; |
| 88 |
pub(crate) use prune::spawn_prune_task; |
| 89 |
pub(crate) use routes::spawn_route_tasks; |
| 90 |
pub(crate) use scan_pipeline::spawn_scan_pipeline_tasks; |
| 91 |
pub(crate) use synckit_fleet::spawn_synckit_fleet_tasks; |
| 92 |
pub(crate) use systemd::spawn_systemd_tasks; |
| 93 |
pub(crate) use test_suite::spawn_test_tasks; |
| 94 |
pub(crate) use tls::spawn_tls_tasks; |
| 95 |
pub(crate) use whois::spawn_whois_tasks; |
| 96 |
|