1pub mod dispatcher;
2pub mod inbound;
3pub mod outbound;
4pub mod delivery;
5
6pub use dispatcher::{JobError, JobResult};
7
8pub fn spawn(
9 ctx: upub::Context,
10 concurrency: usize,
11 poll: u64,
12 filter: Option<upub::model::job::JobType>,
13 stop: impl StopToken,
14 wake: impl WakeToken,
15) -> tokio::task::JoinHandle<()> {
16 use dispatcher::JobDispatcher;
17 tokio::spawn(async move {
18 tracing::info!("starting worker task");
19 ctx.run(concurrency, poll, filter, stop, wake).await
20 })
21}
22
23pub trait StopToken: Sync + Send + 'static {
24 fn stop(&self) -> bool;
25}
26
27pub trait WakeToken: Sync + Send + 'static {
28 fn wait(&mut self) -> impl std::future::Future<Output = ()> + std::marker::Send;
30}