Settings¶
settings ¶
Application Settings - Configuration Management.
Provides centralized configuration management using singleton pattern to ensure consistent settings across the application.
Classes:
| Name | Description |
|---|---|
Settings | Application settings manager with YAML configuration support |
Classes¶
Settings ¶
Application settings manager with singleton pattern.
Loads configuration from YAML file and provides access to settings throughout the application. Only one instance exists per application.
Attributes:
| Name | Type | Description |
|---|---|---|
config_file | Path | Path to configuration YAML file |
_settings | Dict[str, Any] | Loaded settings dictionary |
Methods:
| Name | Description |
|---|---|
get | Get setting value by dot-notation key |
set | Set setting value by dot-notation key |
get_section | Get entire settings section |
reload | Reload settings from file |
save | Save current settings to YAML file |
get_all | Get all settings |
Initialize settings.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config_file | Optional[Path] | Path to YAML configuration file. Defaults to 'config/settings.yaml'. | None |
Source code in src/infrastructure/config/settings.py
Functions¶
__new__ ¶
Singleton implementation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config_file | Optional[Path] | Path to config file. Only used on first instantiation. | None |
Source code in src/infrastructure/config/settings.py
get ¶
Get setting value by dot-notation key.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key | str | Setting key in dot notation (e.g., 'cache.max_size') | required |
default | Any | Default value if key not found | None |
Returns:
| Type | Description |
|---|---|
Any | Setting value or default |
Source code in src/infrastructure/config/settings.py
set ¶
Set setting value by dot-notation key.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key | str | Setting key in dot notation | required |
value | Any | Value to set | required |
Source code in src/infrastructure/config/settings.py
get_section ¶
Get entire settings section.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
section | str | Section name (e.g., 'cache') | required |
Returns:
| Type | Description |
|---|---|
Dict[str, Any] | Section dictionary or empty dict if not found |
Source code in src/infrastructure/config/settings.py
reload ¶
save ¶
Save current settings to YAML file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
output_file | Optional[Path] | Output file path. If None, uses original config_file. | None |
Source code in src/infrastructure/config/settings.py
get_all ¶
Get all settings.
Returns:
| Type | Description |
|---|---|
Dict[str, Any] | Complete settings dictionary. |