diff options
author | Quentin <quentin@dufour.io> | 2021-09-17 10:06:51 +0200 |
---|---|---|
committer | Quentin <quentin@dufour.io> | 2021-09-17 10:06:51 +0200 |
commit | 2bbc9109991f8bb79a09a965a1d2779e1749b25b (patch) | |
tree | 57dcb5b115b854d651ac6f952466d4109bac2d45 /src/consul.rs | |
parent | fa25c54e47decf9f323ba0c614f4d9de106626d5 (diff) | |
parent | bf226d077ef2bea0567a7b36b4d25ce2d0b5191c (diff) | |
download | diplonat-2bbc9109991f8bb79a09a965a1d2779e1749b25b.tar.gz diplonat-2bbc9109991f8bb79a09a965a1d2779e1749b25b.zip |
Merge pull request 'added rustfmt, a guide about this, and a CI job to enforce code quality' (#10) from adrien/diplonat:meta/formating into main
Reviewed-on: https://git.deuxfleurs.fr/Deuxfleurs/diplonat/pulls/10
Diffstat (limited to 'src/consul.rs')
-rw-r--r-- | src/consul.rs | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/src/consul.rs b/src/consul.rs index 1bb30aa..1123996 100644 --- a/src/consul.rs +++ b/src/consul.rs @@ -1,21 +1,21 @@ -use serde::{Serialize, Deserialize}; +use anyhow::{anyhow, Result}; +use serde::{Deserialize, Serialize}; use std::collections::HashMap; -use anyhow::{Result, anyhow}; #[derive(Serialize, Deserialize, Debug)] pub struct ServiceEntry { - pub Tags: Vec<String> + pub Tags: Vec<String>, } #[derive(Serialize, Deserialize, Debug)] pub struct CatalogNode { - pub Services: HashMap<String, ServiceEntry> + pub Services: HashMap<String, ServiceEntry>, } pub struct Consul { client: reqwest::Client, url: String, - idx: Option<u64> + idx: Option<u64>, } impl Consul { @@ -23,7 +23,7 @@ impl Consul { return Self { client: reqwest::Client::new(), url: url.to_string(), - idx: None + idx: None, }; } @@ -34,16 +34,16 @@ impl Consul { pub async fn watch_node(&mut self, host: &str) -> Result<CatalogNode> { let url = match self.idx { Some(i) => format!("{}/v1/catalog/node/{}?index={}", self.url, host, i), - None => format!("{}/v1/catalog/node/{}", self.url, host) + None => format!("{}/v1/catalog/node/{}", self.url, host), }; let http = self.client.get(&url).send().await?; self.idx = match http.headers().get("X-Consul-Index") { Some(v) => Some(v.to_str()?.parse::<u64>()?), - None => return Err(anyhow!("X-Consul-Index header not found")) + None => return Err(anyhow!("X-Consul-Index header not found")), }; let resp: CatalogNode = http.json().await?; - return Ok(resp) + return Ok(resp); } } |