mirror of
https://github.com/rustfs/rustfs.git
synced 2026-08-19 19:16:17 +00:00
style: format code for consistency and readability
This commit is contained in:
@@ -53,7 +53,7 @@ pub(crate) struct Config {
|
|||||||
s3: S3,
|
s3: S3,
|
||||||
release: Release,
|
release: Release,
|
||||||
license: License,
|
license: License,
|
||||||
doc: String
|
doc: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Config {
|
impl Config {
|
||||||
@@ -74,7 +74,7 @@ impl Config {
|
|||||||
name: "Apache-2.0".to_string(),
|
name: "Apache-2.0".to_string(),
|
||||||
url: "https://www.apache.org/licenses/LICENSE-2.0".to_string(),
|
url: "https://www.apache.org/licenses/LICENSE-2.0".to_string(),
|
||||||
},
|
},
|
||||||
doc: "https://rustfs.com/docs/".to_string()
|
doc: "https://rustfs.com/docs/".to_string(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -162,10 +162,14 @@ pub async fn start_static_file_server(addrs: &str, local_ip: Ipv4Addr, access_ke
|
|||||||
let listener = tokio::net::TcpListener::bind(addrs).await.unwrap();
|
let listener = tokio::net::TcpListener::bind(addrs).await.unwrap();
|
||||||
let local_addr = listener.local_addr().unwrap();
|
let local_addr = listener.local_addr().unwrap();
|
||||||
|
|
||||||
timed_println!(format!("WebUI: http://{}:{} http://127.0.0.1:{}",
|
timed_println!(format!(
|
||||||
local_ip, local_addr.port(), local_addr.port()));
|
"WebUI: http://{}:{} http://127.0.0.1:{}",
|
||||||
|
local_ip,
|
||||||
|
local_addr.port(),
|
||||||
|
local_addr.port()
|
||||||
|
));
|
||||||
timed_println!(format!(" RootUser: {}", access_key));
|
timed_println!(format!(" RootUser: {}", access_key));
|
||||||
timed_println!(format!(" RootPass: {}", secret_key));
|
timed_println!(format!(" RootPass: {}", secret_key));
|
||||||
|
|
||||||
axum::serve(listener, app).await.unwrap();
|
axum::serve(listener, app).await.unwrap();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ use syn::{parse_macro_input, Expr, LitStr};
|
|||||||
pub fn timed_println(input: TokenStream) -> TokenStream {
|
pub fn timed_println(input: TokenStream) -> TokenStream {
|
||||||
// 解析输入
|
// 解析输入
|
||||||
let expr = parse_macro_input!(input as Expr);
|
let expr = parse_macro_input!(input as Expr);
|
||||||
|
|
||||||
// 生成带有时间戳的打印代码
|
// 生成带有时间戳的打印代码
|
||||||
let expanded = quote! {
|
let expanded = quote! {
|
||||||
{
|
{
|
||||||
@@ -15,17 +15,16 @@ pub fn timed_println(input: TokenStream) -> TokenStream {
|
|||||||
println!("{} rustfs: {}", timestamp, #expr);
|
println!("{} rustfs: {}", timestamp, #expr);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
TokenStream::from(expanded)
|
TokenStream::from(expanded)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#[proc_macro]
|
#[proc_macro]
|
||||||
pub fn timed_println_str(input: TokenStream) -> TokenStream {
|
pub fn timed_println_str(input: TokenStream) -> TokenStream {
|
||||||
// 尝试将输入解析为字符串字面量
|
// 尝试将输入解析为字符串字面量
|
||||||
let input_str = parse_macro_input!(input as LitStr);
|
let input_str = parse_macro_input!(input as LitStr);
|
||||||
let str_value = input_str.value();
|
let str_value = input_str.value();
|
||||||
|
|
||||||
// 生成带有时间戳的打印代码
|
// 生成带有时间戳的打印代码
|
||||||
let expanded = quote! {
|
let expanded = quote! {
|
||||||
{
|
{
|
||||||
@@ -34,6 +33,6 @@ pub fn timed_println_str(input: TokenStream) -> TokenStream {
|
|||||||
println!("{} rustfs: {}", timestamp, #str_value);
|
println!("{} rustfs: {}", timestamp, #str_value);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
TokenStream::from(expanded)
|
TokenStream::from(expanded)
|
||||||
}
|
}
|
||||||
|
|||||||
+8
-10
@@ -13,6 +13,7 @@ use rustfs_macro::timed_println;
|
|||||||
|
|
||||||
use crate::auth::IAMAuth;
|
use crate::auth::IAMAuth;
|
||||||
use crate::console::{init_console_cfg, CONSOLE_CONFIG};
|
use crate::console::{init_console_cfg, CONSOLE_CONFIG};
|
||||||
|
use chrono::Datelike;
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
use common::{
|
use common::{
|
||||||
error::{Error, Result},
|
error::{Error, Result},
|
||||||
@@ -44,15 +45,13 @@ use tokio::net::TcpListener;
|
|||||||
use tonic::{metadata::MetadataValue, Request, Status};
|
use tonic::{metadata::MetadataValue, Request, Status};
|
||||||
use tower_http::cors::CorsLayer;
|
use tower_http::cors::CorsLayer;
|
||||||
use tracing::{debug, error, info, warn};
|
use tracing::{debug, error, info, warn};
|
||||||
use chrono::Datelike;
|
|
||||||
use tracing_error::ErrorLayer;
|
use tracing_error::ErrorLayer;
|
||||||
use tracing_subscriber::{fmt, layer::SubscriberExt, util::SubscriberInitExt};
|
use tracing_subscriber::{fmt, layer::SubscriberExt, util::SubscriberInitExt};
|
||||||
|
|
||||||
fn setup_tracing() {
|
fn setup_tracing() {
|
||||||
use tracing_subscriber::EnvFilter;
|
use tracing_subscriber::EnvFilter;
|
||||||
|
|
||||||
let env_filter = EnvFilter::try_from_default_env()
|
let env_filter = EnvFilter::try_from_default_env().unwrap_or_else(|_| EnvFilter::new("info"));
|
||||||
.unwrap_or_else(|_| EnvFilter::new("info"));
|
|
||||||
let enable_color = std::io::stdout().is_terminal();
|
let enable_color = std::io::stdout().is_terminal();
|
||||||
|
|
||||||
let subscriber = fmt()
|
let subscriber = fmt()
|
||||||
@@ -80,7 +79,7 @@ fn check_auth(req: Request<()>) -> Result<Request<()>, Status> {
|
|||||||
fn print_server_info() {
|
fn print_server_info() {
|
||||||
let cfg = CONSOLE_CONFIG.get().unwrap();
|
let cfg = CONSOLE_CONFIG.get().unwrap();
|
||||||
let current_year = chrono::Utc::now().year();
|
let current_year = chrono::Utc::now().year();
|
||||||
|
|
||||||
// 使用过程宏打印服务器信息
|
// 使用过程宏打印服务器信息
|
||||||
timed_println!("RustFS Object Storage Server");
|
timed_println!("RustFS Object Storage Server");
|
||||||
timed_println!(format!("Copyright: 2024-{} RustFS, Inc", current_year));
|
timed_println!(format!("Copyright: 2024-{} RustFS, Inc", current_year));
|
||||||
@@ -135,14 +134,14 @@ async fn run(opt: config::Opt) -> Result<()> {
|
|||||||
for (i, eps) in endpoint_pools.as_ref().iter().enumerate() {
|
for (i, eps) in endpoint_pools.as_ref().iter().enumerate() {
|
||||||
info!(
|
info!(
|
||||||
"Formatting {}st pool, {} set(s), {} drives per set.",
|
"Formatting {}st pool, {} set(s), {} drives per set.",
|
||||||
i + 1, eps.set_count, eps.drives_per_set
|
i + 1,
|
||||||
|
eps.set_count,
|
||||||
|
eps.drives_per_set
|
||||||
);
|
);
|
||||||
|
|
||||||
// Add warning for host with multiple drives in a set (similar to RustFS)
|
// Add warning for host with multiple drives in a set (similar to RustFS)
|
||||||
if eps.drives_per_set > 1 {
|
if eps.drives_per_set > 1 {
|
||||||
warn!(
|
warn!("WARNING: Host local has more than 0 drives of set. A host failure will result in data becoming unavailable.");
|
||||||
"WARNING: Host local has more than 0 drives of set. A host failure will result in data becoming unavailable."
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -291,7 +290,6 @@ async fn run(opt: config::Opt) -> Result<()> {
|
|||||||
init_console_cfg(&srv_addr);
|
init_console_cfg(&srv_addr);
|
||||||
print_server_info();
|
print_server_info();
|
||||||
|
|
||||||
|
|
||||||
if opt.console_enable {
|
if opt.console_enable {
|
||||||
debug!("console is enabled");
|
debug!("console is enabled");
|
||||||
let access_key = opt.access_key.clone();
|
let access_key = opt.access_key.clone();
|
||||||
|
|||||||
+2
-2
@@ -5,6 +5,6 @@ pub(crate) fn get_local_ip() -> Option<std::net::Ipv4Addr> {
|
|||||||
match local_ip_address::local_ip() {
|
match local_ip_address::local_ip() {
|
||||||
Ok(IpAddr::V4(ip)) => Some(ip),
|
Ok(IpAddr::V4(ip)) => Some(ip),
|
||||||
Err(_) => None,
|
Err(_) => None,
|
||||||
Ok(IpAddr::V6(_)) => todo!()
|
Ok(IpAddr::V6(_)) => todo!(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user