refactor(config): migrate server config consumers (#3353)

This commit is contained in:
安正超
2026-06-11 17:04:50 +08:00
committed by GitHub
parent 2205991180
commit ca58d7f0ec
53 changed files with 238 additions and 213 deletions
+1 -1
View File
@@ -27,7 +27,7 @@ categories = ["web-programming", "development-tools", "asynchronous", "api-bindi
[dependencies]
rustfs-targets = { workspace = true }
rustfs-config = { workspace = true, features = ["audit", "constants"] }
rustfs-config = { workspace = true, features = ["audit", "constants", "server-config-model"] }
rustfs-ecstore = { workspace = true }
rustfs-s3-types = { workspace = true }
chrono = { workspace = true }
+1 -1
View File
@@ -33,7 +33,7 @@ rustfs-audit = "0.1"
```rust
use rustfs_audit::{start_audit_system, AuditLogger};
use rustfs_ecstore::config::Config;
use rustfs_config::server_config::Config;
#[tokio::main]
async fn main() {
+1 -1
View File
@@ -31,8 +31,8 @@ pub fn builtin_target_plugins() -> Vec<TargetPluginDescriptor<AuditEntry>> {
mod tests {
use super::builtin_target_descriptors;
use rustfs_config::audit::AUDIT_AMQP_KEYS;
use rustfs_config::server_config::KVS;
use rustfs_config::{AMQP_EXCHANGE, AMQP_QUEUE_DIR, AMQP_ROUTING_KEY, AMQP_URL};
use rustfs_ecstore::config::KVS;
use rustfs_targets::target::ChannelTargetType;
fn amqp_base_config() -> KVS {
+1 -1
View File
@@ -13,7 +13,7 @@
// limitations under the License.
use crate::{AuditEntry, AuditResult, AuditSystem, system::AuditTargetMetricSnapshot};
use rustfs_ecstore::config::Config;
use rustfs_config::server_config::Config;
use std::sync::{Arc, OnceLock};
use tracing::{debug, error, trace, warn};
+1 -1
View File
@@ -14,7 +14,7 @@
use crate::{AuditEntry, AuditError, AuditResult, factory::builtin_target_plugins};
use rustfs_config::audit::AUDIT_ROUTE_PREFIX;
use rustfs_ecstore::config::{Config, KVS};
use rustfs_config::server_config::{Config, KVS};
use rustfs_targets::arn::TargetID;
use rustfs_targets::{SharedTarget, Target, TargetError, TargetPluginRegistry, TargetRuntimeManager};
use tracing::info;
+3 -3
View File
@@ -16,7 +16,7 @@ use crate::{
AuditEntry, AuditError, AuditRegistry, AuditResult, observability,
pipeline::{AuditPipeline, AuditRuntimeFacade, AuditRuntimeView},
};
use rustfs_ecstore::config::Config;
use rustfs_config::server_config::Config;
use rustfs_targets::{ReplayWorkerManager, Target};
use std::sync::Arc;
use tokio::sync::{Mutex, RwLock};
@@ -537,7 +537,7 @@ mod tests {
}
system
.reload_config(rustfs_ecstore::config::Config(HashMap::new()))
.reload_config(rustfs_config::server_config::Config(HashMap::new()))
.await
.expect("reload with empty config should succeed");
@@ -545,6 +545,6 @@ mod tests {
assert!(system.list_targets().await.is_empty());
assert_eq!(system.runtime_status_snapshot().await, ReplayWorkerManager::new().snapshot(0));
assert_eq!(close_calls.load(Ordering::SeqCst), 1);
assert_eq!(*system.config.read().await, Some(rustfs_ecstore::config::Config(HashMap::new())));
assert_eq!(*system.config.read().await, Some(rustfs_config::server_config::Config(HashMap::new())));
}
}
+1 -1
View File
@@ -14,7 +14,7 @@
//! Tests for audit configuration parsing and validation
use rustfs_ecstore::config::KVS;
use rustfs_config::server_config::KVS;
#[test]
fn test_webhook_valid_fields() {
+1 -1
View File
@@ -13,7 +13,7 @@
// limitations under the License.
use rustfs_audit::*;
use rustfs_ecstore::config::{Config, KVS};
use rustfs_config::server_config::{Config, KVS};
use std::collections::HashMap;
use temp_env::with_vars;
+5 -5
View File
@@ -26,7 +26,7 @@ async fn test_audit_system_startup_performance() {
let start = Instant::now();
// Create minimal config for testing
let config = rustfs_ecstore::config::Config(std::collections::HashMap::new());
let config = rustfs_config::server_config::Config(std::collections::HashMap::new());
// System should start quickly even with empty config
let _result = timeout(Duration::from_secs(5), system.start(config)).await;
@@ -47,12 +47,12 @@ async fn test_concurrent_target_creation() {
let registry = AuditRegistry::new();
// Create config with multiple webhook instances
let mut config = rustfs_ecstore::config::Config(std::collections::HashMap::new());
let mut config = rustfs_config::server_config::Config(std::collections::HashMap::new());
let mut webhook_section = std::collections::HashMap::new();
// Create multiple instances for concurrent creation test
for i in 1..=5 {
let mut kvs = rustfs_ecstore::config::KVS::new();
let mut kvs = rustfs_config::server_config::KVS::new();
kvs.insert("enable".to_string(), "on".to_string());
kvs.insert("endpoint".to_string(), format!("http://localhost:302{i}/webhook"));
webhook_section.insert(format!("instance_{i}"), kvs);
@@ -90,7 +90,7 @@ async fn test_audit_log_dispatch_performance() {
let system = AuditSystem::new();
// Create minimal config
let config = rustfs_ecstore::config::Config(HashMap::new());
let config = rustfs_config::server_config::Config(HashMap::new());
let start_result = system.start(config).await;
if start_result.is_err() {
println!("AuditSystem failed to start: {start_result:?}");
@@ -186,7 +186,7 @@ async fn test_system_state_transitions() {
assert_eq!(system.get_state().await, rustfs_audit::system::AuditSystemState::Stopped);
// Start system
let config = rustfs_ecstore::config::Config(std::collections::HashMap::new());
let config = rustfs_config::server_config::Config(std::collections::HashMap::new());
let start_result = system.start(config).await;
// Empty config keeps the audit system stopped even when start() succeeds.
@@ -15,7 +15,7 @@
//! Comprehensive integration tests for the complete audit system
use rustfs_audit::*;
use rustfs_ecstore::config::{Config, KVS};
use rustfs_config::server_config::{Config, KVS};
use std::collections::HashMap;
use std::sync::Arc;
use std::time::Duration;