dmsc/core/
mod.rs

1//! Copyright © 2025-2026 Wenze Wei. All Rights Reserved.
2//! 
3//! This file is part of DMSC.
4//! The DMSC project belongs to the Dunimd Team.
5//! 
6//! Licensed under the Apache License, Version 2.0 (the "License");
7//! You may not use this file except in compliance with the License.
8//! You may obtain a copy of the License at
9//! 
10//!     http://www.apache.org/licenses/LICENSE-2.0
11//! 
12//! Unless required by applicable law or agreed to in writing, software
13//! distributed under the License is distributed on an "AS IS" BASIS,
14//! WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15//! See the License for the specific language governing permissions and
16//! limitations under the License.
17
18//! # Core Runtime Module
19//! 
20//! The core module provides the fundamental building blocks for DMSC applications,
21//! including the application builder, service context, error handling, and module lifecycle management.
22//! 
23//! ## Key Components
24//! 
25//! - **error**: Error handling with custom error types and result aliases
26//! - **context**: Service context for accessing core functionalities
27//! - **module**: Module system for extending DMSC with custom functionality
28//! - **runtime**: Application runtime and builder for constructing DMSC applications
29//! - **lifecycle**: Lifecycle management for modules
30//! - **analytics**: Basic analytics and telemetry support
31//! 
32//! ## Design Principles
33//! 
34//! The core module follows the following design principles:
35//! 
36//! 1. **Dependency Injection**: Components are accessed through the service context, 
37//!    allowing for easy mocking and testing
38//! 2. **Builder Pattern**: The `DMSCAppBuilder` provides a fluent API for configuring applications
39//! 3. **Module System**: A flexible module system allows for easy extension
40//! 4. **Error Handling**: A unified error type simplifies error management across modules
41//! 5. **Async First**: Full support for asynchronous operations
42//!
43//! ## Usage Example
44//!
45//! ```rust
46//! use dmsc::prelude::*;
47//!
48//! #[tokio::main]
49//! async fn main() -> DMSCResult<()> {
50//!     let app = DMSCAppBuilder::new()
51//!         .with_config("config.yaml")?
52//!         .with_module(Box::new(MyModule::new()))
53//!         .build()?;
54//!
55//!     app.run(|ctx| async move {
56//!         ctx.logger().info("service", "DMSC service started")?;
57//!         Ok(())
58//!     }).await
59//! }
60//! ```
61
62/// Error handling with custom error types and result aliases
63pub mod error;
64/// Safe lock utilities for concurrent programming
65pub mod lock;
66/// Service context for accessing core functionalities
67pub mod context;
68/// Module system for extending DMSC with custom functionality
69pub mod module;
70/// Application runtime and builder for constructing DMSC applications
71pub mod runtime;
72/// Application builder for constructing DMSC applications
73pub mod app_builder;
74/// Application runtime for managing DMSC application lifecycle
75pub mod app_runtime;
76/// Module types for distinguishing between sync and async modules
77pub mod module_types;
78/// Module sorter for sorting modules based on dependencies and priority
79pub mod module_sorter;
80/// Lifecycle management for modules
81pub mod lifecycle;
82/// Basic analytics and telemetry support
83pub mod analytics;
84/// Health checks for modules and services
85pub mod health;
86/// Error chain utilities
87pub mod error_chain;
88
89/// Main error type for DMSC operations
90pub use error::{DMSCError, DMSCResult};
91/// Service context providing access to core functionalities
92pub use context::DMSCServiceContext;
93/// Module traits for extending DMSC functionality
94pub use module::DMSCModule;
95/// Application builder and runtime for constructing DMSC applications
96pub use runtime::{DMSCAppBuilder, DMSCAppRuntime};
97/// Internal module traits
98pub use module::{ServiceModule, AsyncServiceModule};
99
100/// Lock utilities
101#[cfg(feature = "pyo3")]
102pub use lock::{DMSCLockError, DMSCLockResult, RwLockExtensions, MutexExtensions, from_poison_error};
103
104/// Python module bindings
105#[cfg(feature = "pyo3")]
106pub use module::{DMSCPythonModule, DMSCPythonModuleAdapter, DMSCPythonServiceModule, DMSCPythonAsyncServiceModule};
107
108/// Error chain utilities
109#[cfg(feature = "pyo3")]
110pub use error_chain::{DMSCErrorChain, DMSCErrorChainIter, DMSCErrorContext, DMSCOptionErrorContext};
111
112/// Health check types
113#[cfg(feature = "pyo3")]
114pub use health::{DMSCHealthStatus, DMSCHealthCheckResult, DMSCHealthCheckConfig, DMSCHealthReport, DMSCHealthChecker};
115
116/// Lifecycle management
117#[cfg(feature = "pyo3")]
118pub use lifecycle::DMSCLifecycleObserver;
119
120/// Analytics module
121#[cfg(feature = "pyo3")]
122pub use analytics::DMSCLogAnalyticsModule;