apalis_core/backend/poll_strategy/strategies/
mod.rs1use std::pin::Pin;
2
3use futures_core::Stream;
4use futures_util::StreamExt;
5
6use crate::backend::poll_strategy::{PollContext, PollStrategy};
7
8mod stream;
9pub use stream::*;
10#[cfg(feature = "sleep")]
11mod interval;
12#[cfg(feature = "sleep")]
13pub use interval::*;
14mod future;
15pub use future::*;
16#[cfg(feature = "sleep")]
17mod backoff;
18#[cfg(feature = "sleep")]
19pub use backoff::*;
20
21#[derive(Debug, Clone)]
24pub struct WrapperStrategy<S>
25where
26 S: PollStrategy + Send + 'static,
27{
28 strategy: S,
29}
30
31impl<S> WrapperStrategy<S>
32where
33 S: PollStrategy + Send + 'static,
34{
35 pub fn new(strategy: S) -> Self {
37 Self { strategy }
38 }
39}
40
41impl<S> PollStrategy for WrapperStrategy<S>
42where
43 S: PollStrategy + Send + 'static,
44{
45 type Stream = Pin<Box<dyn Stream<Item = ()> + Send>>;
46
47 fn poll_strategy(self: Box<Self>, ctx: &PollContext) -> Self::Stream {
48 Box::new(self.strategy)
49 .poll_strategy(ctx)
50 .map(|_| ())
51 .boxed()
52 }
53}