Trait wasm_framework::Runnable[][src]

pub trait Runnable {
#[must_use]    fn run<'life0, 'life1, 'async_trait>(
        &'life0 self,
        ctx: &'life1 RunContext
    ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        'life1: 'async_trait,
        Self: 'async_trait
; }

Runnable trait for deferred tasks Deferred tasks are often useful for logging and analytics.

use std::{rc::Rc,sync::Mutex};;
use async_trait::async_trait;
use service_logging::{log,Logger,LogQueue,Severity};
use wasm_service::{Runnable,RunContext};

struct Data { s: String }
#[async_trait]
impl Runnable for Data {
    async fn run(&self, ctx: &RunContext) {
        log!(ctx, Severity::Info, msg: format!("Deferred with data: {}", self.s ));
    }
}

Required methods

#[must_use]fn run<'life0, 'life1, 'async_trait>(
    &'life0 self,
    ctx: &'life1 RunContext
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>> where
    'life0: 'async_trait,
    'life1: 'async_trait,
    Self: 'async_trait, 
[src]

Execute a deferred task. The task may append logs to lq using the log macro. Logs generated are sent to the log service after all deferred tasks have run.

Note that if there is a failure sending logs to the logging service, those log messages (and the error from the send failure) will be unreported.

Loading content...

Implementors

Loading content...