- chore: ran cargo fix on the codebase

This commit is contained in:
2025-03-07 21:03:15 -05:00
parent 3b789d0fd4
commit b6f2d3f456
59 changed files with 1324 additions and 523 deletions

View File

@@ -1,5 +1,5 @@
use std::collections::HashMap;
use serde::Deserialize;
use std::collections::HashMap;
#[derive(Debug, Deserialize)]
pub struct ServiceNode {
@@ -9,23 +9,24 @@ pub struct ServiceNode {
pub ServiceMeta: HashMap<String, String>,
}
pub async fn get_service_address(consul_url: &str, service_name: &str) -> Result<Vec<ServiceNode>, Box<dyn std::error::Error>> {
pub async fn get_service_address(
consul_url: &str,
service_name: &str,
) -> Result<Vec<ServiceNode>, Box<dyn std::error::Error>> {
let client = reqwest::Client::new();
let consul_service_url = format!("{}/v1/catalog/service/{}", consul_url, service_name);
let response = client
.get(&consul_service_url)
.send()
.await?;
let response = client.get(&consul_service_url).send().await?;
if !response.status().is_success() {
return Err(format!(
"Failed to fetch service nodes for '{}': {}",
service_name, response.status()
service_name,
response.status()
)
.into());
.into());
}
// Deserialize the response into a Vec<ServiceNode>
let nodes: Vec<ServiceNode> = response.json().await?;
@@ -48,9 +49,10 @@ async fn get_services_with_tag(
if !response.status().is_success() {
return Err(format!(
"Failed to fetch service nodes for '{}': {}",
service_name, response.status()
service_name,
response.status()
)
.into());
.into());
}
// Deserialize the response into a Vec<ServiceNode>