Trait fuel_core::service::ServiceTrait
source · pub trait ServiceTrait {
// Required methods
fn start(&self) -> Result<(), Error>;
fn start_and_await<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<State, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait,
Self: 'async_trait;
fn await_start_or_stop<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<State, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait,
Self: 'async_trait;
fn stop(&self) -> bool;
fn stop_and_await<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<State, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait,
Self: 'async_trait;
fn await_stop<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<State, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait,
Self: 'async_trait;
fn state(&self) -> State;
fn state_watcher(&self) -> StateWatcher;
}
Expand description
Trait for service runners, providing a minimal interface for managing the lifecycle of services such as start/stop and health status.
Required Methods§
sourcefn start(&self) -> Result<(), Error>
fn start(&self) -> Result<(), Error>
Send a start signal to the service without waiting for it to start. Returns an error if the service was already started.
sourcefn start_and_await<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<State, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn start_and_await<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<State, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
Send a start signal to the service and wait for it to start up. Returns an error if the service was already started.
sourcefn await_start_or_stop<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<State, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn await_start_or_stop<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<State, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
Wait for service to start or stop (without sending any signal).
sourcefn stop(&self) -> bool
fn stop(&self) -> bool
Send a stop signal to the service without waiting for it to shutdown. Returns false if the service was already stopped, true if it is running.
sourcefn stop_and_await<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<State, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn stop_and_await<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<State, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
Send stop signal to service and wait for it to shutdown.
sourcefn await_stop<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<State, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn await_stop<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<State, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
Wait for service to stop (without sending a stop signal).
sourcefn state_watcher(&self) -> StateWatcher
fn state_watcher(&self) -> StateWatcher
Returns the state watcher of the service.