pub trait ModuleService: Send + Sync {
// Required methods
fn service_id(&self) -> &'static str;
fn service_type(&self) -> &'static str;
fn module_name(&self) -> &'static str;
fn health_check<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<ServiceHealth, String>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
// Provided method
fn as_any(&self) -> Option<&dyn Any> { ... }
}Expand description
Trait for module services that can be registered and discovered
Services implement this trait to be registered in the ServiceRegistry. The registry provides service discovery and health checking.
§Example
ⓘ
use backbone_core::registry::ModuleService;
struct UserQueryService { /* ... */ }
#[async_trait]
impl ModuleService for UserQueryService {
fn service_id(&self) -> &'static str {
"sapiens.user_query"
}
fn service_type(&self) -> &'static str {
"query"
}
fn module_name(&self) -> &'static str {
"sapiens"
}
async fn health_check(&self) -> Result<ServiceHealth, String> {
Ok(ServiceHealth::healthy())
}
}Required Methods§
Sourcefn service_id(&self) -> &'static str
fn service_id(&self) -> &'static str
Unique service identifier (e.g., “sapiens.user_query”, “postman.email_sender”)
Format: {module}.{service_name}
Sourcefn service_type(&self) -> &'static str
fn service_type(&self) -> &'static str
Service type (e.g., “query”, “command”, “notification”)
Sourcefn module_name(&self) -> &'static str
fn module_name(&self) -> &'static str
Module that owns this service (e.g., “sapiens”, “postman”)
Sourcefn health_check<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<ServiceHealth, String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn health_check<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<ServiceHealth, String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Health check for the service
Provided Methods§
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".