Config
provide.foundation.config
¶
TODO: Add module docstring.
Classes¶
BaseConfig
¶
Base configuration class with common functionality.
All configuration classes should inherit from this.
Note on Validation
The validate() method is synchronous. Subclasses can override it to add custom validation logic. If async validation is needed, subclasses should implement their own async validation methods.
Functions¶
__attrs_post_init__
¶
Post-initialization hook for subclasses.
Note: validate() is not called automatically to allow subclasses to perform validation at the appropriate time (e.g., after all fields are populated from multiple sources).
Source code in provide/foundation/config/base.py
__repr__
¶
String representation hiding sensitive fields.
Source code in provide/foundation/config/base.py
clone
¶
diff
¶
Compare with another configuration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
other
|
BaseConfig
|
Configuration to compare with |
required |
Returns:
| Type | Description |
|---|---|
dict[str, tuple[Any, Any]]
|
Dictionary of differences (field_name: (self_value, other_value)) |
Source code in provide/foundation/config/base.py
from_dict
classmethod
¶
Create configuration from dictionary.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
ConfigDict
|
Configuration data |
required |
source
|
ConfigSource
|
Source of the configuration |
RUNTIME
|
Returns:
| Type | Description |
|---|---|
Self
|
Configuration instance |
Raises:
| Type | Description |
|---|---|
ValidationError
|
If validation fails |
Source code in provide/foundation/config/base.py
get_source
¶
Get the source of a configuration field.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
field_name
|
str
|
Name of the field |
required |
Returns:
| Type | Description |
|---|---|
ConfigSource | None
|
Source of the field value or None |
Source code in provide/foundation/config/base.py
reset_to_defaults
¶
Reset all fields to their default values.
Source code in provide/foundation/config/base.py
to_dict
¶
Convert configuration to dictionary.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
include_sensitive
|
bool
|
Whether to include sensitive fields |
False
|
Returns:
| Type | Description |
|---|---|
ConfigDict
|
Dictionary representation of the configuration |
Source code in provide/foundation/config/base.py
update
¶
Update configuration with new values.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
updates
|
ConfigDict
|
Dictionary of updates |
required |
source
|
ConfigSource
|
Source of the updates |
RUNTIME
|
Raises:
| Type | Description |
|---|---|
ValidationError
|
If validation fails after update |
Source code in provide/foundation/config/base.py
validate
¶
Validate the configuration.
This is a synchronous validation method. Override this in subclasses to add custom validation logic. Call this explicitly after creating and populating a configuration instance.
Raises:
| Type | Description |
|---|---|
ValidationError
|
If validation fails |
Source code in provide/foundation/config/base.py
ConfigError
¶
ConfigError(
message: str,
*,
config_key: str | None = None,
config_source: str | None = None,
**kwargs: Any
)
Bases: FoundationError
Raised when configuration is invalid or cannot be loaded.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
message
|
str
|
Error message describing the configuration issue. |
required |
config_key
|
str | None
|
Optional configuration key that caused the error. |
None
|
config_source
|
str | None
|
Optional source of the configuration (file, env, etc.). |
None
|
**kwargs
|
Any
|
Additional context passed to FoundationError. |
{}
|
Examples:
>>> raise ConfigurationError("Missing required config")
>>> raise ConfigurationError("Invalid timeout", config_key="timeout")
Source code in provide/foundation/errors/config.py
ConfigLoader
¶
Bases: ABC
Abstract base class for configuration loaders.
Built-in implementations: - FileConfigLoader: YAML, JSON, TOML, .env files - RuntimeConfigLoader: Environment variables - DictConfigLoader: In-memory dictionaries
For cloud secret managers (Vault, AWS Secrets, Azure Key Vault), implement custom loaders following this protocol.
Examples: docs/guide/advanced/integration-patterns.md#custom-configuration-sources
ConfigManager
¶
Centralized configuration manager.
Manages multiple configuration objects and provides a unified interface.
Initialize configuration manager.
Source code in provide/foundation/config/manager.py
Functions¶
add_loader
¶
clear
¶
export
¶
Export a configuration as dictionary.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Configuration name |
required |
include_sensitive
|
bool
|
Whether to include sensitive fields |
False
|
Returns:
| Type | Description |
|---|---|
ConfigDict
|
Configuration dictionary |
Source code in provide/foundation/config/manager.py
export_all
¶
Export all configurations.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
include_sensitive
|
bool
|
Whether to include sensitive fields |
False
|
Returns:
| Type | Description |
|---|---|
dict[str, ConfigDict]
|
Dictionary of all configurations |
Source code in provide/foundation/config/manager.py
export_to_dict
¶
get
¶
Get a configuration by name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Configuration name |
required |
Returns:
| Type | Description |
|---|---|
BaseConfig | None
|
Configuration instance or None |
get_all
¶
get_or_create
¶
Get existing config or create new one with defaults.
Source code in provide/foundation/config/manager.py
list_configs
¶
load
¶
Load a configuration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Configuration name |
required |
config_class
|
type[T]
|
Configuration class |
required |
loader
|
ConfigLoader | None
|
Optional loader (uses registered if None) |
None
|
Returns:
| Type | Description |
|---|---|
T
|
Configuration instance |
Source code in provide/foundation/config/manager.py
load_from_dict
¶
register
¶
register(
name: str,
config: BaseConfig | None = None,
schema: ConfigSchema | None = None,
loader: ConfigLoader | None = None,
defaults: ConfigDict | None = None,
) -> None
Register a configuration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Configuration name |
required |
config
|
BaseConfig | None
|
Configuration instance |
None
|
schema
|
ConfigSchema | None
|
Configuration schema |
None
|
loader
|
ConfigLoader | None
|
Configuration loader |
None
|
defaults
|
ConfigDict | None
|
Default configuration values |
None
|
Source code in provide/foundation/config/manager.py
reload
¶
Reload a configuration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Configuration name |
required |
Returns:
| Type | Description |
|---|---|
BaseConfig
|
Reloaded configuration instance |
Source code in provide/foundation/config/manager.py
remove
¶
reset
¶
Reset a configuration to defaults.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Configuration name |
required |
Source code in provide/foundation/config/manager.py
set
¶
Set a configuration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Configuration name |
required |
config
|
BaseConfig
|
Configuration instance |
required |
unregister
¶
Unregister a configuration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Configuration name |
required |
Source code in provide/foundation/config/manager.py
update
¶
Update a configuration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Configuration name |
required |
updates
|
ConfigDict
|
Configuration updates |
required |
source
|
ConfigSource
|
Source of updates |
RUNTIME
|
Source code in provide/foundation/config/manager.py
validate_all
¶
Validate all configurations.
Source code in provide/foundation/config/manager.py
ConfigSchema
¶
Schema definition for configuration classes.
Initialize configuration schema.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
fields
|
list[SchemaField] | None
|
List of schema fields |
None
|
Source code in provide/foundation/config/schema.py
Functions¶
add_field
¶
apply_defaults
¶
Apply default values to configuration data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
ConfigDict
|
Configuration data |
required |
Returns:
| Type | Description |
|---|---|
ConfigDict
|
Data with defaults applied |
Source code in provide/foundation/config/schema.py
filter_extra_fields
¶
Remove fields not defined in schema.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
ConfigDict
|
Configuration data |
required |
Returns:
| Type | Description |
|---|---|
ConfigDict
|
Filtered data |
Source code in provide/foundation/config/schema.py
from_config_class
classmethod
¶
Generate schema from configuration class.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config_class
|
type[BaseConfig]
|
Configuration class |
required |
Returns:
| Type | Description |
|---|---|
ConfigSchema
|
Generated schema |
Source code in provide/foundation/config/schema.py
validate
¶
Validate configuration data against schema.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
ConfigDict
|
Configuration data to validate |
required |
Raises:
| Type | Description |
|---|---|
ConfigValidationError
|
If validation fails |
Source code in provide/foundation/config/schema.py
ConfigSource
¶
ConfigValidationError
¶
ConfigValidationError(
message: str,
*,
field: str | None = None,
value: Any = None,
rule: str | None = None,
**kwargs: Any
)
Bases: FoundationError
Raised when data validation fails.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
message
|
str
|
Validation error message. |
required |
field
|
str | None
|
Optional field name that failed validation. |
None
|
value
|
Any
|
Optional invalid value. |
None
|
rule
|
str | None
|
Optional validation rule that failed. |
None
|
**kwargs
|
Any
|
Additional context passed to FoundationError. |
{}
|
Examples:
>>> raise ValidationError("Invalid email format")
>>> raise ValidationError("Value out of range", field="age", value=-1)
Source code in provide/foundation/errors/config.py
DictConfigLoader
¶
Bases: ConfigLoader
Load configuration from a dictionary.
Initialize dictionary configuration loader.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
ConfigDict
|
Configuration data |
required |
source
|
ConfigSource
|
Source of the configuration |
RUNTIME
|
Source code in provide/foundation/config/loader.py
FileConfigLoader
¶
Bases: ConfigLoader
Load configuration from files.
Initialize file configuration loader.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str | Path
|
Path to configuration file |
required |
format
|
ConfigFormat | None
|
File format (auto-detected if None) |
None
|
encoding
|
str
|
File encoding |
'utf-8'
|
Source code in provide/foundation/config/loader.py
Functions¶
exists
¶
load
¶
Load configuration from file.
Source code in provide/foundation/config/loader.py
MultiSourceLoader
¶
Bases: ConfigLoader
Load configuration from multiple sources with precedence.
Initialize multi-source configuration loader.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*loaders
|
ConfigLoader
|
Configuration loaders in order of precedence (later overrides earlier) |
()
|
Source code in provide/foundation/config/loader.py
Functions¶
exists
¶
load
¶
Load and merge configuration from multiple sources.
Source code in provide/foundation/config/loader.py
RuntimeConfig
¶
Bases: BaseConfig
Configuration that can be loaded from environment variables.
Functions¶
from_env
classmethod
¶
Load configuration from environment variables synchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
prefix
|
str
|
Prefix for all environment variables |
''
|
delimiter
|
str
|
Delimiter between prefix and field name |
'_'
|
case_sensitive
|
bool
|
Whether variable names are case-sensitive |
False
|
Returns:
| Type | Description |
|---|---|
Self
|
Configuration instance |
Source code in provide/foundation/config/env.py
to_env_dict
¶
Convert configuration to environment variable dictionary.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
prefix
|
str
|
Prefix for all environment variables |
''
|
delimiter
|
str
|
Delimiter between prefix and field name |
'_'
|
Returns:
| Type | Description |
|---|---|
dict[str, str]
|
Dictionary of environment variables |
Source code in provide/foundation/config/env.py
SchemaField
¶
Schema definition for a configuration field.
Functions¶
validate
¶
Validate a value against this schema field.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
Any
|
Value to validate |
required |
Raises:
| Type | Description |
|---|---|
ConfigValidationError
|
If validation fails |
Source code in provide/foundation/config/schema.py
Functions¶
env_field
¶
env_field(
env_var: str | None = None,
env_prefix: str | None = None,
parser: Callable[[str], Any] | None = None,
**kwargs: Any
) -> Any
Create a field that can be loaded from environment variables.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
env_var
|
str | None
|
Explicit environment variable name |
None
|
env_prefix
|
str | None
|
Prefix for environment variable |
None
|
parser
|
Callable[[str], Any] | None
|
Custom parser function |
None
|
**kwargs
|
Any
|
Additional field arguments |
{}
|
Returns:
| Type | Description |
|---|---|
Any
|
Field descriptor |
Source code in provide/foundation/config/env.py
field
¶
field(
*,
default: Any = NOTHING,
factory: Callable[[], Any] | None = None,
validator: (
Callable[[Any, Attribute[Any], Any], None] | None
) = None,
converter: Callable[[Any], Any] | None = None,
metadata: dict[str, Any] | None = None,
description: str | None = None,
env_var: str | None = None,
env_prefix: str | None = None,
sensitive: bool = False,
**kwargs: Any
) -> Any
Enhanced attrs field with configuration-specific metadata.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
default
|
Any
|
Default value for the field |
NOTHING
|
factory
|
Callable[[], Any] | None
|
Factory function to generate default value |
None
|
validator
|
Callable[[Any, Attribute[Any], Any], None] | None
|
Validation function |
None
|
converter
|
Callable[[Any], Any] | None
|
Conversion function |
None
|
metadata
|
dict[str, Any] | None
|
Additional metadata |
None
|
description
|
str | None
|
Human-readable description |
None
|
env_var
|
str | None
|
Environment variable name override |
None
|
env_prefix
|
str | None
|
Prefix for environment variable |
None
|
sensitive
|
bool
|
Whether this field contains sensitive data |
False
|
**kwargs
|
Any
|
Additional attrs field arguments |
{}
|
Source code in provide/foundation/config/base.py
get_config
¶
Get a configuration from the global manager.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Configuration name |
required |
Returns:
| Type | Description |
|---|---|
BaseConfig | None
|
Configuration instance or None |
get_env
¶
get_env(
var_name: str,
default: str | None = None,
required: bool = False,
secret_file: bool = True,
) -> str | None
Get environment variable value with optional file-based secret support.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
var_name
|
str
|
Environment variable name |
required |
default
|
str | None
|
Default value if not found |
None
|
required
|
bool
|
Whether the variable is required |
False
|
secret_file
|
bool
|
Whether to support file:// prefix for secrets |
True
|
Returns:
| Type | Description |
|---|---|
str | None
|
Environment variable value or default |
Raises:
| Type | Description |
|---|---|
ValueError
|
If required and not found |
Source code in provide/foundation/config/env.py
load_config
¶
Load a configuration using the global manager.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Configuration name |
required |
config_class
|
type[T]
|
Configuration class |
required |
loader
|
ConfigLoader | None
|
Optional loader |
None
|
Returns:
| Type | Description |
|---|---|
T
|
Configuration instance |
Source code in provide/foundation/config/manager.py
parse_bool
¶
Parse a boolean value from string or other types.
Accepts: true/false, yes/no, 1/0, on/off (case-insensitive)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
Any
|
Value to parse as boolean |
required |
strict
|
bool
|
If True, only accept bool or string types (raise TypeError otherwise) |
False
|
Returns:
| Type | Description |
|---|---|
bool
|
Boolean value |
Raises:
| Type | Description |
|---|---|
TypeError
|
If strict=True and value is not bool or string, or if value is not bool/str |
ValueError
|
If value cannot be parsed as boolean |
Source code in provide/foundation/parsers/primitives.py
parse_bool_extended
¶
Parse boolean from string with lenient/forgiving interpretation.
This is the lenient boolean parser - designed for user-facing configuration where we want to be forgiving of various inputs. Any unrecognized string defaults to False rather than raising an error.
Use Cases: - Environment variables set by end users - Feature flags that should default to "off" if misconfigured - Optional telemetry settings where failure should not break the system
Recognized True Values: true, yes, 1, on (case-insensitive) Recognized False Values: false, no, 0, off (case-insensitive) Default Behavior: Any other string → False (no error)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
str | bool
|
Boolean string representation or actual bool |
required |
Returns:
| Type | Description |
|---|---|
bool
|
Boolean value (defaults to False for unrecognized strings) |
Examples:
>>> parse_bool_extended("yes") # True
>>> parse_bool_extended("FALSE") # False
>>> parse_bool_extended("invalid") # False (no error)
>>> parse_bool_extended(True) # True
Source code in provide/foundation/parsers/primitives.py
parse_comma_list
¶
parse_console_formatter
¶
Parse and validate console formatter string.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
str
|
Formatter string (case-insensitive) |
required |
Returns:
| Type | Description |
|---|---|
ConsoleFormatterStr
|
Valid formatter string in lowercase |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the formatter is invalid |
Source code in provide/foundation/parsers/telemetry.py
parse_dict
¶
parse_dict(
value: str | dict[str, str],
item_separator: str = ",",
key_separator: str = "=",
strip: bool = True,
) -> dict[str, str]
Parse a dictionary from a string.
Format: "key1=value1,key2=value2"
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
str | dict[str, str]
|
String or dict to parse |
required |
item_separator
|
str
|
Separator between items |
','
|
key_separator
|
str
|
Separator between key and value |
'='
|
strip
|
bool
|
Whether to strip whitespace |
True
|
Returns:
| Type | Description |
|---|---|
dict[str, str]
|
Dictionary of string keys and values |
Raises:
| Type | Description |
|---|---|
ValueError
|
If format is invalid |
Source code in provide/foundation/parsers/collections.py
parse_float_with_validation
¶
parse_float_with_validation(
value: str,
min_val: float | None = None,
max_val: float | None = None,
) -> float
Parse float with optional range validation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
str
|
String representation of float |
required |
min_val
|
float | None
|
Minimum allowed value (inclusive) |
None
|
max_val
|
float | None
|
Maximum allowed value (inclusive) |
None
|
Returns:
| Type | Description |
|---|---|
float
|
Parsed float value |
Raises:
| Type | Description |
|---|---|
ValueError
|
If value is not a valid float or out of range |
Source code in provide/foundation/parsers/primitives.py
parse_headers
¶
Parse HTTP headers from string format.
Format Requirements: - Comma-separated key=value pairs: "key1=value1,key2=value2" - Header names and values are trimmed of whitespace - Empty header names are ignored - Each pair must contain exactly one '=' separator - Invalid pairs are silently skipped
Examples: >>> parse_headers("Authorization=Bearer token,Content-Type=application/json")
>>> parse_headers("X-API-Key=secret123") # Single header
{'X-API-Key': 'secret123'}
>>> parse_headers("valid=ok,invalid-no-equals,another=good") # Partial success
{'valid': 'ok', 'another': 'good'}
>>> parse_headers("empty-value=") # Empty values allowed
{'empty-value': ''}
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
str | dict[str, str]
|
Comma-separated key=value pairs for HTTP headers, or dict if already parsed |
required |
Returns:
| Type | Description |
|---|---|
dict[str, str]
|
Dictionary of header name-value pairs. |
dict[str, str]
|
Invalid entries are silently ignored. |
Note
This parser is lenient by design - invalid header pairs are skipped rather than raising errors to allow partial configuration success in production environments.
Source code in provide/foundation/parsers/structured.py
parse_json_dict
¶
Parse JSON string into dictionary.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
str
|
JSON string |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Parsed dictionary |
Raises:
| Type | Description |
|---|---|
ValueError
|
If JSON is invalid |
Source code in provide/foundation/parsers/primitives.py
parse_json_list
¶
Parse JSON string into list.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
str
|
JSON string |
required |
Returns:
| Type | Description |
|---|---|
list[Any]
|
Parsed list |
Raises:
| Type | Description |
|---|---|
ValueError
|
If JSON is invalid |
Source code in provide/foundation/parsers/primitives.py
parse_list
¶
Parse a list from a string.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
str | list[str]
|
String or list to parse |
required |
separator
|
str
|
Separator character |
','
|
strip
|
bool
|
Whether to strip whitespace from items |
True
|
Returns:
| Type | Description |
|---|---|
list[str]
|
List of strings |
Source code in provide/foundation/parsers/collections.py
parse_log_level
¶
Parse and validate log level string.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
str
|
Log level string (case-insensitive) |
required |
Returns:
| Type | Description |
|---|---|
LogLevelStr
|
Valid log level string in uppercase |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the log level is invalid |
Source code in provide/foundation/parsers/telemetry.py
parse_module_levels
¶
Parse module-specific log levels from string format.
Format Requirements: - String format: "module1:LEVEL,module2:LEVEL" (comma-separated pairs) - Dict format: Already parsed dictionary (validated and returned) - Log levels must be valid: TRACE, DEBUG, INFO, WARNING, ERROR, CRITICAL - Module names are trimmed of whitespace - Invalid log levels are silently ignored
Examples: >>> parse_module_levels("auth.service:DEBUG,database:ERROR")
>>> parse_module_levels("api:INFO") # Single module
{'api': 'INFO'}
>>> parse_module_levels({"web": "warning"}) # Dict input (case normalized)
{'web': 'WARNING'}
>>> parse_module_levels("api:INFO,bad:INVALID,db:ERROR") # Partial success
{'api': 'INFO', 'db': 'ERROR'}
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
str | dict[str, str]
|
Comma-separated module:level pairs or pre-parsed dict |
required |
Returns:
| Type | Description |
|---|---|
dict[str, LogLevelStr]
|
Dictionary mapping module names to validated log level strings. |
dict[str, LogLevelStr]
|
Invalid entries are silently ignored. |
Note
This parser is lenient by design - invalid log levels are skipped rather than raising errors to allow partial configuration success in production environments.
Source code in provide/foundation/parsers/structured.py
parse_rate_limits
¶
Parse per-logger rate limits from string format.
Format Requirements: - Comma-separated triplets: "logger1:rate:capacity,logger2:rate:capacity" - Rate and capacity must be valid float numbers - Logger names are trimmed of whitespace - Empty logger names are ignored - Invalid entries are silently skipped to allow partial success
Examples: >>> parse_rate_limits("api:10.0:100.0,worker:5.0:50.0")
>>> parse_rate_limits("db:1.5:25.0") # Single entry
{'db': (1.5, 25.0)}
>>> parse_rate_limits("api:10:100,invalid:bad,worker:5:50") # Partial success
{'api': (10.0, 100.0), 'worker': (5.0, 50.0)}
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
str
|
Comma-separated logger:rate:capacity triplets |
required |
Returns:
| Type | Description |
|---|---|
dict[str, tuple[float, float]]
|
Dictionary mapping logger names to (rate, capacity) tuples. |
dict[str, tuple[float, float]]
|
Invalid entries are silently ignored. |
Note
This parser is lenient by design - invalid entries are skipped rather than raising errors to allow partial configuration success in production environments.
Source code in provide/foundation/parsers/structured.py
parse_sample_rate
¶
Parse sampling rate (0.0 to 1.0).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
str
|
String representation of sampling rate |
required |
Returns:
| Type | Description |
|---|---|
float
|
Float between 0.0 and 1.0 |
Raises:
| Type | Description |
|---|---|
ValueError
|
If value is not valid or out of range |
Source code in provide/foundation/parsers/primitives.py
register_config
¶
register_config(
name: str,
config: BaseConfig | None = None,
schema: ConfigSchema | None = None,
loader: ConfigLoader | None = None,
defaults: ConfigDict | None = None,
) -> None
Register a configuration with the global manager.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Configuration name |
required |
config
|
BaseConfig | None
|
Configuration instance |
None
|
schema
|
ConfigSchema | None
|
Configuration schema |
None
|
loader
|
ConfigLoader | None
|
Configuration loader |
None
|
defaults
|
ConfigDict | None
|
Default configuration values |
None
|
Source code in provide/foundation/config/manager.py
set_config
¶
Set a configuration in the global manager.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Configuration name |
required |
config
|
BaseConfig
|
Configuration instance |
required |
validate_choice
¶
Create a validator that ensures value is one of the given choices.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
choices
|
list[Any]
|
List of valid choices |
required |
Returns:
| Type | Description |
|---|---|
Callable[[Any, Any, Any], None]
|
Validator function for use with attrs |
Source code in provide/foundation/config/validators.py
validate_log_level
¶
Validate that a log level is valid.
Source code in provide/foundation/config/validators.py
validate_non_negative
¶
Validate that a value is non-negative.
Source code in provide/foundation/config/validators.py
validate_overflow_policy
¶
Validate rate limit overflow policy.
Source code in provide/foundation/config/validators.py
validate_port
¶
Validate that a port number is valid.
Source code in provide/foundation/config/validators.py
validate_positive
¶
Validate that a value is positive.
Source code in provide/foundation/config/validators.py
validate_range
¶
Create a validator that ensures value is within the given numeric range.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
min_val
|
float
|
Minimum allowed value (inclusive) |
required |
max_val
|
float
|
Maximum allowed value (inclusive) |
required |
Returns:
| Type | Description |
|---|---|
Callable[[Any, Any, Any], None]
|
Validator function for use with attrs |
Source code in provide/foundation/config/validators.py
validate_sample_rate
¶
Validate that a sample rate is between 0.0 and 1.0.
Source code in provide/foundation/config/validators.py
validate_schema
¶
Validate configuration instance against schema.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
BaseConfig
|
Configuration instance |
required |
schema
|
ConfigSchema
|
Schema to validate against |
required |
Raises:
| Type | Description |
|---|---|
ConfigValidationError
|
If validation fails |