Grove/Services/mod.rs
1//! Services Module
2//!
3//! Provides various services for Grove operation.
4//! Includes configuration service, logging service, and more.
5
6pub mod ConfigurationService;
7
8// Re-exports for convenience - use module prefix to avoid E0255 conflicts
9// Note: ConfigurationService must be accessed via
10// ConfigurationService::ConfigurationServiceImpl
11
12/// Service configuration
13#[derive(Debug, Clone)]
14pub struct ServiceConfig {
15 /// Enable service
16 pub enabled:bool,
17
18 /// Service name
19 pub name:String,
20}
21
22/// Service trait
23#[allow(async_fn_in_trait)]
24pub trait Service: Send + Sync {
25 /// Get service name
26 fn name(&self) -> &str;
27
28 /// Start the service
29 async fn start(&self) -> anyhow::Result<()>;
30
31 /// Stop the service
32 async fn stop(&self) -> anyhow::Result<()>;
33
34 /// Check if service is running
35 async fn is_running(&self) -> bool;
36}
37
38#[cfg(test)]
39mod tests {
40
41 use super::*;
42
43 #[test]
44 fn test_service_config() {
45 let config = ServiceConfig { enabled:true, name:"test-service".to_string() };
46
47 assert_eq!(config.name, "test-service");
48
49 assert!(config.enabled);
50 }
51}