feat: Add comprehensive provider health monitoring and failover system

- Implemented ProviderHealthMonitor for real-time tracking
  - Monitors availability, response times, success rates
  - Automatic marking unavailable after failures
  - Background health check loop

- Added ProviderFailover for automatic provider switching
  - Configurable retry attempts with exponential backoff
  - Integration with health monitoring
  - Smart provider selection

- Created MonitoredProviderWrapper for performance tracking
  - Transparent monitoring for any provider
  - Automatic metric recording
  - No changes needed to existing providers

- Implemented ProviderConfigManager for dynamic configuration
  - Runtime updates without restart
  - Per-provider settings (timeout, retries, bandwidth)
  - JSON-based persistence

- Added Provider Management API (15+ endpoints)
  - Health monitoring endpoints
  - Configuration management
  - Failover control

- Comprehensive testing (34 tests, 100% pass rate)
  - Health monitoring tests
  - Failover scenario tests
  - Configuration management tests

- Documentation updates
  - Updated infrastructure.md
  - Updated instructions.md
  - Created PROVIDER_ENHANCEMENT_SUMMARY.md

Total: ~2,593 lines of code, 34 passing tests
This commit is contained in:
2025-10-24 11:01:40 +02:00
parent 85d73b8294
commit fecdb38a90
23 changed files with 3137 additions and 109 deletions

View File

@@ -25,6 +25,7 @@ from src.server.api.config import router as config_router
from src.server.api.diagnostics import router as diagnostics_router
from src.server.api.download import router as download_router
from src.server.api.logging import router as logging_router
from src.server.api.providers import router as providers_router
from src.server.api.scheduler import router as scheduler_router
from src.server.api.websocket import router as websocket_router
from src.server.controllers.error_controller import (
@@ -139,6 +140,7 @@ app.include_router(diagnostics_router)
app.include_router(analytics_router)
app.include_router(anime_router)
app.include_router(download_router)
app.include_router(providers_router)
app.include_router(websocket_router)
# Register exception handlers