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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
//! apalis is a simple, extensible multithreaded background job processing library for rust.
//! ## Core Features
//! - Simple and predictable functional job handling model with a macro free API.
//! - Takes full advantage of the [`tower`] ecosystem of
//! middleware, services, and utilities.
//! - Anything that implements [`Stream`] can be used as a job source.
//! - Runtime agnostic with inbuilt support for tokio and async-std.
//! - Provides high concurrency, and allows for configuration of workers, jobs and thread pool.
//!
//! An apalis job is powered by a tower [`Service`] which means you have access to the [`tower`] middleware.
//! ### Example
//! ```rust, no_run
//! use apalis::prelude::*;
//! use serde::{Deserialize, Serialize};
//! use apalis_redis::{RedisStorage, Config};
//!
//! #[derive(Debug, Deserialize, Serialize)]
//! struct Email {
//! to: String,
//! }
//!
//! async fn send_email(job: Email, data: Data<usize>) -> Result<(), Error> {
//! Ok(())
//! }
//!
//! #[tokio::main]
//! async fn main() {
//! let redis = std::env::var("REDIS_URL").expect("Missing REDIS_URL env variable");
//! let conn = apalis_redis::connect(redis).await.unwrap();
//! let storage = RedisStorage::new(conn);
//! Monitor::new()
//! .register({
//! WorkerBuilder::new(&format!("quick-sand"))
//! .concurrency(2)
//! .data(0usize)
//! .backend(storage.clone())
//! .build_fn(send_email)
//! })
//! .run()
//! .await
//! .unwrap();
//! }
//!```
//!
//! ## Web UI Available
//! 
//! See [this example](https://github.com/geofmureithi/apalis/tree/main/examples/rest-api)
//! ## Feature flags
//!
//! [`Service`]: https://docs.rs/tower/latest/tower/trait.Service.html
//! [`tower`]: https://crates.io/crates/tower
//! [`tower-http`]: https://crates.io/crates/tower-http
//! [`Layer`]: https://docs.rs/tower/latest/tower/trait.Layer.html
//! [`Stream`]: https://docs.rs/futures/latest/futures/stream/trait.Stream.html
/// apalis fully supports middleware via [`Layer`](https://docs.rs/tower/latest/tower/trait.Layer.html)
/// Common imports