From aee6ba54c638a704362b47e335eb62a111b55752 Mon Sep 17 00:00:00 2001 From: kjuulh Date: Fri, 22 Nov 2024 12:57:08 +0100 Subject: [PATCH] feat: use actual url Signed-off-by: kjuulh --- crates/iamalive/assets/html/index.html | 2 +- crates/iamalive/src/main.rs | 41 +++++++++++++------------- 2 files changed, 22 insertions(+), 21 deletions(-) diff --git a/crates/iamalive/assets/html/index.html b/crates/iamalive/assets/html/index.html index 9393bb9..e49112c 100644 --- a/crates/iamalive/assets/html/index.html +++ b/crates/iamalive/assets/html/index.html @@ -63,7 +63,7 @@ let intervalNow = Math.floor(Date.now() / 1000) - 1; setInterval(() => { const unixTimestampNow = Math.floor(Date.now() / 1000); - let resp = fetch("http://localhost:3000/metrics?start=" + intervalNow + "&end=" + unixTimestampNow) + let resp = fetch("https://iamvisual.prod.kjuulh.app/metrics?start=" + intervalNow + "&end=" + unixTimestampNow) .then((resp) => { if (resp.ok) { return resp.json() diff --git a/crates/iamalive/src/main.rs b/crates/iamalive/src/main.rs index ed5497c..1e0ee9e 100644 --- a/crates/iamalive/src/main.rs +++ b/crates/iamalive/src/main.rs @@ -134,30 +134,31 @@ async fn main() -> anyhow::Result<()> { .add_fn(move |cancel| { let state = state.clone(); async move { - let nodrift_cancel = nodrift::schedule(std::time::Duration::from_millis(1), { - let state = state.clone(); - move || { + let nodrift_cancel = + nodrift::schedule(std::time::Duration::from_millis(100), { let state = state.clone(); - let mut rng = rand::thread_rng(); - let category_index = rng.gen_range(0..CATEGORIES.len()); + move || { + let state = state.clone(); + let mut rng = rand::thread_rng(); + let category_index = rng.gen_range(0..CATEGORIES.len()); - async move { - state - .event_metrics - .push_event(Event { - event_name: CATEGORIES[category_index].to_string(), - timestamp: std::time::SystemTime::now() - .duration_since(UNIX_EPOCH) - .unwrap() - .as_secs() - as usize, - }) - .await; + async move { + state + .event_metrics + .push_event(Event { + event_name: CATEGORIES[category_index].to_string(), + timestamp: std::time::SystemTime::now() + .duration_since(UNIX_EPOCH) + .unwrap() + .as_secs() + as usize, + }) + .await; - Ok(()) + Ok(()) + } } - } - }); + }); tokio::select! { _ = cancel.cancelled() => {