pub trait ServiceWithDependents: Send + Sync {
// Required methods
fn start_service<'life0, 'async_trait>(
&'life0 mut self,
fds: Option<ListenFds>,
shutdown: ShutdownWatch,
listeners_per_fd: usize,
ready_notifier: ServiceReadyNotifier,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn name(&self) -> &str;
// Provided methods
fn threads(&self) -> Option<usize> { ... }
fn on_startup_delay(&self, time_waited: Duration) { ... }
}Required Methods§
Sourcefn start_service<'life0, 'async_trait>(
&'life0 mut self,
fds: Option<ListenFds>,
shutdown: ShutdownWatch,
listeners_per_fd: usize,
ready_notifier: ServiceReadyNotifier,
) -> 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,
ready_notifier: ServiceReadyNotifier,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
This function will be called when the server is ready to start the service.
Override this method if you need to control exactly when the service signals readiness (e.g., after async initialization is complete).
§Arguments
fds(Unix only): a collection of listening file descriptors. During zero downtime restart thefdswould contain the listening sockets passed from the old service, services should take the sockets they need to use then. If the sockets the service looks for don’t appear in the collection, the service should create its own listening sockets and then put them into the collection in order for them to be passed to the next server.shutdown: the shutdown signal this server would receive.listeners_per_fd: number of listener tasks to spawn per file descriptor.ready_notifier: notifier to signal when the service is ready. Services with dependents should callready_notifier.notify_ready()once they are fully initialized.
Provided Methods§
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