dmsc 0.1.5__cp312-cp312-macosx_10_12_x86_64.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.
dmsc/__init__.py ADDED
@@ -0,0 +1,390 @@
1
+ #!/usr/bin/env python3
2
+
3
+ # Copyright © 2025-2026 Wenze Wei. All Rights Reserved.
4
+ #
5
+ # This file is part of DMSC.
6
+ # The DMSC project belongs to the Dunimd Team.
7
+ #
8
+ # Licensed under the Apache License, Version 2.0 (the "License");
9
+ # You may not use this file except in compliance with the License.
10
+ # You may obtain a copy of the License at
11
+ #
12
+ # http://www.apache.org/licenses/LICENSE-2.0
13
+ #
14
+ # Unless required by applicable law or agreed to in writing, software
15
+ # distributed under the License is distributed on an "AS IS" BASIS,
16
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
+ # See the License for the specific language governing permissions and
18
+ # limitations under the License.
19
+
20
+ """
21
+ DMSC (Dunimd Middleware Service) - A high-performance Rust middleware framework with modular architecture.
22
+
23
+ This Python library provides bindings to the DMSC Rust core, enabling Python applications to leverage
24
+ a comprehensive set of middleware services including caching, messaging, service mesh, authentication,
25
+ device management, observability, protocol handling, and database integration. The framework follows
26
+ a plugin-based architecture where each module provides specialized functionality that can be composed
27
+ into unified middleware solutions.
28
+
29
+ Key Components:
30
+ - Core Framework: Application lifecycle management, configuration, logging, and filesystem abstraction
31
+ - Python Module Support: Native integration for Python-based service modules
32
+ - Infrastructure Services: Caching, queuing, and database connectivity
33
+ - Traffic Management: Gateway routing, rate limiting, and circuit breaker patterns
34
+ - Service Mesh: Service discovery, load balancing, and traffic routing
35
+ - Security: Authentication, authorization, and session management
36
+ - Device Management: IoT device control and resource allocation
37
+ - Observability: Metrics collection, tracing, and health monitoring
38
+ - Protocol Support: Multi-protocol connection handling and frame processing
39
+ - Data Validation: Schema validation, sanitization, and error reporting
40
+
41
+ Example Usage:
42
+ from dmsc import DMSCAppBuilder, DMSCCacheModule, DMSCGateway
43
+
44
+ app = (DMSCAppBuilder()
45
+ .with_config("config.yaml")
46
+ .with_logging(DMSCLogConfig())
47
+ .build())
48
+ cache = DMSCCacheModule()
49
+ gateway = DMSCGateway()
50
+ """
51
+
52
+ __version__ = "0.1.5"
53
+ __author__ = "Dunimd Team"
54
+ __license__ = "Apache-2.0"
55
+
56
+ # Import the Rust extension module containing all DMSC bindings
57
+ # The dmsc extension is generated by PyO3 and provides zero-overhead access to Rust implementations
58
+ from .dmsc import (
59
+ # =============================================================================
60
+ # Core classes - Fundamental framework components for application lifecycle,
61
+ # configuration management, logging, hooks, and service context management
62
+ # =============================================================================
63
+ DMSCAppRuntime, DMSCConfig, DMSCConfigManager, DMSCError,
64
+ DMSCFileSystem, DMSCHookBus, DMSCHookEvent, DMSCHookKind, DMSCLogConfig,
65
+ DMSCLogLevel, DMSCLogger, DMSCModulePhase, DMSCServiceContext,
66
+
67
+ # =============================================================================
68
+ # Lock utilities - Safe lock utilities for concurrent programming
69
+ # Note: DMSCLockResult is a type alias, not a pyclass
70
+ # =============================================================================
71
+ DMSCLockError,
72
+
73
+ # =============================================================================
74
+ # Python module support - Enables Python-based service modules to integrate
75
+ # with the DMSC framework, supporting both synchronous and asynchronous service patterns
76
+ # =============================================================================
77
+ DMSCPythonModule, DMSCPythonModuleAdapter, DMSCPythonServiceModule, DMSCPythonAsyncServiceModule,
78
+
79
+ # =============================================================================
80
+ # Health check types - Health monitoring for services and modules
81
+ # =============================================================================
82
+ DMSCHealthStatus, DMSCHealthCheckResult, DMSCHealthCheckConfig, DMSCHealthReport,
83
+
84
+ # =============================================================================
85
+ # Lifecycle management - Module lifecycle observation
86
+ # =============================================================================
87
+ DMSCLifecycleObserver,
88
+
89
+ # =============================================================================
90
+ # Cache classes - In-memory caching with configurable backends, eviction policies,
91
+ # statistics tracking, and event notification capabilities
92
+ # =============================================================================
93
+ DMSCCacheModule, DMSCCacheManager, DMSCCacheConfig, DMSCCacheBackendType,
94
+ DMSCCachePolicy, DMSCCacheStats, DMSCCachedValue, DMSCCacheEvent,
95
+
96
+ # =============================================================================
97
+ # Queue classes - Message queuing with multiple backend support, retry policies,
98
+ # dead letter handling, and queue statistics monitoring
99
+ # =============================================================================
100
+ DMSCQueueModule, DMSCQueueConfig, DMSCQueueManager, DMSCQueueMessage,
101
+ DMSCQueueStats, DMSCQueueBackendType, DMSCRetryPolicy, DMSCDeadLetterConfig,
102
+
103
+ # =============================================================================
104
+ # Gateway classes - Traffic management including HTTP routing, rate limiting,
105
+ # circuit breaker patterns, and sliding window algorithms for distributed systems
106
+ # =============================================================================
107
+ DMSCGateway, DMSCGatewayConfig, DMSCRouter, DMSCRoute,
108
+ DMSCRateLimiter, DMSCRateLimitConfig, RateLimitStats,
109
+ DMSCSlidingWindowRateLimiter, DMSCCircuitBreaker, DMSCCircuitBreakerConfig,
110
+ DMSCCircuitBreakerState, CircuitBreakerMetrics,
111
+ DMSCBackendServer, LoadBalancerServerStats,
112
+
113
+ # =============================================================================
114
+ # Service mesh classes - Service discovery, traffic routing, load balancing,
115
+ # weighted destinations, and traffic splitting for microservices architecture
116
+ # =============================================================================
117
+ DMSCServiceMesh, DMSCServiceMeshConfig, DMSCServiceDiscovery,
118
+ DMSCServiceInstance, DMSCServiceStatus, DMSCServiceMeshStats,
119
+ DMSCTrafficRoute, DMSCMatchCriteria, DMSCRouteAction, DMSCWeightedDestination,
120
+ DMSCTrafficManager, DMSCHealthChecker,
121
+
122
+ # =============================================================================
123
+ # Auth classes - Authentication and authorization including JWT management,
124
+ # session handling, OAuth integration, role-based and permission-based access control
125
+ # =============================================================================
126
+ DMSCAuthModule, DMSCAuthConfig, DMSCJWTManager, DMSCJWTClaims, DMSCJWTValidationOptions,
127
+ DMSCSessionManager, DMSCSession, DMSCPermissionManager, DMSCPermission, DMSCRole,
128
+ DMSCOAuthManager, DMSCOAuthToken, DMSCOAuthUserInfo, DMSCOAuthProvider,
129
+ DMSCJWTRevocationList, DMSCRevokedTokenInfo,
130
+
131
+ # =============================================================================
132
+ # Device classes - IoT device management including device control, health monitoring,
133
+ # resource allocation, connection pooling, and network device discovery
134
+ # =============================================================================
135
+ DMSCDeviceControlModule, DMSCDevice, DMSCDeviceType, DMSCDeviceStatus,
136
+ DMSCDeviceCapabilities, DMSCDeviceHealthMetrics, DMSCDeviceController,
137
+ DMSCDeviceConfig, DMSCDeviceControlConfig, DMSCDeviceSchedulingConfig, NetworkDeviceInfo,
138
+ DMSCDiscoveryResult, DMSCResourceRequest,
139
+ DMSCResourceAllocation, DMSCRequestSlaClass, DMSCResourceWeights,
140
+ DMSCAffinityRules,
141
+ DMSCResourcePool, DMSCResourcePoolConfig, DMSCResourcePoolStatistics, DMSCResourcePoolManager,
142
+ DMSCConnectionPoolStatistics,
143
+ DMSCResourceScheduler, DMSCDeviceScheduler, DMSCSchedulingPolicy,
144
+ DMSCAllocationRecord, DMSCAllocationRequest, DMSCAllocationStatistics,
145
+ DMSCDeviceTypeStatistics, DMSCSchedulingRecommendation, DMSCSchedulingRecommendationType,
146
+
147
+ # =============================================================================
148
+ # Observability classes - Metrics, tracing, and health monitoring for system
149
+ # observability and performance analysis
150
+ # =============================================================================
151
+ DMSCObservabilityModule, DMSCObservabilityConfig,
152
+ DMSCMetricsRegistry, DMSCTracer,
153
+ DMSCMetricType, DMSCMetricConfig, DMSCMetricSample, DMSCMetric,
154
+ DMSCObservabilityData,
155
+
156
+ # =============================================================================
157
+ # Validation classes - Data validation, schema validation, sanitization,
158
+ # and validation result reporting with configurable severity levels
159
+ # =============================================================================
160
+ DMSCValidationError, DMSCValidationResult, DMSCValidationSeverity,
161
+ DMSCValidatorBuilder, DMSCValidationRunner, DMSCSanitizer,
162
+ DMSCSanitizationConfig, DMSCSchemaValidator, DMSCValidationModule,
163
+
164
+ # =============================================================================
165
+ # Protocol classes - Multi-protocol support including connection management,
166
+ # frame processing, security levels, and protocol statistics monitoring
167
+ # =============================================================================
168
+ DMSCProtocolManager, DMSCProtocolType, DMSCProtocolConfig,
169
+ DMSCProtocolStatus, DMSCProtocolStats, DMSCConnectionState,
170
+ DMSCConnectionStats, DMSCProtocolHealth,
171
+ DMSCFrame, DMSCFrameHeader, DMSCFrameType,
172
+ DMSCConnectionInfo, DMSCMessageFlags, DMSCSecurityLevel,
173
+ DMSCFrameParser, DMSCFrameBuilder,
174
+
175
+ # =============================================================================
176
+ # Database classes - Database configuration, connection pooling, row-level
177
+ # access, and result set management across different database backends
178
+ # =============================================================================
179
+ DMSCDatabaseConfig, DMSCDatabasePool, DMSCDBRow, DMSCDBResult, DatabaseType,
180
+ ColumnDefinition, IndexDefinition, ForeignKeyDefinition,
181
+ TableDefinition, LogicalOperator, Criteria, JoinClause,
182
+ ComparisonOperator, SortOrder, Pagination, QueryBuilder, JoinType,
183
+ )
184
+
185
+ # =============================================================================
186
+ # Submodules - Functional submodules organized by domain area, providing
187
+ # specialized functionality for specific middleware concerns
188
+ # =============================================================================
189
+ from .dmsc import (
190
+ device, cache, fs, hooks, observability,
191
+ queue, gateway, service_mesh, auth, protocol, database
192
+ )
193
+
194
+ # =============================================================================
195
+ # __all__ export list - Public API surface defining all symbols intended for
196
+ # external use. These symbols are imported when 'from dmsc import *' is used.
197
+ # Organized by functional category for clarity and maintainability.
198
+ # =============================================================================
199
+ __all__ = [
200
+ # Core classes - Application framework, configuration, logging, and hooks
201
+ 'DMSCAppRuntime', 'DMSCConfig', 'DMSCConfigManager', 'DMSCError',
202
+ 'DMSCFileSystem', 'DMSCHookBus', 'DMSCHookEvent', 'DMSCHookKind', 'DMSCLogConfig',
203
+ 'DMSCLogLevel', 'DMSCLogger', 'DMSCModulePhase', 'DMSCServiceContext',
204
+
205
+ # Lock utilities - Safe lock utilities for concurrent programming
206
+ 'DMSCLockError',
207
+
208
+ # Python module support - Python service module integration
209
+ 'DMSCPythonModule', 'DMSCPythonModuleAdapter', 'DMSCPythonServiceModule', 'DMSCPythonAsyncServiceModule',
210
+
211
+ # Health check types - Health monitoring for services and modules
212
+ 'DMSCHealthStatus', 'DMSCHealthCheckResult', 'DMSCHealthCheckConfig', 'DMSCHealthReport',
213
+
214
+ # Lifecycle management - Module lifecycle observation
215
+ 'DMSCLifecycleObserver',
216
+
217
+ # Cache classes - Caching infrastructure and management
218
+ 'DMSCCacheModule', 'DMSCCacheManager', 'DMSCCacheConfig', 'DMSCCacheBackendType',
219
+ 'DMSCCachePolicy', 'DMSCCacheStats', 'DMSCCachedValue', 'DMSCCacheEvent',
220
+
221
+ # Queue classes - Message queuing infrastructure
222
+ 'DMSCQueueModule', 'DMSCQueueConfig', 'DMSCQueueManager', 'DMSCQueueMessage',
223
+ 'DMSCQueueStats', 'DMSCQueueBackendType', 'DMSCRetryPolicy', 'DMSCDeadLetterConfig',
224
+
225
+ # Gateway classes - Traffic management and resilience patterns
226
+ 'DMSCGateway', 'DMSCGatewayConfig', 'DMSCRouter', 'DMSCRoute',
227
+ 'DMSCRateLimiter', 'DMSCRateLimitConfig', 'RateLimitStats',
228
+ 'DMSCSlidingWindowRateLimiter', 'DMSCCircuitBreaker', 'DMSCCircuitBreakerConfig',
229
+ 'DMSCCircuitBreakerState', 'CircuitBreakerMetrics',
230
+ 'DMSCBackendServer', 'LoadBalancerServerStats',
231
+
232
+ # Service mesh classes - Service discovery and traffic routing
233
+ 'DMSCServiceMesh', 'DMSCServiceMeshConfig', 'DMSCServiceDiscovery',
234
+ 'DMSCServiceInstance', 'DMSCServiceStatus', 'DMSCServiceMeshStats',
235
+ 'DMSCTrafficRoute', 'DMSCMatchCriteria', 'DMSCRouteAction', 'DMSCWeightedDestination',
236
+ 'DMSCTrafficManager', 'DMSCHealthChecker',
237
+
238
+ # Auth classes - Authentication, authorization, and session management
239
+ 'DMSCAuthModule', 'DMSCAuthConfig', 'DMSCJWTManager', 'DMSCJWTClaims', 'DMSCJWTValidationOptions',
240
+ 'DMSCSessionManager', 'DMSCSession', 'DMSCPermissionManager', 'DMSCPermission', 'DMSCRole',
241
+ 'DMSCOAuthManager', 'DMSCOAuthToken', 'DMSCOAuthUserInfo', 'DMSCOAuthProvider',
242
+ 'DMSCJWTRevocationList', 'DMSCRevokedTokenInfo',
243
+
244
+ # Device classes - IoT device control and resource management
245
+ 'DMSCDeviceControlModule', 'DMSCDevice', 'DMSCDeviceType', 'DMSCDeviceStatus',
246
+ 'DMSCDeviceCapabilities', 'DMSCDeviceHealthMetrics', 'DMSCDeviceController',
247
+ 'DMSCDeviceConfig', 'DMSCDeviceControlConfig', 'DMSCDeviceSchedulingConfig', 'NetworkDeviceInfo',
248
+ 'DMSCDiscoveryResult', 'DMSCResourceRequest',
249
+ 'DMSCResourceAllocation', 'DMSCRequestSlaClass', 'DMSCResourceWeights',
250
+ 'DMSCAffinityRules',
251
+ 'DMSCResourcePool', 'DMSCResourcePoolConfig', 'DMSCResourcePoolStatistics', 'DMSCResourcePoolManager',
252
+ 'DMSCConnectionPoolStatistics',
253
+ 'DMSCResourceScheduler', 'DMSCDeviceScheduler', 'DMSCSchedulingPolicy',
254
+ 'DMSCAllocationRecord', 'DMSCAllocationRequest', 'DMSCAllocationStatistics',
255
+ 'DMSCDeviceTypeStatistics', 'DMSCSchedulingRecommendation', 'DMSCSchedulingRecommendationType',
256
+
257
+ # Observability classes - Metrics, tracing, and health monitoring
258
+ 'DMSCObservabilityModule', 'DMSCObservabilityConfig',
259
+ 'DMSCMetricsRegistry', 'DMSCTracer',
260
+ 'DMSCMetricType', 'DMSCMetricConfig', 'DMSCMetricSample', 'DMSCMetric',
261
+ 'DMSCObservabilityData',
262
+
263
+ # Validation classes - Data validation and sanitization
264
+ 'DMSCValidationError', 'DMSCValidationResult', 'DMSCValidationSeverity',
265
+ 'DMSCValidatorBuilder', 'DMSCValidationRunner', 'DMSCSanitizer',
266
+ 'DMSCSanitizationConfig', 'DMSCSchemaValidator', 'DMSCValidationModule',
267
+
268
+ # Protocol classes - Protocol management and connection handling
269
+ 'DMSCProtocolManager', 'DMSCProtocolType', 'DMSCProtocolConfig',
270
+ 'DMSCProtocolStatus', 'DMSCProtocolStats', 'DMSCConnectionState',
271
+ 'DMSCConnectionStats', 'DMSCProtocolHealth',
272
+ 'DMSCFrame', 'DMSCFrameHeader', 'DMSCFrameType',
273
+ 'DMSCConnectionInfo', 'DMSCMessageFlags', 'DMSCSecurityLevel',
274
+ 'DMSCFrameParser', 'DMSCFrameBuilder',
275
+
276
+ # Database classes - Database configuration and connection pooling
277
+ 'DMSCDatabaseConfig', 'DMSCDatabasePool', 'DMSCDBRow', 'DMSCDBResult', 'DatabaseType',
278
+ 'ColumnDefinition', 'IndexDefinition', 'ForeignKeyDefinition',
279
+ 'TableDefinition', 'LogicalOperator', 'Criteria', 'JoinClause',
280
+ 'ComparisonOperator', 'SortOrder', 'Pagination', 'QueryBuilder', 'JoinType',
281
+
282
+ # Submodules - Functional submodule references
283
+ 'device', 'cache', 'fs', 'hooks', 'observability',
284
+ 'queue', 'gateway', 'service_mesh', 'auth', 'protocol', 'database'
285
+ ]
286
+
287
+
288
+ class DMSCAppBuilder:
289
+ """
290
+ Fluent API builder for DMSC applications.
291
+
292
+ This class provides a Python-friendly chainable interface for building
293
+ DMSC applications. All configuration methods return `self` to enable
294
+ fluent-style method chaining.
295
+
296
+ Example:
297
+ app = (DMSCAppBuilder()
298
+ .with_config("config.yaml")
299
+ .with_logging(DMSCLogConfig())
300
+ .build())
301
+ """
302
+
303
+ def __init__(self):
304
+ from .dmsc import DMSCAppBuilder as RustBuilder
305
+ self._builder = RustBuilder()
306
+
307
+ def with_config(self, config_path: str) -> 'DMSCAppBuilder':
308
+ """Add a configuration file path."""
309
+ self._builder.py_with_config(config_path)
310
+ return self
311
+
312
+ def with_logging(self, log_config) -> 'DMSCAppBuilder':
313
+ """Add logging configuration."""
314
+ self._builder.py_with_logging(log_config)
315
+ return self
316
+
317
+ def with_observability(self, observability_config) -> 'DMSCAppBuilder':
318
+ """Add observability configuration."""
319
+ self._builder.py_with_observability(observability_config)
320
+ return self
321
+
322
+ def with_module(self, module) -> 'DMSCAppBuilder':
323
+ """Add a synchronous Python service module."""
324
+ self._builder.py_with_module(module)
325
+ return self
326
+
327
+ def with_python_module(self, module) -> 'DMSCAppBuilder':
328
+ """Add a Python module adapter."""
329
+ self._builder.py_with_python_module(module)
330
+ return self
331
+
332
+ def with_async_module(self, module) -> 'DMSCAppBuilder':
333
+ """Add an asynchronous Python service module."""
334
+ self._builder.py_with_async_module(module)
335
+ return self
336
+
337
+ def with_dms_module(self, module) -> 'DMSCAppBuilder':
338
+ """Add a DMSC module adapter."""
339
+ self._builder.py_with_dms_module(module)
340
+ return self
341
+
342
+ def with_modules(self, modules: list) -> 'DMSCAppBuilder':
343
+ """Add multiple synchronous Python service modules."""
344
+ self._builder.py_with_modules(modules)
345
+ return self
346
+
347
+ def with_async_modules(self, modules: list) -> 'DMSCAppBuilder':
348
+ """Add multiple asynchronous Python service modules."""
349
+ self._builder.py_with_async_modules(modules)
350
+ return self
351
+
352
+ def with_dms_modules(self, modules: list) -> 'DMSCAppBuilder':
353
+ """Add multiple DMSC module adapters."""
354
+ self._builder.py_with_dms_modules(modules)
355
+ return self
356
+
357
+ def build(self):
358
+ """Build and return the DMSC application runtime."""
359
+ return DMSCAppRuntime(self._builder.py_build())
360
+
361
+ def run(self, callback=None):
362
+ """Run the application with an optional callback."""
363
+ runtime = self.build()
364
+ runtime.run(callback)
365
+
366
+
367
+ class DMSCAppRuntime:
368
+ """
369
+ DMSC Application Runtime.
370
+
371
+ This class provides the runtime for executing a DMSC application.
372
+ It wraps the Rust implementation and provides a Python-friendly interface.
373
+ """
374
+
375
+ def __init__(self, runtime):
376
+ self._runtime = runtime
377
+
378
+ def run(self, callback=None):
379
+ """Run the application with an optional callback."""
380
+ if callback:
381
+ self._runtime.py_run(callback)
382
+ else:
383
+ self._runtime.py_run(lambda ctx: None)
384
+
385
+ def get_context(self):
386
+ """Get the service context."""
387
+ return self._runtime.get_context()
388
+
389
+
390
+ __all__.extend(['DMSCAppBuilder', 'DMSCAppRuntime'])
Binary file
@@ -0,0 +1,360 @@
1
+ Metadata-Version: 2.4
2
+ Name: dmsc
3
+ Version: 0.1.5
4
+ Classifier: Programming Language :: Rust
5
+ Classifier: Programming Language :: Python :: Implementation :: CPython
6
+ Classifier: Programming Language :: Python :: Implementation :: PyPy
7
+ Classifier: Programming Language :: Python :: 3.8
8
+ Classifier: Programming Language :: Python :: 3.9
9
+ Classifier: Programming Language :: Python :: 3.10
10
+ Classifier: Programming Language :: Python :: 3.11
11
+ Classifier: Programming Language :: Python :: 3.12
12
+ Classifier: Programming Language :: Python :: 3.13
13
+ Classifier: Programming Language :: Python :: 3.14
14
+ License-File: LICENSE
15
+ Summary: Dunimd Middleware Service - A high-performance Rust middleware framework with modular architecture
16
+ Keywords: middleware,rust,async,gateway,service-mesh
17
+ Author: Dunimd Team
18
+ Requires-Python: >=3.8
19
+ Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
20
+
21
+ <div align="center">
22
+
23
+ # DMSC (Dunimd Middleware Service)
24
+
25
+ English | [简体中文](README.zh.md)
26
+
27
+ [Help Documentation](doc/en/index.md) | [Changelog](CHANGELOG.md)
28
+
29
+ <a href="https://space.bilibili.com/3493284091529457" target="_blank">
30
+ <img alt="BiliBili" src="https://img.shields.io/badge/BiliBili-Dunimd-00A1D6?style=flat-square&logo=bilibili"/>
31
+ </a>
32
+ <a href="https://gitee.com/dunimd" target="_blank">
33
+ <img alt="Gitee" src="https://img.shields.io/badge/Gitee-Dunimd-C71D23?style=flat-square&logo=gitee"/>
34
+ </a>
35
+ <a href="https://github.com/mf2023/DMSC" target="_blank">
36
+ <img alt="GitHub" src="https://img.shields.io/badge/GitHub-DMSC-181717?style=flat-square&logo=github"/>
37
+ </a>
38
+ <a href="https://crates.io/crates/dmsc" target="_blank">
39
+ <img alt="Crates.io" src="https://img.shields.io/badge/Crates-DMSC-000000?style=flat-square&logo=rust"/>
40
+ </a>
41
+ <a href="https://pypi.org/project/dmsc/" target="_blank">
42
+ <img alt="PyPI" src="https://img.shields.io/badge/PyPI-DMSC-3775A9?style=flat-square&logo=pypi"/>
43
+ </a>
44
+
45
+ **DMSC (Dunimd Middleware Service)** — A high-performance Rust middleware framework that unifies backend infrastructure. Built for enterprise-scale with modular architecture, built-in observability, and distributed systems support.
46
+
47
+ </div>
48
+
49
+ <h2 align="center">🏗️ Core Architecture</h2>
50
+
51
+ ### 📐 Modular Design
52
+ DMSC adopts a highly modular architecture with 16 core modules plus 3 optional modules, enabling on-demand composition and seamless extension:
53
+
54
+ <div align="center">
55
+
56
+ | Module | Description |
57
+ |:--------|:-------------|
58
+ | **auth** | Authentication & authorization (JWT, OAuth, permissions) |
59
+ | **cache** | Multi-backend cache abstraction (Memory, Redis, Hybrid) |
60
+ | **config** | Multi-source configuration management with hot reload |
61
+ | **core** | Runtime, error handling, and service context |
62
+ | **database** | Database abstraction with PostgreSQL, MySQL, SQLite support |
63
+ | **device** | Device control, discovery, and intelligent scheduling |
64
+ | **fs** | Secure file system operations and management |
65
+ | **gateway** | API gateway with load balancing, rate limiting, and circuit breaking |
66
+ | **grpc** | gRPC server and client support with Python bindings (requires `grpc` feature) |
67
+ | **hooks** | Lifecycle event hooks (Startup, Shutdown, etc.) |
68
+ | **log** | Structured logging with tracing context integration |
69
+ | **module_rpc** | Inter-module RPC communication for distributed method calls |
70
+ | **observability** | Metrics, tracing, and Grafana integration |
71
+ | **database.orm** | Type-safe ORM with repository pattern, query builder, and Python bindings |
72
+ | **protocol** | Protocol abstraction layer for multi-protocol support (requires `pyo3` feature) |
73
+ | **queue** | Distributed queue abstraction (Kafka, RabbitMQ, Redis, Memory) |
74
+ | **service_mesh** | Service discovery, health checking, and traffic management |
75
+ | **validation** | Input validation and data sanitization utilities |
76
+ | **ws** | WebSocket server support with Python bindings (requires `websocket` feature) |
77
+
78
+ </div>
79
+
80
+ > **Note**: Some modules require specific feature flags:
81
+ > - `grpc`: gRPC support (`--features grpc`)
82
+ > - `websocket`: WebSocket support (`--features websocket`)
83
+ > - `protocol`: Protocol abstraction layer (`--features protocol` or `full`)
84
+
85
+ ### 🚀 Key Features
86
+
87
+ #### 🔍 Distributed Tracing
88
+ - W3C Trace Context standard implementation
89
+ - Full-chain TraceID/SpanID propagation
90
+ - Baggage data transmission for business context
91
+ - Multi-language compatibility (Java, Go, Python)
92
+ - Automatic span creation via `#[tracing::instrument]` attribute
93
+
94
+ #### 📊 Enterprise Observability
95
+ - Native Prometheus metrics export
96
+ - Counter, Gauge, Histogram, Summary metric types
97
+ - Out-of-the-box Grafana dashboard integration
98
+ - Real-time performance statistics with quantile calculation
99
+ - Full-stack metrics (CPU, memory, I/O, network)
100
+
101
+ #### 🤖 Intelligent Device Management
102
+ - Auto-discovery and registration
103
+ - Efficient resource pool management
104
+ - Policy-based scheduling with priority support
105
+ - Dynamic load balancing
106
+ - Complete device lifecycle management
107
+
108
+ #### 📝 Structured Logging
109
+ - JSON and text format support
110
+ - Configurable sampling rates
111
+ - Intelligent log rotation
112
+ - Automatic tracing context inclusion
113
+ - DEBUG/INFO/WARN/ERROR log levels
114
+
115
+ #### ⚙️ Flexible Configuration
116
+ - Multi-source loading (files, environment variables, runtime)
117
+ - Hot configuration updates
118
+ - Modular architecture for on-demand composition
119
+ - Plugin-based extension mechanism
120
+
121
+ #### 📁 Secure File System
122
+ - Unified project root directory management
123
+ - Atomic file operations
124
+ - Categorized directory structure
125
+ - JSON data persistence
126
+ - Secure path handling
127
+
128
+ <h2 align="center">🛠️ Installation & Environment</h2>
129
+
130
+ ### Prerequisites
131
+ - **Rust**: 1.65+ (2021 Edition)
132
+ - **Cargo**: 1.65+
133
+ - **Platforms**: Linux, macOS, Windows
134
+
135
+ ### Quick Setup
136
+
137
+ Add DMSC to your project's `Cargo.toml`:
138
+
139
+ ```toml
140
+ [dependencies]
141
+ dmsc = { git = "https://github.com/mf2023/DMSC" }
142
+ ```
143
+
144
+ Or use cargo add:
145
+
146
+ ```bash
147
+ cargo add DMSC --git https://github.com/mf2023/DMSC
148
+ ```
149
+
150
+ <h2 align="center">⚡ Quick Start</h2>
151
+
152
+ ### Core API Usage
153
+
154
+ ```rust
155
+ use dmsc::prelude::*;
156
+
157
+ #[tokio::main]
158
+ async fn main() -> DMSCResult<()> {
159
+ // Build service runtime
160
+ let app = DMSCAppBuilder::new()
161
+ .with_config("config.yaml")?
162
+ .with_logging(DMSCLogConfig::default())?
163
+ .with_observability(DMSCObservabilityConfig::default())?
164
+ .build()?;
165
+
166
+ // Run business logic
167
+ app.run(|ctx: &DMSCServiceContext| async move {
168
+ ctx.logger().info("service", "DMSC service started")?;
169
+ // Your business code here
170
+ Ok(())
171
+ }).await
172
+ }
173
+ ```
174
+
175
+ ### Observability Example
176
+
177
+ ```rust
178
+ use dmsc::prelude::*;
179
+ use dmsc::observability::{DMSCTracer, DMSCSpanKind, DMSCSpanStatus};
180
+
181
+ #[tracing::instrument(name = "user_service", skip(ctx))]
182
+ async fn get_user(ctx: &DMSCServiceContext, user_id: u64) -> DMSCResult<User> {
183
+ let user = fetch_user_from_db(user_id).await?;
184
+ Ok(user)
185
+ }
186
+ ```
187
+
188
+ Or using DMSCTracer directly:
189
+
190
+ ```rust
191
+ use dmsc::prelude::*;
192
+ use dmsc::observability::DMSCTracer;
193
+
194
+ async fn get_user(ctx: &DMSCServiceContext, user_id: u64) -> DMSCResult<User> {
195
+ let tracer = DMSCTracer::new(1.0);
196
+ let _span = tracer.span("get_user")
197
+ .with_attribute("user_id", user_id.to_string())
198
+ .start();
199
+ let user = fetch_user_from_db(user_id).await?;
200
+ Ok(user)
201
+ }
202
+ ```
203
+
204
+ <h2 align="center">🔧 Configuration</h2>
205
+
206
+ ### Configuration Example
207
+
208
+ ```yaml
209
+ # config.yaml
210
+ service:
211
+ name: "my-service"
212
+ version: "1.0.0"
213
+
214
+ logging:
215
+ level: "info"
216
+ file_format: "json"
217
+ file_enabled: true
218
+ console_enabled: true
219
+
220
+ observability:
221
+ metrics_enabled: true
222
+ tracing_enabled: true
223
+ prometheus_port: 9090
224
+
225
+ resource:
226
+ providers: ["cpu", "gpu", "memory"]
227
+ scheduling_policy: "priority_based"
228
+ ```
229
+
230
+ ### Configuration Sources
231
+
232
+ DMSC supports multiple configuration sources in order of priority (lowest to highest):
233
+ 1. Configuration files (YAML, TOML, JSON)
234
+ 2. Custom configuration via code
235
+ 3. Environment variables (prefixed with `DMSC_`)
236
+
237
+ <h2 align="center">🧪 Development & Testing</h2>
238
+
239
+ ### Running Tests
240
+
241
+ ```bash
242
+ # Run all tests
243
+ cargo test
244
+
245
+ # Run specific test module
246
+ cargo test cache
247
+
248
+ # Run with verbose output
249
+ cargo test -- --nocapture
250
+ ```
251
+
252
+ <h2 align="center">❓ Frequently Asked Questions</h2>
253
+
254
+ **Q: How to add a new module?**
255
+ A: Implement the `DMSCModule` trait and register it via `DMSCAppBuilder::with_module`.
256
+
257
+ **Q: How to configure logging level?**
258
+ A: Set `logging.level` in the configuration file, supporting DEBUG/INFO/WARN/ERROR levels.
259
+
260
+ **Q: How to enable metrics export?**
261
+ A: Set `observability.metrics_enabled: true` and configure `prometheus_port` in the configuration file.
262
+
263
+ **Q: How to extend configuration sources?**
264
+ A: Implement a custom configuration loader and register it with `DMSCConfigManager`.
265
+
266
+ **Q: How to handle asynchronous tasks?**
267
+ A: Use `DMSCAppBuilder::with_async_module` to add async modules, the framework handles async lifecycle automatically.
268
+
269
+ <h2 align="center">🌏 Community & Citation</h2>
270
+
271
+ - Welcome to submit Issues and PRs!
272
+ - Gitee: https://github.com/mf2023/DMSC.git
273
+
274
+
275
+ <div align="center">
276
+
277
+ ## 📄 License & Open Source Agreements
278
+
279
+ ### 🏛️ Project License
280
+
281
+ <p align="center">
282
+ <a href="LICENSE">
283
+ <img src="https://img.shields.io/badge/License-Apache%202.0-blue.svg" alt="Apache License 2.0">
284
+ </a>
285
+ </p>
286
+
287
+ This project uses **Apache License 2.0** open source agreement, see [LICENSE](LICENSE) file.
288
+
289
+ ### 📋 Dependency Package Open Source Agreements
290
+
291
+ Open source packages and their agreement information used by this project:
292
+
293
+ ### Dependencies License
294
+
295
+ <div align="center">
296
+
297
+ | 📦 Package | 📜 License |
298
+ |:-----------|:-----------|
299
+ | serde | Apache 2.0 |
300
+ | serde_json | MIT |
301
+ | serde_yaml | MIT |
302
+ | tokio | MIT |
303
+ | prometheus | Apache 2.0 |
304
+ | redis | MIT |
305
+ | hyper | MIT |
306
+ | lapin | Apache 2.0 |
307
+ | futures | MIT |
308
+ | yaml-rust | MIT |
309
+ | toml | MIT |
310
+ | etcd-client | MIT |
311
+ | sysinfo | MIT |
312
+ | async-trait | MIT |
313
+ | dashmap | MIT |
314
+ | chrono | MIT |
315
+ | uuid | Apache 2.0 |
316
+ | rand | MIT |
317
+ | notify | MIT |
318
+ | jsonwebtoken | MIT |
319
+ | reqwest | MIT |
320
+ | urlencoding | MIT |
321
+ | parking_lot | MIT |
322
+ | log | MIT |
323
+ | pyo3 | Apache 2.0 |
324
+ | tempfile | MIT |
325
+ | tracing | MIT |
326
+ | thiserror | MIT |
327
+ | hex | MIT |
328
+ | base64 | MIT |
329
+ | regex | MIT |
330
+ | url | Apache 2.0 |
331
+ | aes-gcm | Apache 2.0 |
332
+ | ring | Apache 2.0 |
333
+ | lazy_static | MIT |
334
+ | libloading | MIT |
335
+ | zeroize | MIT/Apache-2.0 |
336
+ | secrecy | MIT |
337
+ | data-encoding | MIT |
338
+ | crc32fast | MIT |
339
+ | generic-array | MIT |
340
+ | bincode | MIT |
341
+ | typenum | MIT |
342
+ | html-escape | MIT |
343
+ | rustls | Apache 2.0/MIT |
344
+ | rustls-pemfile | Apache 2.0/MIT |
345
+ | webpki | ISC |
346
+ | rustls-native-certs | Apache 2.0/MIT |
347
+ | bytes | Apache 2.0 |
348
+ | tonic | MIT |
349
+ | prost | Apache 2.0 |
350
+ | tokio-stream | MIT |
351
+ | tower | MIT |
352
+ | async-stream | MIT |
353
+ | tokio-tungstenite | MIT |
354
+ | tungstenite | MPL-2.0 |
355
+ | num-bigint | MIT/Apache-2.0 |
356
+ | oqs | MIT/Apache-2.0 |
357
+
358
+ </div>
359
+
360
+ </div>
@@ -0,0 +1,6 @@
1
+ dmsc/__init__.py,sha256=lezcKJ2TU5AfHe0FyiTdmbRyOPgQQTEvcDwNZeNuqhk,20210
2
+ dmsc/dmsc.cpython-312-darwin.so,sha256=_GheCQ5NjArKAq2nNrvYddsV0uDWNBUfz7VSZdYTnSY,16641776
3
+ dmsc-0.1.5.dist-info/METADATA,sha256=WAO0ReFnivRwknpEPCml7j2jO9D4Ts0s6cYzi-HiaYI,10821
4
+ dmsc-0.1.5.dist-info/WHEEL,sha256=5PbULt6DKUkIiubOjwQPyn-vzBuHJr28QRlczaBjcdg,107
5
+ dmsc-0.1.5.dist-info/licenses/LICENSE,sha256=QwcOLU5TJoTeUhuIXzhdCEEDDvorGiC6-3YTOl4TecE,11356
6
+ dmsc-0.1.5.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: maturin (1.11.5)
3
+ Root-Is-Purelib: false
4
+ Tag: cp312-cp312-macosx_10_12_x86_64
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.