Skip to main content

RocketServiceHandler

Trait RocketServiceHandler 

Source
pub trait RocketServiceHandler {
    type AppErr;

    // Required methods
    fn init<'life0, 'life1, 'async_trait>(
        &'life0 mut self,
        ictx: &'life1 mut InitCtx,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<Rocket<Build>>, Self::AppErr>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn run<'life0, 'life1, 'async_trait>(
        &'life0 mut self,
        rockets: Vec<Rocket<Ignite>>,
        re: &'life1 RunEnv,
    ) -> Pin<Box<dyn Future<Output = Result<(), Self::AppErr>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn shutdown<'life0, 'life1, 'async_trait>(
        &'life0 mut self,
        tctx: &'life1 mut TermCtx,
    ) -> Pin<Box<dyn Future<Output = Result<(), Self::AppErr>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
}
Available on crate features rt and rocket only.
Expand description

Rocket server application handler.

While Rocket is built on top of tokio, it [Rocket] wants to initialize tokio itself.

There are two major ways to write Rocket services using qsu; either the application can let qsu be aware of the server applications’ Rocket instances. It does this by creating the Rocket instances in RocketServiceHandler::init() and returns them. qsu will ignite these rockets and pass them to RocketServiceHandler::run(). The application is responsible for launching the rockets at this point.

The other way to do it is to completely manage the Rocket instances in application code (by not returning rocket instances from init()).

Allowing qsu to manage the Rocket instances will cause qsu to request graceful shutdown of all Rocket instances once a SvcEvt::Shutdown is sent by the runtime.

It is recommended that ctrlc shutdown and termination signals are disabled in each Rocket instance’s configuration, and allow the qsu runtime to be responsible for initiating the Rocket shutdown.

Required Associated Types§

Required Methods§

Source

fn init<'life0, 'life1, 'async_trait>( &'life0 mut self, ictx: &'life1 mut InitCtx, ) -> Pin<Box<dyn Future<Output = Result<Vec<Rocket<Build>>, Self::AppErr>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Rocket service initialization.

The returned Rockets will be ignited and their shutdown handlers will be triggered on shutdown.

Source

fn run<'life0, 'life1, 'async_trait>( &'life0 mut self, rockets: Vec<Rocket<Ignite>>, re: &'life1 RunEnv, ) -> Pin<Box<dyn Future<Output = Result<(), Self::AppErr>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Server application main entry point.

If the init() trait method returned Rocket<Build> instances to the qsu runtime it will ignote these and pass them to run(). It is the responsibility of this method to launch the rockets and await them.

Source

fn shutdown<'life0, 'life1, 'async_trait>( &'life0 mut self, tctx: &'life1 mut TermCtx, ) -> Pin<Box<dyn Future<Output = Result<(), Self::AppErr>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Implementors§