Vaultx.Config (Vaultx v0.7.0)
View SourceModern configuration management system for VaultX.
This module provides the main interface to the configuration system, delegating to specialized modules for specific functionality.
Architecture
- Config: Main configuration interface (this module)
- Builder: Configuration building and environment merging
- Validator: Configuration validation and error checking
- Optimizer: Performance and security optimization suggestions
- Diagnostics: Health monitoring and diagnostics
Usage Examples
# Get configuration
config = Vaultx.Config.get()
# Get specific values
url = Vaultx.Config.get_value(:url)
# Validate configuration
:ok = Vaultx.Config.validate()
# Get health status
status = Vaultx.Config.health_status()
Summary
Functions
Performs comprehensive configuration analysis.
Provides backward-compatible diagnose function for legacy code.
Modern feature management with intelligent analysis.
Gets comprehensive feature status with recommendations.
Gets the complete configuration.
Gets the configuration health status.
Gets a specific configuration value by key.
Gets multiple configuration values efficiently.
Checks if a configuration key exists and has a non-nil value.
Provides a comprehensive health check of the configuration system.
Validates the current configuration.
Validates and provides optimization recommendations.
Types
Functions
@spec analyze() :: {:ok, config_analysis()}
Performs comprehensive configuration analysis.
Examples
iex> {:ok, analysis} = Vaultx.Config.analyze()
iex> analysis.valid
true
@spec diagnose() :: %{ valid: boolean(), warnings: [String.t()], errors: [String.t()], recommendations: [String.t()] }
Provides backward-compatible diagnose function for legacy code.
This function converts the modern analysis format to the legacy format expected by existing code.
Examples
iex> Vaultx.Config.diagnose()
%{
valid: true,
warnings: [],
errors: [],
recommendations: []
}
Modern feature management with intelligent analysis.
This provides enhanced feature detection and recommendations.
@spec features_status() :: %{ enabled: [atom()], disabled: [atom()], recommendations: [String.t()] }
Gets comprehensive feature status with recommendations.
@spec get() :: map()
Gets the complete configuration.
This is the primary configuration access method that provides a clean, validated configuration map.
@spec get_health_status() :: :healthy | :degraded | :unhealthy | :critical
Gets the configuration health status.
This provides a quick health assessment without complex analysis.
Examples
iex> Vaultx.Config.get_health_status()
:healthy
Gets a specific configuration value by key.
Examples
iex> Vaultx.Config.get_value(:url)
"https://vault.example.com:8200"
iex> Vaultx.Config.get_value(:timeout, 60_000)
30000
Gets multiple configuration values efficiently.
Examples
iex> Vaultx.Config.get_values([:url, :timeout, :ssl_verify])
%{url: "https://vault.example.com:8200", timeout: 30000, ssl_verify: true}
Checks if a configuration key exists and has a non-nil value.
@spec health_status() :: :healthy | :degraded | :unhealthy | :critical
Provides a comprehensive health check of the configuration system.
@spec validate() :: :ok | {:error, [String.t()]}
Validates the current configuration.
Examples
iex> Vaultx.Config.validate()
:ok
iex> Vaultx.Config.validate()
{:error, ["URL is required", "Invalid timeout value"]}
@spec validate_and_optimize() :: {:ok, map()}
Validates and provides optimization recommendations.
Examples
iex> {:ok, result} = Vaultx.Config.validate_and_optimize()
iex> result.optimization_potential
:low