Skip to content

Commit 21ed332

Browse files
Make it easier to list plugins enabled across the entire cluster
1 parent b861310 commit 21ed332

File tree

5 files changed

+108
-1
lines changed

5 files changed

+108
-1
lines changed

CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22

33
## v0.62.0 (in development)
44

5-
No changes yet.
5+
### Enhancements
6+
7+
* `Client#list_all_cluster_plugins` is a new function that returns a combined set of plugins enabled across all cluster nodes
8+
* `Client#list_node_plugins` is a new function that returns the list of plugins enabled on a specific node
69

710
## v0.61.0 (Oct 8, 2025)
811

src/api/nodes.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,28 @@ where
4646
let response = response.json().await?;
4747
Ok(response)
4848
}
49+
50+
/// Returns a unique set of plugins enabled on all cluster nodes.
51+
/// See [RabbitMQ Plugins Guide](https://www.rabbitmq.com/docs/plugins) to learn more.
52+
pub async fn list_all_cluster_plugins(&self) -> Result<responses::PluginList> {
53+
let nodes = self.list_nodes().await?;
54+
55+
let mut aggregated_set: Vec<String> = nodes
56+
.into_iter()
57+
.flat_map(|node| node.enabled_plugins.into_iter())
58+
.collect::<std::collections::HashSet<_>>()
59+
.into_iter()
60+
.collect();
61+
62+
aggregated_set.sort();
63+
Ok(responses::PluginList(aggregated_set))
64+
}
65+
66+
/// Returns the list of plugins enabled on a specific cluster node.
67+
/// This is a convenience method equivalent to `get_node_info(name).enabled_plugins`.
68+
/// See [RabbitMQ Plugins Guide](https://www.rabbitmq.com/docs/plugins) to learn more.
69+
pub async fn list_node_plugins(&self, name: &str) -> Result<responses::PluginList> {
70+
let node = self.get_node_info(name).await?;
71+
Ok(node.enabled_plugins)
72+
}
4973
}

src/blocking_api/nodes.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,28 @@ where
4141
let response = response.json()?;
4242
Ok(response)
4343
}
44+
45+
/// Returns a unique set of plugins enabled on all cluster nodes.
46+
/// See [RabbitMQ Plugins Guide](https://www.rabbitmq.com/docs/plugins) to learn more.
47+
pub fn list_all_cluster_plugins(&self) -> Result<responses::PluginList> {
48+
let nodes = self.list_nodes()?;
49+
50+
let mut aggregated_set: Vec<String> = nodes
51+
.into_iter()
52+
.flat_map(|node| node.enabled_plugins.into_iter())
53+
.collect::<std::collections::HashSet<_>>()
54+
.into_iter()
55+
.collect();
56+
57+
aggregated_set.sort();
58+
Ok(responses::PluginList(aggregated_set))
59+
}
60+
61+
/// Returns the list of plugins enabled on a specific cluster node.
62+
/// This is a convenience method equivalent to `get_node_info(name).enabled_plugins`.
63+
/// See [RabbitMQ Plugins Guide](https://www.rabbitmq.com/docs/plugins) to learn more.
64+
pub fn list_node_plugins(&self, name: &str) -> Result<responses::PluginList> {
65+
let node = self.get_node_info(name)?;
66+
Ok(node.enabled_plugins)
67+
}
4468
}

tests/async_node_tests.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,31 @@ async fn test_async_get_node_memory_footprint() {
6464
}
6565
}
6666
}
67+
68+
#[tokio::test]
69+
async fn test_async_list_all_cluster_plugins() {
70+
let endpoint = endpoint();
71+
let rc = Client::new(&endpoint, USERNAME, PASSWORD);
72+
let result = rc.list_all_cluster_plugins().await;
73+
74+
assert!(result.is_ok());
75+
let plugins = result.unwrap();
76+
assert!(!plugins.is_empty());
77+
// The management plugin should be enabled since we're using the HTTP API
78+
assert!(plugins.contains("rabbitmq_management"));
79+
}
80+
81+
#[tokio::test]
82+
async fn test_async_list_node_plugins() {
83+
let endpoint = endpoint();
84+
let rc = Client::new(&endpoint, USERNAME, PASSWORD);
85+
let nodes = rc.list_nodes().await.unwrap();
86+
let name = nodes.first().unwrap().name.clone();
87+
let result = rc.list_node_plugins(&name).await;
88+
89+
assert!(result.is_ok());
90+
let plugins = result.unwrap();
91+
assert!(!plugins.is_empty());
92+
// The management plugin should be enabled since we're using the HTTP API
93+
assert!(plugins.contains("rabbitmq_management"));
94+
}

tests/blocking_node_tests.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,31 @@ fn test_blocking_get_node_memory_footprint() {
6464
}
6565
}
6666
}
67+
68+
#[test]
69+
fn test_blocking_list_all_cluster_plugins() {
70+
let endpoint = endpoint();
71+
let rc = Client::new(&endpoint, USERNAME, PASSWORD);
72+
let result = rc.list_all_cluster_plugins();
73+
74+
assert!(result.is_ok());
75+
let plugins = result.unwrap();
76+
assert!(!plugins.is_empty());
77+
// The management plugin should be enabled since we're using the HTTP API
78+
assert!(plugins.contains("rabbitmq_management"));
79+
}
80+
81+
#[test]
82+
fn test_blocking_list_node_plugins() {
83+
let endpoint = endpoint();
84+
let rc = Client::new(&endpoint, USERNAME, PASSWORD);
85+
let nodes = rc.list_nodes().unwrap();
86+
let name = nodes.first().unwrap().name.clone();
87+
let result = rc.list_node_plugins(&name);
88+
89+
assert!(result.is_ok());
90+
let plugins = result.unwrap();
91+
assert!(!plugins.is_empty());
92+
// The management plugin should be enabled since we're using the HTTP API
93+
assert!(plugins.contains("rabbitmq_management"));
94+
}

0 commit comments

Comments
 (0)