pingora_core::services

Trait Service

Source
pub trait Service: Sync + Send {
    // Required methods
    fn start_service<'life0, 'async_trait>(
        &'life0 mut self,
        fds: Option<ListenFds>,
        shutdown: ShutdownWatch,
    ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn name(&self) -> &str;

    // Provided method
    fn threads(&self) -> Option<usize> { ... }
}
Expand description

The service interface

Required Methods§

Source

fn start_service<'life0, 'async_trait>( &'life0 mut self, fds: Option<ListenFds>, shutdown: ShutdownWatch, ) -> 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.

  • fds (Unix only): a collection of listening file descriptors. During zero downtime restart the fds would 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.
Source

fn name(&self) -> &str

The name of the service, just for logging and naming the threads assigned to this service

Note that due to the limit of the underlying system, only the first 16 chars will be used

Provided Methods§

Source

fn threads(&self) -> Option<usize>

The preferred number of threads to run this service

If None, the global setting will be used

Implementors§

Source§

impl<A> Service for GenBackgroundService<A>
where A: BackgroundService + Send + Sync + 'static,

Source§

impl<A: ServerApp + Send + Sync + 'static> Service for Service<A>