pub trait Service: Sync + Send {
// Required method
fn name(&self) -> &str;
// Provided methods
fn start_service<'life0, 'async_trait>(
&'life0 mut self,
_fds: Option<ListenFds>,
_shutdown: ShutdownWatch,
_listeners_per_fd: usize,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait { ... }
fn threads(&self) -> Option<usize> { ... }
fn on_startup_delay(&self, time_waited: Duration) { ... }
}Expand description
The service interface
Required Methods§
Provided Methods§
Sourcefn start_service<'life0, 'async_trait>(
&'life0 mut self,
_fds: Option<ListenFds>,
_shutdown: ShutdownWatch,
_listeners_per_fd: usize,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn start_service<'life0, 'async_trait>(
&'life0 mut self,
_fds: Option<ListenFds>,
_shutdown: ShutdownWatch,
_listeners_per_fd: usize,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Start the service without readiness notification.
This is a simpler version of Self::start_service() for services that don’t need
to control when they signal readiness. The default implementation does nothing.
Most services should override this method instead of Self::start_service().
§Arguments
fds(Unix only): a collection of listening file descriptors.shutdown: the shutdown signal this server would receive.listeners_per_fd: number of listener tasks to spawn per file descriptor.
Sourcefn threads(&self) -> Option<usize>
fn threads(&self) -> Option<usize>
The preferred number of threads to run this service
If None, the global setting will be used
Sourcefn on_startup_delay(&self, time_waited: Duration)
fn on_startup_delay(&self, time_waited: Duration)
This is currently called to inform the service about the delay it experienced from between waiting on its dependencies. Default behavior is to log the time.
TODO. It would be nice if this function was called intermittently by the server while the service was waiting to give live updates while the service was waiting and allow the service to decide whether to keep waiting, continue anyway, or exit