apalis_core/poller/
mod.rsuse futures::{future::BoxFuture, Future, FutureExt};
use std::fmt::{self, Debug};
use tower::layer::util::Identity;
pub mod controller;
pub mod stream;
pub struct Poller<S, L = Identity> {
pub stream: S,
pub heartbeat: BoxFuture<'static, ()>,
pub layer: L,
pub(crate) _priv: (),
}
impl<S> Poller<S, Identity> {
pub fn new(stream: S, heartbeat: impl Future<Output = ()> + Send + 'static) -> Self {
Self::new_with_layer(stream, heartbeat, Identity::new())
}
pub fn new_with_layer<L>(
stream: S,
heartbeat: impl Future<Output = ()> + Send + 'static,
layer: L,
) -> Poller<S, L> {
Poller {
stream,
heartbeat: heartbeat.boxed(),
layer,
_priv: (),
}
}
}
impl<S, L> Debug for Poller<S, L>
where
S: Debug,
L: Debug,
{
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("Poller")
.field("stream", &self.stream)
.field("heartbeat", &"...")
.field("layer", &self.layer)
.finish()
}
}
const STOPPED: usize = 2;
const PLUGGED: usize = 1;
const UNPLUGGED: usize = 0;