aboutsummaryrefslogtreecommitdiff
path: root/src/consul.rs
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2022-01-13 11:31:08 +0100
committerAlex Auvolat <alex@adnab.me>2022-01-13 11:36:52 +0100
commitced324bc876eb592c0ed4aea889827c0000cf9ad (patch)
treef9c7fb31a0328ff28ad010ad706c245741a345c4 /src/consul.rs
parentc030c4764570974b09d2387854b30538e81e7b86 (diff)
downloadtricot-ced324bc876eb592c0ed4aea889827c0000cf9ad.tar.gz
tricot-ced324bc876eb592c0ed4aea889827c0000cf9ad.zip
Make nodes aware of where they are and use that to priorize backendsdocker-28
Diffstat (limited to 'src/consul.rs')
-rw-r--r--src/consul.rs6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/consul.rs b/src/consul.rs
index 14df1ee..cba435a 100644
--- a/src/consul.rs
+++ b/src/consul.rs
@@ -23,6 +23,8 @@ pub struct ConsulNode {
pub node: String,
#[serde(rename = "Address")]
pub address: String,
+ #[serde(rename = "Meta")]
+ pub meta: HashMap<String, String>,
}
#[derive(Serialize, Deserialize, Debug)]
@@ -117,14 +119,14 @@ impl Consul {
})
}
- pub async fn list_nodes(&self) -> Result<Vec<String>> {
+ pub async fn list_nodes(&self) -> Result<Vec<ConsulNode>> {
debug!("list_nodes");
let url = format!("{}/v1/catalog/nodes", self.url);
let http = self.client.get(&url).send().await?;
let resp: Vec<ConsulNode> = http.json().await?;
- Ok(resp.into_iter().map(|n| n.node).collect::<Vec<_>>())
+ Ok(resp)
}
pub async fn watch_node(