aboutsummaryrefslogtreecommitdiffstats
path: root/src/api/dashboard/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/api/dashboard/mod.rs')
-rw-r--r--src/api/dashboard/mod.rs17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/api/dashboard/mod.rs b/src/api/dashboard/mod.rs
index 1d63f38..7a643d0 100644
--- a/src/api/dashboard/mod.rs
+++ b/src/api/dashboard/mod.rs
@@ -250,13 +250,21 @@ impl Hub {
};
logged = last.seq;
by_node(&self.state, &mut messages).await;
- if let Ok(json) = serde_json::to_string(&messages) {
- let _ = self.messages.send(Arc::new(json));
- }
+ let batch = json!({ "sent": now_millis(), "messages": messages });
+ let _ = self.messages.send(Arc::new(batch.to_string()));
}
}
}
+/// Unix milliseconds by the system's clock, as the message log stamps messages
+/// (`Logged::at`): when a batch of them goes, so the page tells the time they waited
+/// in the node from the time they took on the way.
+fn now_millis() -> u64 {
+ std::time::SystemTime::now()
+ .duration_since(std::time::UNIX_EPOCH)
+ .map_or(0, |since| since.as_millis() as u64)
+}
+
/// A task stopped when this is dropped.
struct AbortOnDrop(tokio::task::JoinHandle<()>);
@@ -605,7 +613,8 @@ async fn own_messages_events(Extension(hub): Extension<Arc<Hub>>) -> impl IntoRe
Some(json)
})
.collect();
- yield Ok(Event::default().event("messages").data(JsonValue::Array(messages).to_string()));
+ let batch = json!({ "sent": now_millis(), "messages": messages });
+ yield Ok(Event::default().event("messages").data(batch.to_string()));
}
};
(