unrealon 1.1.5__py3-none-any.whl → 2.0.4__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-1.1.5.dist-info/licenses → unrealon-2.0.4.dist-info}/LICENSE +1 -1
- unrealon-2.0.4.dist-info/METADATA +491 -0
- unrealon-2.0.4.dist-info/RECORD +129 -0
- {unrealon-1.1.5.dist-info → unrealon-2.0.4.dist-info}/WHEEL +2 -1
- unrealon-2.0.4.dist-info/entry_points.txt +3 -0
- unrealon-2.0.4.dist-info/top_level.txt +3 -0
- unrealon_browser/__init__.py +5 -2
- unrealon_browser/cli/browser_cli.py +18 -9
- unrealon_browser/cli/interactive_mode.py +18 -7
- unrealon_browser/core/browser_manager.py +76 -13
- unrealon_browser/dto/__init__.py +21 -0
- unrealon_browser/dto/bot_detection.py +175 -0
- unrealon_browser/dto/models/config.py +14 -1
- unrealon_browser/managers/__init__.py +4 -1
- unrealon_browser/managers/logger_bridge.py +3 -6
- unrealon_browser/managers/page_wait_manager.py +198 -0
- unrealon_browser/stealth/__init__.py +27 -0
- unrealon_browser/stealth/bypass_techniques.pyc +0 -0
- unrealon_browser/stealth/manager.pyc +0 -0
- unrealon_browser/stealth/nodriver_stealth.pyc +0 -0
- unrealon_browser/stealth/playwright_stealth.pyc +0 -0
- unrealon_browser/stealth/scanner_tester.pyc +0 -0
- unrealon_browser/stealth/undetected_chrome.pyc +0 -0
- unrealon_core/__init__.py +160 -0
- unrealon_core/config/__init__.py +16 -0
- unrealon_core/config/environment.py +98 -0
- unrealon_core/config/urls.py +93 -0
- unrealon_core/enums/__init__.py +24 -0
- unrealon_core/enums/status.py +216 -0
- unrealon_core/enums/types.py +240 -0
- unrealon_core/error_handling/__init__.py +45 -0
- unrealon_core/error_handling/circuit_breaker.py +292 -0
- unrealon_core/error_handling/error_context.py +324 -0
- unrealon_core/error_handling/recovery.py +371 -0
- unrealon_core/error_handling/retry.py +268 -0
- unrealon_core/exceptions/__init__.py +46 -0
- unrealon_core/exceptions/base.py +292 -0
- unrealon_core/exceptions/communication.py +22 -0
- unrealon_core/exceptions/driver.py +11 -0
- unrealon_core/exceptions/proxy.py +11 -0
- unrealon_core/exceptions/task.py +12 -0
- unrealon_core/exceptions/validation.py +17 -0
- unrealon_core/models/__init__.py +98 -0
- unrealon_core/models/arq_context.py +252 -0
- unrealon_core/models/arq_responses.py +125 -0
- unrealon_core/models/base.py +291 -0
- unrealon_core/models/bridge_stats.py +58 -0
- unrealon_core/models/communication.py +39 -0
- unrealon_core/models/config.py +47 -0
- unrealon_core/models/connection_stats.py +47 -0
- unrealon_core/models/driver.py +30 -0
- unrealon_core/models/driver_details.py +98 -0
- unrealon_core/models/logging.py +28 -0
- unrealon_core/models/task.py +21 -0
- unrealon_core/models/typed_responses.py +210 -0
- unrealon_core/models/websocket/__init__.py +91 -0
- unrealon_core/models/websocket/base.py +49 -0
- unrealon_core/models/websocket/config.py +200 -0
- unrealon_core/models/websocket/driver.py +215 -0
- unrealon_core/models/websocket/errors.py +138 -0
- unrealon_core/models/websocket/heartbeat.py +100 -0
- unrealon_core/models/websocket/logging.py +261 -0
- unrealon_core/models/websocket/proxy.py +496 -0
- unrealon_core/models/websocket/tasks.py +275 -0
- unrealon_core/models/websocket/utils.py +153 -0
- unrealon_core/models/websocket_session.py +144 -0
- unrealon_core/monitoring/__init__.py +43 -0
- unrealon_core/monitoring/alerts.py +398 -0
- unrealon_core/monitoring/dashboard.py +307 -0
- unrealon_core/monitoring/health_check.py +354 -0
- unrealon_core/monitoring/metrics.py +352 -0
- unrealon_core/utils/__init__.py +11 -0
- unrealon_core/utils/time.py +61 -0
- unrealon_core/version.py +219 -0
- unrealon_driver/__init__.py +88 -50
- unrealon_driver/core_module/__init__.py +34 -0
- unrealon_driver/core_module/base.py +184 -0
- unrealon_driver/core_module/config.py +30 -0
- unrealon_driver/core_module/event_manager.py +127 -0
- unrealon_driver/core_module/protocols.py +98 -0
- unrealon_driver/core_module/registry.py +146 -0
- unrealon_driver/decorators/__init__.py +15 -0
- unrealon_driver/decorators/retry.py +117 -0
- unrealon_driver/decorators/schedule.py +137 -0
- unrealon_driver/decorators/task.py +61 -0
- unrealon_driver/decorators/timing.py +132 -0
- unrealon_driver/driver/__init__.py +20 -0
- unrealon_driver/driver/communication/__init__.py +10 -0
- unrealon_driver/driver/communication/session.py +203 -0
- unrealon_driver/driver/communication/websocket_client.py +197 -0
- unrealon_driver/driver/core/__init__.py +10 -0
- unrealon_driver/driver/core/config.py +85 -0
- unrealon_driver/driver/core/driver.py +221 -0
- unrealon_driver/driver/factory/__init__.py +9 -0
- unrealon_driver/driver/factory/manager_factory.py +130 -0
- unrealon_driver/driver/lifecycle/__init__.py +11 -0
- unrealon_driver/driver/lifecycle/daemon.py +76 -0
- unrealon_driver/driver/lifecycle/initialization.py +97 -0
- unrealon_driver/driver/lifecycle/shutdown.py +48 -0
- unrealon_driver/driver/monitoring/__init__.py +9 -0
- unrealon_driver/driver/monitoring/health.py +63 -0
- unrealon_driver/driver/utilities/__init__.py +10 -0
- unrealon_driver/driver/utilities/logging.py +51 -0
- unrealon_driver/driver/utilities/serialization.py +61 -0
- unrealon_driver/managers/__init__.py +32 -0
- unrealon_driver/managers/base.py +174 -0
- unrealon_driver/managers/browser.py +98 -0
- unrealon_driver/managers/cache.py +116 -0
- unrealon_driver/managers/http.py +107 -0
- unrealon_driver/managers/logger.py +286 -0
- unrealon_driver/managers/proxy.py +99 -0
- unrealon_driver/managers/registry.py +87 -0
- unrealon_driver/managers/threading.py +54 -0
- unrealon_driver/managers/update.py +107 -0
- unrealon_driver/utils/__init__.py +9 -0
- unrealon_driver/utils/time.py +10 -0
- unrealon/__init__.py +0 -40
- unrealon-1.1.5.dist-info/METADATA +0 -621
- unrealon-1.1.5.dist-info/RECORD +0 -54
- unrealon-1.1.5.dist-info/entry_points.txt +0 -9
- unrealon_browser/managers/stealth.py +0 -388
- unrealon_driver/exceptions.py +0 -33
- unrealon_driver/html_analyzer/__init__.py +0 -32
- unrealon_driver/html_analyzer/cleaner.py +0 -657
- unrealon_driver/html_analyzer/config.py +0 -64
- unrealon_driver/html_analyzer/manager.py +0 -247
- unrealon_driver/html_analyzer/models.py +0 -115
- unrealon_driver/html_analyzer/websocket_analyzer.py +0 -157
- unrealon_driver/models/__init__.py +0 -31
- unrealon_driver/models/websocket.py +0 -98
- unrealon_driver/parser/__init__.py +0 -36
- unrealon_driver/parser/cli_manager.py +0 -142
- unrealon_driver/parser/daemon_manager.py +0 -403
- unrealon_driver/parser/managers/__init__.py +0 -25
- unrealon_driver/parser/managers/config.py +0 -293
- unrealon_driver/parser/managers/error.py +0 -412
- unrealon_driver/parser/managers/result.py +0 -321
- unrealon_driver/parser/parser_manager.py +0 -458
- unrealon_driver/smart_logging/__init__.py +0 -24
- unrealon_driver/smart_logging/models.py +0 -44
- unrealon_driver/smart_logging/smart_logger.py +0 -406
- unrealon_driver/smart_logging/unified_logger.py +0 -525
- unrealon_driver/websocket/__init__.py +0 -31
- unrealon_driver/websocket/client.py +0 -249
- unrealon_driver/websocket/config.py +0 -188
- unrealon_driver/websocket/manager.py +0 -90
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Status enums for UnrealOn system.
|
|
3
|
+
|
|
4
|
+
These enums define all possible status values for different
|
|
5
|
+
components in the system. Using enums ensures type safety
|
|
6
|
+
and prevents invalid status values.
|
|
7
|
+
|
|
8
|
+
Phase 1: Foundation status enums
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
from enum import Enum
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class DriverStatus(str, Enum):
|
|
15
|
+
"""
|
|
16
|
+
Driver connection and operational status.
|
|
17
|
+
|
|
18
|
+
Used to track the current state of driver connections
|
|
19
|
+
and their ability to process tasks.
|
|
20
|
+
"""
|
|
21
|
+
|
|
22
|
+
# Connection states
|
|
23
|
+
DISCONNECTED = "disconnected" # Driver is not connected
|
|
24
|
+
CONNECTING = "connecting" # Driver is attempting to connect
|
|
25
|
+
CONNECTED = "connected" # Driver is connected and idle
|
|
26
|
+
|
|
27
|
+
# Operational states
|
|
28
|
+
BUSY = "busy" # Driver is processing a task
|
|
29
|
+
READY = "ready" # Driver is ready to receive tasks
|
|
30
|
+
|
|
31
|
+
# Error states
|
|
32
|
+
ERROR = "error" # Driver encountered an error
|
|
33
|
+
TIMEOUT = "timeout" # Driver connection timed out
|
|
34
|
+
|
|
35
|
+
# Maintenance states
|
|
36
|
+
MAINTENANCE = "maintenance" # Driver is in maintenance mode
|
|
37
|
+
SHUTDOWN = "shutdown" # Driver is shutting down
|
|
38
|
+
|
|
39
|
+
def is_connected(self) -> bool:
|
|
40
|
+
"""Check if driver is in a connected state."""
|
|
41
|
+
return self in [
|
|
42
|
+
DriverStatus.CONNECTED,
|
|
43
|
+
DriverStatus.BUSY,
|
|
44
|
+
DriverStatus.READY
|
|
45
|
+
]
|
|
46
|
+
|
|
47
|
+
def is_available(self) -> bool:
|
|
48
|
+
"""Check if driver is available for new tasks."""
|
|
49
|
+
return self in [
|
|
50
|
+
DriverStatus.CONNECTED,
|
|
51
|
+
DriverStatus.READY
|
|
52
|
+
]
|
|
53
|
+
|
|
54
|
+
def is_error_state(self) -> bool:
|
|
55
|
+
"""Check if driver is in an error state."""
|
|
56
|
+
return self in [
|
|
57
|
+
DriverStatus.ERROR,
|
|
58
|
+
DriverStatus.TIMEOUT
|
|
59
|
+
]
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
class TaskStatus(str, Enum):
|
|
63
|
+
"""
|
|
64
|
+
Task execution status throughout its lifecycle.
|
|
65
|
+
|
|
66
|
+
Tracks a task from creation through completion,
|
|
67
|
+
including error and retry states.
|
|
68
|
+
"""
|
|
69
|
+
|
|
70
|
+
# Initial states
|
|
71
|
+
CREATED = "created" # Task created but not queued
|
|
72
|
+
PENDING = "pending" # Task queued, waiting for assignment
|
|
73
|
+
ASSIGNED = "assigned" # Task assigned to a driver
|
|
74
|
+
|
|
75
|
+
# Execution states
|
|
76
|
+
RUNNING = "running" # Task is being executed
|
|
77
|
+
PAUSED = "paused" # Task execution paused
|
|
78
|
+
|
|
79
|
+
# Completion states
|
|
80
|
+
COMPLETED = "completed" # Task completed successfully
|
|
81
|
+
FAILED = "failed" # Task failed permanently
|
|
82
|
+
CANCELLED = "cancelled" # Task was cancelled
|
|
83
|
+
|
|
84
|
+
# Retry states
|
|
85
|
+
RETRYING = "retrying" # Task is being retried
|
|
86
|
+
RETRY_FAILED = "retry_failed" # All retries exhausted
|
|
87
|
+
|
|
88
|
+
# Timeout states
|
|
89
|
+
TIMEOUT = "timeout" # Task execution timed out
|
|
90
|
+
|
|
91
|
+
def is_active(self) -> bool:
|
|
92
|
+
"""Check if task is actively being processed."""
|
|
93
|
+
return self in [
|
|
94
|
+
TaskStatus.ASSIGNED,
|
|
95
|
+
TaskStatus.RUNNING,
|
|
96
|
+
TaskStatus.RETRYING
|
|
97
|
+
]
|
|
98
|
+
|
|
99
|
+
def is_completed(self) -> bool:
|
|
100
|
+
"""Check if task has reached a final state."""
|
|
101
|
+
return self in [
|
|
102
|
+
TaskStatus.COMPLETED,
|
|
103
|
+
TaskStatus.FAILED,
|
|
104
|
+
TaskStatus.CANCELLED,
|
|
105
|
+
TaskStatus.RETRY_FAILED,
|
|
106
|
+
TaskStatus.TIMEOUT
|
|
107
|
+
]
|
|
108
|
+
|
|
109
|
+
def is_successful(self) -> bool:
|
|
110
|
+
"""Check if task completed successfully."""
|
|
111
|
+
return self == TaskStatus.COMPLETED
|
|
112
|
+
|
|
113
|
+
def can_retry(self) -> bool:
|
|
114
|
+
"""Check if task can be retried."""
|
|
115
|
+
return self in [
|
|
116
|
+
TaskStatus.FAILED,
|
|
117
|
+
TaskStatus.TIMEOUT
|
|
118
|
+
]
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
class ProxyStatus(str, Enum):
|
|
122
|
+
"""
|
|
123
|
+
Proxy server health and availability status.
|
|
124
|
+
|
|
125
|
+
Used to track proxy server health and determine
|
|
126
|
+
which proxies should be used for requests.
|
|
127
|
+
"""
|
|
128
|
+
|
|
129
|
+
# Operational states
|
|
130
|
+
ACTIVE = "active" # Proxy is healthy and available
|
|
131
|
+
INACTIVE = "inactive" # Proxy is temporarily unavailable
|
|
132
|
+
|
|
133
|
+
# Health states
|
|
134
|
+
HEALTHY = "healthy" # Proxy is responding normally
|
|
135
|
+
DEGRADED = "degraded" # Proxy is slow but functional
|
|
136
|
+
|
|
137
|
+
# Error states
|
|
138
|
+
BANNED = "banned" # Proxy is banned/blocked
|
|
139
|
+
TIMEOUT = "timeout" # Proxy is not responding
|
|
140
|
+
ERROR = "error" # Proxy returned errors
|
|
141
|
+
|
|
142
|
+
# Testing states
|
|
143
|
+
TESTING = "testing" # Proxy is being health-checked
|
|
144
|
+
UNKNOWN = "unknown" # Proxy status is unknown
|
|
145
|
+
|
|
146
|
+
def is_usable(self) -> bool:
|
|
147
|
+
"""Check if proxy can be used for requests."""
|
|
148
|
+
return self in [
|
|
149
|
+
ProxyStatus.ACTIVE,
|
|
150
|
+
ProxyStatus.HEALTHY,
|
|
151
|
+
ProxyStatus.DEGRADED
|
|
152
|
+
]
|
|
153
|
+
|
|
154
|
+
def is_healthy(self) -> bool:
|
|
155
|
+
"""Check if proxy is in good health."""
|
|
156
|
+
return self in [
|
|
157
|
+
ProxyStatus.ACTIVE,
|
|
158
|
+
ProxyStatus.HEALTHY
|
|
159
|
+
]
|
|
160
|
+
|
|
161
|
+
def needs_health_check(self) -> bool:
|
|
162
|
+
"""Check if proxy needs a health check."""
|
|
163
|
+
return self in [
|
|
164
|
+
ProxyStatus.UNKNOWN,
|
|
165
|
+
ProxyStatus.TIMEOUT,
|
|
166
|
+
ProxyStatus.ERROR
|
|
167
|
+
]
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
class LogLevel(str, Enum):
|
|
171
|
+
"""
|
|
172
|
+
Logging levels for the UnrealOn system.
|
|
173
|
+
|
|
174
|
+
Standard logging levels with additional
|
|
175
|
+
system-specific levels for better categorization.
|
|
176
|
+
"""
|
|
177
|
+
|
|
178
|
+
# Standard levels
|
|
179
|
+
DEBUG = "debug" # Detailed debugging information
|
|
180
|
+
INFO = "info" # General information
|
|
181
|
+
WARNING = "warning" # Warning messages
|
|
182
|
+
ERROR = "error" # Error messages
|
|
183
|
+
CRITICAL = "critical" # Critical system errors
|
|
184
|
+
|
|
185
|
+
# System-specific levels
|
|
186
|
+
TRACE = "trace" # Very detailed tracing
|
|
187
|
+
PERFORMANCE = "performance" # Performance-related logs
|
|
188
|
+
SECURITY = "security" # Security-related logs
|
|
189
|
+
AUDIT = "audit" # Audit trail logs
|
|
190
|
+
|
|
191
|
+
def get_numeric_level(self) -> int:
|
|
192
|
+
"""Get numeric level for comparison."""
|
|
193
|
+
levels = {
|
|
194
|
+
LogLevel.TRACE: 5,
|
|
195
|
+
LogLevel.DEBUG: 10,
|
|
196
|
+
LogLevel.INFO: 20,
|
|
197
|
+
LogLevel.PERFORMANCE: 25,
|
|
198
|
+
LogLevel.WARNING: 30,
|
|
199
|
+
LogLevel.ERROR: 40,
|
|
200
|
+
LogLevel.SECURITY: 45,
|
|
201
|
+
LogLevel.CRITICAL: 50,
|
|
202
|
+
LogLevel.AUDIT: 60,
|
|
203
|
+
}
|
|
204
|
+
return levels.get(self, 20)
|
|
205
|
+
|
|
206
|
+
def is_at_least(self, other: 'LogLevel') -> bool:
|
|
207
|
+
"""Check if this level is at least as severe as another."""
|
|
208
|
+
return self.get_numeric_level() >= other.get_numeric_level()
|
|
209
|
+
|
|
210
|
+
@classmethod
|
|
211
|
+
def from_string(cls, level_str: str) -> 'LogLevel':
|
|
212
|
+
"""Create LogLevel from string, with fallback to INFO."""
|
|
213
|
+
try:
|
|
214
|
+
return cls(level_str.lower())
|
|
215
|
+
except ValueError:
|
|
216
|
+
return cls.INFO
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Type enums for UnrealOn system.
|
|
3
|
+
|
|
4
|
+
These enums define types for messages, proxies, tasks, and other
|
|
5
|
+
system components. They ensure type safety and consistent
|
|
6
|
+
categorization throughout the system.
|
|
7
|
+
|
|
8
|
+
Phase 1: Foundation type enums
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
from enum import Enum
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class MessageType(str, Enum):
|
|
15
|
+
"""
|
|
16
|
+
WebSocket message types for driver communication.
|
|
17
|
+
|
|
18
|
+
Defines all possible message types that can be sent
|
|
19
|
+
between the system and drivers via WebSocket.
|
|
20
|
+
"""
|
|
21
|
+
|
|
22
|
+
# Driver lifecycle messages
|
|
23
|
+
DRIVER_REGISTER = "driver_register" # Driver registration request
|
|
24
|
+
DRIVER_REGISTER_RESPONSE = "driver_register_response" # Registration response
|
|
25
|
+
DRIVER_HEARTBEAT = "driver_heartbeat" # Driver heartbeat/ping
|
|
26
|
+
DRIVER_STATUS = "driver_status" # Driver status update
|
|
27
|
+
DRIVER_DISCONNECT = "driver_disconnect" # Driver disconnect notification
|
|
28
|
+
|
|
29
|
+
# Task management messages
|
|
30
|
+
TASK_ASSIGN = "task_assign" # Assign task to driver
|
|
31
|
+
TASK_RESULT = "task_result" # Task result from driver
|
|
32
|
+
TASK_ERROR = "task_error" # Task error from driver
|
|
33
|
+
TASK_PROGRESS = "task_progress" # Task progress update
|
|
34
|
+
TASK_CANCEL = "task_cancel" # Cancel task request
|
|
35
|
+
|
|
36
|
+
# Command messages
|
|
37
|
+
COMMAND_START = "command_start" # Start command
|
|
38
|
+
COMMAND_STOP = "command_stop" # Stop command
|
|
39
|
+
COMMAND_RESTART = "command_restart" # Restart command
|
|
40
|
+
COMMAND_PAUSE = "command_pause" # Pause command
|
|
41
|
+
COMMAND_RESUME = "command_resume" # Resume command
|
|
42
|
+
COMMAND_CONFIG_UPDATE = "command_config_update" # Update configuration
|
|
43
|
+
|
|
44
|
+
# Proxy management messages
|
|
45
|
+
PROXY_REQUEST = "proxy_request" # Request proxy from pool
|
|
46
|
+
PROXY_RESPONSE = "proxy_response" # Proxy response
|
|
47
|
+
PROXY_HEALTH_REPORT = "proxy_health_report" # Report proxy health
|
|
48
|
+
PROXY_ROTATION_REQUEST = "proxy_rotation_request" # Request proxy rotation
|
|
49
|
+
PROXY_RELEASE = "proxy_release" # Release proxy assignment
|
|
50
|
+
|
|
51
|
+
# Logging messages
|
|
52
|
+
LOG_MESSAGE = "log_message" # Log message from driver
|
|
53
|
+
LOG_BATCH = "log_batch" # Batch of log messages
|
|
54
|
+
|
|
55
|
+
# System messages
|
|
56
|
+
PING = "ping" # Ping message
|
|
57
|
+
PONG = "pong" # Pong response
|
|
58
|
+
ERROR = "error" # Error message
|
|
59
|
+
ACK = "ack" # Acknowledgment
|
|
60
|
+
|
|
61
|
+
def is_driver_lifecycle(self) -> bool:
|
|
62
|
+
"""Check if message is related to driver lifecycle."""
|
|
63
|
+
return self in [
|
|
64
|
+
MessageType.DRIVER_REGISTER,
|
|
65
|
+
MessageType.DRIVER_REGISTER_RESPONSE,
|
|
66
|
+
MessageType.DRIVER_HEARTBEAT,
|
|
67
|
+
MessageType.DRIVER_STATUS,
|
|
68
|
+
MessageType.DRIVER_DISCONNECT
|
|
69
|
+
]
|
|
70
|
+
|
|
71
|
+
def is_task_related(self) -> bool:
|
|
72
|
+
"""Check if message is related to task management."""
|
|
73
|
+
return self in [
|
|
74
|
+
MessageType.TASK_ASSIGN,
|
|
75
|
+
MessageType.TASK_RESULT,
|
|
76
|
+
MessageType.TASK_ERROR,
|
|
77
|
+
MessageType.TASK_PROGRESS,
|
|
78
|
+
MessageType.TASK_CANCEL
|
|
79
|
+
]
|
|
80
|
+
|
|
81
|
+
def is_command(self) -> bool:
|
|
82
|
+
"""Check if message is a command."""
|
|
83
|
+
return self.value.startswith("command_")
|
|
84
|
+
|
|
85
|
+
def requires_response(self) -> bool:
|
|
86
|
+
"""Check if message type requires a response."""
|
|
87
|
+
return self in [
|
|
88
|
+
MessageType.DRIVER_REGISTER,
|
|
89
|
+
MessageType.PROXY_REQUEST,
|
|
90
|
+
MessageType.PING
|
|
91
|
+
]
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
class ProxyType(str, Enum):
|
|
95
|
+
"""
|
|
96
|
+
Proxy server types supported by the system.
|
|
97
|
+
|
|
98
|
+
Defines the different types of proxy servers
|
|
99
|
+
that can be used for web requests.
|
|
100
|
+
"""
|
|
101
|
+
|
|
102
|
+
HTTP = "http" # HTTP proxy
|
|
103
|
+
HTTPS = "https" # HTTPS proxy
|
|
104
|
+
SOCKS4 = "socks4" # SOCKS4 proxy
|
|
105
|
+
SOCKS5 = "socks5" # SOCKS5 proxy
|
|
106
|
+
|
|
107
|
+
def supports_https(self) -> bool:
|
|
108
|
+
"""Check if proxy type supports HTTPS."""
|
|
109
|
+
return self in [ProxyType.HTTPS, ProxyType.SOCKS5]
|
|
110
|
+
|
|
111
|
+
def is_socks(self) -> bool:
|
|
112
|
+
"""Check if proxy is a SOCKS proxy."""
|
|
113
|
+
return self in [ProxyType.SOCKS4, ProxyType.SOCKS5]
|
|
114
|
+
|
|
115
|
+
def get_default_port(self) -> int:
|
|
116
|
+
"""Get default port for proxy type."""
|
|
117
|
+
ports = {
|
|
118
|
+
ProxyType.HTTP: 8080,
|
|
119
|
+
ProxyType.HTTPS: 8080,
|
|
120
|
+
ProxyType.SOCKS4: 1080,
|
|
121
|
+
ProxyType.SOCKS5: 1080,
|
|
122
|
+
}
|
|
123
|
+
return ports.get(self, 8080)
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
class TaskPriority(str, Enum):
|
|
127
|
+
"""
|
|
128
|
+
Task priority levels for queue management.
|
|
129
|
+
|
|
130
|
+
Defines priority levels that determine the order
|
|
131
|
+
in which tasks are processed by drivers.
|
|
132
|
+
"""
|
|
133
|
+
|
|
134
|
+
LOW = "low" # Low priority task
|
|
135
|
+
NORMAL = "normal" # Normal priority task (default)
|
|
136
|
+
HIGH = "high" # High priority task
|
|
137
|
+
URGENT = "urgent" # Urgent priority task
|
|
138
|
+
CRITICAL = "critical" # Critical priority task
|
|
139
|
+
|
|
140
|
+
def get_numeric_priority(self) -> int:
|
|
141
|
+
"""Get numeric priority for sorting (higher = more urgent)."""
|
|
142
|
+
priorities = {
|
|
143
|
+
TaskPriority.LOW: 1,
|
|
144
|
+
TaskPriority.NORMAL: 5,
|
|
145
|
+
TaskPriority.HIGH: 10,
|
|
146
|
+
TaskPriority.URGENT: 20,
|
|
147
|
+
TaskPriority.CRITICAL: 50,
|
|
148
|
+
}
|
|
149
|
+
return priorities.get(self, 5)
|
|
150
|
+
|
|
151
|
+
def is_urgent(self) -> bool:
|
|
152
|
+
"""Check if task has urgent or critical priority."""
|
|
153
|
+
return self in [TaskPriority.URGENT, TaskPriority.CRITICAL]
|
|
154
|
+
|
|
155
|
+
@classmethod
|
|
156
|
+
def from_numeric(cls, priority: int) -> 'TaskPriority':
|
|
157
|
+
"""Create TaskPriority from numeric value."""
|
|
158
|
+
if priority >= 50:
|
|
159
|
+
return cls.CRITICAL
|
|
160
|
+
elif priority >= 20:
|
|
161
|
+
return cls.URGENT
|
|
162
|
+
elif priority >= 10:
|
|
163
|
+
return cls.HIGH
|
|
164
|
+
elif priority >= 5:
|
|
165
|
+
return cls.NORMAL
|
|
166
|
+
else:
|
|
167
|
+
return cls.LOW
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
class DriverType(str, Enum):
|
|
171
|
+
"""
|
|
172
|
+
Driver types for categorization and capability matching.
|
|
173
|
+
|
|
174
|
+
Defines different types of drivers based on their
|
|
175
|
+
primary functionality and target websites.
|
|
176
|
+
"""
|
|
177
|
+
|
|
178
|
+
# General purpose
|
|
179
|
+
UNIVERSAL = "universal" # Universal driver for any site
|
|
180
|
+
GENERIC = "generic" # Generic web scraping driver
|
|
181
|
+
|
|
182
|
+
# E-commerce specific
|
|
183
|
+
ECOMMERCE = "ecommerce" # E-commerce sites
|
|
184
|
+
MARKETPLACE = "marketplace" # Online marketplaces
|
|
185
|
+
PRODUCT_CATALOG = "product_catalog" # Product catalogs
|
|
186
|
+
|
|
187
|
+
# Content specific
|
|
188
|
+
NEWS = "news" # News websites
|
|
189
|
+
BLOG = "blog" # Blog sites
|
|
190
|
+
SOCIAL_MEDIA = "social_media" # Social media platforms
|
|
191
|
+
|
|
192
|
+
# Data specific
|
|
193
|
+
API = "api" # API-based data collection
|
|
194
|
+
DATABASE = "database" # Database extraction
|
|
195
|
+
FILE = "file" # File processing
|
|
196
|
+
|
|
197
|
+
def is_web_scraping(self) -> bool:
|
|
198
|
+
"""Check if driver type involves web scraping."""
|
|
199
|
+
return self in [
|
|
200
|
+
DriverType.UNIVERSAL,
|
|
201
|
+
DriverType.GENERIC,
|
|
202
|
+
DriverType.ECOMMERCE,
|
|
203
|
+
DriverType.MARKETPLACE,
|
|
204
|
+
DriverType.PRODUCT_CATALOG,
|
|
205
|
+
DriverType.NEWS,
|
|
206
|
+
DriverType.BLOG,
|
|
207
|
+
DriverType.SOCIAL_MEDIA
|
|
208
|
+
]
|
|
209
|
+
|
|
210
|
+
def requires_browser(self) -> bool:
|
|
211
|
+
"""Check if driver type typically requires a browser."""
|
|
212
|
+
return self in [
|
|
213
|
+
DriverType.ECOMMERCE,
|
|
214
|
+
DriverType.MARKETPLACE,
|
|
215
|
+
DriverType.SOCIAL_MEDIA
|
|
216
|
+
]
|
|
217
|
+
|
|
218
|
+
|
|
219
|
+
class ConfigType(str, Enum):
|
|
220
|
+
"""
|
|
221
|
+
Configuration types for different system components.
|
|
222
|
+
|
|
223
|
+
Used to categorize and validate different types
|
|
224
|
+
of configuration objects in the system.
|
|
225
|
+
"""
|
|
226
|
+
|
|
227
|
+
SYSTEM = "system" # System-wide configuration
|
|
228
|
+
DRIVER = "driver" # Driver-specific configuration
|
|
229
|
+
HTTP = "http" # HTTP client configuration
|
|
230
|
+
PROXY = "proxy" # Proxy management configuration
|
|
231
|
+
BROWSER = "browser" # Browser automation configuration
|
|
232
|
+
LOGGING = "logging" # Logging configuration
|
|
233
|
+
CACHE = "cache" # Cache configuration
|
|
234
|
+
THREAD = "thread" # Threading configuration
|
|
235
|
+
DATABASE = "database" # Database configuration
|
|
236
|
+
SECURITY = "security" # Security configuration
|
|
237
|
+
|
|
238
|
+
def get_config_schema(self) -> str:
|
|
239
|
+
"""Get the schema identifier for this config type."""
|
|
240
|
+
return f"unrealon.config.{self.value}"
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Error Handling Package
|
|
3
|
+
|
|
4
|
+
Comprehensive error handling and retry logic for UnrealOn RPC system.
|
|
5
|
+
Following critical requirements - max 500 lines, 100% Pydantic v2.
|
|
6
|
+
|
|
7
|
+
Phase 2: Core Systems - Error Handling
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
from .retry import (
|
|
11
|
+
RetryConfig, RetryStrategy, RetryResult,
|
|
12
|
+
ExponentialBackoff, LinearBackoff, FixedBackoff,
|
|
13
|
+
retry_async, retry_sync
|
|
14
|
+
)
|
|
15
|
+
from .circuit_breaker import (
|
|
16
|
+
CircuitBreakerConfig, CircuitBreakerState,
|
|
17
|
+
CircuitBreaker, circuit_breaker, get_circuit_breaker
|
|
18
|
+
)
|
|
19
|
+
from .error_context import (
|
|
20
|
+
ErrorContext, ErrorSeverity,
|
|
21
|
+
create_error_context, format_error_context
|
|
22
|
+
)
|
|
23
|
+
from .recovery import (
|
|
24
|
+
RecoveryStrategy, RecoveryAction,
|
|
25
|
+
AutoRecovery, recovery_handler
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
__all__ = [
|
|
29
|
+
# Retry system
|
|
30
|
+
'RetryConfig', 'RetryStrategy', 'RetryResult',
|
|
31
|
+
'ExponentialBackoff', 'LinearBackoff', 'FixedBackoff',
|
|
32
|
+
'retry_async', 'retry_sync',
|
|
33
|
+
|
|
34
|
+
# Circuit breaker
|
|
35
|
+
'CircuitBreakerConfig', 'CircuitBreakerState',
|
|
36
|
+
'CircuitBreaker', 'circuit_breaker', 'get_circuit_breaker',
|
|
37
|
+
|
|
38
|
+
# Error context
|
|
39
|
+
'ErrorContext', 'ErrorSeverity',
|
|
40
|
+
'create_error_context', 'format_error_context',
|
|
41
|
+
|
|
42
|
+
# Recovery system
|
|
43
|
+
'RecoveryStrategy', 'RecoveryAction',
|
|
44
|
+
'AutoRecovery', 'recovery_handler',
|
|
45
|
+
]
|