1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/// Re-exports of test helpers for verifying custom [`Store`] implementations.
pub use frame;
/// Attribute macro that wraps an `async fn` so it appears in
/// [`async_backtrace`](https://docs.rs/async-backtrace) stack traces.
///
/// Apply `#[framed]` to your processor function to get richer async backtraces
/// when a panic or error occurs inside a job. The worker already catches panics
/// and converts them to failures, but having the full async call stack in the
/// trace makes debugging much easier.
///
/// # Example
///
/// ```rust
/// use std::sync::Arc;
/// use kiomq::{framed, InMemoryStore, Job, KioError, Queue, Store, Worker, WorkerOpts};
///
/// #[framed]
/// async fn my_processor<S: Store<u64, u64, ()>>(
/// _store: Arc<S>,
/// job: Job<u64, u64, ()>,
/// ) -> Result<u64, KioError> {
/// let data = job.data.unwrap_or_default();
/// if data == 0 {
/// // Returning Err marks the job as failed and triggers a retry
/// // (up to `attempts` times, as configured in QueueOpts / JobOptions).
/// return Err(std::io::Error::new(std::io::ErrorKind::Other, "zero input").into());
/// }
/// Ok(data * 2)
/// }
///
/// # #[tokio::main]
/// # async fn main() -> kiomq::KioResult<()> {
/// # let store: InMemoryStore<u64, u64, ()> = InMemoryStore::new(None, "framed-demo");
/// # let queue = Queue::new(store, None).await?;
/// # let worker = Worker::new_async(&queue, |s, j| my_processor(s, j), Some(WorkerOpts::default()))?;
/// # worker.run()?;
/// # worker.close();
/// # Ok(())
/// # }
/// ```
pub use framed;
pub use Config;
pub use *;
pub use EventEmitter;
pub use EventParameters;
pub use *;
pub use *;
pub use *;
pub use ;
pub use ;
pub use ;
/// Convenience alias for `Result<T, KioError>`.
pub type KioResult<T> = ;