1pub use harmos_domain::model::services::policy::{RestartPolicy, ServicePolicy};
15
16use std::future::Future;
20
21use crate::operations::ExecutionContext;
25
26pub trait Service: Send + Sized + 'static {
39 type Error: std::error::Error + Send + Sync + 'static;
40
41 fn initialize(context: ExecutionContext) -> impl Future<Output = Result<Self, Self::Error>> + Send;
42 fn run(&mut self, context: ExecutionContext) -> impl Future<Output = Result<(), Self::Error>> + Send;
43
44 fn stop(&mut self) -> impl Future<Output = Result<(), Self::Error>> + Send {
45 async { Ok(()) }
46 }
47 fn cleanup(&mut self) -> impl Future<Output = Result<(), Self::Error>> + Send {
48 async { Ok(()) }
49 }
50}
51
52