Skip to main content

Service

Trait Service 

Source
pub(crate) trait Service:
    Any
    + Send
    + Sync {
    // Required methods
    fn build(args: &Args<'_>) -> Result<Arc<impl Service>>
       where Self: Sized;
    fn name(&self) -> &str;

    // Provided methods
    fn worker<'async_trait>(
        self: Arc<Self>,
    ) -> Pin<Box<dyn Future<Output = Result> + Send + 'async_trait>>
       where Self: 'async_trait { ... }
    fn interrupt<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait { ... }
    fn clear_cache<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait { ... }
    fn memory_usage<'life0, 'life1, 'async_trait>(
        &'life0 self,
        _out: &'life1 mut (dyn Write + Send),
    ) -> Pin<Box<dyn Future<Output = Result> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait { ... }
    fn unconstrained(&self) -> bool { ... }
}
Expand description

Abstract interface for a Service

Required Methods§

Source

fn build(args: &Args<'_>) -> Result<Arc<impl Service>>
where Self: Sized,

Implement the construction of the service instance. Services are generally singletons so expect this to only be called once for a service type. Note that it may be called again after a server reload, but the prior instance will have been dropped first. Failure will shutdown the server with an error.

Source

fn name(&self) -> &str

Return the name of the service. i.e. crate::service::make_name(std::module_path!())

Provided Methods§

Source

fn worker<'async_trait>( self: Arc<Self>, ) -> Pin<Box<dyn Future<Output = Result> + Send + 'async_trait>>
where Self: 'async_trait,

Implement the service’s worker loop. The service manager spawns a task and calls this function after all services have been built.

Source

fn interrupt<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Interrupt the service. This is sent to initiate a graceful shutdown. The service worker should return from its work loop.

Source

fn clear_cache<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Clear any caches or similar runtime state.

Source

fn memory_usage<'life0, 'life1, 'async_trait>( &'life0 self, _out: &'life1 mut (dyn Write + Send), ) -> Pin<Box<dyn Future<Output = Result> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Memory usage report in a markdown string.

Source

fn unconstrained(&self) -> bool

Return true if the service worker opts out of the tokio cooperative budgeting. This can reduce tail latency at the risk of event loop starvation.

Implementors§

Source§

impl Service for tuwunel_service::account_data::Service

Source§

impl Service for tuwunel_service::admin::Service

Source§

impl Service for tuwunel_service::appservice::Service

Source§

impl Service for tuwunel_service::client::Service

Source§

impl Service for tuwunel_service::config::Service

Source§

impl Service for tuwunel_service::deactivate::Service

Source§

impl Service for tuwunel_service::emergency::Service

Source§

impl Service for tuwunel_service::federation::Service

Source§

impl Service for tuwunel_service::globals::Service

Source§

impl Service for tuwunel_service::key_backups::Service

Source§

impl Service for tuwunel_service::media::Service

Source§

impl Service for tuwunel_service::membership::Service

Source§

impl Service for tuwunel_service::oauth::Service

Source§

impl Service for tuwunel_service::presence::Service

Source§

impl Service for tuwunel_service::pusher::Service

Source§

impl Service for tuwunel_service::registration_tokens::Service

Source§

impl Service for tuwunel_service::resolver::Service

Source§

impl Service for tuwunel_service::rooms::alias::Service

Source§

impl Service for tuwunel_service::rooms::auth_chain::Service

Source§

impl Service for tuwunel_service::rooms::delete::Service

Source§

impl Service for tuwunel_service::rooms::directory::Service

Source§

impl Service for tuwunel_service::rooms::event_handler::Service

Source§

impl Service for tuwunel_service::rooms::lazy_loading::Service

Source§

impl Service for tuwunel_service::rooms::metadata::Service

Source§

impl Service for tuwunel_service::rooms::pdu_metadata::Service

Source§

impl Service for tuwunel_service::rooms::read_receipt::Service

Source§

impl Service for tuwunel_service::rooms::retention::Service

Source§

impl Service for tuwunel_service::rooms::search::Service

Source§

impl Service for tuwunel_service::rooms::short::Service

Source§

impl Service for tuwunel_service::rooms::spaces::Service

Source§

impl Service for tuwunel_service::rooms::state::Service

Source§

impl Service for tuwunel_service::rooms::state_accessor::Service

Source§

impl Service for tuwunel_service::rooms::state_cache::Service

Source§

impl Service for tuwunel_service::rooms::state_compressor::Service

Source§

impl Service for tuwunel_service::rooms::threads::Service

Source§

impl Service for tuwunel_service::rooms::timeline::Service

Source§

impl Service for tuwunel_service::rooms::typing::Service

Source§

impl Service for tuwunel_service::sending::Service

Source§

impl Service for tuwunel_service::server_keys::Service

Source§

impl Service for tuwunel_service::storage::Service

Source§

impl Service for tuwunel_service::sync::Service

Source§

impl Service for tuwunel_service::transaction_ids::Service

Source§

impl Service for tuwunel_service::uiaa::Service

Source§

impl Service for tuwunel_service::users::Service