Module core

Module core 

Source
Expand description

Core runtime, application builder, and service context Copyright © 2025-2026 Wenze Wei. All Rights Reserved.

This file is part of DMSC. The DMSC project belongs to the Dunimd Team.

Licensed under the Apache License, Version 2.0 (the “License”); You may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

§Core Runtime Module

The core module provides the fundamental building blocks for DMSC applications, including the application builder, service context, error handling, and module lifecycle management.

§Key Components

  • error: Error handling with custom error types and result aliases
  • context: Service context for accessing core functionalities
  • module: Module system for extending DMSC with custom functionality
  • runtime: Application runtime and builder for constructing DMSC applications
  • lifecycle: Lifecycle management for modules
  • analytics: Basic analytics and telemetry support

§Design Principles

The core module follows the following design principles:

  1. Dependency Injection: Components are accessed through the service context, allowing for easy mocking and testing
  2. Builder Pattern: The DMSCAppBuilder provides a fluent API for configuring applications
  3. Module System: A flexible module system allows for easy extension
  4. Error Handling: A unified error type simplifies error management across modules
  5. Async First: Full support for asynchronous operations

§Usage Example

use dmsc::prelude::*;

#[tokio::main]
async fn main() -> DMSCResult<()> {
    let app = DMSCAppBuilder::new()
        .with_config("config.yaml")?
        .with_module(Box::new(MyModule::new()))
        .build()?;

    app.run(|ctx| async move {
        ctx.logger().info("service", "DMSC service started")?;
        Ok(())
    }).await
}

Re-exports§

pub use error::DMSCError;
pub use error::DMSCResult;
pub use context::DMSCServiceContext;
pub use module::DMSCModule;
pub use runtime::DMSCAppBuilder;
pub use runtime::DMSCAppRuntime;
pub use module::ServiceModule;
pub use module::AsyncServiceModule;
pub use lock::DMSCLockError;
pub use lock::DMSCLockResult;
pub use lock::RwLockExtensions;
pub use lock::MutexExtensions;
pub use lock::from_poison_error;
pub use module::DMSCPythonModule;
pub use module::DMSCPythonModuleAdapter;
pub use module::DMSCPythonServiceModule;
pub use module::DMSCPythonAsyncServiceModule;
pub use error_chain::DMSCErrorChain;
pub use error_chain::DMSCErrorChainIter;
pub use error_chain::DMSCErrorContext;
pub use error_chain::DMSCOptionErrorContext;
pub use health::DMSCHealthStatus;
pub use health::DMSCHealthCheckResult;
pub use health::DMSCHealthCheckConfig;
pub use health::DMSCHealthReport;
pub use health::DMSCHealthChecker;
pub use lifecycle::DMSCLifecycleObserver;
pub use analytics::DMSCLogAnalyticsModule;

Modules§

analytics
Basic analytics and telemetry support Copyright © 2025-2026 Wenze Wei. All Rights Reserved.
app_builder
Application builder for constructing DMSC applications Copyright © 2025-2026 Wenze Wei. All Rights Reserved.
app_runtime
Application runtime for managing DMSC application lifecycle Copyright © 2025-2026 Wenze Wei. All Rights Reserved.
context
Service context for accessing core functionalities Copyright © 2025-2026 Wenze Wei. All Rights Reserved.
error
Error handling with custom error types and result aliases Copyright © 2025-2026 Wenze Wei. All Rights Reserved.
error_chain
Error chain utilities Copyright © 2025-2026 Wenze Wei. All Rights Reserved.
health
Health checks for modules and services Copyright © 2025-2026 Wenze Wei. All Rights Reserved.
lifecycle
Lifecycle management for modules Copyright © 2025-2026 Wenze Wei. All Rights Reserved.
lock
Safe lock utilities for concurrent programming Copyright © 2025-2026 Wenze Wei. All Rights Reserved.
module
Module system for extending DMSC with custom functionality Copyright © 2025-2026 Wenze Wei. All Rights Reserved.
module_sorter
Module sorter for sorting modules based on dependencies and priority Copyright © 2025-2026 Wenze Wei. All Rights Reserved.
module_types
Module types for distinguishing between sync and async modules Copyright © 2025-2026 Wenze Wei. All Rights Reserved.
runtime
Application runtime and builder for constructing DMSC applications Copyright © 2025-2026 Wenze Wei. All Rights Reserved.