Signed-off-by: kjuulh <contact@kjuulh.io>
This commit is contained in:
parent
463e49ecf3
commit
aee6ba54c6
@ -63,7 +63,7 @@
|
|||||||
let intervalNow = Math.floor(Date.now() / 1000) - 1;
|
let intervalNow = Math.floor(Date.now() / 1000) - 1;
|
||||||
setInterval(() => {
|
setInterval(() => {
|
||||||
const unixTimestampNow = Math.floor(Date.now() / 1000);
|
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) => {
|
.then((resp) => {
|
||||||
if (resp.ok) {
|
if (resp.ok) {
|
||||||
return resp.json()
|
return resp.json()
|
||||||
|
@ -134,30 +134,31 @@ async fn main() -> anyhow::Result<()> {
|
|||||||
.add_fn(move |cancel| {
|
.add_fn(move |cancel| {
|
||||||
let state = state.clone();
|
let state = state.clone();
|
||||||
async move {
|
async move {
|
||||||
let nodrift_cancel = nodrift::schedule(std::time::Duration::from_millis(1), {
|
let nodrift_cancel =
|
||||||
let state = state.clone();
|
nodrift::schedule(std::time::Duration::from_millis(100), {
|
||||||
move || {
|
|
||||||
let state = state.clone();
|
let state = state.clone();
|
||||||
let mut rng = rand::thread_rng();
|
move || {
|
||||||
let category_index = rng.gen_range(0..CATEGORIES.len());
|
let state = state.clone();
|
||||||
|
let mut rng = rand::thread_rng();
|
||||||
|
let category_index = rng.gen_range(0..CATEGORIES.len());
|
||||||
|
|
||||||
async move {
|
async move {
|
||||||
state
|
state
|
||||||
.event_metrics
|
.event_metrics
|
||||||
.push_event(Event {
|
.push_event(Event {
|
||||||
event_name: CATEGORIES[category_index].to_string(),
|
event_name: CATEGORIES[category_index].to_string(),
|
||||||
timestamp: std::time::SystemTime::now()
|
timestamp: std::time::SystemTime::now()
|
||||||
.duration_since(UNIX_EPOCH)
|
.duration_since(UNIX_EPOCH)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.as_secs()
|
.as_secs()
|
||||||
as usize,
|
as usize,
|
||||||
})
|
})
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
});
|
|
||||||
|
|
||||||
tokio::select! {
|
tokio::select! {
|
||||||
_ = cancel.cancelled() => {
|
_ = cancel.cancelled() => {
|
||||||
|
Loading…
Reference in New Issue
Block a user