From 21f4767d164a12dc4f50beddb76c387176a0bf69 Mon Sep 17 00:00:00 2001 From: Michael Klishin Date: Sun, 5 Jan 2025 22:02:34 -0500 Subject: [PATCH] Add queue_totals to Overview --- src/formatting.rs | 25 +++++++++++++++++++++++++ src/responses.rs | 26 +++++++++++++++++++++++++- 2 files changed, 50 insertions(+), 1 deletion(-) diff --git a/src/formatting.rs b/src/formatting.rs index 5d1c7f1..fd9b4fd 100644 --- a/src/formatting.rs +++ b/src/formatting.rs @@ -27,6 +27,31 @@ impl Display for ObjectTotals { } } +impl Display for Rate { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + writeln!(f, "{:.2}", self.rate)?; + Ok(()) + } +} + +impl Display for QueueTotals { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + writeln!(f, "all messages: {}", self.messages)?; + writeln!( + f, + "messages ready for dlievery: {}", + self.messages_ready_for_delivery + )?; + writeln!( + f, + "messages delivered but unacknowledged by consumer: {}", + self.messages_delivered_but_unacknowledged_by_consumers + )?; + + Ok(()) + } +} + impl Display for TagList { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fmt_comma_separated_list(f, &self.0) diff --git a/src/responses.rs b/src/responses.rs index 47deb71..92fc0b4 100644 --- a/src/responses.rs +++ b/src/responses.rs @@ -980,6 +980,13 @@ impl fmt::Display for ChurnRates { } } +#[derive(Debug, Deserialize, Clone, PartialEq, PartialOrd)] +#[serde(transparent)] +#[cfg_attr(feature = "tabled", derive(Tabled))] +pub struct Rate { + pub rate: f64, +} + #[derive(Debug, Deserialize, Clone, Eq, PartialEq)] #[cfg_attr(feature = "tabled", derive(Tabled))] pub struct ObjectTotals { @@ -990,6 +997,22 @@ pub struct ObjectTotals { pub consumers: u64, } +#[derive(Debug, Deserialize, Clone, PartialEq)] +#[cfg_attr(feature = "tabled", derive(Tabled))] +pub struct QueueTotals { + pub messages: u64, + #[serde(rename = "messages_ready")] + pub messages_ready_for_delivery: u64, + #[serde(rename = "messages_unacknowledged")] + pub messages_delivered_but_unacknowledged_by_consumers: u64, + + pub message_details: Rate, + #[serde(rename = "messages_ready_details")] + pub messages_ready_for_delivery_details: Rate, + #[serde(rename = "messages_unacknowledged_details")] + pub messages_delivered_but_unacknowledged_by_consumers_details: Rate, +} + #[derive(Debug, Deserialize, Clone, Eq, PartialEq)] #[cfg_attr(feature = "tabled", derive(Tabled))] pub struct Listener { @@ -1004,7 +1027,7 @@ pub struct Listener { #[serde(transparent)] pub struct TagMap(pub Map); -#[derive(Debug, Deserialize, Clone, Eq, PartialEq)] +#[derive(Debug, Deserialize, Clone, PartialEq)] #[cfg_attr(feature = "tabled", derive(Tabled))] pub struct Overview { pub cluster_name: String, @@ -1024,6 +1047,7 @@ pub struct Overview { pub statistics_db_event_queue: u64, pub churn_rates: ChurnRates, + pub queue_totals: QueueTotals, pub object_totals: ObjectTotals, }