From b7a8c3fddbf975c563d0020e2909a958efb03cba Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Mon, 16 Mar 2026 15:25:46 -0700 Subject: [PATCH] Format pending Rust server updates --- seaweed-volume/src/server/grpc_server.rs | 43 ++++++++++++----------- seaweed-volume/src/server/handlers.rs | 21 ++++++----- seaweed-volume/src/server/heartbeat.rs | 8 ++--- seaweed-volume/src/server/request_id.rs | 11 +++--- seaweed-volume/src/server/server_stats.rs | 1 - seaweed-volume/src/server/ui.rs | 16 +++++++-- 6 files changed, 57 insertions(+), 43 deletions(-) diff --git a/seaweed-volume/src/server/grpc_server.rs b/seaweed-volume/src/server/grpc_server.rs index ce973dc03..f6a99d807 100644 --- a/seaweed-volume/src/server/grpc_server.rs +++ b/seaweed-volume/src/server/grpc_server.rs @@ -103,8 +103,8 @@ impl VolumeGrpcService { channel, super::request_id::outgoing_request_id_interceptor, ) - .max_decoding_message_size(GRPC_MAX_MESSAGE_SIZE) - .max_encoding_message_size(GRPC_MAX_MESSAGE_SIZE); + .max_decoding_message_size(GRPC_MAX_MESSAGE_SIZE) + .max_encoding_message_size(GRPC_MAX_MESSAGE_SIZE); client .volume_mark_readonly(master_pb::VolumeMarkReadonlyRequest { ip: info.ip.clone(), @@ -901,12 +901,13 @@ impl VolumeServer for VolumeGrpcService { )) })?; - let mut client = volume_server_pb::volume_server_client::VolumeServerClient::with_interceptor( - channel, - super::request_id::outgoing_request_id_interceptor, - ) - .max_decoding_message_size(GRPC_MAX_MESSAGE_SIZE) - .max_encoding_message_size(GRPC_MAX_MESSAGE_SIZE); + let mut client = + volume_server_pb::volume_server_client::VolumeServerClient::with_interceptor( + channel, + super::request_id::outgoing_request_id_interceptor, + ) + .max_decoding_message_size(GRPC_MAX_MESSAGE_SIZE) + .max_encoding_message_size(GRPC_MAX_MESSAGE_SIZE); // Get file status from source let vol_info = client @@ -1636,12 +1637,13 @@ impl VolumeServer for VolumeGrpcService { .await .map_err(|e| Status::internal(format!("connect to {}: {}", grpc_addr, e)))?; - let mut client = volume_server_pb::volume_server_client::VolumeServerClient::with_interceptor( - channel, - super::request_id::outgoing_request_id_interceptor, - ) - .max_decoding_message_size(GRPC_MAX_MESSAGE_SIZE) - .max_encoding_message_size(GRPC_MAX_MESSAGE_SIZE); + let mut client = + volume_server_pb::volume_server_client::VolumeServerClient::with_interceptor( + channel, + super::request_id::outgoing_request_id_interceptor, + ) + .max_decoding_message_size(GRPC_MAX_MESSAGE_SIZE) + .max_encoding_message_size(GRPC_MAX_MESSAGE_SIZE); // Call VolumeTailSender on source let mut stream = client @@ -1905,12 +1907,13 @@ impl VolumeServer for VolumeGrpcService { )) })?; - let mut client = volume_server_pb::volume_server_client::VolumeServerClient::with_interceptor( - channel, - super::request_id::outgoing_request_id_interceptor, - ) - .max_decoding_message_size(GRPC_MAX_MESSAGE_SIZE) - .max_encoding_message_size(GRPC_MAX_MESSAGE_SIZE); + let mut client = + volume_server_pb::volume_server_client::VolumeServerClient::with_interceptor( + channel, + super::request_id::outgoing_request_id_interceptor, + ) + .max_decoding_message_size(GRPC_MAX_MESSAGE_SIZE) + .max_encoding_message_size(GRPC_MAX_MESSAGE_SIZE); // Copy each shard for &shard_id in &req.shard_ids { diff --git a/seaweed-volume/src/server/handlers.rs b/seaweed-volume/src/server/handlers.rs index ebde2b0d2..0e74569fd 100644 --- a/seaweed-volume/src/server/handlers.rs +++ b/seaweed-volume/src/server/handlers.rs @@ -1797,14 +1797,12 @@ pub async fn post_handler( // Fix JPEG orientation from EXIF data before storing (matches Go behavior). // Only for non-compressed uploads that are JPEG files. - let body_data = if state.fix_jpg_orientation - && !is_gzipped - && crate::images::is_jpeg(&mime_type, &path) - { - crate::images::fix_jpg_orientation(&body_data_raw) - } else { - body_data_raw - }; + let body_data = + if state.fix_jpg_orientation && !is_gzipped && crate::images::is_jpeg(&mime_type, &path) { + crate::images::fix_jpg_orientation(&body_data_raw) + } else { + body_data_raw + }; // H3: Capture original data size BEFORE auto-compression let original_data_size = body_data.len() as u32; @@ -2405,7 +2403,12 @@ pub async fn stats_disk_handler( pub async fn favicon_handler() -> Response { let asset = super::ui::favicon_asset(); - (StatusCode::OK, [(header::CONTENT_TYPE, asset.content_type)], asset.bytes).into_response() + ( + StatusCode::OK, + [(header::CONTENT_TYPE, asset.content_type)], + asset.bytes, + ) + .into_response() } pub async fn static_asset_handler(Path(path): Path) -> Response { diff --git a/seaweed-volume/src/server/heartbeat.rs b/seaweed-volume/src/server/heartbeat.rs index 532aaf106..22760671c 100644 --- a/seaweed-volume/src/server/heartbeat.rs +++ b/seaweed-volume/src/server/heartbeat.rs @@ -226,8 +226,8 @@ async fn try_get_master_configuration( channel, super::request_id::outgoing_request_id_interceptor, ) - .max_decoding_message_size(GRPC_MAX_MESSAGE_SIZE) - .max_encoding_message_size(GRPC_MAX_MESSAGE_SIZE); + .max_decoding_message_size(GRPC_MAX_MESSAGE_SIZE) + .max_encoding_message_size(GRPC_MAX_MESSAGE_SIZE); let resp = client .get_master_configuration(master_pb::GetMasterConfigurationRequest {}) .await?; @@ -256,8 +256,8 @@ async fn do_heartbeat( channel, super::request_id::outgoing_request_id_interceptor, ) - .max_decoding_message_size(GRPC_MAX_MESSAGE_SIZE) - .max_encoding_message_size(GRPC_MAX_MESSAGE_SIZE); + .max_decoding_message_size(GRPC_MAX_MESSAGE_SIZE) + .max_encoding_message_size(GRPC_MAX_MESSAGE_SIZE); let (tx, rx) = tokio::sync::mpsc::channel::(32); diff --git a/seaweed-volume/src/server/request_id.rs b/seaweed-volume/src/server/request_id.rs index 6af2008e6..f3e43c560 100644 --- a/seaweed-volume/src/server/request_id.rs +++ b/seaweed-volume/src/server/request_id.rs @@ -78,9 +78,7 @@ pub fn current_request_id() -> Option { CURRENT_REQUEST_ID.try_with(Clone::clone).ok() } -pub fn outgoing_request_id_interceptor( - mut request: Request<()>, -) -> Result, Status> { +pub fn outgoing_request_id_interceptor(mut request: Request<()>) -> Result, Status> { if let Some(request_id) = current_request_id() { let value = MetadataValue::try_from(request_id.as_str()) .map_err(|_| Status::internal("invalid scoped request id"))?; @@ -112,9 +110,10 @@ mod tests { #[tokio::test] async fn test_scope_request_id_exposes_current_value() { let request_id = "req-123".to_string(); - let current = scope_request_id(request_id.clone(), async move { - current_request_id().unwrap() - }) + let current = scope_request_id( + request_id.clone(), + async move { current_request_id().unwrap() }, + ) .await; assert_eq!(current, request_id); } diff --git a/seaweed-volume/src/server/server_stats.rs b/seaweed-volume/src/server/server_stats.rs index ae42848b7..bdfa37d33 100644 --- a/seaweed-volume/src/server/server_stats.rs +++ b/seaweed-volume/src/server/server_stats.rs @@ -238,4 +238,3 @@ pub fn reset_for_tests() { let mut inner = SERVER_STATS.inner.lock().unwrap(); *inner = ServerStatsInner::default(); } - diff --git a/seaweed-volume/src/server/ui.rs b/seaweed-volume/src/server/ui.rs index 4bc2dfa72..f1f830a56 100644 --- a/seaweed-volume/src/server/ui.rs +++ b/seaweed-volume/src/server/ui.rs @@ -365,7 +365,14 @@ pub fn render_volume_server_html(state: &VolumeServerState) -> String { ) } -fn collect_ui_data(store: &Store) -> (Vec, Vec, Vec, Vec) { +fn collect_ui_data( + store: &Store, +) -> ( + Vec, + Vec, + Vec, + Vec, +) { let mut disk_rows = Vec::new(); let mut volumes = Vec::new(); let mut remote_volumes = Vec::new(); @@ -484,7 +491,11 @@ fn bytes_to_human_readable(bytes: u64) -> String { exp += 1; } - format!("{:.2} {}iB", bytes as f64 / div as f64, ["K", "M", "G", "T", "P", "E"][exp]) + format!( + "{:.2} {}iB", + bytes as f64 / div as f64, + ["K", "M", "G", "T", "P", "E"][exp] + ) } fn escape_html(input: &str) -> String { @@ -494,4 +505,3 @@ fn escape_html(input: &str) -> String { .replace('>', ">") .replace('"', """) } -