Skip to main content

fixed_monitor/
fixed_monitor.rs

1use std::{error::Error, time::Duration};
2
3use beatwise::{Monitor, TaskConfig, Timing};
4
5fn main() -> Result<(), Box<dyn Error>> {
6    let monitor = Monitor::new();
7    let heartbeat = monitor.register(TaskConfig::new(
8        "fixed-worker",
9        Timing::fixed(Duration::from_secs(1)),
10    ))?;
11
12    heartbeat.beat()?;
13
14    for status in monitor.snapshot() {
15        println!(
16            "id={} name={} heartbeats={} health={:?}",
17            status.id.get(),
18            status.name,
19            status.heartbeat_count,
20            status.health,
21        );
22    }
23
24    Ok(())
25}