aboutsummaryrefslogtreecommitdiff
path: root/src/consul.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/consul.rs')
-rw-r--r--src/consul.rs11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/consul.rs b/src/consul.rs
index 240c177..eb7aafd 100644
--- a/src/consul.rs
+++ b/src/consul.rs
@@ -9,13 +9,18 @@ use serde::{Deserialize, Serialize};
// ---- Watch and retrieve Consul catalog ----
//
#[derive(Serialize, Deserialize, Debug)]
-pub struct ConsulNodeListNode {
+pub struct ConsulNode {
#[serde(rename = "Node")]
pub node: String,
+ #[serde(rename = "Address")]
+ pub address: String,
}
#[derive(Serialize, Deserialize, Debug)]
pub struct ConsulServiceEntry {
+ #[serde(rename = "Service")]
+ pub service: String,
+
#[serde(rename = "Address")]
pub address: String,
@@ -28,6 +33,8 @@ pub struct ConsulServiceEntry {
#[derive(Serialize, Deserialize, Debug)]
pub struct ConsulNodeCatalog {
+ #[serde(rename = "Node")]
+ pub node: ConsulNode,
#[serde(rename = "Services")]
pub services: HashMap<String, ConsulServiceEntry>,
}
@@ -84,7 +91,7 @@ impl Consul {
let url = format!("{}/v1/catalog/nodes", self.url);
let http = self.client.get(&url).send().await?;
- let resp: Vec<ConsulNodeListNode> = http.json().await?;
+ let resp: Vec<ConsulNode> = http.json().await?;
Ok(resp.into_iter().map(|n| n.node).collect::<Vec<_>>())
}