unrealon 1.0.9__py3-none-any.whl → 1.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- unrealon/__init__.py +23 -21
- unrealon-1.1.0.dist-info/METADATA +164 -0
- unrealon-1.1.0.dist-info/RECORD +82 -0
- {unrealon-1.0.9.dist-info → unrealon-1.1.0.dist-info}/WHEEL +1 -1
- unrealon-1.1.0.dist-info/entry_points.txt +9 -0
- {unrealon-1.0.9.dist-info → unrealon-1.1.0.dist-info/licenses}/LICENSE +1 -1
- unrealon_bridge/__init__.py +114 -0
- unrealon_bridge/cli.py +316 -0
- unrealon_bridge/client/__init__.py +93 -0
- unrealon_bridge/client/base.py +78 -0
- unrealon_bridge/client/commands.py +89 -0
- unrealon_bridge/client/connection.py +90 -0
- unrealon_bridge/client/events.py +65 -0
- unrealon_bridge/client/health.py +38 -0
- unrealon_bridge/client/html_parser.py +146 -0
- unrealon_bridge/client/logging.py +139 -0
- unrealon_bridge/client/proxy.py +70 -0
- unrealon_bridge/client/scheduler.py +450 -0
- unrealon_bridge/client/session.py +70 -0
- unrealon_bridge/configs/__init__.py +14 -0
- unrealon_bridge/configs/bridge_config.py +212 -0
- unrealon_bridge/configs/bridge_config.yaml +39 -0
- unrealon_bridge/models/__init__.py +138 -0
- unrealon_bridge/models/base.py +28 -0
- unrealon_bridge/models/command.py +41 -0
- unrealon_bridge/models/events.py +40 -0
- unrealon_bridge/models/html_parser.py +79 -0
- unrealon_bridge/models/logging.py +55 -0
- unrealon_bridge/models/parser.py +63 -0
- unrealon_bridge/models/proxy.py +41 -0
- unrealon_bridge/models/requests.py +95 -0
- unrealon_bridge/models/responses.py +88 -0
- unrealon_bridge/models/scheduler.py +592 -0
- unrealon_bridge/models/session.py +28 -0
- unrealon_bridge/server/__init__.py +91 -0
- unrealon_bridge/server/base.py +171 -0
- unrealon_bridge/server/handlers/__init__.py +23 -0
- unrealon_bridge/server/handlers/command.py +110 -0
- unrealon_bridge/server/handlers/html_parser.py +139 -0
- unrealon_bridge/server/handlers/logging.py +95 -0
- unrealon_bridge/server/handlers/parser.py +95 -0
- unrealon_bridge/server/handlers/proxy.py +75 -0
- unrealon_bridge/server/handlers/scheduler.py +545 -0
- unrealon_bridge/server/handlers/session.py +66 -0
- unrealon_browser/__init__.py +61 -18
- unrealon_browser/{src/cli → cli}/browser_cli.py +6 -13
- unrealon_browser/{src/cli → cli}/cookies_cli.py +5 -1
- unrealon_browser/{src/core → core}/browser_manager.py +2 -2
- unrealon_browser/{src/managers → managers}/captcha.py +1 -1
- unrealon_browser/{src/managers → managers}/cookies.py +1 -1
- unrealon_browser/managers/logger_bridge.py +231 -0
- unrealon_browser/{src/managers → managers}/profile.py +1 -1
- unrealon_driver/__init__.py +73 -19
- unrealon_driver/browser/__init__.py +8 -0
- unrealon_driver/browser/config.py +74 -0
- unrealon_driver/browser/manager.py +416 -0
- unrealon_driver/exceptions.py +28 -0
- unrealon_driver/parser/__init__.py +55 -0
- unrealon_driver/parser/cli_manager.py +141 -0
- unrealon_driver/parser/daemon_manager.py +227 -0
- unrealon_driver/parser/managers/__init__.py +46 -0
- unrealon_driver/parser/managers/browser.py +51 -0
- unrealon_driver/parser/managers/config.py +281 -0
- unrealon_driver/parser/managers/error.py +412 -0
- unrealon_driver/parser/managers/html.py +732 -0
- unrealon_driver/parser/managers/logging.py +609 -0
- unrealon_driver/parser/managers/result.py +321 -0
- unrealon_driver/parser/parser_manager.py +628 -0
- unrealon/sdk_config.py +0 -88
- unrealon-1.0.9.dist-info/METADATA +0 -810
- unrealon-1.0.9.dist-info/RECORD +0 -246
- unrealon_browser/pyproject.toml +0 -182
- unrealon_browser/src/__init__.py +0 -62
- unrealon_browser/src/managers/logger_bridge.py +0 -395
- unrealon_driver/README.md +0 -204
- unrealon_driver/pyproject.toml +0 -187
- unrealon_driver/src/__init__.py +0 -90
- unrealon_driver/src/cli/__init__.py +0 -10
- unrealon_driver/src/cli/main.py +0 -66
- unrealon_driver/src/cli/simple.py +0 -510
- unrealon_driver/src/config/__init__.py +0 -11
- unrealon_driver/src/config/auto_config.py +0 -478
- unrealon_driver/src/core/__init__.py +0 -18
- unrealon_driver/src/core/exceptions.py +0 -289
- unrealon_driver/src/core/parser.py +0 -638
- unrealon_driver/src/dto/__init__.py +0 -66
- unrealon_driver/src/dto/cli.py +0 -119
- unrealon_driver/src/dto/config.py +0 -18
- unrealon_driver/src/dto/events.py +0 -237
- unrealon_driver/src/dto/execution.py +0 -313
- unrealon_driver/src/dto/services.py +0 -311
- unrealon_driver/src/execution/__init__.py +0 -23
- unrealon_driver/src/execution/daemon_mode.py +0 -317
- unrealon_driver/src/execution/interactive_mode.py +0 -88
- unrealon_driver/src/execution/modes.py +0 -45
- unrealon_driver/src/execution/scheduled_mode.py +0 -209
- unrealon_driver/src/execution/test_mode.py +0 -250
- unrealon_driver/src/logging/__init__.py +0 -24
- unrealon_driver/src/logging/driver_logger.py +0 -512
- unrealon_driver/src/services/__init__.py +0 -24
- unrealon_driver/src/services/browser_service.py +0 -726
- unrealon_driver/src/services/llm/__init__.py +0 -15
- unrealon_driver/src/services/llm/browser_llm_service.py +0 -363
- unrealon_driver/src/services/llm/llm.py +0 -195
- unrealon_driver/src/services/logger_service.py +0 -232
- unrealon_driver/src/services/metrics_service.py +0 -185
- unrealon_driver/src/services/scheduler_service.py +0 -489
- unrealon_driver/src/services/websocket_service.py +0 -362
- unrealon_driver/src/utils/__init__.py +0 -16
- unrealon_driver/src/utils/service_factory.py +0 -317
- unrealon_driver/src/utils/time_formatter.py +0 -338
- unrealon_llm/README.md +0 -44
- unrealon_llm/__init__.py +0 -26
- unrealon_llm/pyproject.toml +0 -154
- unrealon_llm/src/__init__.py +0 -228
- unrealon_llm/src/cli/__init__.py +0 -0
- unrealon_llm/src/core/__init__.py +0 -11
- unrealon_llm/src/core/smart_client.py +0 -438
- unrealon_llm/src/dto/__init__.py +0 -155
- unrealon_llm/src/dto/models/__init__.py +0 -0
- unrealon_llm/src/dto/models/config.py +0 -343
- unrealon_llm/src/dto/models/core.py +0 -328
- unrealon_llm/src/dto/models/enums.py +0 -123
- unrealon_llm/src/dto/models/html_analysis.py +0 -345
- unrealon_llm/src/dto/models/statistics.py +0 -473
- unrealon_llm/src/dto/models/translation.py +0 -383
- unrealon_llm/src/dto/models/type_conversion.py +0 -462
- unrealon_llm/src/dto/schemas/__init__.py +0 -0
- unrealon_llm/src/exceptions.py +0 -392
- unrealon_llm/src/llm_config/__init__.py +0 -20
- unrealon_llm/src/llm_config/logging_config.py +0 -178
- unrealon_llm/src/llm_logging/__init__.py +0 -42
- unrealon_llm/src/llm_logging/llm_events.py +0 -107
- unrealon_llm/src/llm_logging/llm_logger.py +0 -466
- unrealon_llm/src/managers/__init__.py +0 -15
- unrealon_llm/src/managers/cache_manager.py +0 -67
- unrealon_llm/src/managers/cost_manager.py +0 -107
- unrealon_llm/src/managers/request_manager.py +0 -298
- unrealon_llm/src/modules/__init__.py +0 -0
- unrealon_llm/src/modules/html_processor/__init__.py +0 -25
- unrealon_llm/src/modules/html_processor/base_processor.py +0 -415
- unrealon_llm/src/modules/html_processor/details_processor.py +0 -85
- unrealon_llm/src/modules/html_processor/listing_processor.py +0 -91
- unrealon_llm/src/modules/html_processor/models/__init__.py +0 -20
- unrealon_llm/src/modules/html_processor/models/processing_models.py +0 -40
- unrealon_llm/src/modules/html_processor/models/universal_model.py +0 -56
- unrealon_llm/src/modules/html_processor/processor.py +0 -102
- unrealon_llm/src/modules/llm/__init__.py +0 -0
- unrealon_llm/src/modules/translator/__init__.py +0 -0
- unrealon_llm/src/provider.py +0 -116
- unrealon_llm/src/utils/__init__.py +0 -95
- unrealon_llm/src/utils/common.py +0 -64
- unrealon_llm/src/utils/data_extractor.py +0 -188
- unrealon_llm/src/utils/html_cleaner.py +0 -767
- unrealon_llm/src/utils/language_detector.py +0 -308
- unrealon_llm/src/utils/models_cache.py +0 -592
- unrealon_llm/src/utils/smart_counter.py +0 -229
- unrealon_llm/src/utils/token_counter.py +0 -189
- unrealon_sdk/README.md +0 -25
- unrealon_sdk/__init__.py +0 -30
- unrealon_sdk/pyproject.toml +0 -231
- unrealon_sdk/src/__init__.py +0 -150
- unrealon_sdk/src/cli/__init__.py +0 -12
- unrealon_sdk/src/cli/commands/__init__.py +0 -22
- unrealon_sdk/src/cli/commands/benchmark.py +0 -42
- unrealon_sdk/src/cli/commands/diagnostics.py +0 -573
- unrealon_sdk/src/cli/commands/health.py +0 -46
- unrealon_sdk/src/cli/commands/integration.py +0 -498
- unrealon_sdk/src/cli/commands/reports.py +0 -43
- unrealon_sdk/src/cli/commands/security.py +0 -36
- unrealon_sdk/src/cli/commands/server.py +0 -483
- unrealon_sdk/src/cli/commands/servers.py +0 -56
- unrealon_sdk/src/cli/commands/tests.py +0 -55
- unrealon_sdk/src/cli/main.py +0 -126
- unrealon_sdk/src/cli/utils/reporter.py +0 -519
- unrealon_sdk/src/clients/openapi.yaml +0 -3347
- unrealon_sdk/src/clients/python_http/__init__.py +0 -3
- unrealon_sdk/src/clients/python_http/api_config.py +0 -228
- unrealon_sdk/src/clients/python_http/models/BaseModel.py +0 -12
- unrealon_sdk/src/clients/python_http/models/BroadcastDeliveryStats.py +0 -33
- unrealon_sdk/src/clients/python_http/models/BroadcastMessage.py +0 -17
- unrealon_sdk/src/clients/python_http/models/BroadcastMessageRequest.py +0 -35
- unrealon_sdk/src/clients/python_http/models/BroadcastPriority.py +0 -10
- unrealon_sdk/src/clients/python_http/models/BroadcastResponse.py +0 -21
- unrealon_sdk/src/clients/python_http/models/BroadcastResultResponse.py +0 -33
- unrealon_sdk/src/clients/python_http/models/BroadcastTarget.py +0 -11
- unrealon_sdk/src/clients/python_http/models/ConnectionStats.py +0 -27
- unrealon_sdk/src/clients/python_http/models/ConnectionsResponse.py +0 -21
- unrealon_sdk/src/clients/python_http/models/DeveloperMessageResponse.py +0 -23
- unrealon_sdk/src/clients/python_http/models/ErrorResponse.py +0 -25
- unrealon_sdk/src/clients/python_http/models/HTTPValidationError.py +0 -16
- unrealon_sdk/src/clients/python_http/models/HealthResponse.py +0 -23
- unrealon_sdk/src/clients/python_http/models/HealthStatus.py +0 -33
- unrealon_sdk/src/clients/python_http/models/LogLevel.py +0 -10
- unrealon_sdk/src/clients/python_http/models/LoggingRequest.py +0 -27
- unrealon_sdk/src/clients/python_http/models/LoggingResponse.py +0 -23
- unrealon_sdk/src/clients/python_http/models/MaintenanceMode.py +0 -9
- unrealon_sdk/src/clients/python_http/models/MaintenanceModeRequest.py +0 -33
- unrealon_sdk/src/clients/python_http/models/MaintenanceStatusResponse.py +0 -39
- unrealon_sdk/src/clients/python_http/models/ParserCommandRequest.py +0 -25
- unrealon_sdk/src/clients/python_http/models/ParserMessageResponse.py +0 -21
- unrealon_sdk/src/clients/python_http/models/ParserRegistrationRequest.py +0 -28
- unrealon_sdk/src/clients/python_http/models/ParserRegistrationResponse.py +0 -25
- unrealon_sdk/src/clients/python_http/models/ParserType.py +0 -10
- unrealon_sdk/src/clients/python_http/models/ProxyBlockRequest.py +0 -19
- unrealon_sdk/src/clients/python_http/models/ProxyEndpointResponse.py +0 -20
- unrealon_sdk/src/clients/python_http/models/ProxyListResponse.py +0 -19
- unrealon_sdk/src/clients/python_http/models/ProxyProvider.py +0 -10
- unrealon_sdk/src/clients/python_http/models/ProxyPurchaseRequest.py +0 -25
- unrealon_sdk/src/clients/python_http/models/ProxyResponse.py +0 -47
- unrealon_sdk/src/clients/python_http/models/ProxyRotationRequest.py +0 -23
- unrealon_sdk/src/clients/python_http/models/ProxyStatus.py +0 -10
- unrealon_sdk/src/clients/python_http/models/ProxyUsageRequest.py +0 -19
- unrealon_sdk/src/clients/python_http/models/ProxyUsageStatsResponse.py +0 -26
- unrealon_sdk/src/clients/python_http/models/ServiceRegistrationDto.py +0 -23
- unrealon_sdk/src/clients/python_http/models/ServiceStatsResponse.py +0 -31
- unrealon_sdk/src/clients/python_http/models/SessionStartRequest.py +0 -23
- unrealon_sdk/src/clients/python_http/models/SuccessResponse.py +0 -25
- unrealon_sdk/src/clients/python_http/models/SystemNotificationResponse.py +0 -23
- unrealon_sdk/src/clients/python_http/models/ValidationError.py +0 -18
- unrealon_sdk/src/clients/python_http/models/ValidationErrorResponse.py +0 -21
- unrealon_sdk/src/clients/python_http/models/WebSocketMetrics.py +0 -21
- unrealon_sdk/src/clients/python_http/models/__init__.py +0 -44
- unrealon_sdk/src/clients/python_http/services/None_service.py +0 -35
- unrealon_sdk/src/clients/python_http/services/ParserManagement_service.py +0 -190
- unrealon_sdk/src/clients/python_http/services/ProxyManagement_service.py +0 -289
- unrealon_sdk/src/clients/python_http/services/SocketLogging_service.py +0 -187
- unrealon_sdk/src/clients/python_http/services/SystemHealth_service.py +0 -119
- unrealon_sdk/src/clients/python_http/services/WebSocketAPI_service.py +0 -198
- unrealon_sdk/src/clients/python_http/services/__init__.py +0 -0
- unrealon_sdk/src/clients/python_http/services/admin_service.py +0 -125
- unrealon_sdk/src/clients/python_http/services/async_None_service.py +0 -35
- unrealon_sdk/src/clients/python_http/services/async_ParserManagement_service.py +0 -190
- unrealon_sdk/src/clients/python_http/services/async_ProxyManagement_service.py +0 -289
- unrealon_sdk/src/clients/python_http/services/async_SocketLogging_service.py +0 -189
- unrealon_sdk/src/clients/python_http/services/async_SystemHealth_service.py +0 -123
- unrealon_sdk/src/clients/python_http/services/async_WebSocketAPI_service.py +0 -200
- unrealon_sdk/src/clients/python_http/services/async_admin_service.py +0 -125
- unrealon_sdk/src/clients/python_websocket/__init__.py +0 -28
- unrealon_sdk/src/clients/python_websocket/client.py +0 -490
- unrealon_sdk/src/clients/python_websocket/events.py +0 -732
- unrealon_sdk/src/clients/python_websocket/example.py +0 -136
- unrealon_sdk/src/clients/python_websocket/types.py +0 -871
- unrealon_sdk/src/core/__init__.py +0 -64
- unrealon_sdk/src/core/client.py +0 -556
- unrealon_sdk/src/core/config.py +0 -465
- unrealon_sdk/src/core/exceptions.py +0 -239
- unrealon_sdk/src/core/metadata.py +0 -191
- unrealon_sdk/src/core/models.py +0 -142
- unrealon_sdk/src/core/types.py +0 -68
- unrealon_sdk/src/dto/__init__.py +0 -268
- unrealon_sdk/src/dto/authentication.py +0 -108
- unrealon_sdk/src/dto/cache.py +0 -208
- unrealon_sdk/src/dto/common.py +0 -19
- unrealon_sdk/src/dto/concurrency.py +0 -393
- unrealon_sdk/src/dto/events.py +0 -108
- unrealon_sdk/src/dto/health.py +0 -339
- unrealon_sdk/src/dto/load_balancing.py +0 -336
- unrealon_sdk/src/dto/logging.py +0 -230
- unrealon_sdk/src/dto/performance.py +0 -165
- unrealon_sdk/src/dto/rate_limiting.py +0 -295
- unrealon_sdk/src/dto/resource_pooling.py +0 -128
- unrealon_sdk/src/dto/structured_logging.py +0 -112
- unrealon_sdk/src/dto/task_scheduling.py +0 -121
- unrealon_sdk/src/dto/websocket.py +0 -55
- unrealon_sdk/src/enterprise/__init__.py +0 -59
- unrealon_sdk/src/enterprise/authentication.py +0 -401
- unrealon_sdk/src/enterprise/cache_manager.py +0 -578
- unrealon_sdk/src/enterprise/error_recovery.py +0 -494
- unrealon_sdk/src/enterprise/event_system.py +0 -549
- unrealon_sdk/src/enterprise/health_monitor.py +0 -747
- unrealon_sdk/src/enterprise/load_balancer.py +0 -964
- unrealon_sdk/src/enterprise/logging/__init__.py +0 -68
- unrealon_sdk/src/enterprise/logging/cleanup.py +0 -156
- unrealon_sdk/src/enterprise/logging/development.py +0 -744
- unrealon_sdk/src/enterprise/logging/service.py +0 -410
- unrealon_sdk/src/enterprise/multithreading_manager.py +0 -853
- unrealon_sdk/src/enterprise/performance_monitor.py +0 -539
- unrealon_sdk/src/enterprise/proxy_manager.py +0 -696
- unrealon_sdk/src/enterprise/rate_limiter.py +0 -652
- unrealon_sdk/src/enterprise/resource_pool.py +0 -763
- unrealon_sdk/src/enterprise/task_scheduler.py +0 -709
- unrealon_sdk/src/internal/__init__.py +0 -10
- unrealon_sdk/src/internal/command_router.py +0 -497
- unrealon_sdk/src/internal/connection_manager.py +0 -397
- unrealon_sdk/src/internal/http_client.py +0 -446
- unrealon_sdk/src/internal/websocket_client.py +0 -420
- unrealon_sdk/src/provider.py +0 -471
- unrealon_sdk/src/utils.py +0 -234
- /unrealon_browser/{src/cli → cli}/__init__.py +0 -0
- /unrealon_browser/{src/cli → cli}/interactive_mode.py +0 -0
- /unrealon_browser/{src/cli → cli}/main.py +0 -0
- /unrealon_browser/{src/core → core}/__init__.py +0 -0
- /unrealon_browser/{src/dto → dto}/__init__.py +0 -0
- /unrealon_browser/{src/dto → dto}/models/config.py +0 -0
- /unrealon_browser/{src/dto → dto}/models/core.py +0 -0
- /unrealon_browser/{src/dto → dto}/models/dataclasses.py +0 -0
- /unrealon_browser/{src/dto → dto}/models/detection.py +0 -0
- /unrealon_browser/{src/dto → dto}/models/enums.py +0 -0
- /unrealon_browser/{src/dto → dto}/models/statistics.py +0 -0
- /unrealon_browser/{src/managers → managers}/__init__.py +0 -0
- /unrealon_browser/{src/managers → managers}/stealth.py +0 -0
unrealon_sdk/src/dto/health.py
DELETED
|
@@ -1,339 +0,0 @@
|
|
|
1
|
-
"""
|
|
2
|
-
Health Monitoring DTOs - Data Transfer Objects for health monitoring system.
|
|
3
|
-
|
|
4
|
-
This module contains all Pydantic models and enums related to system health monitoring,
|
|
5
|
-
separated from business logic for clean architecture and reusability.
|
|
6
|
-
|
|
7
|
-
Components:
|
|
8
|
-
- Health status and alert severity models
|
|
9
|
-
- Component health and system metrics models
|
|
10
|
-
- Health check configuration and diagnostics
|
|
11
|
-
- Monitoring and alerting data structures
|
|
12
|
-
"""
|
|
13
|
-
|
|
14
|
-
import uuid
|
|
15
|
-
from datetime import datetime, timezone, timedelta
|
|
16
|
-
from typing import Dict, List, Optional, Any, Union
|
|
17
|
-
from enum import Enum
|
|
18
|
-
|
|
19
|
-
from pydantic import BaseModel, Field, ConfigDict
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
class ComponentStatus(str, Enum):
|
|
23
|
-
"""Component health status."""
|
|
24
|
-
|
|
25
|
-
HEALTHY = "healthy"
|
|
26
|
-
DEGRADED = "degraded"
|
|
27
|
-
UNHEALTHY = "unhealthy"
|
|
28
|
-
UNKNOWN = "unknown"
|
|
29
|
-
MAINTENANCE = "maintenance"
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
class HealthCheckType(str, Enum):
|
|
33
|
-
"""Types of health checks."""
|
|
34
|
-
|
|
35
|
-
CONNECTION = "connection"
|
|
36
|
-
DATABASE = "database"
|
|
37
|
-
API = "api"
|
|
38
|
-
MEMORY = "memory"
|
|
39
|
-
CPU = "cpu"
|
|
40
|
-
DISK = "disk"
|
|
41
|
-
NETWORK = "network"
|
|
42
|
-
CUSTOM = "custom"
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
class AlertSeverity(str, Enum):
|
|
46
|
-
"""Health alert severity levels."""
|
|
47
|
-
|
|
48
|
-
INFO = "info"
|
|
49
|
-
WARNING = "warning"
|
|
50
|
-
ERROR = "error"
|
|
51
|
-
CRITICAL = "critical"
|
|
52
|
-
FATAL = "fatal"
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
class HealthCheckFrequency(str, Enum):
|
|
56
|
-
"""Health check frequency settings."""
|
|
57
|
-
|
|
58
|
-
CONTINUOUS = "continuous" # Real-time monitoring
|
|
59
|
-
HIGH = "high" # Every 5 seconds
|
|
60
|
-
NORMAL = "normal" # Every 30 seconds
|
|
61
|
-
LOW = "low" # Every 5 minutes
|
|
62
|
-
CUSTOM = "custom" # User-defined interval
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
class ConnectionHealthStatus(BaseModel):
|
|
66
|
-
"""Connection health status model."""
|
|
67
|
-
|
|
68
|
-
model_config = ConfigDict(extra="forbid")
|
|
69
|
-
|
|
70
|
-
# Connection info
|
|
71
|
-
is_connected: bool = Field(..., description="Whether connection is active")
|
|
72
|
-
last_ping_ms: Optional[float] = Field(default=None, description="Last ping time in ms")
|
|
73
|
-
connection_uptime_seconds: float = Field(default=0.0, description="Connection uptime")
|
|
74
|
-
|
|
75
|
-
# Quality metrics
|
|
76
|
-
success_rate_percent: float = Field(default=100.0, description="Success rate percentage")
|
|
77
|
-
error_count: int = Field(default=0, description="Number of errors")
|
|
78
|
-
retry_count: int = Field(default=0, description="Number of retries")
|
|
79
|
-
|
|
80
|
-
# Timestamps
|
|
81
|
-
last_successful_request: Optional[datetime] = Field(
|
|
82
|
-
default=None, description="Last successful request"
|
|
83
|
-
)
|
|
84
|
-
last_error: Optional[datetime] = Field(default=None, description="Last error time")
|
|
85
|
-
status_changed_at: datetime = Field(default_factory=lambda: datetime.now(timezone.utc))
|
|
86
|
-
|
|
87
|
-
# Status
|
|
88
|
-
status: ComponentStatus = Field(default=ComponentStatus.UNKNOWN, description="Overall status")
|
|
89
|
-
status_message: str = Field(default="", description="Status description")
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
class ComponentHealth(BaseModel):
|
|
93
|
-
"""Individual component health model."""
|
|
94
|
-
|
|
95
|
-
model_config = ConfigDict(extra="forbid")
|
|
96
|
-
|
|
97
|
-
# Component identification
|
|
98
|
-
component_id: str = Field(..., description="Unique component identifier")
|
|
99
|
-
component_name: str = Field(..., description="Human-readable component name")
|
|
100
|
-
component_type: str = Field(..., description="Component type/category")
|
|
101
|
-
|
|
102
|
-
# Health status
|
|
103
|
-
status: ComponentStatus = Field(..., description="Current health status")
|
|
104
|
-
status_message: str = Field(default="", description="Status description")
|
|
105
|
-
last_check_time: datetime = Field(default_factory=lambda: datetime.now(timezone.utc))
|
|
106
|
-
|
|
107
|
-
# Metrics
|
|
108
|
-
response_time_ms: Optional[float] = Field(
|
|
109
|
-
default=None, description="Response time in milliseconds"
|
|
110
|
-
)
|
|
111
|
-
cpu_usage_percent: Optional[float] = Field(default=None, description="CPU usage percentage")
|
|
112
|
-
memory_usage_percent: Optional[float] = Field(
|
|
113
|
-
default=None, description="Memory usage percentage"
|
|
114
|
-
)
|
|
115
|
-
disk_usage_percent: Optional[float] = Field(default=None, description="Disk usage percentage")
|
|
116
|
-
|
|
117
|
-
# Connection metrics (if applicable)
|
|
118
|
-
connection_count: Optional[int] = Field(default=None, description="Active connections")
|
|
119
|
-
error_rate_percent: Optional[float] = Field(default=None, description="Error rate percentage")
|
|
120
|
-
|
|
121
|
-
# History
|
|
122
|
-
uptime_seconds: float = Field(default=0.0, description="Component uptime")
|
|
123
|
-
last_restart: Optional[datetime] = Field(default=None, description="Last restart time")
|
|
124
|
-
restart_count: int = Field(default=0, description="Number of restarts")
|
|
125
|
-
|
|
126
|
-
# Dependencies
|
|
127
|
-
dependencies: List[str] = Field(default_factory=list, description="Component dependencies")
|
|
128
|
-
dependent_components: List[str] = Field(
|
|
129
|
-
default_factory=list, description="Dependent components"
|
|
130
|
-
)
|
|
131
|
-
|
|
132
|
-
# Metadata
|
|
133
|
-
version: Optional[str] = Field(default=None, description="Component version")
|
|
134
|
-
environment: Optional[str] = Field(default=None, description="Environment (dev/prod/etc)")
|
|
135
|
-
tags: Dict[str, str] = Field(default_factory=dict, description="Component tags")
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
class HealthCheckConfig(BaseModel):
|
|
139
|
-
"""Health check configuration model."""
|
|
140
|
-
|
|
141
|
-
model_config = ConfigDict(extra="forbid")
|
|
142
|
-
|
|
143
|
-
# Basic settings
|
|
144
|
-
enabled: bool = Field(default=True, description="Enable health checks")
|
|
145
|
-
check_type: HealthCheckType = Field(..., description="Type of health check")
|
|
146
|
-
frequency: HealthCheckFrequency = Field(
|
|
147
|
-
default=HealthCheckFrequency.NORMAL, description="Check frequency"
|
|
148
|
-
)
|
|
149
|
-
custom_interval_seconds: Optional[float] = Field(
|
|
150
|
-
default=None, description="Custom check interval"
|
|
151
|
-
)
|
|
152
|
-
|
|
153
|
-
# Timeout settings
|
|
154
|
-
timeout_seconds: float = Field(default=30.0, description="Health check timeout")
|
|
155
|
-
retry_attempts: int = Field(default=3, description="Number of retry attempts")
|
|
156
|
-
retry_delay_seconds: float = Field(default=5.0, description="Delay between retries")
|
|
157
|
-
|
|
158
|
-
# Thresholds
|
|
159
|
-
warning_threshold: Optional[float] = Field(default=None, description="Warning threshold")
|
|
160
|
-
error_threshold: Optional[float] = Field(default=None, description="Error threshold")
|
|
161
|
-
critical_threshold: Optional[float] = Field(default=None, description="Critical threshold")
|
|
162
|
-
|
|
163
|
-
# Alerting
|
|
164
|
-
enable_alerts: bool = Field(default=True, description="Enable alerting")
|
|
165
|
-
alert_on_status_change: bool = Field(default=True, description="Alert on status changes")
|
|
166
|
-
alert_on_threshold_breach: bool = Field(default=True, description="Alert on threshold breaches")
|
|
167
|
-
|
|
168
|
-
# Custom check settings
|
|
169
|
-
custom_check_endpoint: Optional[str] = Field(default=None, description="Custom check endpoint")
|
|
170
|
-
expected_response: Optional[str] = Field(default=None, description="Expected response")
|
|
171
|
-
custom_headers: Dict[str, str] = Field(default_factory=dict, description="Custom headers")
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
class HealthAlert(BaseModel):
|
|
175
|
-
"""Health monitoring alert model."""
|
|
176
|
-
|
|
177
|
-
model_config = ConfigDict(extra="forbid")
|
|
178
|
-
|
|
179
|
-
# Alert identification
|
|
180
|
-
alert_id: str = Field(default_factory=lambda: str(uuid.uuid4()))
|
|
181
|
-
component_id: str = Field(..., description="Component that triggered alert")
|
|
182
|
-
alert_type: HealthCheckType = Field(..., description="Type of alert")
|
|
183
|
-
|
|
184
|
-
# Alert details
|
|
185
|
-
severity: AlertSeverity = Field(..., description="Alert severity")
|
|
186
|
-
title: str = Field(..., description="Alert title")
|
|
187
|
-
message: str = Field(..., description="Alert message")
|
|
188
|
-
description: Optional[str] = Field(default=None, description="Detailed description")
|
|
189
|
-
|
|
190
|
-
# Timing
|
|
191
|
-
triggered_at: datetime = Field(default_factory=lambda: datetime.now(timezone.utc))
|
|
192
|
-
resolved_at: Optional[datetime] = Field(default=None, description="When alert was resolved")
|
|
193
|
-
acknowledged_at: Optional[datetime] = Field(
|
|
194
|
-
default=None, description="When alert was acknowledged"
|
|
195
|
-
)
|
|
196
|
-
|
|
197
|
-
# Status tracking
|
|
198
|
-
is_active: bool = Field(default=True, description="Whether alert is still active")
|
|
199
|
-
is_acknowledged: bool = Field(default=False, description="Whether alert was acknowledged")
|
|
200
|
-
is_resolved: bool = Field(default=False, description="Whether alert was resolved")
|
|
201
|
-
|
|
202
|
-
# Context
|
|
203
|
-
current_value: Optional[float] = Field(default=None, description="Current metric value")
|
|
204
|
-
threshold_value: Optional[float] = Field(
|
|
205
|
-
default=None, description="Threshold that was breached"
|
|
206
|
-
)
|
|
207
|
-
previous_status: Optional[ComponentStatus] = Field(
|
|
208
|
-
default=None, description="Previous component status"
|
|
209
|
-
)
|
|
210
|
-
current_status: ComponentStatus = Field(..., description="Current component status")
|
|
211
|
-
|
|
212
|
-
# Metadata
|
|
213
|
-
tags: Dict[str, str] = Field(default_factory=dict, description="Alert tags")
|
|
214
|
-
additional_data: Dict[str, Any] = Field(
|
|
215
|
-
default_factory=dict, description="Additional alert data"
|
|
216
|
-
)
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
class SystemHealthSummary(BaseModel):
|
|
220
|
-
"""Overall system health summary model."""
|
|
221
|
-
|
|
222
|
-
model_config = ConfigDict(extra="forbid")
|
|
223
|
-
|
|
224
|
-
# Overall status
|
|
225
|
-
overall_status: ComponentStatus = Field(..., description="Overall system status")
|
|
226
|
-
healthy_components: int = Field(default=0, description="Number of healthy components")
|
|
227
|
-
degraded_components: int = Field(default=0, description="Number of degraded components")
|
|
228
|
-
unhealthy_components: int = Field(default=0, description="Number of unhealthy components")
|
|
229
|
-
total_components: int = Field(default=0, description="Total number of components")
|
|
230
|
-
|
|
231
|
-
# System metrics
|
|
232
|
-
system_uptime_seconds: float = Field(default=0.0, description="System uptime")
|
|
233
|
-
avg_response_time_ms: float = Field(default=0.0, description="Average response time")
|
|
234
|
-
total_requests: int = Field(default=0, description="Total requests processed")
|
|
235
|
-
error_rate_percent: float = Field(default=0.0, description="Overall error rate")
|
|
236
|
-
|
|
237
|
-
# Resource utilization
|
|
238
|
-
avg_cpu_usage_percent: float = Field(default=0.0, description="Average CPU usage")
|
|
239
|
-
avg_memory_usage_percent: float = Field(default=0.0, description="Average memory usage")
|
|
240
|
-
avg_disk_usage_percent: float = Field(default=0.0, description="Average disk usage")
|
|
241
|
-
|
|
242
|
-
# Alert summary
|
|
243
|
-
active_alerts: int = Field(default=0, description="Number of active alerts")
|
|
244
|
-
critical_alerts: int = Field(default=0, description="Number of critical alerts")
|
|
245
|
-
warning_alerts: int = Field(default=0, description="Number of warning alerts")
|
|
246
|
-
|
|
247
|
-
# Timestamps
|
|
248
|
-
last_updated: datetime = Field(default_factory=lambda: datetime.now(timezone.utc))
|
|
249
|
-
monitoring_since: datetime = Field(default_factory=lambda: datetime.now(timezone.utc))
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
class HealthCheckResult(BaseModel):
|
|
253
|
-
"""Health check execution result model."""
|
|
254
|
-
|
|
255
|
-
model_config = ConfigDict(extra="forbid")
|
|
256
|
-
|
|
257
|
-
# Check identification
|
|
258
|
-
check_id: str = Field(default_factory=lambda: str(uuid.uuid4()))
|
|
259
|
-
component_id: str = Field(..., description="Component being checked")
|
|
260
|
-
check_type: HealthCheckType = Field(..., description="Type of check")
|
|
261
|
-
|
|
262
|
-
# Result
|
|
263
|
-
status: ComponentStatus = Field(..., description="Check result status")
|
|
264
|
-
success: bool = Field(..., description="Whether check was successful")
|
|
265
|
-
response_time_ms: float = Field(..., description="Check response time")
|
|
266
|
-
|
|
267
|
-
# Details
|
|
268
|
-
message: str = Field(default="", description="Check result message")
|
|
269
|
-
error_message: Optional[str] = Field(default=None, description="Error message if failed")
|
|
270
|
-
details: Dict[str, Any] = Field(default_factory=dict, description="Additional check details")
|
|
271
|
-
|
|
272
|
-
# Metrics collected during check
|
|
273
|
-
cpu_usage: Optional[float] = Field(default=None, description="CPU usage at check time")
|
|
274
|
-
memory_usage: Optional[float] = Field(default=None, description="Memory usage at check time")
|
|
275
|
-
disk_usage: Optional[float] = Field(default=None, description="Disk usage at check time")
|
|
276
|
-
network_latency_ms: Optional[float] = Field(default=None, description="Network latency")
|
|
277
|
-
|
|
278
|
-
# Timing
|
|
279
|
-
started_at: datetime = Field(default_factory=lambda: datetime.now(timezone.utc))
|
|
280
|
-
completed_at: datetime = Field(default_factory=lambda: datetime.now(timezone.utc))
|
|
281
|
-
|
|
282
|
-
# Context
|
|
283
|
-
retry_attempt: int = Field(default=0, description="Retry attempt number")
|
|
284
|
-
is_retry: bool = Field(default=False, description="Whether this was a retry")
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
class HealthTrend(BaseModel):
|
|
288
|
-
"""Health trend analysis model."""
|
|
289
|
-
|
|
290
|
-
model_config = ConfigDict(extra="forbid")
|
|
291
|
-
|
|
292
|
-
# Component identification
|
|
293
|
-
component_id: str = Field(..., description="Component ID")
|
|
294
|
-
metric_name: str = Field(..., description="Metric being analyzed")
|
|
295
|
-
|
|
296
|
-
# Trend analysis
|
|
297
|
-
trend_direction: str = Field(..., description="Trend direction (up/down/stable)")
|
|
298
|
-
trend_strength: float = Field(..., description="Trend strength (0.0-1.0)")
|
|
299
|
-
change_percentage: float = Field(..., description="Percentage change")
|
|
300
|
-
|
|
301
|
-
# Time periods
|
|
302
|
-
analysis_period_hours: int = Field(..., description="Analysis period in hours")
|
|
303
|
-
data_points: int = Field(..., description="Number of data points analyzed")
|
|
304
|
-
|
|
305
|
-
# Statistical measures
|
|
306
|
-
current_value: float = Field(..., description="Current metric value")
|
|
307
|
-
average_value: float = Field(..., description="Average value in period")
|
|
308
|
-
min_value: float = Field(..., description="Minimum value in period")
|
|
309
|
-
max_value: float = Field(..., description="Maximum value in period")
|
|
310
|
-
standard_deviation: float = Field(..., description="Standard deviation")
|
|
311
|
-
|
|
312
|
-
# Predictions
|
|
313
|
-
predicted_value_1h: Optional[float] = Field(
|
|
314
|
-
default=None, description="Predicted value in 1 hour"
|
|
315
|
-
)
|
|
316
|
-
predicted_value_24h: Optional[float] = Field(
|
|
317
|
-
default=None, description="Predicted value in 24 hours"
|
|
318
|
-
)
|
|
319
|
-
confidence_level: float = Field(default=0.0, description="Prediction confidence (0.0-1.0)")
|
|
320
|
-
|
|
321
|
-
# Analysis timestamp
|
|
322
|
-
analyzed_at: datetime = Field(default_factory=lambda: datetime.now(timezone.utc))
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
__all__ = [
|
|
326
|
-
# Enums
|
|
327
|
-
"ComponentStatus",
|
|
328
|
-
"HealthCheckType",
|
|
329
|
-
"AlertSeverity",
|
|
330
|
-
"HealthCheckFrequency",
|
|
331
|
-
# Core models
|
|
332
|
-
"ConnectionHealthStatus",
|
|
333
|
-
"ComponentHealth",
|
|
334
|
-
"HealthCheckConfig",
|
|
335
|
-
"HealthAlert",
|
|
336
|
-
"SystemHealthSummary",
|
|
337
|
-
"HealthCheckResult",
|
|
338
|
-
"HealthTrend",
|
|
339
|
-
]
|
|
@@ -1,336 +0,0 @@
|
|
|
1
|
-
"""
|
|
2
|
-
Load Balancing DTOs - Data Transfer Objects for load balancing system.
|
|
3
|
-
|
|
4
|
-
This module contains all Pydantic models, enums, and dataclasses related to load balancing,
|
|
5
|
-
separated from business logic for clean architecture and reusability.
|
|
6
|
-
|
|
7
|
-
Components:
|
|
8
|
-
- Load balancing strategies and algorithms
|
|
9
|
-
- Node health and performance tracking
|
|
10
|
-
- Traffic distribution and routing models
|
|
11
|
-
- Circuit breaker and failover patterns
|
|
12
|
-
"""
|
|
13
|
-
|
|
14
|
-
from typing import Dict, List, Optional, Any, Set
|
|
15
|
-
from datetime import datetime, timezone, timedelta
|
|
16
|
-
from enum import Enum
|
|
17
|
-
from dataclasses import dataclass, field
|
|
18
|
-
|
|
19
|
-
from pydantic import BaseModel, Field, ConfigDict
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
class LoadBalancingAlgorithm(str, Enum):
|
|
23
|
-
"""Load balancing algorithms."""
|
|
24
|
-
|
|
25
|
-
ROUND_ROBIN = "round_robin" # Simple round-robin
|
|
26
|
-
WEIGHTED_ROUND_ROBIN = "weighted_round_robin" # Weighted round-robin
|
|
27
|
-
LEAST_CONNECTIONS = "least_connections" # Least active connections
|
|
28
|
-
WEIGHTED_LEAST_CONNECTIONS = "weighted_least_connections" # Weighted least connections
|
|
29
|
-
LEAST_RESPONSE_TIME = "least_response_time" # Fastest response time
|
|
30
|
-
RESOURCE_BASED = "resource_based" # Based on resource utilization
|
|
31
|
-
GEOGRAPHIC = "geographic" # Geographic proximity
|
|
32
|
-
HASH_BASED = "hash_based" # Consistent hashing
|
|
33
|
-
RANDOM = "random" # Random selection
|
|
34
|
-
ADAPTIVE = "adaptive" # Adaptive algorithm
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
class NodeHealthStatus(str, Enum):
|
|
38
|
-
"""Node health status."""
|
|
39
|
-
|
|
40
|
-
HEALTHY = "healthy" # Node is healthy and available
|
|
41
|
-
DEGRADED = "degraded" # Node is working but performance is degraded
|
|
42
|
-
UNHEALTHY = "unhealthy" # Node is unhealthy but still responding
|
|
43
|
-
UNAVAILABLE = "unavailable" # Node is not responding
|
|
44
|
-
DRAINING = "draining" # Node is draining connections
|
|
45
|
-
MAINTENANCE = "maintenance" # Node is under maintenance
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
class TrafficDirection(str, Enum):
|
|
49
|
-
"""Traffic direction for routing."""
|
|
50
|
-
|
|
51
|
-
INBOUND = "inbound" # Incoming traffic
|
|
52
|
-
OUTBOUND = "outbound" # Outgoing traffic
|
|
53
|
-
BIDIRECTIONAL = "bidirectional" # Both directions
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
class FailoverStrategy(str, Enum):
|
|
57
|
-
"""Failover strategies."""
|
|
58
|
-
|
|
59
|
-
IMMEDIATE = "immediate" # Immediate failover
|
|
60
|
-
GRACEFUL = "graceful" # Graceful failover with draining
|
|
61
|
-
DELAYED = "delayed" # Delayed failover with retry
|
|
62
|
-
CIRCUIT_BREAKER = "circuit_breaker" # Circuit breaker pattern
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
class CircuitBreakerState(str, Enum):
|
|
66
|
-
"""Circuit breaker states."""
|
|
67
|
-
|
|
68
|
-
CLOSED = "closed" # Normal operation
|
|
69
|
-
OPEN = "open" # Circuit breaker is open (failing)
|
|
70
|
-
HALF_OPEN = "half_open" # Testing if service is back
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
class LoadBalancerNode(BaseModel):
|
|
74
|
-
"""Load balancer node configuration and status."""
|
|
75
|
-
|
|
76
|
-
model_config = ConfigDict(extra="forbid")
|
|
77
|
-
|
|
78
|
-
# Node identification
|
|
79
|
-
node_id: str = Field(..., description="Unique node identifier")
|
|
80
|
-
node_name: str = Field(..., description="Human-readable node name")
|
|
81
|
-
host: str = Field(..., description="Node hostname or IP")
|
|
82
|
-
port: int = Field(..., description="Node port")
|
|
83
|
-
|
|
84
|
-
# Node configuration
|
|
85
|
-
weight: int = Field(default=1, description="Node weight for weighted algorithms")
|
|
86
|
-
priority: int = Field(default=1, description="Node priority (1=highest)")
|
|
87
|
-
max_connections: Optional[int] = Field(default=None, description="Maximum connections")
|
|
88
|
-
timeout_seconds: float = Field(default=30.0, description="Connection timeout")
|
|
89
|
-
|
|
90
|
-
# Health and status
|
|
91
|
-
health_status: NodeHealthStatus = Field(
|
|
92
|
-
default=NodeHealthStatus.HEALTHY, description="Health status"
|
|
93
|
-
)
|
|
94
|
-
is_enabled: bool = Field(default=True, description="Whether node is enabled")
|
|
95
|
-
last_health_check: Optional[datetime] = Field(
|
|
96
|
-
default=None, description="Last health check time"
|
|
97
|
-
)
|
|
98
|
-
|
|
99
|
-
# Performance metrics
|
|
100
|
-
current_connections: int = Field(default=0, description="Current active connections")
|
|
101
|
-
total_requests: int = Field(default=0, description="Total requests handled")
|
|
102
|
-
failed_requests: int = Field(default=0, description="Failed requests count")
|
|
103
|
-
avg_response_time_ms: float = Field(default=0.0, description="Average response time")
|
|
104
|
-
|
|
105
|
-
# Geographic and metadata
|
|
106
|
-
region: Optional[str] = Field(default=None, description="Geographic region")
|
|
107
|
-
zone: Optional[str] = Field(default=None, description="Availability zone")
|
|
108
|
-
tags: Dict[str, str] = Field(default_factory=dict, description="Node tags")
|
|
109
|
-
|
|
110
|
-
# Circuit breaker
|
|
111
|
-
circuit_breaker_state: CircuitBreakerState = Field(
|
|
112
|
-
default=CircuitBreakerState.CLOSED, description="Circuit breaker state"
|
|
113
|
-
)
|
|
114
|
-
failure_count: int = Field(default=0, description="Consecutive failure count")
|
|
115
|
-
last_failure: Optional[datetime] = Field(default=None, description="Last failure time")
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
class LoadBalancingRule(BaseModel):
|
|
119
|
-
"""Load balancing rule configuration."""
|
|
120
|
-
|
|
121
|
-
model_config = ConfigDict(extra="forbid")
|
|
122
|
-
|
|
123
|
-
# Rule identification
|
|
124
|
-
rule_id: str = Field(..., description="Rule identifier")
|
|
125
|
-
rule_name: str = Field(..., description="Rule name")
|
|
126
|
-
|
|
127
|
-
# Rule configuration
|
|
128
|
-
algorithm: LoadBalancingAlgorithm = Field(..., description="Load balancing algorithm")
|
|
129
|
-
traffic_direction: TrafficDirection = Field(
|
|
130
|
-
default=TrafficDirection.INBOUND, description="Traffic direction"
|
|
131
|
-
)
|
|
132
|
-
priority: int = Field(default=1, description="Rule priority")
|
|
133
|
-
|
|
134
|
-
# Conditions
|
|
135
|
-
source_patterns: List[str] = Field(
|
|
136
|
-
default_factory=list, description="Source IP/hostname patterns"
|
|
137
|
-
)
|
|
138
|
-
destination_patterns: List[str] = Field(
|
|
139
|
-
default_factory=list, description="Destination patterns"
|
|
140
|
-
)
|
|
141
|
-
port_ranges: List[str] = Field(default_factory=list, description="Port ranges")
|
|
142
|
-
path_patterns: List[str] = Field(default_factory=list, description="URL path patterns")
|
|
143
|
-
|
|
144
|
-
# Target nodes
|
|
145
|
-
target_nodes: List[str] = Field(default_factory=list, description="Target node IDs")
|
|
146
|
-
backup_nodes: List[str] = Field(default_factory=list, description="Backup node IDs")
|
|
147
|
-
|
|
148
|
-
# Failover configuration
|
|
149
|
-
failover_strategy: FailoverStrategy = Field(
|
|
150
|
-
default=FailoverStrategy.GRACEFUL, description="Failover strategy"
|
|
151
|
-
)
|
|
152
|
-
health_check_interval_seconds: float = Field(default=30.0, description="Health check interval")
|
|
153
|
-
failure_threshold: int = Field(default=3, description="Failure threshold for marking unhealthy")
|
|
154
|
-
recovery_threshold: int = Field(default=2, description="Recovery threshold for marking healthy")
|
|
155
|
-
|
|
156
|
-
# Advanced settings
|
|
157
|
-
session_affinity: bool = Field(default=False, description="Enable session affinity")
|
|
158
|
-
connection_draining_timeout_seconds: float = Field(
|
|
159
|
-
default=300.0, description="Connection draining timeout"
|
|
160
|
-
)
|
|
161
|
-
enable_circuit_breaker: bool = Field(default=True, description="Enable circuit breaker")
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
class LoadBalancingDecisionRequest(BaseModel):
|
|
165
|
-
"""Request for load balancing decision."""
|
|
166
|
-
|
|
167
|
-
model_config = ConfigDict(extra="forbid")
|
|
168
|
-
|
|
169
|
-
# Request identification
|
|
170
|
-
request_id: str = Field(..., description="Request identifier")
|
|
171
|
-
session_id: Optional[str] = Field(default=None, description="Session identifier")
|
|
172
|
-
|
|
173
|
-
# Request details
|
|
174
|
-
source_ip: str = Field(..., description="Source IP address")
|
|
175
|
-
source_port: Optional[int] = Field(default=None, description="Source port")
|
|
176
|
-
destination_ip: Optional[str] = Field(default=None, description="Destination IP")
|
|
177
|
-
destination_port: Optional[int] = Field(default=None, description="Destination port")
|
|
178
|
-
|
|
179
|
-
# HTTP-specific (if applicable)
|
|
180
|
-
http_method: Optional[str] = Field(default=None, description="HTTP method")
|
|
181
|
-
path: Optional[str] = Field(default=None, description="Request path")
|
|
182
|
-
headers: Dict[str, str] = Field(default_factory=dict, description="Request headers")
|
|
183
|
-
|
|
184
|
-
# Context
|
|
185
|
-
timestamp: datetime = Field(
|
|
186
|
-
default_factory=lambda: datetime.now(timezone.utc), description="Request timestamp"
|
|
187
|
-
)
|
|
188
|
-
traffic_direction: TrafficDirection = Field(
|
|
189
|
-
default=TrafficDirection.INBOUND, description="Traffic direction"
|
|
190
|
-
)
|
|
191
|
-
priority: int = Field(default=1, description="Request priority")
|
|
192
|
-
|
|
193
|
-
# Constraints
|
|
194
|
-
required_tags: Dict[str, str] = Field(default_factory=dict, description="Required node tags")
|
|
195
|
-
excluded_nodes: Set[str] = Field(default_factory=set, description="Nodes to exclude")
|
|
196
|
-
preferred_region: Optional[str] = Field(default=None, description="Preferred geographic region")
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
class LoadBalancingDecisionResult(BaseModel):
|
|
200
|
-
"""Result of load balancing decision."""
|
|
201
|
-
|
|
202
|
-
model_config = ConfigDict(extra="forbid")
|
|
203
|
-
|
|
204
|
-
# Decision result
|
|
205
|
-
selected_node: Optional[LoadBalancerNode] = Field(default=None, description="Selected node")
|
|
206
|
-
backup_nodes: List[LoadBalancerNode] = Field(default_factory=list, description="Backup nodes")
|
|
207
|
-
|
|
208
|
-
# Decision metadata
|
|
209
|
-
algorithm_used: LoadBalancingAlgorithm = Field(..., description="Algorithm used")
|
|
210
|
-
rule_applied: Optional[str] = Field(default=None, description="Rule ID applied")
|
|
211
|
-
decision_time_ms: float = Field(..., description="Time taken to make decision")
|
|
212
|
-
|
|
213
|
-
# Reasoning
|
|
214
|
-
selection_factors: Dict[str, Any] = Field(
|
|
215
|
-
default_factory=dict, description="Factors in selection"
|
|
216
|
-
)
|
|
217
|
-
rejected_nodes: List[str] = Field(default_factory=list, description="Rejected node IDs")
|
|
218
|
-
rejection_reasons: Dict[str, str] = Field(default_factory=dict, description="Rejection reasons")
|
|
219
|
-
|
|
220
|
-
# Session affinity
|
|
221
|
-
session_affinity_used: bool = Field(
|
|
222
|
-
default=False, description="Whether session affinity was used"
|
|
223
|
-
)
|
|
224
|
-
new_session_created: bool = Field(default=False, description="Whether new session was created")
|
|
225
|
-
|
|
226
|
-
# Timing
|
|
227
|
-
timestamp: datetime = Field(
|
|
228
|
-
default_factory=lambda: datetime.now(timezone.utc), description="Decision timestamp"
|
|
229
|
-
)
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
class LoadBalancerStatistics(BaseModel):
|
|
233
|
-
"""Load balancer statistics and metrics."""
|
|
234
|
-
|
|
235
|
-
model_config = ConfigDict(extra="forbid")
|
|
236
|
-
|
|
237
|
-
# Request metrics
|
|
238
|
-
total_requests: int = Field(default=0, description="Total requests processed")
|
|
239
|
-
successful_requests: int = Field(default=0, description="Successful requests")
|
|
240
|
-
failed_requests: int = Field(default=0, description="Failed requests")
|
|
241
|
-
avg_response_time_ms: float = Field(default=0.0, description="Average response time")
|
|
242
|
-
|
|
243
|
-
# Node metrics
|
|
244
|
-
total_nodes: int = Field(default=0, description="Total configured nodes")
|
|
245
|
-
healthy_nodes: int = Field(default=0, description="Healthy nodes")
|
|
246
|
-
unhealthy_nodes: int = Field(default=0, description="Unhealthy nodes")
|
|
247
|
-
|
|
248
|
-
# Algorithm metrics
|
|
249
|
-
algorithm_usage: Dict[str, int] = Field(
|
|
250
|
-
default_factory=dict, description="Usage count by algorithm"
|
|
251
|
-
)
|
|
252
|
-
node_selection_count: Dict[str, int] = Field(
|
|
253
|
-
default_factory=dict, description="Selection count by node"
|
|
254
|
-
)
|
|
255
|
-
|
|
256
|
-
# Circuit breaker metrics
|
|
257
|
-
circuit_breaker_trips: int = Field(default=0, description="Circuit breaker trip count")
|
|
258
|
-
failover_events: int = Field(default=0, description="Failover events")
|
|
259
|
-
|
|
260
|
-
# Performance metrics
|
|
261
|
-
decisions_per_second: float = Field(
|
|
262
|
-
default=0.0, description="Load balancing decisions per second"
|
|
263
|
-
)
|
|
264
|
-
avg_decision_time_ms: float = Field(default=0.0, description="Average decision time")
|
|
265
|
-
|
|
266
|
-
# Time range
|
|
267
|
-
start_time: datetime = Field(
|
|
268
|
-
default_factory=lambda: datetime.now(timezone.utc), description="Statistics start time"
|
|
269
|
-
)
|
|
270
|
-
end_time: datetime = Field(
|
|
271
|
-
default_factory=lambda: datetime.now(timezone.utc), description="Statistics end time"
|
|
272
|
-
)
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
class HealthCheckConfig(BaseModel):
|
|
276
|
-
"""Health check configuration."""
|
|
277
|
-
|
|
278
|
-
model_config = ConfigDict(extra="forbid")
|
|
279
|
-
|
|
280
|
-
# Basic settings
|
|
281
|
-
enabled: bool = Field(default=True, description="Enable health checks")
|
|
282
|
-
interval_seconds: float = Field(default=30.0, description="Health check interval")
|
|
283
|
-
timeout_seconds: float = Field(default=10.0, description="Health check timeout")
|
|
284
|
-
|
|
285
|
-
# Thresholds
|
|
286
|
-
failure_threshold: int = Field(default=3, description="Failures before marking unhealthy")
|
|
287
|
-
success_threshold: int = Field(default=2, description="Successes before marking healthy")
|
|
288
|
-
|
|
289
|
-
# Check configuration
|
|
290
|
-
check_type: str = Field(default="tcp", description="Health check type (tcp, http, https)")
|
|
291
|
-
check_path: str = Field(default="/health", description="Health check path (for HTTP)")
|
|
292
|
-
expected_status_codes: List[int] = Field(
|
|
293
|
-
default_factory=lambda: [200], description="Expected HTTP status codes"
|
|
294
|
-
)
|
|
295
|
-
expected_response_body: Optional[str] = Field(
|
|
296
|
-
default=None, description="Expected response body pattern"
|
|
297
|
-
)
|
|
298
|
-
|
|
299
|
-
# Advanced settings
|
|
300
|
-
follow_redirects: bool = Field(default=False, description="Follow HTTP redirects")
|
|
301
|
-
verify_ssl: bool = Field(default=True, description="Verify SSL certificates")
|
|
302
|
-
custom_headers: Dict[str, str] = Field(default_factory=dict, description="Custom headers")
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
@dataclass
|
|
306
|
-
class LoadBalancingSession:
|
|
307
|
-
"""Load balancing session for sticky sessions."""
|
|
308
|
-
|
|
309
|
-
session_id: str
|
|
310
|
-
client_ip: str
|
|
311
|
-
assigned_node_id: str
|
|
312
|
-
created_at: datetime
|
|
313
|
-
last_accessed: datetime
|
|
314
|
-
request_count: int = 0
|
|
315
|
-
is_active: bool = True
|
|
316
|
-
expires_at: Optional[datetime] = None
|
|
317
|
-
metadata: Dict[str, Any] = field(default_factory=dict)
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
__all__ = [
|
|
321
|
-
# Enums
|
|
322
|
-
"LoadBalancingAlgorithm",
|
|
323
|
-
"NodeHealthStatus",
|
|
324
|
-
"TrafficDirection",
|
|
325
|
-
"FailoverStrategy",
|
|
326
|
-
"CircuitBreakerState",
|
|
327
|
-
# Core models
|
|
328
|
-
"LoadBalancerNode",
|
|
329
|
-
"LoadBalancingRule",
|
|
330
|
-
"LoadBalancingDecisionRequest",
|
|
331
|
-
"LoadBalancingDecisionResult",
|
|
332
|
-
"LoadBalancerStatistics",
|
|
333
|
-
"HealthCheckConfig",
|
|
334
|
-
# Data classes
|
|
335
|
-
"LoadBalancingSession",
|
|
336
|
-
]
|