pub trait Service: Send + Sync {
// Required methods
fn run_forever<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Never> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn heartbeat_ttl(&self) -> i32;
fn set_heartbeat(&mut self, heartbeat: Arc<dyn Heartbeat + 'static>);
fn is_healthy(&self) -> bool;
// Provided method
fn name(&self) -> String { ... }
}
Required Methods§
Sourcefn run_forever<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Never> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn run_forever<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Never> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
The service is never expected to stop, it should do its job until externally shutdown.
Sourcefn heartbeat_ttl(&self) -> i32
fn heartbeat_ttl(&self) -> i32
The maximum amount of seconds allowed between heartbeats before the service is deemed “dead”
Sourcefn set_heartbeat(&mut self, heartbeat: Arc<dyn Heartbeat + 'static>)
fn set_heartbeat(&mut self, heartbeat: Arc<dyn Heartbeat + 'static>)
The service should frequently call “beat” to indicate that it is still alive.
Sourcefn is_healthy(&self) -> bool
fn is_healthy(&self) -> bool
The service should be able to self-diagnose any internal issues and report if there is a problem.