//! DelayBy — sleep for a fixed duration before continuing.
use async_trait::async_trait;
use coreon_core::{Exchange, Processor, Result};
use std::{sync::Arc, time::Duration};
pub struct DelayBy {
duration: Duration,
}
impl DelayBy {
pub fn new(duration: Duration) -> Arc<Self> {
Arc::new(Self { duration })
}
}
#[async_trait]
impl Processor for DelayBy {
async fn process(&self, _exchange: &mut Exchange) -> Result<()> {
tokio::time::sleep(self.duration).await;
Ok(())
}
}