This commit is contained in:
houseme
2025-06-09 12:25:56 +08:00
parent 152ad57c1d
commit 28c71cc351
12 changed files with 23 additions and 315 deletions

163
Cargo.lock generated
View File

@@ -242,12 +242,6 @@ dependencies = [
"password-hash",
]
[[package]]
name = "arraydeque"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7d902e3d592a523def97af8f317b08ce16b7ab854c1985a0c671e6f15cebc236"
[[package]]
name = "arrayref"
version = "0.3.9"
@@ -1823,25 +1817,6 @@ dependencies = [
"crossbeam-utils",
]
[[package]]
name = "config"
version = "0.15.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "595aae20e65c3be792d05818e8c63025294ac3cb7e200f11459063a352a6ef80"
dependencies = [
"async-trait",
"convert_case 0.6.0",
"json5",
"pathdiff",
"ron",
"rust-ini",
"serde",
"serde_json",
"toml",
"winnow 0.7.10",
"yaml-rust2",
]
[[package]]
name = "console_error_panic_hook"
version = "0.1.7"
@@ -3480,15 +3455,6 @@ dependencies = [
"syn 2.0.101",
]
[[package]]
name = "dlv-list"
version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "442039f5147480ba31067cb00ada1adae6892028e40e45fc5de7b7df6dcc1b5f"
dependencies = [
"const-random",
]
[[package]]
name = "dotenvy"
version = "0.15.7"
@@ -4569,15 +4535,6 @@ dependencies = [
"foldhash",
]
[[package]]
name = "hashlink"
version = "0.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7382cf6263419f2d8df38c55d7da83da5c18aef87fc7a7fc1fb1e344edfe14c1"
dependencies = [
"hashbrown 0.15.3",
]
[[package]]
name = "heck"
version = "0.4.1"
@@ -5286,17 +5243,6 @@ dependencies = [
"wasm-bindgen",
]
[[package]]
name = "json5"
version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "96b0db21af676c1ce64250b5f40f3ce2cf27e4e47cb91ed91eb6fe9350b430c1"
dependencies = [
"pest",
"pest_derive",
"serde",
]
[[package]]
name = "jsonwebtoken"
version = "9.3.1"
@@ -6665,16 +6611,6 @@ dependencies = [
"num-traits",
]
[[package]]
name = "ordered-multimap"
version = "0.7.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "49203cdcae0030493bad186b28da2fa25645fa276a51b6fec8010d281e02ef79"
dependencies = [
"dlv-list",
"hashbrown 0.14.5",
]
[[package]]
name = "ordered-stream"
version = "0.2.0"
@@ -6873,12 +6809,6 @@ dependencies = [
"once_cell",
]
[[package]]
name = "pathdiff"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "df94ce210e5bc13cb6651479fa48d14f601d9858cfe0467f43ae157023b938d3"
[[package]]
name = "pbkdf2"
version = "0.12.2"
@@ -6914,51 +6844,6 @@ version = "2.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e"
[[package]]
name = "pest"
version = "2.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "198db74531d58c70a361c42201efde7e2591e976d518caf7662a47dc5720e7b6"
dependencies = [
"memchr",
"thiserror 2.0.12",
"ucd-trie",
]
[[package]]
name = "pest_derive"
version = "2.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d725d9cfd79e87dccc9341a2ef39d1b6f6353d68c4b33c177febbe1a402c97c5"
dependencies = [
"pest",
"pest_generator",
]
[[package]]
name = "pest_generator"
version = "2.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "db7d01726be8ab66ab32f9df467ae8b1148906685bbe75c82d1e65d7f5b3f841"
dependencies = [
"pest",
"pest_meta",
"proc-macro2",
"quote",
"syn 2.0.101",
]
[[package]]
name = "pest_meta"
version = "2.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7f9f832470494906d1fca5329f8ab5791cc60beb230c74815dff541cbd2b5ca0"
dependencies = [
"once_cell",
"pest",
"sha2 0.10.9",
]
[[package]]
name = "petgraph"
version = "0.7.1"
@@ -7999,18 +7884,6 @@ dependencies = [
"serde",
]
[[package]]
name = "ron"
version = "0.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b91f7eff05f748767f183df4320a63d6936e9c6107d97c9e6bdd9784f4289c94"
dependencies = [
"base64 0.21.7",
"bitflags 2.9.1",
"serde",
"serde_derive",
]
[[package]]
name = "rsa"
version = "0.9.8"
@@ -8138,17 +8011,6 @@ dependencies = [
"triomphe",
]
[[package]]
name = "rust-ini"
version = "0.21.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4e310ef0e1b6eeb79169a1171daf9abcb87a2e17c03bee2c4bb100b55c75409f"
dependencies = [
"cfg-if",
"ordered-multimap",
"trim-in-place",
]
[[package]]
name = "rustc-demangle"
version = "0.1.24"
@@ -8259,7 +8121,6 @@ dependencies = [
name = "rustfs-config"
version = "0.0.1"
dependencies = [
"config",
"const-str",
"serde",
"serde_json",
@@ -8293,7 +8154,6 @@ dependencies = [
"async-trait",
"axum",
"common",
"config",
"dotenvy",
"ecstore",
"lazy_static",
@@ -10258,12 +10118,6 @@ dependencies = [
"windows-sys 0.59.0",
]
[[package]]
name = "trim-in-place"
version = "0.1.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "343e926fc669bc8cde4fa3129ab681c63671bae288b1f1081ceee6d9d37904fc"
[[package]]
name = "triomphe"
version = "0.1.14"
@@ -10347,12 +10201,6 @@ dependencies = [
"tz-rs",
]
[[package]]
name = "ucd-trie"
version = "0.1.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2896d95c02a80c6d6a5d6e953d479f5ddf2dfdb6a244441010e373ac0fb88971"
[[package]]
name = "uds_windows"
version = "1.1.0"
@@ -11493,17 +11341,6 @@ dependencies = [
"lzma-sys",
]
[[package]]
name = "yaml-rust2"
version = "0.10.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "18b783b2c2789414f8bb84ca3318fc9c2d7e7be1c22907d37839a58dedb369d3"
dependencies = [
"arraydeque",
"encoding_rs",
"hashlink",
]
[[package]]
name = "yoke"
version = "0.8.0"

View File

@@ -75,12 +75,10 @@ cfg-if = "1.0.0"
chacha20poly1305 = { version = "0.10.1" }
chrono = { version = "0.4.41", features = ["serde"] }
clap = { version = "4.5.39", features = ["derive", "env"] }
config = "0.15.11"
const-str = { version = "0.6.2", features = ["std", "proc"] }
crc32fast = "1.4.2"
datafusion = "46.0.1"
derive_builder = "0.20.2"
dotenvy = "0.15.7"
dioxus = { version = "0.6.3", features = ["router"] }
dirs = "6.0.0"
dotenvy = "0.15.7"

View File

@@ -7,11 +7,17 @@ rust-version.workspace = true
version.workspace = true
[dependencies]
config = { workspace = true }
const-str = { workspace = true }
const-str = { workspace = true, optional = true }
serde = { workspace = true }
serde_json = { workspace = true }
[lints]
workspace = true
[features]
default = []
constants = ["dep:const-str"]
notify = []
observability = []

View File

@@ -1,116 +0,0 @@
use crate::ObservabilityConfig;
/// RustFs configuration
pub struct RustFsConfig {
pub observability: ObservabilityConfig,
}
impl RustFsConfig {
pub fn new() -> Self {
Self {
observability: ObservabilityConfig::new(),
}
}
}
impl Default for RustFsConfig {
fn default() -> Self {
Self::new()
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_rustfs_config_new() {
let config = RustFsConfig::new();
// Verify that observability config is properly initialized
assert!(!config.observability.sinks.is_empty(), "Observability sinks should not be empty");
assert!(config.observability.logger.is_some(), "Logger config should be present");
}
#[test]
fn test_rustfs_config_default() {
let config = RustFsConfig::default();
// Default should be equivalent to new()
let new_config = RustFsConfig::new();
// Compare observability config
assert_eq!(config.observability.sinks.len(), new_config.observability.sinks.len());
assert_eq!(config.observability.logger.is_some(), new_config.observability.logger.is_some());
}
#[test]
fn test_rustfs_config_components_independence() {
let mut config = RustFsConfig::new();
// Modify observability config
config.observability.sinks.clear();
// Create new config to verify independence
let new_config = RustFsConfig::new();
assert!(!new_config.observability.sinks.is_empty(), "New config should have default sinks");
}
#[test]
fn test_rustfs_config_observability_integration() {
let config = RustFsConfig::new();
// Test observability config properties
assert!(config.observability.otel.endpoint.is_empty() || !config.observability.otel.endpoint.is_empty());
assert!(config.observability.otel.use_stdout.is_some());
assert!(config.observability.otel.sample_ratio.is_some());
assert!(config.observability.otel.meter_interval.is_some());
assert!(config.observability.otel.service_name.is_some());
assert!(config.observability.otel.service_version.is_some());
assert!(config.observability.otel.environment.is_some());
assert!(config.observability.otel.logger_level.is_some());
}
#[test]
fn test_rustfs_config_memory_usage() {
// Test that config doesn't use excessive memory
let config = RustFsConfig::new();
// Basic memory usage checks
assert!(std::mem::size_of_val(&config) < 10000, "Config should not use excessive memory");
// Test that collections are reasonably sized
assert!(config.observability.sinks.len() < 100, "Sinks collection should be reasonably sized");
}
#[test]
fn test_rustfs_config_serialization_compatibility() {
let config = RustFsConfig::new();
// Test that observability config can be serialized (it has Serialize trait)
let observability_json = serde_json::to_string(&config.observability);
assert!(observability_json.is_ok(), "Observability config should be serializable");
}
#[test]
fn test_rustfs_config_debug_format() {
let config = RustFsConfig::new();
// Test that observability config has Debug trait
let observability_debug = format!("{:?}", config.observability);
assert!(!observability_debug.is_empty(), "Observability config should have debug output");
assert!(
observability_debug.contains("ObservabilityConfig"),
"Debug output should contain type name"
);
}
#[test]
fn test_rustfs_config_clone_behavior() {
let config = RustFsConfig::new();
// Test that observability config can be cloned
let observability_clone = config.observability.clone();
assert_eq!(observability_clone.sinks.len(), config.observability.sinks.len());
}
}

View File

@@ -1,9 +1,10 @@
use crate::observability::config::ObservabilityConfig;
mod config;
mod constants;
mod notify;
mod observability;
pub use config::RustFsConfig;
#[cfg(feature = "constants")]
pub mod constants;
#[cfg(feature = "constants")]
pub use constants::app::*;
#[cfg(feature = "notify")]
pub mod notify;
#[cfg(feature = "observability")]
pub mod observability;

View File

@@ -1,5 +1,5 @@
pub mod config;
pub mod webhook;
pub mod mqtt;
pub mod help;
pub mod legacy;
pub mod mqtt;
pub mod webhook;

View File

@@ -14,7 +14,6 @@ kafka = ["dep:rdkafka"]
[dependencies]
async-trait = { workspace = true }
config = { workspace = true }
common = { workspace = true }
ecstore = { workspace = true }
lazy_static = { workspace = true }

View File

@@ -1,4 +1,3 @@
use config::ConfigError;
use thiserror::Error;
use tokio::sync::mpsc::error;
use tokio::task::JoinError;
@@ -35,8 +34,6 @@ pub enum Error {
Custom(String),
#[error("Configuration error: {0}")]
ConfigError(String),
#[error("Configuration loading error: {0}")]
Config(#[from] ConfigError),
#[error("create adapter failed error: {0}")]
AdapterCreationFailed(String),
}
@@ -150,20 +147,6 @@ mod tests {
}
}
#[test]
fn test_config_error_conversion() {
// Test configuration error conversion
let config_error = ConfigError::Message("invalid configuration".to_string());
let converted_error: Error = config_error.into();
match converted_error {
Error::Config(_) => {
assert!(converted_error.to_string().contains("Configuration loading error"));
}
_ => panic!("Expected Config error variant"),
}
}
#[tokio::test]
async fn test_channel_send_error_conversion() {
// Test channel send error conversion

View File

@@ -17,7 +17,7 @@ webhook = ["dep:reqwest"]
kafka = ["dep:rdkafka"]
[dependencies]
rustfs-config = { workspace = true }
rustfs-config = { workspace = true, features = ["constants"] }
async-trait = { workspace = true }
chrono = { workspace = true }
flexi_logger = { workspace = true, features = ["trc", "kv"] }

View File

@@ -8,7 +8,7 @@ version.workspace = true
[dependencies]
local-ip-address = { workspace = true, optional = true }
rustfs-config = { workspace = true }
rustfs-config = { workspace = true, features = ["constants"] }
rustls = { workspace = true, optional = true }
rustls-pemfile = { workspace = true, optional = true }
rustls-pki-types = { workspace = true, optional = true }

View File

@@ -11,7 +11,7 @@ rust-version.workspace = true
workspace = true
[dependencies]
rustfs-config = { workspace = true }
rustfs-config = { workspace = true, features = ["constants"] }
async-trait.workspace = true
backon.workspace = true
blake2 = { workspace = true }

View File

@@ -57,7 +57,7 @@ protos.workspace = true
query = { workspace = true }
regex = { workspace = true }
rmp-serde.workspace = true
rustfs-config = { workspace = true }
rustfs-config = { workspace = true, features = ["constants"] }
rustfs-notify = { workspace = true }
rustfs-obs = { workspace = true }
rustfs-utils = { workspace = true, features = ["full"] }