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
//! Kue
//!
//! Kue is a job queue backed by pg/memory/redis.
//!
//! ```edition2018
//! use kue::{KueAdapter, KueTask, KueError, TaskOptions};
//!
//! type TNResult = i32;
//!
//! #[derive(Debug, PartialEq)]
//! pub struct TNAdapter {
//! pub result: i32,
//! pub current: i32,
//! pub iterations: i32
//! }
//!
//! #[derive(Debug, PartialEq)]
//! pub struct TNTask {
//! pub result: i32,
//! pub current: i32
//! }
//!
//! impl TNAdapter {
//! pub fn new(iterations: i32) -> Self {
//! Self { result: 0, current: 1, iterations }
//! }
//! }
//!
//! impl KueAdapter<TNResult, TNTask> for TNAdapter {
//! fn get_task(&mut self) -> Result<Option<TNTask>, KueError> {
//! if self.iterations == 0 {
//! return Ok(None);
//! }
//!
//! let task = TNTask::new(self.result, self.current);
//! self.iterations -= 1;
//! self.current += 1;
//!
//! Ok(Some(task))
//! }
//!
//! fn register_result(
//! &mut self,
//! _: &TNTask,
//! result: &Result<TNResult, KueError>
//! ) -> Result<(), KueError> {
//! match result {
//! Ok(r) => {
//! self.result = *r;
//! Ok(())
//! },
//! Err(e) => Err(e.clone())
//! }
//! }
//! }
//!
//! impl TNTask {
//! pub fn new(result: i32, current: i32) -> Self {
//! Self { result, current }
//! }
//! }
//!
//! impl KueTask<TNResult> for TNTask {
//! fn execute(&mut self) -> Result<TNResult, KueError> {
//! Ok(self.result + self.current)
//! }
//!
//! fn options(&self) -> TaskOptions {
//! TaskOptions::new(0, 0)
//! }
//! }
//! ```
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;