- chore: ran cargo fix on the codebase
This commit is contained in:
@@ -2,8 +2,7 @@ use dotenv::dotenv;
|
||||
use std::collections::HashMap;
|
||||
use std::env;
|
||||
use std::str::FromStr;
|
||||
use tokio::{select, signal};
|
||||
use tracing::{info, Level};
|
||||
use tracing::Level;
|
||||
use utils::consul_registration;
|
||||
use utils::service_discovery::get_service_address;
|
||||
|
||||
@@ -11,7 +10,10 @@ use utils::service_discovery::get_service_address;
|
||||
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
dotenv().ok();
|
||||
tracing_subscriber::fmt()
|
||||
.with_max_level(Level::from_str(&env::var("LOG_LEVEL").unwrap_or_else(|_| "info".to_string())).unwrap_or_else(|_| Level::INFO))
|
||||
.with_max_level(
|
||||
Level::from_str(&env::var("LOG_LEVEL").unwrap_or_else(|_| "info".to_string()))
|
||||
.unwrap_or_else(|_| Level::INFO),
|
||||
)
|
||||
.init();
|
||||
|
||||
// Set the gRPC server address
|
||||
@@ -21,7 +23,8 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
|
||||
let consul_url = env::var("CONSUL_URL").unwrap_or_else(|_| "http://127.0.0.1:8500".to_string());
|
||||
let service_name = env::var("SERVICE_NAME").unwrap_or_else(|_| "world-service".to_string());
|
||||
let service_address = env::var("WORLD_SERVICE_ADDR").unwrap_or_else(|_| "127.0.0.1".to_string());
|
||||
let service_address =
|
||||
env::var("WORLD_SERVICE_ADDR").unwrap_or_else(|_| "127.0.0.1".to_string());
|
||||
let service_port = port.clone();
|
||||
let health_check_url = format!("http://{}:{}/health", service_address, health_port);
|
||||
let health_check_endpoint_addr = format!("{}:{}", service_address, health_port);
|
||||
@@ -43,15 +46,20 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
meta,
|
||||
&health_check_url,
|
||||
)
|
||||
.await?;
|
||||
.await?;
|
||||
|
||||
// Start health-check endpoint
|
||||
consul_registration::start_health_check(addr.as_str()).await?;
|
||||
|
||||
let db_address = db_nodes.get(0).unwrap();
|
||||
let db_url = format!("http://{}:{}", db_address.ServiceAddress, db_address.ServicePort);
|
||||
let db_url = format!(
|
||||
"http://{}:{}",
|
||||
db_address.ServiceAddress, db_address.ServicePort
|
||||
);
|
||||
|
||||
utils::signal_handler::wait_for_signal().await;
|
||||
consul_registration::deregister_service(&consul_url, service_id.as_str()).await.expect("");
|
||||
consul_registration::deregister_service(&consul_url, service_id.as_str())
|
||||
.await
|
||||
.expect("");
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user