Constellation, Spacedust, Slingshot, UFOs: atproto crates and services for microcosm
1use crate::error::HealthCheckError; 2use reqwest::Client; 3use std::time::Duration; 4use tokio::time::sleep; 5use tokio_util::sync::CancellationToken; 6 7pub async fn healthcheck( 8 endpoint: String, 9 shutdown: CancellationToken, 10) -> Result<(), HealthCheckError> { 11 let client = Client::builder() 12 .user_agent(format!( 13 "microcosm slingshot v{} (dev: @bad-example.com)", 14 env!("CARGO_PKG_VERSION") 15 )) 16 .no_proxy() 17 .timeout(Duration::from_secs(10)) 18 .build()?; 19 20 loop { 21 tokio::select! { 22 res = client.get(&endpoint).send() => { 23 let _ = res 24 .and_then(|r| r.error_for_status()) 25 .inspect_err(|e| log::error!("failed to send healthcheck: {e}")); 26 }, 27 _ = shutdown.cancelled() => break, 28 } 29 sleep(Duration::from_secs(51)).await; 30 } 31 Ok(()) 32}