Skip to main content

DomainService

Trait DomainService 

Source
pub trait DomainService: Send + Sync {
    // Required method
    fn service_id(&self) -> &'static str;

    // Provided methods
    fn health_check<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<(), Box<dyn Error + Send + Sync>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait { ... }
    fn service_name(&self) -> &'static str { ... }
    fn module_name(&self) -> &'static str { ... }
}
Expand description

Base trait for all domain services.

Domain services are stateless operations that coordinate between multiple entities or handle complex business logic.

Required Methods§

Source

fn service_id(&self) -> &'static str

Unique identifier for this service.

Format: {module}.{service_name} Example: "corpus.organization_service"

Provided Methods§

Source

fn health_check<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<(), Box<dyn Error + Send + Sync>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Perform a health check for this service.

Returns Ok(()) if the service is healthy, or an error describing the issue.

Source

fn service_name(&self) -> &'static str

Get the service name (derived from service_id).

Source

fn module_name(&self) -> &'static str

Get the module name (derived from service_id).

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§