From f0e64e0c1d2f83e31df089b8cbae8a35a5935dc3 Mon Sep 17 00:00:00 2001 From: qpismont Date: Fri, 31 Jul 2026 20:32:59 +0000 Subject: [PATCH] Fix fmt --- .devcontainer/Dockerfile | 3 +- .zed/settings.json | 6 ++++ crates/devcontainer-rs/src/lib.rs | 4 ++- crates/herald-server/src/bot.rs | 4 ++- crates/herald-server/src/main.rs | 7 +++- crates/herald-server/src/metrics.rs | 50 ++++++++++++++++++++++------- 6 files changed, 58 insertions(+), 16 deletions(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index dd02efa..ba2efc9 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -19,7 +19,8 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ RUN groupadd --gid ${USER_GID:-1000} $USERNAME \ && useradd --uid ${USER_UID:-1000} --gid ${USER_GID:-1000} -m $USERNAME \ - && rustup component add clippy + && rustup component add clippy \ + && rustup component add rustfmt diff --git a/.zed/settings.json b/.zed/settings.json index d569920..afccddd 100644 --- a/.zed/settings.json +++ b/.zed/settings.json @@ -1,4 +1,10 @@ { + "languages": { + "Rust": { + "format_on_save": "on", + "formatter": "language_server" + } + }, "lsp": { "rust-analyzer": { "initialization_options": { diff --git a/crates/devcontainer-rs/src/lib.rs b/crates/devcontainer-rs/src/lib.rs index 1dd6d69..81960de 100644 --- a/crates/devcontainer-rs/src/lib.rs +++ b/crates/devcontainer-rs/src/lib.rs @@ -67,7 +67,9 @@ pub enum ParseError { impl TryFrom<(DevContainerSchema, PathBuf)> for DevContainer { type Error = ParseError; - fn try_from((schema, devcontainer_path): (DevContainerSchema, PathBuf)) -> Result { + fn try_from( + (schema, devcontainer_path): (DevContainerSchema, PathBuf), + ) -> Result { let base_dir = devcontainer_path .parent() .ok_or_else(|| ParseError::InvalidDevContainerPath(devcontainer_path.clone()))?; diff --git a/crates/herald-server/src/bot.rs b/crates/herald-server/src/bot.rs index 470990f..12ba2d7 100644 --- a/crates/herald-server/src/bot.rs +++ b/crates/herald-server/src/bot.rs @@ -1,5 +1,7 @@ use crate::{ - gitea::{GiteaAPI, WebhookType}, metrics, open_router::OpenRouterClient, + gitea::{GiteaAPI, WebhookType}, + metrics, + open_router::OpenRouterClient, }; use serde::Deserialize; use std::{collections::HashSet, sync::Arc}; diff --git a/crates/herald-server/src/main.rs b/crates/herald-server/src/main.rs index 27d0554..3a5ab03 100644 --- a/crates/herald-server/src/main.rs +++ b/crates/herald-server/src/main.rs @@ -1,4 +1,9 @@ -use crate::{bot::Bot, gitea::{GiteaAPI, WebhookType}, open_router::OpenRouterClient, state::AppState}; +use crate::{ + bot::Bot, + gitea::{GiteaAPI, WebhookType}, + open_router::OpenRouterClient, + state::AppState, +}; use dotenvy::dotenv; use tokio::signal::unix::{SignalKind, signal}; diff --git a/crates/herald-server/src/metrics.rs b/crates/herald-server/src/metrics.rs index 23698d8..44d3347 100644 --- a/crates/herald-server/src/metrics.rs +++ b/crates/herald-server/src/metrics.rs @@ -1,10 +1,9 @@ use std::{net::SocketAddr, str::FromStr}; -use metrics::{Unit, describe_counter, describe_gauge, counter, gauge}; +use metrics::{Unit, counter, describe_counter, describe_gauge, gauge}; pub fn webhook_received(event_type: &str) { - counter!("herald_webhooks_received_total", "event_type" => event_type.to_string()) - .increment(1); + counter!("herald_webhooks_received_total", "event_type" => event_type.to_string()).increment(1); } pub fn webhook_duplicate(event_type: &str) { @@ -31,8 +30,7 @@ pub fn task_completed(event_type: &str) { } pub fn task_failed(event_type: &str) { - counter!("herald_bot_tasks_failed_total", "event_type" => event_type.to_string()) - .increment(1); + counter!("herald_bot_tasks_failed_total", "event_type" => event_type.to_string()).increment(1); } pub fn openrouter_cost_usd(cost: f64) { @@ -40,13 +38,41 @@ pub fn openrouter_cost_usd(cost: f64) { } pub fn describe() { - describe_counter!("herald_webhooks_received_total", Unit::Count, "Total webhooks received"); - describe_counter!("herald_webhooks_duplicate_total", Unit::Count, "Webhooks rejected as duplicates"); - describe_counter!("herald_webhooks_channel_full_total", Unit::Count, "Webhooks dropped because the bot channel was full"); - describe_gauge!("herald_bot_tasks_active", Unit::Count, "Bot tasks currently in progress"); - describe_counter!("herald_bot_tasks_completed_total", Unit::Count, "Bot tasks completed successfully"); - describe_counter!("herald_bot_tasks_failed_total", Unit::Count, "Bot tasks that failed"); - describe_counter!("herald_openrouter_cost_cents_total", Unit::Count, "Total OpenRouter cost in cents (divide by 100 for USD)"); + describe_counter!( + "herald_webhooks_received_total", + Unit::Count, + "Total webhooks received" + ); + describe_counter!( + "herald_webhooks_duplicate_total", + Unit::Count, + "Webhooks rejected as duplicates" + ); + describe_counter!( + "herald_webhooks_channel_full_total", + Unit::Count, + "Webhooks dropped because the bot channel was full" + ); + describe_gauge!( + "herald_bot_tasks_active", + Unit::Count, + "Bot tasks currently in progress" + ); + describe_counter!( + "herald_bot_tasks_completed_total", + Unit::Count, + "Bot tasks completed successfully" + ); + describe_counter!( + "herald_bot_tasks_failed_total", + Unit::Count, + "Bot tasks that failed" + ); + describe_counter!( + "herald_openrouter_cost_cents_total", + Unit::Count, + "Total OpenRouter cost in cents (divide by 100 for USD)" + ); } pub fn install(bind_addr: &str) -> anyhow::Result<()> {