Skip to main content

ServiceJob

Trait ServiceJob 

Source
pub trait ServiceJob: Send + Sync {
    // Required methods
    fn name(&self) -> &str;
    fn job_type(&self) -> JobType;
    fn period(&self) -> Option<Duration>;
    fn schedule(&self) -> Option<TimeOfDay>;
    fn run<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<ServiceResult<Value>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;

    // Provided methods
    fn is_critical(&self) -> bool { ... }
    fn stop_gracefully<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait { ... }
}
Expand description

A unit of background work managed by JobRegistry.

period supplies the repeat interval for Periodic jobs (defaulting to 60 seconds when the job type needs it but None is returned), and schedule supplies the daily time for Exact jobs.

Required Methods§

Source

fn name(&self) -> &str

Stable name of the job, used in logs.

Source

fn job_type(&self) -> JobType

Scheduling behavior of the job.

Source

fn period(&self) -> Option<Duration>

Repeat interval for periodic legs; None means no interval configured.

Source

fn schedule(&self) -> Option<TimeOfDay>

Daily time for exact legs; None means no daily time configured.

Source

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

Executes one run of the job.

Provided Methods§

Source

fn is_critical(&self) -> bool

Whether the job is critical. Defaults to false.

Source

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

Releases job resources on shutdown. Defaults to doing nothing.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§