[Fix] Clean
Some checks failed
CI / checks (push) Failing after 2m37s

This commit is contained in:
Alex 2026-08-19 11:46:40 +02:00
commit d11eb04d12
Signed by: alex
SSH key fingerprint: SHA256:D1+Ub8o0v4K5y1JNivW8IxEOelqLSvPmUzBbDIoZkRQ
13 changed files with 163 additions and 973 deletions

View file

@ -47,7 +47,7 @@ fn pong(tm: &TypeMap, data: impl Into<String>) -> Result<CommunicationValue, Str
CommunicationValue::from_comm(CommunicationType::Pong, tm)
.add_data(desc_id, DataValue::Str("MTP example response".into()))
.map_err(|e| e.to_string())?
.add_data(ts_id, DataValue::UnsignedNumber(now as u128))
.add_data(ts_id, DataValue::UnsignedNumber(now))
.map_err(|e| e.to_string())?
.add_data(data_id, DataValue::Str(data.into()))
.map_err(|e| e.to_string())
@ -388,7 +388,7 @@ pub fn process_and_respond(
let response = CommunicationValue::from_comm(CommunicationType::Pong, tm)
.add_data(desc_id, description)
.map_err(|e| e.to_string())?
.add_data(ts_id, DataValue::UnsignedNumber(now as u128))
.add_data(ts_id, DataValue::UnsignedNumber(now))
.map_err(|e| e.to_string())?
.add_data(
data_id,

View file

@ -100,10 +100,10 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
serde_json::to_string_pretty(&*db).ok()
};
if let Some(json) = json {
if let Err(error) = tokio::fs::write("clients.json", json).await {
eprintln!("Failed to persist clients.json: {error}");
}
if let Some(json) = json
&& let Err(error) = tokio::fs::write("clients.json", json).await
{
eprintln!("Failed to persist clients.json: {error}");
}
println!("Registered new client with ID: {id}");

View file

@ -108,6 +108,7 @@ pub struct ServerMetrics {
}
impl ServerMetrics {
#[cfg(test)]
pub fn new() -> Self {
Self {
inner: Mutex::new(Inner {
@ -218,6 +219,7 @@ impl ServerMetrics {
}
}
#[cfg(test)]
pub fn snapshot(&self) -> ServerMetricsFile {
let inner = self.inner.lock().unwrap();
self.to_file(&inner)
@ -553,11 +555,11 @@ mod tests {
let metrics = ServerMetrics::new();
for i in 0..3 {
let mut session = metrics.start_session(1000 + i as u64, format!("session {i}"));
let mut session = metrics.start_session(1000 + i, format!("session {i}"));
for _ in 0..(i + 1) * 2 {
session.record_message(Duration::from_millis(1 + i), true);
}
session.record_pipe((i as u64 + 1) * 1000);
session.record_pipe((i + 1) * 1000);
session.finish(format!("exit {i}"));
}