Skip to content

Commit

Permalink
Add queue_totals to Overview
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelklishin committed Jan 6, 2025
1 parent 879e99d commit 21f4767
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 1 deletion.
25 changes: 25 additions & 0 deletions src/formatting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
26 changes: 25 additions & 1 deletion src/responses.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 {
Expand All @@ -1004,7 +1027,7 @@ pub struct Listener {
#[serde(transparent)]
pub struct TagMap(pub Map<String, serde_json::Value>);

#[derive(Debug, Deserialize, Clone, Eq, PartialEq)]
#[derive(Debug, Deserialize, Clone, PartialEq)]
#[cfg_attr(feature = "tabled", derive(Tabled))]
pub struct Overview {
pub cluster_name: String,
Expand All @@ -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,
}

Expand Down

0 comments on commit 21f4767

Please sign in to comment.