rmq_rs_admin/modules/
queues.rs1use serde::Deserialize;
2use std::{collections::HashMap, error::Error};
3
4use super::client::Client;
5
6#[derive(Deserialize, Debug)]
7pub struct MessageStats {
8 pub publish: u32,
9 pub publish_details: HashMap<String, f32>,
10}
11
12#[derive(Deserialize, Debug)]
13pub struct Queue {
14 pub arguments: HashMap<String, String>,
15 pub auto_delete: bool,
16 pub consumer_capacity: u32,
17 pub consumer_utilisation: f32,
18 pub consumers: u16,
19 pub durable: bool,
20 pub exclusive: bool,
21 pub exclusive_consumer_tag: Option<String>,
22 pub garbage_collection: HashMap<String, u32>,
23 pub head_message_timestamp: Option<String>,
24 pub idle_since: String,
25 pub memory: u32,
26 pub message_bytes: u32,
27 pub message_bytes_paged_out: u32,
28 pub message_bytes_persistent: u32,
29 pub message_bytes_ram: u32,
30 pub message_bytes_ready: u32,
31 pub message_bytes_unacknowledged: u32,
32 pub message_stats: MessageStats,
33 pub messages_paged_out: u32,
34 pub messages_persistent: u32,
35 pub messages_ram: u32,
36 pub messages_ready: u32,
37 pub messages_ready_details: HashMap<String, f32>,
38 pub messages_ready_ram: u32,
39 pub messages_unacknowledged: u32,
40 pub messages_unacknowledged_details: HashMap<String, f32>,
41 pub messages_unacknowledged_ram: u32,
42 pub name: String,
43 pub node: String,
44 pub operator_policy: Option<String>,
45 pub policy: String,
46 pub recoverable_slaves: Option<String>,
47 pub reductions: u32,
48 pub reductions_details: HashMap<String, f32>,
49 pub state: String,
50 pub vhost: String,
51 pub single_active_consumer_tag: Option<String>,
52}
53
54pub struct QueueManager {
55 client: Box<Client>,
56}
57
58impl QueueManager {
59 pub fn new(client: Box<Client>) -> Self {
60 Self { client }
61 }
62
63 pub async fn get(&self) -> Result<Vec<Queue>, Box<dyn Error>> {
64 let uri = "api/queues".to_string();
65 let queues = self
66 .client
67 .get(uri, None)
68 .await?
69 .json::<Vec<Queue>>()
70 .await?;
71 Ok(queues)
72 }
73}