exonware-xwsystem 0.0.1.409__py3-none-any.whl → 0.0.1.411__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.
- exonware/__init__.py +2 -2
- exonware/conf.py +10 -20
- exonware/xwsystem/__init__.py +6 -16
- exonware/xwsystem/caching/__init__.py +1 -1
- exonware/xwsystem/caching/base.py +16 -16
- exonware/xwsystem/caching/bloom_cache.py +5 -5
- exonware/xwsystem/caching/cache_manager.py +2 -2
- exonware/xwsystem/caching/conditional.py +4 -4
- exonware/xwsystem/caching/contracts.py +12 -12
- exonware/xwsystem/caching/decorators.py +2 -2
- exonware/xwsystem/caching/defs.py +1 -1
- exonware/xwsystem/caching/disk_cache.py +4 -4
- exonware/xwsystem/caching/distributed.py +1 -1
- exonware/xwsystem/caching/errors.py +1 -1
- exonware/xwsystem/caching/events.py +8 -8
- exonware/xwsystem/caching/eviction_strategies.py +9 -9
- exonware/xwsystem/caching/fluent.py +1 -1
- exonware/xwsystem/caching/integrity.py +1 -1
- exonware/xwsystem/caching/lfu_cache.py +24 -9
- exonware/xwsystem/caching/lfu_optimized.py +21 -21
- exonware/xwsystem/caching/lru_cache.py +14 -7
- exonware/xwsystem/caching/memory_bounded.py +8 -8
- exonware/xwsystem/caching/metrics_exporter.py +6 -6
- exonware/xwsystem/caching/observable_cache.py +1 -1
- exonware/xwsystem/caching/pluggable_cache.py +9 -9
- exonware/xwsystem/caching/rate_limiter.py +1 -1
- exonware/xwsystem/caching/read_through.py +6 -6
- exonware/xwsystem/caching/secure_cache.py +1 -1
- exonware/xwsystem/caching/serializable.py +3 -3
- exonware/xwsystem/caching/stats.py +7 -7
- exonware/xwsystem/caching/tagging.py +11 -11
- exonware/xwsystem/caching/ttl_cache.py +21 -6
- exonware/xwsystem/caching/two_tier_cache.py +5 -5
- exonware/xwsystem/caching/utils.py +3 -3
- exonware/xwsystem/caching/validation.py +1 -1
- exonware/xwsystem/caching/warming.py +9 -9
- exonware/xwsystem/caching/write_behind.py +5 -5
- exonware/xwsystem/cli/__init__.py +1 -1
- exonware/xwsystem/cli/args.py +10 -10
- exonware/xwsystem/cli/base.py +15 -15
- exonware/xwsystem/cli/colors.py +1 -1
- exonware/xwsystem/cli/console.py +1 -1
- exonware/xwsystem/cli/contracts.py +5 -5
- exonware/xwsystem/cli/defs.py +1 -1
- exonware/xwsystem/cli/errors.py +1 -1
- exonware/xwsystem/cli/progress.py +1 -1
- exonware/xwsystem/cli/prompts.py +1 -1
- exonware/xwsystem/cli/tables.py +7 -7
- exonware/xwsystem/config/__init__.py +1 -1
- exonware/xwsystem/config/base.py +14 -14
- exonware/xwsystem/config/contracts.py +22 -22
- exonware/xwsystem/config/defaults.py +2 -2
- exonware/xwsystem/config/defs.py +1 -1
- exonware/xwsystem/config/errors.py +2 -2
- exonware/xwsystem/config/logging.py +1 -1
- exonware/xwsystem/config/logging_setup.py +2 -2
- exonware/xwsystem/config/performance.py +7 -7
- exonware/xwsystem/config/performance_modes.py +20 -20
- exonware/xwsystem/config/version_manager.py +4 -4
- exonware/xwsystem/{http → http_client}/__init__.py +1 -1
- exonware/xwsystem/{http → http_client}/advanced_client.py +20 -20
- exonware/xwsystem/{http → http_client}/base.py +13 -13
- exonware/xwsystem/{http → http_client}/client.py +43 -43
- exonware/xwsystem/{http → http_client}/contracts.py +5 -5
- exonware/xwsystem/{http → http_client}/defs.py +2 -2
- exonware/xwsystem/{http → http_client}/errors.py +2 -2
- exonware/xwsystem/io/__init__.py +1 -1
- exonware/xwsystem/io/archive/__init__.py +1 -1
- exonware/xwsystem/io/archive/archive.py +5 -5
- exonware/xwsystem/io/archive/archive_files.py +8 -8
- exonware/xwsystem/io/archive/archivers.py +3 -3
- exonware/xwsystem/io/archive/base.py +17 -17
- exonware/xwsystem/io/archive/codec_integration.py +1 -1
- exonware/xwsystem/io/archive/compression.py +1 -1
- exonware/xwsystem/io/archive/formats/__init__.py +1 -1
- exonware/xwsystem/io/archive/formats/brotli_format.py +12 -9
- exonware/xwsystem/io/archive/formats/lz4_format.py +12 -9
- exonware/xwsystem/io/archive/formats/rar.py +12 -9
- exonware/xwsystem/io/archive/formats/sevenzip.py +12 -9
- exonware/xwsystem/io/archive/formats/squashfs_format.py +7 -7
- exonware/xwsystem/io/archive/formats/tar.py +8 -8
- exonware/xwsystem/io/archive/formats/wim_format.py +12 -9
- exonware/xwsystem/io/archive/formats/zip.py +8 -8
- exonware/xwsystem/io/archive/formats/zpaq_format.py +7 -7
- exonware/xwsystem/io/archive/formats/zstandard.py +12 -9
- exonware/xwsystem/io/base.py +17 -17
- exonware/xwsystem/io/codec/__init__.py +1 -1
- exonware/xwsystem/io/codec/base.py +261 -14
- exonware/xwsystem/io/codec/contracts.py +3 -6
- exonware/xwsystem/io/codec/registry.py +29 -29
- exonware/xwsystem/io/common/__init__.py +1 -1
- exonware/xwsystem/io/common/atomic.py +2 -2
- exonware/xwsystem/io/common/base.py +1 -1
- exonware/xwsystem/io/common/lock.py +1 -1
- exonware/xwsystem/io/common/watcher.py +4 -4
- exonware/xwsystem/io/contracts.py +34 -39
- exonware/xwsystem/io/data_operations.py +480 -0
- exonware/xwsystem/io/defs.py +2 -2
- exonware/xwsystem/io/errors.py +32 -3
- exonware/xwsystem/io/facade.py +4 -4
- exonware/xwsystem/io/file/__init__.py +1 -1
- exonware/xwsystem/io/file/base.py +2 -2
- exonware/xwsystem/io/file/conversion.py +1 -1
- exonware/xwsystem/io/file/file.py +10 -8
- exonware/xwsystem/io/file/paged_source.py +8 -1
- exonware/xwsystem/io/file/paging/__init__.py +1 -1
- exonware/xwsystem/io/file/paging/byte_paging.py +1 -1
- exonware/xwsystem/io/file/paging/line_paging.py +1 -1
- exonware/xwsystem/io/file/paging/record_paging.py +1 -1
- exonware/xwsystem/io/file/paging/registry.py +5 -5
- exonware/xwsystem/io/file/source.py +22 -11
- exonware/xwsystem/io/filesystem/__init__.py +1 -1
- exonware/xwsystem/io/filesystem/base.py +1 -1
- exonware/xwsystem/io/filesystem/local.py +9 -1
- exonware/xwsystem/io/folder/__init__.py +1 -1
- exonware/xwsystem/io/folder/base.py +2 -2
- exonware/xwsystem/io/folder/folder.py +6 -6
- exonware/xwsystem/io/serialization/__init__.py +1 -1
- exonware/xwsystem/io/serialization/auto_serializer.py +53 -40
- exonware/xwsystem/io/serialization/base.py +248 -35
- exonware/xwsystem/io/serialization/contracts.py +93 -4
- exonware/xwsystem/io/serialization/defs.py +1 -1
- exonware/xwsystem/io/serialization/errors.py +1 -1
- exonware/xwsystem/io/serialization/flyweight.py +22 -22
- exonware/xwsystem/io/serialization/format_detector.py +18 -15
- exonware/xwsystem/io/serialization/formats/__init__.py +1 -1
- exonware/xwsystem/io/serialization/formats/binary/bson.py +1 -1
- exonware/xwsystem/io/serialization/formats/binary/cbor.py +1 -1
- exonware/xwsystem/io/serialization/formats/binary/marshal.py +1 -1
- exonware/xwsystem/io/serialization/formats/binary/msgpack.py +1 -1
- exonware/xwsystem/io/serialization/formats/binary/pickle.py +1 -1
- exonware/xwsystem/io/serialization/formats/binary/plistlib.py +1 -1
- exonware/xwsystem/io/serialization/formats/database/dbm.py +53 -1
- exonware/xwsystem/io/serialization/formats/database/shelve.py +48 -1
- exonware/xwsystem/io/serialization/formats/database/sqlite3.py +85 -1
- exonware/xwsystem/io/serialization/formats/text/configparser.py +2 -2
- exonware/xwsystem/io/serialization/formats/text/csv.py +2 -2
- exonware/xwsystem/io/serialization/formats/text/formdata.py +2 -2
- exonware/xwsystem/io/serialization/formats/text/json.py +23 -5
- exonware/xwsystem/io/serialization/formats/text/json5.py +98 -13
- exonware/xwsystem/io/serialization/formats/text/jsonlines.py +230 -20
- exonware/xwsystem/io/serialization/formats/text/multipart.py +2 -2
- exonware/xwsystem/io/serialization/formats/text/toml.py +65 -4
- exonware/xwsystem/io/serialization/formats/text/xml.py +451 -69
- exonware/xwsystem/io/serialization/formats/text/yaml.py +52 -2
- exonware/xwsystem/io/serialization/registry.py +5 -5
- exonware/xwsystem/io/serialization/serializer.py +184 -12
- exonware/xwsystem/io/serialization/utils/__init__.py +1 -1
- exonware/xwsystem/io/serialization/utils/path_ops.py +3 -3
- exonware/xwsystem/io/stream/__init__.py +1 -1
- exonware/xwsystem/io/stream/async_operations.py +3 -3
- exonware/xwsystem/io/stream/base.py +3 -7
- exonware/xwsystem/io/stream/codec_io.py +4 -7
- exonware/xwsystem/ipc/async_fabric.py +7 -8
- exonware/xwsystem/ipc/base.py +9 -9
- exonware/xwsystem/ipc/contracts.py +5 -5
- exonware/xwsystem/ipc/defs.py +1 -1
- exonware/xwsystem/ipc/errors.py +2 -2
- exonware/xwsystem/ipc/message_queue.py +4 -6
- exonware/xwsystem/ipc/pipes.py +2 -2
- exonware/xwsystem/ipc/process_manager.py +7 -7
- exonware/xwsystem/ipc/process_pool.py +8 -8
- exonware/xwsystem/ipc/shared_memory.py +7 -7
- exonware/xwsystem/monitoring/base.py +33 -33
- exonware/xwsystem/monitoring/contracts.py +27 -27
- exonware/xwsystem/monitoring/defs.py +1 -1
- exonware/xwsystem/monitoring/error_recovery.py +16 -16
- exonware/xwsystem/monitoring/errors.py +2 -2
- exonware/xwsystem/monitoring/memory_monitor.py +12 -12
- exonware/xwsystem/monitoring/metrics.py +8 -8
- exonware/xwsystem/monitoring/performance_manager_generic.py +20 -20
- exonware/xwsystem/monitoring/performance_monitor.py +11 -11
- exonware/xwsystem/monitoring/performance_validator.py +21 -21
- exonware/xwsystem/monitoring/system_monitor.py +17 -17
- exonware/xwsystem/monitoring/tracing.py +20 -20
- exonware/xwsystem/monitoring/tracker.py +7 -7
- exonware/xwsystem/operations/__init__.py +5 -5
- exonware/xwsystem/operations/base.py +3 -3
- exonware/xwsystem/operations/contracts.py +3 -3
- exonware/xwsystem/operations/defs.py +5 -5
- exonware/xwsystem/operations/diff.py +5 -5
- exonware/xwsystem/operations/merge.py +2 -2
- exonware/xwsystem/operations/patch.py +5 -5
- exonware/xwsystem/patterns/base.py +4 -4
- exonware/xwsystem/patterns/context_manager.py +7 -7
- exonware/xwsystem/patterns/contracts.py +29 -31
- exonware/xwsystem/patterns/defs.py +1 -1
- exonware/xwsystem/patterns/dynamic_facade.py +9 -9
- exonware/xwsystem/patterns/errors.py +10 -10
- exonware/xwsystem/patterns/handler_factory.py +15 -14
- exonware/xwsystem/patterns/import_registry.py +22 -22
- exonware/xwsystem/patterns/object_pool.py +14 -13
- exonware/xwsystem/patterns/registry.py +45 -32
- exonware/xwsystem/plugins/__init__.py +1 -1
- exonware/xwsystem/plugins/base.py +25 -25
- exonware/xwsystem/plugins/contracts.py +28 -28
- exonware/xwsystem/plugins/defs.py +1 -1
- exonware/xwsystem/plugins/errors.py +9 -9
- exonware/xwsystem/runtime/__init__.py +1 -1
- exonware/xwsystem/runtime/base.py +42 -42
- exonware/xwsystem/runtime/contracts.py +9 -9
- exonware/xwsystem/runtime/defs.py +1 -1
- exonware/xwsystem/runtime/env.py +9 -9
- exonware/xwsystem/runtime/errors.py +1 -1
- exonware/xwsystem/runtime/reflection.py +15 -15
- exonware/xwsystem/security/auth.py +47 -15
- exonware/xwsystem/security/base.py +17 -17
- exonware/xwsystem/security/contracts.py +30 -30
- exonware/xwsystem/security/crypto.py +8 -8
- exonware/xwsystem/security/defs.py +1 -1
- exonware/xwsystem/security/errors.py +2 -2
- exonware/xwsystem/security/hazmat.py +7 -7
- exonware/xwsystem/security/path_validator.py +1 -1
- exonware/xwsystem/shared/__init__.py +1 -1
- exonware/xwsystem/shared/base.py +14 -14
- exonware/xwsystem/shared/contracts.py +6 -6
- exonware/xwsystem/shared/defs.py +1 -1
- exonware/xwsystem/shared/errors.py +1 -1
- exonware/xwsystem/structures/__init__.py +1 -1
- exonware/xwsystem/structures/base.py +29 -29
- exonware/xwsystem/structures/circular_detector.py +15 -15
- exonware/xwsystem/structures/contracts.py +9 -9
- exonware/xwsystem/structures/defs.py +1 -1
- exonware/xwsystem/structures/errors.py +2 -2
- exonware/xwsystem/structures/tree_walker.py +8 -8
- exonware/xwsystem/threading/async_primitives.py +7 -7
- exonware/xwsystem/threading/base.py +19 -19
- exonware/xwsystem/threading/contracts.py +13 -13
- exonware/xwsystem/threading/defs.py +1 -1
- exonware/xwsystem/threading/errors.py +2 -2
- exonware/xwsystem/threading/safe_factory.py +13 -12
- exonware/xwsystem/utils/base.py +34 -34
- exonware/xwsystem/utils/contracts.py +9 -9
- exonware/xwsystem/utils/dt/__init__.py +1 -1
- exonware/xwsystem/utils/dt/base.py +6 -6
- exonware/xwsystem/utils/dt/contracts.py +2 -2
- exonware/xwsystem/utils/dt/defs.py +1 -1
- exonware/xwsystem/utils/dt/errors.py +2 -2
- exonware/xwsystem/utils/dt/formatting.py +3 -3
- exonware/xwsystem/utils/dt/humanize.py +2 -2
- exonware/xwsystem/utils/dt/parsing.py +2 -2
- exonware/xwsystem/utils/dt/timezone_utils.py +5 -5
- exonware/xwsystem/utils/errors.py +2 -2
- exonware/xwsystem/utils/test_runner.py +6 -6
- exonware/xwsystem/utils/utils_contracts.py +1 -1
- exonware/xwsystem/validation/__init__.py +1 -1
- exonware/xwsystem/validation/base.py +48 -48
- exonware/xwsystem/validation/contracts.py +8 -8
- exonware/xwsystem/validation/data_validator.py +10 -0
- exonware/xwsystem/validation/declarative.py +15 -15
- exonware/xwsystem/validation/defs.py +1 -1
- exonware/xwsystem/validation/errors.py +2 -2
- exonware/xwsystem/validation/fluent_validator.py +10 -10
- exonware/xwsystem/version.py +2 -2
- {exonware_xwsystem-0.0.1.409.dist-info → exonware_xwsystem-0.0.1.411.dist-info}/METADATA +9 -11
- exonware_xwsystem-0.0.1.411.dist-info/RECORD +274 -0
- {exonware_xwsystem-0.0.1.409.dist-info → exonware_xwsystem-0.0.1.411.dist-info}/WHEEL +1 -1
- exonware/xwsystem/lazy_bootstrap.py +0 -79
- exonware_xwsystem-0.0.1.409.dist-info/RECORD +0 -274
- {exonware_xwsystem-0.0.1.409.dist-info → exonware_xwsystem-0.0.1.411.dist-info}/licenses/LICENSE +0 -0
|
@@ -16,7 +16,7 @@ import time
|
|
|
16
16
|
import signal
|
|
17
17
|
import subprocess
|
|
18
18
|
import multiprocessing as mp
|
|
19
|
-
from typing import
|
|
19
|
+
from typing import Optional, Callable, Any, Union
|
|
20
20
|
from dataclasses import dataclass
|
|
21
21
|
from threading import Lock, Event
|
|
22
22
|
import logging
|
|
@@ -29,7 +29,7 @@ class ProcessInfo:
|
|
|
29
29
|
"""Information about a managed process."""
|
|
30
30
|
pid: int
|
|
31
31
|
name: str
|
|
32
|
-
command:
|
|
32
|
+
command: list[str]
|
|
33
33
|
started_at: float
|
|
34
34
|
status: str # 'running', 'stopped', 'failed', 'terminated'
|
|
35
35
|
exit_code: Optional[int] = None
|
|
@@ -60,8 +60,8 @@ class ProcessManager:
|
|
|
60
60
|
"""
|
|
61
61
|
self.max_processes = max_processes or mp.cpu_count() * 2
|
|
62
62
|
self.monitor_interval = monitor_interval
|
|
63
|
-
self.processes:
|
|
64
|
-
self.process_info:
|
|
63
|
+
self.processes: dict[str, subprocess.Popen] = {}
|
|
64
|
+
self.process_info: dict[str, ProcessInfo] = {}
|
|
65
65
|
self._lock = Lock()
|
|
66
66
|
self._shutdown_event = Event()
|
|
67
67
|
self._monitor_thread = None
|
|
@@ -74,9 +74,9 @@ class ProcessManager:
|
|
|
74
74
|
|
|
75
75
|
def start_process(self,
|
|
76
76
|
name: str,
|
|
77
|
-
command: Union[str,
|
|
77
|
+
command: Union[str, list[str]],
|
|
78
78
|
cwd: Optional[str] = None,
|
|
79
|
-
env: Optional[
|
|
79
|
+
env: Optional[dict[str, str]] = None,
|
|
80
80
|
shell: bool = False) -> bool:
|
|
81
81
|
"""
|
|
82
82
|
Start a new managed process.
|
|
@@ -227,7 +227,7 @@ class ProcessManager:
|
|
|
227
227
|
with self._lock:
|
|
228
228
|
return self.process_info.get(name)
|
|
229
229
|
|
|
230
|
-
def list_processes(self) ->
|
|
230
|
+
def list_processes(self) -> list[ProcessInfo]:
|
|
231
231
|
"""List all managed processes."""
|
|
232
232
|
with self._lock:
|
|
233
233
|
return list(self.process_info.values())
|
|
@@ -17,7 +17,7 @@ import logging
|
|
|
17
17
|
import multiprocessing as mp
|
|
18
18
|
import time
|
|
19
19
|
from dataclasses import dataclass
|
|
20
|
-
from typing import Any, Callable,
|
|
20
|
+
from typing import Any, Callable, Optional, Union
|
|
21
21
|
|
|
22
22
|
logger = logging.getLogger(__name__)
|
|
23
23
|
|
|
@@ -79,8 +79,8 @@ class ProcessPool:
|
|
|
79
79
|
)
|
|
80
80
|
|
|
81
81
|
# Task tracking
|
|
82
|
-
self._active_tasks:
|
|
83
|
-
self._completed_tasks:
|
|
82
|
+
self._active_tasks: dict[str, concurrent.futures.Future] = {}
|
|
83
|
+
self._completed_tasks: list[TaskResult] = []
|
|
84
84
|
self._task_counter = 0
|
|
85
85
|
|
|
86
86
|
# Statistics
|
|
@@ -202,7 +202,7 @@ class ProcessPool:
|
|
|
202
202
|
|
|
203
203
|
return None
|
|
204
204
|
|
|
205
|
-
def wait_for_all(self, timeout: Optional[float] = None) ->
|
|
205
|
+
def wait_for_all(self, timeout: Optional[float] = None) -> list[TaskResult]:
|
|
206
206
|
"""
|
|
207
207
|
Wait for all active tasks to complete.
|
|
208
208
|
|
|
@@ -247,7 +247,7 @@ class ProcessPool:
|
|
|
247
247
|
|
|
248
248
|
return cancelled
|
|
249
249
|
|
|
250
|
-
def get_active_tasks(self) ->
|
|
250
|
+
def get_active_tasks(self) -> list[str]:
|
|
251
251
|
"""Get list of active task IDs."""
|
|
252
252
|
return list(self._active_tasks.keys())
|
|
253
253
|
|
|
@@ -321,7 +321,7 @@ class AsyncProcessPool:
|
|
|
321
321
|
self._loop: Optional[asyncio.AbstractEventLoop] = None
|
|
322
322
|
|
|
323
323
|
# Task tracking
|
|
324
|
-
self._active_tasks:
|
|
324
|
+
self._active_tasks: dict[str, asyncio.Task] = {}
|
|
325
325
|
self._task_counter = 0
|
|
326
326
|
|
|
327
327
|
def _ensure_executor(self):
|
|
@@ -397,7 +397,7 @@ class AsyncProcessPool:
|
|
|
397
397
|
else:
|
|
398
398
|
return await task
|
|
399
399
|
|
|
400
|
-
async def wait_for_all(self, timeout: Optional[float] = None) ->
|
|
400
|
+
async def wait_for_all(self, timeout: Optional[float] = None) -> list[Any]:
|
|
401
401
|
"""
|
|
402
402
|
Wait for all active tasks to complete.
|
|
403
403
|
|
|
@@ -454,7 +454,7 @@ class AsyncProcessPool:
|
|
|
454
454
|
|
|
455
455
|
return cancelled
|
|
456
456
|
|
|
457
|
-
def get_active_tasks(self) ->
|
|
457
|
+
def get_active_tasks(self) -> list[str]:
|
|
458
458
|
"""Get list of active task IDs."""
|
|
459
459
|
return list(self._active_tasks.keys())
|
|
460
460
|
|
|
@@ -16,16 +16,16 @@ import mmap
|
|
|
16
16
|
import struct
|
|
17
17
|
import pickle
|
|
18
18
|
import threading
|
|
19
|
-
from typing import Any,
|
|
19
|
+
from typing import Any, Optional, Union
|
|
20
|
+
# Root cause: Migrating to Python 3.12 built-in generic syntax for consistency
|
|
21
|
+
# Priority #3: Maintainability - Modern type annotations improve code clarity
|
|
20
22
|
from contextlib import contextmanager
|
|
21
23
|
import logging
|
|
22
24
|
|
|
23
25
|
logger = logging.getLogger(__name__)
|
|
24
26
|
|
|
25
|
-
T = TypeVar('T')
|
|
26
27
|
|
|
27
|
-
|
|
28
|
-
class SharedData(Generic[T]):
|
|
28
|
+
class SharedData[T]:
|
|
29
29
|
"""
|
|
30
30
|
Thread-safe shared data container with automatic serialization.
|
|
31
31
|
|
|
@@ -68,7 +68,7 @@ class SharedData(Generic[T]):
|
|
|
68
68
|
# Unix: Use /dev/shm or temporary files
|
|
69
69
|
import tempfile
|
|
70
70
|
self._file_handle = tempfile.NamedTemporaryFile(
|
|
71
|
-
prefix=f"
|
|
71
|
+
prefix=f"xwsystem_shared_{self.name}_",
|
|
72
72
|
delete=False
|
|
73
73
|
)
|
|
74
74
|
self._file_handle.write(b'\x00' * self.size)
|
|
@@ -242,7 +242,7 @@ class SharedMemoryManager:
|
|
|
242
242
|
"""
|
|
243
243
|
|
|
244
244
|
def __init__(self):
|
|
245
|
-
self._segments:
|
|
245
|
+
self._segments: dict[str, SharedData] = {}
|
|
246
246
|
self._lock = threading.RLock()
|
|
247
247
|
|
|
248
248
|
def create_segment(self, name: str, size: int = 1024 * 1024) -> SharedData:
|
|
@@ -364,7 +364,7 @@ class SharedMemory:
|
|
|
364
364
|
name: Name for the shared memory segment
|
|
365
365
|
size: Size of the memory segment
|
|
366
366
|
"""
|
|
367
|
-
self.name = name or f"
|
|
367
|
+
self.name = name or f"xwsystem_shared_{os.getpid()}"
|
|
368
368
|
self.size = size
|
|
369
369
|
self._manager = SharedMemoryManager()
|
|
370
370
|
self._segment = None
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
#exonware/
|
|
1
|
+
#exonware/xwsystem/monitoring/base.py
|
|
2
2
|
"""
|
|
3
3
|
Company: eXonware.com
|
|
4
4
|
Author: Eng. Muhammad AlShehri
|
|
5
5
|
Email: connect@exonware.com
|
|
6
|
-
Version: 0.0.1.
|
|
6
|
+
Version: 0.0.1.411
|
|
7
7
|
Generation Date: September 04, 2025
|
|
8
8
|
|
|
9
9
|
Monitoring module base classes - abstract classes for monitoring functionality.
|
|
10
10
|
"""
|
|
11
11
|
|
|
12
12
|
from abc import ABC, abstractmethod
|
|
13
|
-
from typing import Any,
|
|
13
|
+
from typing import Any, Optional, Union, Callable, TYPE_CHECKING
|
|
14
14
|
from .defs import MetricType, AlertLevel, HealthStatus, SpanKind
|
|
15
15
|
|
|
16
16
|
if TYPE_CHECKING:
|
|
@@ -28,9 +28,9 @@ class APerformanceMonitorBase(ABC):
|
|
|
28
28
|
monitor_name: Name of the performance monitor
|
|
29
29
|
"""
|
|
30
30
|
self.monitor_name = monitor_name
|
|
31
|
-
self._metrics:
|
|
32
|
-
self._thresholds:
|
|
33
|
-
self._alerts:
|
|
31
|
+
self._metrics: dict[str, Any] = {}
|
|
32
|
+
self._thresholds: dict[str, float] = {}
|
|
33
|
+
self._alerts: list[dict[str, Any]] = []
|
|
34
34
|
|
|
35
35
|
@abstractmethod
|
|
36
36
|
def start_monitoring(self) -> None:
|
|
@@ -58,7 +58,7 @@ class APerformanceMonitorBase(ABC):
|
|
|
58
58
|
pass
|
|
59
59
|
|
|
60
60
|
@abstractmethod
|
|
61
|
-
def get_all_metrics(self) ->
|
|
61
|
+
def get_all_metrics(self) -> dict[str, float]:
|
|
62
62
|
"""Get all metrics."""
|
|
63
63
|
pass
|
|
64
64
|
|
|
@@ -68,12 +68,12 @@ class APerformanceMonitorBase(ABC):
|
|
|
68
68
|
pass
|
|
69
69
|
|
|
70
70
|
@abstractmethod
|
|
71
|
-
def check_thresholds(self) ->
|
|
71
|
+
def check_thresholds(self) -> list[dict[str, Any]]:
|
|
72
72
|
"""Check if any metrics exceed thresholds."""
|
|
73
73
|
pass
|
|
74
74
|
|
|
75
75
|
@abstractmethod
|
|
76
|
-
def get_performance_summary(self) ->
|
|
76
|
+
def get_performance_summary(self) -> dict[str, Any]:
|
|
77
77
|
"""Get performance summary."""
|
|
78
78
|
pass
|
|
79
79
|
|
|
@@ -83,7 +83,7 @@ class AMemoryMonitorBase(ABC):
|
|
|
83
83
|
|
|
84
84
|
def __init__(self):
|
|
85
85
|
"""Initialize memory monitor."""
|
|
86
|
-
self._memory_snapshots:
|
|
86
|
+
self._memory_snapshots: list[dict[str, Any]] = []
|
|
87
87
|
self._leak_detection_enabled = False
|
|
88
88
|
|
|
89
89
|
@abstractmethod
|
|
@@ -97,22 +97,22 @@ class AMemoryMonitorBase(ABC):
|
|
|
97
97
|
pass
|
|
98
98
|
|
|
99
99
|
@abstractmethod
|
|
100
|
-
def take_snapshot(self) ->
|
|
100
|
+
def take_snapshot(self) -> dict[str, Any]:
|
|
101
101
|
"""Take memory snapshot."""
|
|
102
102
|
pass
|
|
103
103
|
|
|
104
104
|
@abstractmethod
|
|
105
|
-
def get_memory_usage(self) ->
|
|
105
|
+
def get_memory_usage(self) -> dict[str, float]:
|
|
106
106
|
"""Get current memory usage."""
|
|
107
107
|
pass
|
|
108
108
|
|
|
109
109
|
@abstractmethod
|
|
110
|
-
def detect_memory_leaks(self) ->
|
|
110
|
+
def detect_memory_leaks(self) -> list[dict[str, Any]]:
|
|
111
111
|
"""Detect potential memory leaks."""
|
|
112
112
|
pass
|
|
113
113
|
|
|
114
114
|
@abstractmethod
|
|
115
|
-
def get_memory_stats(self) ->
|
|
115
|
+
def get_memory_stats(self) -> dict[str, Any]:
|
|
116
116
|
"""Get memory statistics."""
|
|
117
117
|
pass
|
|
118
118
|
|
|
@@ -122,7 +122,7 @@ class AMemoryMonitorBase(ABC):
|
|
|
122
122
|
pass
|
|
123
123
|
|
|
124
124
|
@abstractmethod
|
|
125
|
-
def get_garbage_collection_stats(self) ->
|
|
125
|
+
def get_garbage_collection_stats(self) -> dict[str, Any]:
|
|
126
126
|
"""Get garbage collection statistics."""
|
|
127
127
|
pass
|
|
128
128
|
|
|
@@ -143,10 +143,10 @@ class AMetricsBase(ABC):
|
|
|
143
143
|
metrics_name: Name of the metrics collector
|
|
144
144
|
"""
|
|
145
145
|
self.metrics_name = metrics_name
|
|
146
|
-
self._counters:
|
|
147
|
-
self._gauges:
|
|
148
|
-
self._histograms:
|
|
149
|
-
self._timers:
|
|
146
|
+
self._counters: dict[str, int] = {}
|
|
147
|
+
self._gauges: dict[str, float] = {}
|
|
148
|
+
self._histograms: dict[str, list[float]] = {}
|
|
149
|
+
self._timers: dict[str, list[float]] = {}
|
|
150
150
|
|
|
151
151
|
@abstractmethod
|
|
152
152
|
def increment_counter(self, name: str, value: int = 1) -> None:
|
|
@@ -179,17 +179,17 @@ class AMetricsBase(ABC):
|
|
|
179
179
|
pass
|
|
180
180
|
|
|
181
181
|
@abstractmethod
|
|
182
|
-
def get_histogram_stats(self, name: str) ->
|
|
182
|
+
def get_histogram_stats(self, name: str) -> dict[str, float]:
|
|
183
183
|
"""Get histogram statistics."""
|
|
184
184
|
pass
|
|
185
185
|
|
|
186
186
|
@abstractmethod
|
|
187
|
-
def get_timer_stats(self, name: str) ->
|
|
187
|
+
def get_timer_stats(self, name: str) -> dict[str, float]:
|
|
188
188
|
"""Get timer statistics."""
|
|
189
189
|
pass
|
|
190
190
|
|
|
191
191
|
@abstractmethod
|
|
192
|
-
def export_metrics(self) ->
|
|
192
|
+
def export_metrics(self) -> dict[str, Any]:
|
|
193
193
|
"""Export all metrics."""
|
|
194
194
|
pass
|
|
195
195
|
|
|
@@ -204,8 +204,8 @@ class AErrorRecoveryBase(ABC):
|
|
|
204
204
|
|
|
205
205
|
def __init__(self):
|
|
206
206
|
"""Initialize error recovery."""
|
|
207
|
-
self._recovery_strategies:
|
|
208
|
-
self._circuit_breakers:
|
|
207
|
+
self._recovery_strategies: dict[str, Callable] = {}
|
|
208
|
+
self._circuit_breakers: dict[str, dict[str, Any]] = {}
|
|
209
209
|
|
|
210
210
|
@abstractmethod
|
|
211
211
|
def register_recovery_strategy(self, error_type: str, strategy: Callable) -> None:
|
|
@@ -213,7 +213,7 @@ class AErrorRecoveryBase(ABC):
|
|
|
213
213
|
pass
|
|
214
214
|
|
|
215
215
|
@abstractmethod
|
|
216
|
-
def handle_error(self, error: Exception, context:
|
|
216
|
+
def handle_error(self, error: Exception, context: dict[str, Any]) -> bool:
|
|
217
217
|
"""Handle error with recovery strategy."""
|
|
218
218
|
pass
|
|
219
219
|
|
|
@@ -239,7 +239,7 @@ class AErrorRecoveryBase(ABC):
|
|
|
239
239
|
pass
|
|
240
240
|
|
|
241
241
|
@abstractmethod
|
|
242
|
-
def get_circuit_state(self, name: str) ->
|
|
242
|
+
def get_circuit_state(self, name: str) -> dict[str, Any]:
|
|
243
243
|
"""Get circuit breaker state."""
|
|
244
244
|
pass
|
|
245
245
|
|
|
@@ -250,7 +250,7 @@ class ASystemMonitorBase(ABC):
|
|
|
250
250
|
def __init__(self):
|
|
251
251
|
"""Initialize system monitor."""
|
|
252
252
|
self._monitoring_enabled = False
|
|
253
|
-
self._system_metrics:
|
|
253
|
+
self._system_metrics: dict[str, Any] = {}
|
|
254
254
|
|
|
255
255
|
@abstractmethod
|
|
256
256
|
def start_system_monitoring(self) -> None:
|
|
@@ -268,17 +268,17 @@ class ASystemMonitorBase(ABC):
|
|
|
268
268
|
pass
|
|
269
269
|
|
|
270
270
|
@abstractmethod
|
|
271
|
-
def get_memory_usage(self) ->
|
|
271
|
+
def get_memory_usage(self) -> dict[str, float]:
|
|
272
272
|
"""Get memory usage statistics."""
|
|
273
273
|
pass
|
|
274
274
|
|
|
275
275
|
@abstractmethod
|
|
276
|
-
def get_disk_usage(self) ->
|
|
276
|
+
def get_disk_usage(self) -> dict[str, float]:
|
|
277
277
|
"""Get disk usage statistics."""
|
|
278
278
|
pass
|
|
279
279
|
|
|
280
280
|
@abstractmethod
|
|
281
|
-
def get_network_usage(self) ->
|
|
281
|
+
def get_network_usage(self) -> dict[str, float]:
|
|
282
282
|
"""Get network usage statistics."""
|
|
283
283
|
pass
|
|
284
284
|
|
|
@@ -303,7 +303,7 @@ class ASystemMonitorBase(ABC):
|
|
|
303
303
|
pass
|
|
304
304
|
|
|
305
305
|
@abstractmethod
|
|
306
|
-
def get_system_info(self) ->
|
|
306
|
+
def get_system_info(self) -> dict[str, Any]:
|
|
307
307
|
"""Get comprehensive system information."""
|
|
308
308
|
pass
|
|
309
309
|
|
|
@@ -322,7 +322,7 @@ class ATracingProvider(ABC):
|
|
|
322
322
|
name: str,
|
|
323
323
|
kind: 'SpanKind' = None,
|
|
324
324
|
parent: Optional['SpanContext'] = None,
|
|
325
|
-
attributes: Optional[
|
|
325
|
+
attributes: Optional[dict[str, Any]] = None
|
|
326
326
|
) -> 'SpanContext':
|
|
327
327
|
"""Start a new span."""
|
|
328
328
|
pass
|
|
@@ -338,6 +338,6 @@ class ATracingProvider(ABC):
|
|
|
338
338
|
pass
|
|
339
339
|
|
|
340
340
|
@abstractmethod
|
|
341
|
-
def add_span_event(self, span: 'SpanContext', name: str, attributes: Optional[
|
|
341
|
+
def add_span_event(self, span: 'SpanContext', name: str, attributes: Optional[dict[str, Any]] = None) -> None:
|
|
342
342
|
"""Add event to span."""
|
|
343
343
|
pass
|
|
@@ -3,14 +3,14 @@
|
|
|
3
3
|
Company: eXonware.com
|
|
4
4
|
Author: Eng. Muhammad AlShehri
|
|
5
5
|
Email: connect@exonware.com
|
|
6
|
-
Version: 0.0.1.
|
|
6
|
+
Version: 0.0.1.411
|
|
7
7
|
Generation Date: September 04, 2025
|
|
8
8
|
|
|
9
9
|
Monitoring protocol interfaces for XWSystem.
|
|
10
10
|
"""
|
|
11
11
|
|
|
12
12
|
from abc import ABC, abstractmethod
|
|
13
|
-
from typing import Any,
|
|
13
|
+
from typing import Any, Optional, Union, Iterator, Callable, Protocol
|
|
14
14
|
from typing_extensions import runtime_checkable
|
|
15
15
|
import time
|
|
16
16
|
|
|
@@ -63,7 +63,7 @@ class IPerformance(ABC):
|
|
|
63
63
|
pass
|
|
64
64
|
|
|
65
65
|
@abstractmethod
|
|
66
|
-
def get_metrics(self) ->
|
|
66
|
+
def get_metrics(self) -> dict[str, Any]:
|
|
67
67
|
"""
|
|
68
68
|
Get performance metrics.
|
|
69
69
|
|
|
@@ -172,7 +172,7 @@ class IMonitorable(ABC):
|
|
|
172
172
|
pass
|
|
173
173
|
|
|
174
174
|
@abstractmethod
|
|
175
|
-
def get_health(self) ->
|
|
175
|
+
def get_health(self) -> dict[str, Any]:
|
|
176
176
|
"""
|
|
177
177
|
Get health information.
|
|
178
178
|
|
|
@@ -192,7 +192,7 @@ class IMonitorable(ABC):
|
|
|
192
192
|
pass
|
|
193
193
|
|
|
194
194
|
@abstractmethod
|
|
195
|
-
def get_monitoring_info(self) ->
|
|
195
|
+
def get_monitoring_info(self) -> dict[str, Any]:
|
|
196
196
|
"""
|
|
197
197
|
Get monitoring information.
|
|
198
198
|
|
|
@@ -234,7 +234,7 @@ class IMetrics(ABC):
|
|
|
234
234
|
"""
|
|
235
235
|
|
|
236
236
|
@abstractmethod
|
|
237
|
-
def collect_metrics(self) ->
|
|
237
|
+
def collect_metrics(self) -> dict[str, Any]:
|
|
238
238
|
"""
|
|
239
239
|
Collect all metrics.
|
|
240
240
|
|
|
@@ -244,7 +244,7 @@ class IMetrics(ABC):
|
|
|
244
244
|
pass
|
|
245
245
|
|
|
246
246
|
@abstractmethod
|
|
247
|
-
def add_metric(self, name: str, value: Any, labels: Optional[
|
|
247
|
+
def add_metric(self, name: str, value: Any, labels: Optional[dict[str, str]] = None) -> None:
|
|
248
248
|
"""
|
|
249
249
|
Add metric.
|
|
250
250
|
|
|
@@ -282,7 +282,7 @@ class IMetrics(ABC):
|
|
|
282
282
|
pass
|
|
283
283
|
|
|
284
284
|
@abstractmethod
|
|
285
|
-
def list_metrics(self) ->
|
|
285
|
+
def list_metrics(self) -> list[str]:
|
|
286
286
|
"""
|
|
287
287
|
List all metric names.
|
|
288
288
|
|
|
@@ -312,7 +312,7 @@ class IMetrics(ABC):
|
|
|
312
312
|
pass
|
|
313
313
|
|
|
314
314
|
@abstractmethod
|
|
315
|
-
def get_metrics_summary(self) ->
|
|
315
|
+
def get_metrics_summary(self) -> dict[str, Any]:
|
|
316
316
|
"""
|
|
317
317
|
Get metrics summary.
|
|
318
318
|
|
|
@@ -344,7 +344,7 @@ class IHealthCheck(ABC):
|
|
|
344
344
|
pass
|
|
345
345
|
|
|
346
346
|
@abstractmethod
|
|
347
|
-
def get_health_details(self) ->
|
|
347
|
+
def get_health_details(self) -> dict[str, Any]:
|
|
348
348
|
"""
|
|
349
349
|
Get detailed health information.
|
|
350
350
|
|
|
@@ -378,7 +378,7 @@ class IHealthCheck(ABC):
|
|
|
378
378
|
pass
|
|
379
379
|
|
|
380
380
|
@abstractmethod
|
|
381
|
-
def list_health_checks(self) ->
|
|
381
|
+
def list_health_checks(self) -> list[str]:
|
|
382
382
|
"""
|
|
383
383
|
List all health check names.
|
|
384
384
|
|
|
@@ -388,7 +388,7 @@ class IHealthCheck(ABC):
|
|
|
388
388
|
pass
|
|
389
389
|
|
|
390
390
|
@abstractmethod
|
|
391
|
-
def run_health_checks(self) ->
|
|
391
|
+
def run_health_checks(self) -> dict[str, HealthStatus]:
|
|
392
392
|
"""
|
|
393
393
|
Run all health checks.
|
|
394
394
|
|
|
@@ -446,7 +446,7 @@ class IAlerting(ABC):
|
|
|
446
446
|
pass
|
|
447
447
|
|
|
448
448
|
@abstractmethod
|
|
449
|
-
def get_alert(self, alert_id: str) -> Optional[
|
|
449
|
+
def get_alert(self, alert_id: str) -> Optional[dict[str, Any]]:
|
|
450
450
|
"""
|
|
451
451
|
Get alert by ID.
|
|
452
452
|
|
|
@@ -459,7 +459,7 @@ class IAlerting(ABC):
|
|
|
459
459
|
pass
|
|
460
460
|
|
|
461
461
|
@abstractmethod
|
|
462
|
-
def list_alerts(self, level: Optional[AlertLevel] = None) ->
|
|
462
|
+
def list_alerts(self, level: Optional[AlertLevel] = None) -> list[dict[str, Any]]:
|
|
463
463
|
"""
|
|
464
464
|
List alerts.
|
|
465
465
|
|
|
@@ -513,7 +513,7 @@ class IAlerting(ABC):
|
|
|
513
513
|
pass
|
|
514
514
|
|
|
515
515
|
@abstractmethod
|
|
516
|
-
def get_alert_stats(self) ->
|
|
516
|
+
def get_alert_stats(self) -> dict[str, int]:
|
|
517
517
|
"""
|
|
518
518
|
Get alert statistics.
|
|
519
519
|
|
|
@@ -557,7 +557,7 @@ class ISystemMonitor(ABC):
|
|
|
557
557
|
pass
|
|
558
558
|
|
|
559
559
|
@abstractmethod
|
|
560
|
-
def get_memory_usage(self) ->
|
|
560
|
+
def get_memory_usage(self) -> dict[str, Any]:
|
|
561
561
|
"""
|
|
562
562
|
Get memory usage information.
|
|
563
563
|
|
|
@@ -567,7 +567,7 @@ class ISystemMonitor(ABC):
|
|
|
567
567
|
pass
|
|
568
568
|
|
|
569
569
|
@abstractmethod
|
|
570
|
-
def get_disk_usage(self) ->
|
|
570
|
+
def get_disk_usage(self) -> dict[str, Any]:
|
|
571
571
|
"""
|
|
572
572
|
Get disk usage information.
|
|
573
573
|
|
|
@@ -577,7 +577,7 @@ class ISystemMonitor(ABC):
|
|
|
577
577
|
pass
|
|
578
578
|
|
|
579
579
|
@abstractmethod
|
|
580
|
-
def get_network_usage(self) ->
|
|
580
|
+
def get_network_usage(self) -> dict[str, Any]:
|
|
581
581
|
"""
|
|
582
582
|
Get network usage information.
|
|
583
583
|
|
|
@@ -587,7 +587,7 @@ class ISystemMonitor(ABC):
|
|
|
587
587
|
pass
|
|
588
588
|
|
|
589
589
|
@abstractmethod
|
|
590
|
-
def get_process_info(self) ->
|
|
590
|
+
def get_process_info(self) -> list[dict[str, Any]]:
|
|
591
591
|
"""
|
|
592
592
|
Get process information.
|
|
593
593
|
|
|
@@ -617,7 +617,7 @@ class ISystemMonitor(ABC):
|
|
|
617
617
|
pass
|
|
618
618
|
|
|
619
619
|
@abstractmethod
|
|
620
|
-
def get_system_info(self) ->
|
|
620
|
+
def get_system_info(self) -> dict[str, Any]:
|
|
621
621
|
"""
|
|
622
622
|
Get system information.
|
|
623
623
|
|
|
@@ -652,7 +652,7 @@ class IProfiler(ABC):
|
|
|
652
652
|
pass
|
|
653
653
|
|
|
654
654
|
@abstractmethod
|
|
655
|
-
def stop_profiling(self, session_id: str) ->
|
|
655
|
+
def stop_profiling(self, session_id: str) -> dict[str, Any]:
|
|
656
656
|
"""
|
|
657
657
|
Stop profiling session.
|
|
658
658
|
|
|
@@ -665,7 +665,7 @@ class IProfiler(ABC):
|
|
|
665
665
|
pass
|
|
666
666
|
|
|
667
667
|
@abstractmethod
|
|
668
|
-
def profile_function(self, func: Callable, *args, **kwargs) ->
|
|
668
|
+
def profile_function(self, func: Callable, *args, **kwargs) -> tuple[Any, dict[str, Any]]:
|
|
669
669
|
"""
|
|
670
670
|
Profile function execution.
|
|
671
671
|
|
|
@@ -680,7 +680,7 @@ class IProfiler(ABC):
|
|
|
680
680
|
pass
|
|
681
681
|
|
|
682
682
|
@abstractmethod
|
|
683
|
-
def get_profiling_results(self, session_id: str) -> Optional[
|
|
683
|
+
def get_profiling_results(self, session_id: str) -> Optional[dict[str, Any]]:
|
|
684
684
|
"""
|
|
685
685
|
Get profiling results.
|
|
686
686
|
|
|
@@ -693,7 +693,7 @@ class IProfiler(ABC):
|
|
|
693
693
|
pass
|
|
694
694
|
|
|
695
695
|
@abstractmethod
|
|
696
|
-
def list_profiling_sessions(self) ->
|
|
696
|
+
def list_profiling_sessions(self) -> list[str]:
|
|
697
697
|
"""
|
|
698
698
|
List profiling sessions.
|
|
699
699
|
|
|
@@ -813,7 +813,7 @@ class IMonitoringConfig(ABC):
|
|
|
813
813
|
pass
|
|
814
814
|
|
|
815
815
|
@abstractmethod
|
|
816
|
-
def get_monitoring_config(self) ->
|
|
816
|
+
def get_monitoring_config(self) -> dict[str, Any]:
|
|
817
817
|
"""
|
|
818
818
|
Get monitoring configuration.
|
|
819
819
|
|
|
@@ -823,7 +823,7 @@ class IMonitoringConfig(ABC):
|
|
|
823
823
|
pass
|
|
824
824
|
|
|
825
825
|
@abstractmethod
|
|
826
|
-
def set_monitoring_config(self, config:
|
|
826
|
+
def set_monitoring_config(self, config: dict[str, Any]) -> None:
|
|
827
827
|
"""
|
|
828
828
|
Set monitoring configuration.
|
|
829
829
|
|
|
@@ -849,6 +849,6 @@ class Monitorable(Protocol):
|
|
|
849
849
|
"""Stop performance monitoring."""
|
|
850
850
|
...
|
|
851
851
|
|
|
852
|
-
def get_stats(self) ->
|
|
852
|
+
def get_stats(self) -> dict[str, Any]:
|
|
853
853
|
"""Get performance statistics."""
|
|
854
854
|
...
|