initial integration with telem viz

This commit is contained in:
2026-01-02 15:36:50 -05:00
parent 59b5679dda
commit 275cb07c4c
16 changed files with 1408 additions and 190 deletions

View File

@@ -1,10 +1,9 @@
#![warn(clippy::all, clippy::pedantic)]
use log::info;
use std::sync::Arc;
use std::sync::atomic::{AtomicBool, Ordering};
pub mod command;
pub mod logger;
pub mod on_drop;
pub mod telemetry;
pub mod udp;
@@ -12,10 +11,25 @@ pub mod udp;
///
/// # Errors
/// If a system error occurred while trying to set the ctrl-c handler
pub fn add_ctrlc_handler(flag: Arc<AtomicBool>) -> anyhow::Result<()> {
pub fn add_ctrlc_handler_arc(
flag: std::sync::Arc<std::sync::atomic::AtomicBool>,
) -> anyhow::Result<()> {
ctrlc::set_handler(move || {
info!("Shutdown Requested");
flag.store(false, Ordering::Relaxed);
flag.store(false, std::sync::atomic::Ordering::Relaxed);
})?;
Ok(())
}
/// Add a ctrl-c handler which will set an atomic flag to `false` when ctrl-c is detected
///
/// # Errors
/// If a system error occurred while trying to set the ctrl-c handler
#[cfg(feature = "async")]
pub fn add_ctrlc_handler_cancel(cancel: tokio_util::sync::CancellationToken) -> anyhow::Result<()> {
ctrlc::set_handler(move || {
info!("Shutdown Requested");
cancel.cancel();
})?;
Ok(())
}