workflow_egui/runtime/service.rs
1use crate::imports::*;
2
3/// Result type returned by [`Service`] lifecycle methods.
4pub type ServiceResult = Result<()>;
5
6/// Service is a core component of the Kaspa NG application responsible for
7/// running application services and communication between these services.
8#[async_trait]
9pub trait Service: Sync + Send {
10 /// Returns the human-readable name identifying this service.
11 fn name(&self) -> &'static str;
12
13 /// Start the service
14 async fn spawn(self: Arc<Self>, runtime: Runtime) -> ServiceResult;
15
16 /// Signal the service termination (post a shutdown request)
17 fn terminate(self: Arc<Self>);
18
19 /// Block until the service is terminated
20 async fn join(self: Arc<Self>) -> ServiceResult;
21}