feat: add retires and errors on uncessessful attempts

This commit is contained in:
Jet Pham 2025-06-05 19:39:20 -07:00
parent 0c2e129bbd
commit cfc5f01221
No known key found for this signature in database
5 changed files with 136 additions and 28 deletions

View file

@ -13,12 +13,19 @@ async fn main() -> Result<()> {
tracing_subscriber::fmt::init();
const DEFAULT_GPIO_PIN: u8 = 17;
const DEFAULT_WEBHOOK_RETRIES: u32 = 3;
let gpio_pin = std::env::var("GPIO_PIN")
.ok()
.and_then(|v| v.parse().ok())
.unwrap_or(DEFAULT_GPIO_PIN);
let webhook_notifier = webhook::WebhookNotifier::new()?;
let webhook_retries = std::env::var("WEBHOOK_RETRIES")
.ok()
.and_then(|v| v.parse().ok())
.unwrap_or(DEFAULT_WEBHOOK_RETRIES);
let webhook_notifier = webhook::WebhookNotifier::new(webhook_retries)?;
let mut gpio_monitor = gpio::GpioMonitor::new(gpio_pin, Duration::from_millis(100))?;
let callback = move |event: gpio::CircuitEvent| {