pub async fn background_worker(&self, shutdown: tokio_util::sync::CancellationToken) {
        info!("started background worker");

        let mut interval = tokio::time::interval(tokio::time::Duration::from_secs(1));

        // TODO: Move out of Server background loop
        let job_registry = self.application.job_registry();

        while !shutdown.is_cancelled() {
            self.maybe_initialize_server().await;
            job_registry.reclaim();

            tokio::select! {
                _ = interval.tick() => {},
                _ = shutdown.cancelled() => break
            }
        }

        info!("shutting down background workers");
        if let Ok(config) = self.config() {
            config.drain().await;
        }

        info!("draining tracker registry");

        // Wait for any outstanding jobs to finish - frontend shutdown should be
        // sequenced before shutting down the background workers and so there
        // shouldn't be any
        while job_registry.reclaim() != 0 {
            interval.tick().await;
        }

        info!("drained tracker registry");
    }
/// Background worker function for the server
Background worker function for the server
Background worker function for the server
pub async fn background_worker(&self, shutdown: tokio_util::sync::CancellationToken) {
        info!("started background worker");
        let mut interval = tokio::time::interval(tokio::time::Duration::from_secs(1));
        // TODO: Move out of Server background loop
        let job_registry = self.application.job_registry();
        while !shutdown.is_cancelled() {
            self.maybe_initialize_server().await;
            job_registry.reclaim();
            tokio::select! {
                _ = interval.tick() => {},
                _ = shutdown.cancelled() => break
            }
        }
        info!("shutting down background workers");
        if let Ok(config) = self.config() {
            config.drain().await;
        }
        info!("draining tracker registry");
        // Wait for any outstanding jobs to finish - frontend shutdown should be
        // sequenced before shutting down the background workers and so there
        // shouldn't be any
        while job_registry.reclaim() != 0 {
            interval.tick().await;
        }
        info!("drained tracker registry");
    }
pub async fn background_worker ( & self , shutdown : tokio_util :: sync :: CancellationToken ) { info ! ( " " ) ; let mut interval = tokio :: time :: interval ( tokio :: time :: Duration :: from_secs ( 1 ) ) ; // TODO: Move out of Server background loop let job_registry = self . application . job_registry ( ) ; while ! shutdown . is_cancelled ( ) { self . maybe_initialize_server ( ) . await ; job_registry . reclaim ( ) ; tokio :: select ! { interval tick ( ) { } shutdown cancelled ( ) break } } info ! ( " " ) ; if let Ok ( config ) = self . config ( ) { config . drain ( ) . await ; } info ! ( " " ) ; // Wait for any outstanding jobs to finish - frontend shutdown should be // sequenced before shutting down the background workers and so there // shouldn't be any while job_registry . reclaim ( ) != 0 { interval . tick ( ) . await ; } info ! ( " " ) ; }
Background worker function for the server
Background worker function for the server
&self
shutdown
tokio_util::sync::CancellationToken
&self
shutdown
tokio_util::sync::CancellationToken