time_sigil/
lib.rs

1pub use errors::Error;
2pub use queue::{Queue, Server};
3pub use tasks::{fn_task, IntoTaskRunner, Task, TaskRunner};
4pub use tokio_util::sync::CancellationToken;
5
6mod errors;
7pub mod http;
8mod queue;
9pub mod schedule;
10pub mod service;
11mod tasks;
12
13#[cfg(test)]
14mod tests {
15    use crate::{fn_task, service::new_inmemory, CancellationToken};
16
17    #[tokio::test]
18    async fn test() {
19        let (runner, handler) = new_inmemory(fn_task(|x: i32| x + 1));
20        let cancel = CancellationToken::new();
21        tokio::spawn(runner.listen(4, cancel.clone()));
22
23        handler.push(0).await.unwrap();
24
25        while let Ok(Some(x)) = handler.pull().await {
26            assert_eq!(x, 1);
27            cancel.cancel();
28        }
29    }
30}