pub struct DMSCAppBuilder { /* private fields */ }Expand description
Public-facing application builder for DMSC.
The DMSCAppBuilder provides a fluent API for configuring and building DMSC applications.
It follows the builder pattern, allowing users to configure various aspects of the application
before building the final runtime.
§Usage
use dmsc::prelude::*;
#[tokio::main]
async fn main() -> DMSCResult<()> {
let app = DMSCAppBuilder::new()
.with_config("config.yaml")?
.with_module(Box::new(MySyncModule::new()))
.with_async_module(Box::new(MyAsyncModule::new()))
.build()?;
app.run(|ctx| async move {
ctx.logger().info("service", "DMSC service started")?;
Ok(())
}).await
}Implementations§
Source§impl DMSCAppBuilder
impl DMSCAppBuilder
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new empty application builder.
§Returns
A new DMSCAppBuilder instance with default settings.
Sourcepub fn with_module(self, module: Box<dyn ServiceModule>) -> Self
pub fn with_module(self, module: Box<dyn ServiceModule>) -> Self
Sourcepub fn with_python_module(self, module: DMSCPythonModuleAdapter) -> Self
pub fn with_python_module(self, module: DMSCPythonModuleAdapter) -> Self
Add a Python module to the application.
This method adds a module created from Python code to the application. The module will be treated as an asynchronous DMSC module.
§Parameters
module: A Python module adapter implementing module configuration
§Returns
The updated DMSCAppBuilder instance for method chaining.
Sourcepub fn with_async_module(self, module: Box<dyn AsyncServiceModule>) -> Self
pub fn with_async_module(self, module: Box<dyn AsyncServiceModule>) -> Self
Sourcepub fn with_dms_module(self, module: Box<dyn DMSCModule>) -> Self
pub fn with_dms_module(self, module: Box<dyn DMSCModule>) -> Self
Add a DMSC module to the application.
This method adds a module implementing the public DMSCModule trait to the application.
The module will be treated as an asynchronous module.
§Parameters
module: A boxed module implementingDMSCModule
§Returns
The updated DMSCAppBuilder instance for method chaining.
Sourcepub fn with_modules(self, modules: Vec<Box<dyn ServiceModule>>) -> Self
pub fn with_modules(self, modules: Vec<Box<dyn ServiceModule>>) -> Self
Sourcepub fn with_async_modules(
self,
modules: Vec<Box<dyn AsyncServiceModule>>,
) -> Self
pub fn with_async_modules( self, modules: Vec<Box<dyn AsyncServiceModule>>, ) -> Self
Sourcepub fn with_dms_modules(self, modules: Vec<Box<dyn DMSCModule>>) -> Self
pub fn with_dms_modules(self, modules: Vec<Box<dyn DMSCModule>>) -> Self
Add multiple DMSC modules to the application.
This method adds multiple modules implementing the public DMSCModule trait to the application.
Each module will be treated as an asynchronous module.
§Parameters
modules: A vector of boxed modules implementingDMSCModule
§Returns
The updated DMSCAppBuilder instance for method chaining.
Sourcepub fn with_config(self, config_path: impl Into<String>) -> DMSCResult<Self>
pub fn with_config(self, config_path: impl Into<String>) -> DMSCResult<Self>
Add a configuration file to the application.
§Parameters
config_path: Path to the configuration file
§Returns
A DMSCResult containing the updated DMSCAppBuilder instance for method chaining.
§Errors
This method currently never returns an error, but returns DMSCResult for consistency
with other builder methods and to allow for future error handling.
Sourcepub fn with_logging(self, logging_config: DMSCLogConfig) -> Self
pub fn with_logging(self, logging_config: DMSCLogConfig) -> Self
Sourcepub fn with_observability(
self,
observability_config: DMSCObservabilityConfig,
) -> Self
pub fn with_observability( self, observability_config: DMSCObservabilityConfig, ) -> Self
Sourcepub fn with_cache_module<F>(self, config_fn: F) -> Self
pub fn with_cache_module<F>(self, config_fn: F) -> Self
Add cache module with configuration.
This method adds a cache module to the application with custom configuration. The configuration is provided via a closure that receives a cache config builder.
§Parameters
config_fn: Closure for configuring the cache module
§Returns
The updated DMSCAppBuilder instance for method chaining.
Sourcepub fn with_auth_module<F>(self, config_fn: F) -> Self
pub fn with_auth_module<F>(self, config_fn: F) -> Self
Sourcepub fn with_queue_module<F>(self, config_fn: F) -> Self
pub fn with_queue_module<F>(self, config_fn: F) -> Self
Sourcepub fn with_device_module<F>(self, config_fn: F) -> Self
pub fn with_device_module<F>(self, config_fn: F) -> Self
Sourcepub fn build(self) -> DMSCResult<DMSCAppRuntime>
pub fn build(self) -> DMSCResult<DMSCAppRuntime>
Build the application runtime.
This method performs the following steps:
- Creates and configures the configuration manager
- Loads configuration from specified files and environment variables
- Creates the service context with core functionalities
- Adds core modules (analytics and lifecycle observer)
- Sorts modules based on dependencies and priority
- Creates and returns the application runtime
§Returns
A DMSCResult containing the built DMSCAppRuntime instance, or an error if building fails.
§Errors
- If configuration loading fails
- If service context creation fails
- If module sorting fails due to circular dependencies
Trait Implementations§
Source§impl Default for DMSCAppBuilder
impl Default for DMSCAppBuilder
Source§impl<'py> IntoPyObject<'py> for DMSCAppBuilder
impl<'py> IntoPyObject<'py> for DMSCAppBuilder
Source§type Target = DMSCAppBuilder
type Target = DMSCAppBuilder
Source§type Output = Bound<'py, <DMSCAppBuilder as IntoPyObject<'py>>::Target>
type Output = Bound<'py, <DMSCAppBuilder as IntoPyObject<'py>>::Target>
Source§fn into_pyobject(
self,
py: Python<'py>,
) -> Result<<Self as IntoPyObject<'_>>::Output, <Self as IntoPyObject<'_>>::Error>
fn into_pyobject( self, py: Python<'py>, ) -> Result<<Self as IntoPyObject<'_>>::Output, <Self as IntoPyObject<'_>>::Error>
Source§impl PyClass for DMSCAppBuilder
impl PyClass for DMSCAppBuilder
Source§impl PyClassImpl for DMSCAppBuilder
impl PyClassImpl for DMSCAppBuilder
Source§const IS_BASETYPE: bool = false
const IS_BASETYPE: bool = false
Source§const IS_SUBCLASS: bool = false
const IS_SUBCLASS: bool = false
Source§const IS_MAPPING: bool = false
const IS_MAPPING: bool = false
Source§const IS_SEQUENCE: bool = false
const IS_SEQUENCE: bool = false
Source§const IS_IMMUTABLE_TYPE: bool = false
const IS_IMMUTABLE_TYPE: bool = false
Source§const RAW_DOC: &'static CStr = /// ```
const RAW_DOC: &'static CStr = /// ```
Source§const DOC: &'static CStr
const DOC: &'static CStr
text_signature if a constructor is defined. Read moreSource§type ThreadChecker = SendablePyClass<DMSCAppBuilder>
type ThreadChecker = SendablePyClass<DMSCAppBuilder>
Source§type PyClassMutability = <<PyAny as PyClassBaseType>::PyClassMutability as PyClassMutability>::MutableChild
type PyClassMutability = <<PyAny as PyClassBaseType>::PyClassMutability as PyClassMutability>::MutableChild
Source§type BaseNativeType = PyAny
type BaseNativeType = PyAny
PyAny by default, and when you declare
#[pyclass(extends=PyDict)], it’s PyDict.fn items_iter() -> PyClassItemsIter
fn lazy_type_object() -> &'static LazyTypeObject<Self>
fn dict_offset() -> Option<isize>
fn weaklist_offset() -> Option<isize>
Source§impl PyClassNewTextSignature for DMSCAppBuilder
impl PyClassNewTextSignature for DMSCAppBuilder
const TEXT_SIGNATURE: &'static str = "()"
Source§impl PyMethods<DMSCAppBuilder> for PyClassImplCollector<DMSCAppBuilder>
impl PyMethods<DMSCAppBuilder> for PyClassImplCollector<DMSCAppBuilder>
fn py_methods(self) -> &'static PyClassItems
Source§impl PyTypeInfo for DMSCAppBuilder
impl PyTypeInfo for DMSCAppBuilder
Source§fn type_object_raw(py: Python<'_>) -> *mut PyTypeObject
fn type_object_raw(py: Python<'_>) -> *mut PyTypeObject
§fn type_object(py: Python<'_>) -> Bound<'_, PyType>
fn type_object(py: Python<'_>) -> Bound<'_, PyType>
§fn is_type_of(object: &Bound<'_, PyAny>) -> bool
fn is_type_of(object: &Bound<'_, PyAny>) -> bool
object is an instance of this type or a subclass of this type.§fn is_exact_type_of(object: &Bound<'_, PyAny>) -> bool
fn is_exact_type_of(object: &Bound<'_, PyAny>) -> bool
object is an instance of this type.impl DerefToPyAny for DMSCAppBuilder
impl ExtractPyClassWithClone for DMSCAppBuilder
Auto Trait Implementations§
impl Freeze for DMSCAppBuilder
impl !RefUnwindSafe for DMSCAppBuilder
impl Send for DMSCAppBuilder
impl Sync for DMSCAppBuilder
impl Unpin for DMSCAppBuilder
impl !UnwindSafe for DMSCAppBuilder
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<'py, T> IntoPyObjectExt<'py> for Twhere
T: IntoPyObject<'py>,
impl<'py, T> IntoPyObjectExt<'py> for Twhere
T: IntoPyObject<'py>,
§fn into_bound_py_any(self, py: Python<'py>) -> Result<Bound<'py, PyAny>, PyErr>
fn into_bound_py_any(self, py: Python<'py>) -> Result<Bound<'py, PyAny>, PyErr>
self into an owned Python object, dropping type information.§fn into_py_any(self, py: Python<'py>) -> Result<Py<PyAny>, PyErr>
fn into_py_any(self, py: Python<'py>) -> Result<Py<PyAny>, PyErr>
self into an owned Python object, dropping type information and unbinding it
from the 'py lifetime.§fn into_pyobject_or_pyerr(self, py: Python<'py>) -> Result<Self::Output, PyErr>
fn into_pyobject_or_pyerr(self, py: Python<'py>) -> Result<Self::Output, PyErr>
self into a Python object. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::RequestSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> PyErrArguments for T
impl<T> PyErrArguments for T
§impl<T> PyTypeCheck for Twhere
T: PyTypeInfo,
impl<T> PyTypeCheck for Twhere
T: PyTypeInfo,
§const NAME: &'static str = T::NAME
const NAME: &'static str = T::NAME
§fn type_check(object: &Bound<'_, PyAny>) -> bool
fn type_check(object: &Bound<'_, PyAny>) -> bool
§fn classinfo_object(py: Python<'_>) -> Bound<'_, PyAny>
fn classinfo_object(py: Python<'_>) -> Bound<'_, PyAny>
isinstance and issubclass function. Read more