Expand description
Multi-source configuration management Copyright © 2025-2026 Wenze Wei. All Rights Reserved.
This file is part of DMSC. The DMSC project belongs to the Dunimd Team.
Licensed under the Apache License, Version 2.0 (the “License”); You may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
§Configuration Management
This module provides a comprehensive configuration management system for DMSC, supporting multiple configuration sources, hot reload, and flexible configuration access.
§Key Components
- DMSCConfig: Basic configuration storage with typed access methods
- DMSCConfigManager: Configuration manager that handles multiple sources and hot reload
- DMSCConfigSource: Internal enum for different configuration source types
§Design Principles
- Multiple Sources: Supports configuration from files (JSON, YAML, TOML) and environment variables
- Source Priority: Environment variables override file configuration
- Typed Access: Provides type-safe methods for accessing configuration values
- Flattened Structure: All configuration is flattened into a single key-value store with dot notation
- Hot Reload Support: Simplified hot reload implementation with full support planned for future
- Default Sources: Automatically loads configuration from common locations
§Usage
use dmsc::prelude::*;
fn example() -> DMSCResult<()> {
// Create a new config manager
let mut config_manager = DMSCConfigManager::new();
// Add configuration sources
config_manager.add_file_source("config.yaml");
config_manager.add_environment_source();
// Load configuration
config_manager.load()?;
// Access configuration values
let config = config_manager.config();
let port = config.get_u64("server.port").unwrap_or(8080);
let debug = config.get_bool("app.debug").unwrap_or(false);
Ok(())
}Structs§
- DMSC
Config - Basic configuration storage with typed access methods.
- DMSC
Config Manager - Public-facing configuration manager with hot reload support.
- DMSC
Config Validator