pub struct RiAppBuilder { /* private fields */ }Expand description
Public-facing application builder for Ri.
The RiAppBuilder provides a fluent API for configuring and building Ri applications.
It follows the builder pattern, allowing users to configure various aspects of the application
before building the final runtime.
§Usage
use ri::prelude::*;
#[tokio::main]
async fn main() -> RiResult<()> {
let app = RiAppBuilder::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", "Ri service started")?;
Ok(())
}).await
}Implementations§
Source§impl RiAppBuilder
impl RiAppBuilder
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: RiPythonModuleAdapter) -> Self
pub fn with_python_module(self, module: RiPythonModuleAdapter) -> 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 Ri module.
§Parameters
module: A Python module adapter implementing module configuration
§Returns
The updated RiAppBuilder 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 RiModule>) -> Self
pub fn with_dms_module(self, module: Box<dyn RiModule>) -> Self
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 RiModule>>) -> Self
pub fn with_dms_modules(self, modules: Vec<Box<dyn RiModule>>) -> Self
Add multiple Ri modules to the application.
This method adds multiple modules implementing the public RiModule trait to the application.
Each module will be treated as an asynchronous module.
§Parameters
modules: A vector of boxed modules implementingRiModule
§Returns
The updated RiAppBuilder instance for method chaining.
Sourcepub fn with_config(self, config_path: impl Into<String>) -> RiResult<Self>
pub fn with_config(self, config_path: impl Into<String>) -> RiResult<Self>
Add a configuration file to the application.
§Parameters
config_path: Path to the configuration file
§Returns
A RiResult containing the updated RiAppBuilder instance for method chaining.
§Errors
This method currently never returns an error, but returns RiResult for consistency
with other builder methods and to allow for future error handling.
Sourcepub fn with_logging(self, logging_config: RiLogConfig) -> Self
pub fn with_logging(self, logging_config: RiLogConfig) -> Self
Sourcepub fn with_observability(
self,
observability_config: RiObservabilityConfig,
) -> Self
pub fn with_observability( self, observability_config: RiObservabilityConfig, ) -> 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 RiAppBuilder 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) -> RiResult<RiAppRuntime>
pub fn build(self) -> RiResult<RiAppRuntime>
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 RiResult containing the built RiAppRuntime 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 RiAppBuilder
impl Default for RiAppBuilder
Source§impl<'py> IntoPyObject<'py> for RiAppBuilder
impl<'py> IntoPyObject<'py> for RiAppBuilder
Source§type Target = RiAppBuilder
type Target = RiAppBuilder
Source§type Output = Bound<'py, <RiAppBuilder as IntoPyObject<'py>>::Target>
type Output = Bound<'py, <RiAppBuilder 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 RiAppBuilder
impl PyClass for RiAppBuilder
Source§impl PyClassImpl for RiAppBuilder
impl PyClassImpl for RiAppBuilder
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<RiAppBuilder>
type ThreadChecker = SendablePyClass<RiAppBuilder>
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 RiAppBuilder
impl PyClassNewTextSignature for RiAppBuilder
const TEXT_SIGNATURE: &'static str = "()"
Source§impl PyMethods<RiAppBuilder> for PyClassImplCollector<RiAppBuilder>
impl PyMethods<RiAppBuilder> for PyClassImplCollector<RiAppBuilder>
fn py_methods(self) -> &'static PyClassItems
Source§impl PyTypeInfo for RiAppBuilder
impl PyTypeInfo for RiAppBuilder
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 RiAppBuilder
impl ExtractPyClassWithClone for RiAppBuilder
Auto Trait Implementations§
impl Freeze for RiAppBuilder
impl !RefUnwindSafe for RiAppBuilder
impl Send for RiAppBuilder
impl Sync for RiAppBuilder
impl Unpin for RiAppBuilder
impl UnsafeUnpin for RiAppBuilder
impl !UnwindSafe for RiAppBuilder
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