- update: service discovery now supports retrieving multiple service nodes
This commit is contained in:
@@ -81,7 +81,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 auth_address = get_service_address(&consul_url, "auth-service").await?;
|
||||
let auth_node = get_service_address(&consul_url, "auth-service").await?;
|
||||
|
||||
// Register service with Consul
|
||||
let service_id = consul_registration::generate_service_id();
|
||||
@@ -101,14 +101,13 @@ 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 auth_url = format!("http://{}:{}", auth_address.Address, auth_address.Port);
|
||||
let auth_address = auth_node.get(0).unwrap();
|
||||
let auth_url = format!("http://{}:{}", auth_address.0, auth_address.1);
|
||||
let auth_client = Arc::new(Mutex::new(AuthClient::connect(&auth_url).await?));
|
||||
|
||||
let full_addr = format!("{}:{}", &addr, port);
|
||||
// let address = full_addr.parse().expect("Invalid address");
|
||||
|
||||
|
||||
|
||||
tokio::spawn(async move {
|
||||
let semaphore = Arc::new(Semaphore::new(MAX_CONCURRENT_CONNECTIONS));
|
||||
let listener = TcpListener::bind(full_addr.clone()).await.unwrap();
|
||||
|
||||
Reference in New Issue
Block a user