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
use serde::{Deserialize, Serialize};
use crate::worker_registry::JobEnvelopeFactory;
use crate::{JobEnvelope, OxanaError};
/// Options for listing jobs in a queue.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct QueueListOpts {
/// Maximum number of jobs to return.
pub count: usize,
/// Number of jobs to skip from the start.
pub offset: usize,
}
/// Catalog of all registered workers and queues.
#[derive(Debug, Clone)]
pub struct Catalog {
/// Regular (non-cron) workers.
pub workers: Vec<WorkerInfo>,
/// Cron workers with schedule information.
pub cron_workers: Vec<CronWorkerInfo>,
/// Registered queues.
pub queues: Vec<QueueInfo>,
/// Jobs explicitly exposed for manual enqueueing from the web dashboard.
pub on_demand_jobs: Vec<OnDemandJobInfo>,
}
/// Information about an on-demand job exposed in the web dashboard.
#[derive(Debug, Clone)]
pub struct OnDemandJobInfo {
/// The worker name (Rust type path).
pub name: String,
/// Editable JSON template used to prefill the enqueue form.
pub args_template: serde_json::Value,
pub(crate) enqueue_factory: JobEnvelopeFactory,
}
impl OnDemandJobInfo {
/// Builds an enqueueable envelope using the registered job type.
pub fn enqueue_envelope(
&self,
queue: String,
args: serde_json::Value,
) -> Result<JobEnvelope, OxanaError> {
(self.enqueue_factory)(queue, args)
}
}
/// Information about a registered queue.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct QueueInfo {
/// The queue key or prefix.
pub key: String,
/// Whether this is a dynamic queue.
pub dynamic: bool,
/// The concurrency limit for this queue.
pub concurrency: usize,
/// Throttle configuration, if any.
pub throttle: Option<QueueThrottleInfo>,
}
/// Throttle configuration for a queue.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct QueueThrottleInfo {
/// Throttle window in milliseconds.
pub window_ms: i64,
/// Maximum number of jobs allowed within the window.
pub limit: u64,
}
/// Information about a registered worker.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct WorkerInfo {
/// The worker name (Rust type path).
pub name: String,
}
/// Information about a registered cron worker.
#[derive(Debug, Clone)]
pub struct CronWorkerInfo {
/// The worker name (Rust type path).
pub name: String,
/// The cron schedule expression.
pub schedule: cron::Schedule,
/// The queue key this worker runs on.
pub queue_key: String,
/// Whether jobs for this worker should be resurrected if a process dies.
pub resurrect: bool,
}