feat: add configuration loader for .env and JSON files
- Add ConfigLoader class for loading RateLimitConfig and GlobalConfig - Support .env files with FASTAPI_TRAFFIC_* prefixed variables - Support JSON configuration files with type validation - Add convenience functions: load_rate_limit_config, load_global_config - Add load_rate_limit_config_from_env, load_global_config_from_env - Support custom environment variable prefixes - Add comprehensive error handling with ConfigurationError - Add 47 tests for configuration loading - Add example 11_config_loader.py with 9 usage patterns - Update examples/README.md with config loader documentation - Update CHANGELOG.md with new feature - Fix typo in limiter.py (errant 'fi' on line 4)
This commit is contained in:
10
CHANGELOG.md
10
CHANGELOG.md
@@ -8,6 +8,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
## [Unreleased]
|
||||
|
||||
### Added
|
||||
- **Configuration Loader** - Load rate limiting configuration from external files:
|
||||
- `ConfigLoader` class for loading `RateLimitConfig` and `GlobalConfig`
|
||||
- Support for `.env` files with `FASTAPI_TRAFFIC_*` prefixed variables
|
||||
- Support for JSON configuration files
|
||||
- Environment variable loading with `load_rate_limit_config_from_env()` and `load_global_config_from_env()`
|
||||
- Auto-detection of file format with `load_rate_limit_config()` and `load_global_config()`
|
||||
- Custom environment variable prefix support
|
||||
- Type validation and comprehensive error handling
|
||||
- 47 new tests for configuration loading
|
||||
- Example `11_config_loader.py` demonstrating all configuration loading patterns
|
||||
- `get_stats()` method to `MemoryBackend` for consistency with `RedisBackend`
|
||||
- Comprehensive test suite with 134 tests covering:
|
||||
- All five rate limiting algorithms with timing and concurrency tests
|
||||
|
||||
Reference in New Issue
Block a user