- update: service discovery now supports retrieving multiple service nodes
This commit is contained in:
@@ -9,6 +9,7 @@ use std::str::FromStr;
|
||||
use tokio::{select, signal};
|
||||
use tonic::transport::Server;
|
||||
use tracing::{info, Level};
|
||||
use tracing::log::debug;
|
||||
use warp::Filter;
|
||||
use utils::consul_registration;
|
||||
use utils::service_discovery::get_service_address;
|
||||
@@ -33,7 +34,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
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);
|
||||
let db_address = get_service_address(&consul_url, "database-service").await?;
|
||||
let db_nodes = get_service_address(&consul_url, "database-service").await?;
|
||||
|
||||
// Register service with Consul
|
||||
let service_id = consul_registration::generate_service_id();
|
||||
@@ -53,7 +54,8 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
|
||||
tokio::spawn(warp::serve(health_route).run(health_check_endpoint_addr.to_socket_addrs()?.next().unwrap()));
|
||||
|
||||
let db_url = format!("http://{}:{}", db_address.Address, db_address.Port);
|
||||
let db_address = db_nodes.get(0).unwrap();
|
||||
let db_url = format!("http://{}:{}", db_address.0, db_address.1);
|
||||
let database_client = DatabaseClient::connect(&db_url).await?;
|
||||
|
||||
let full_addr = format!("{}:{}", &addr, port);
|
||||
|
||||
Reference in New Issue
Block a user