- add: consul tags and metadata

- update: login reply now requests for the character services from consul to build the server list
This commit is contained in:
2024-12-10 15:45:35 -05:00
parent a7af7f1b9e
commit 9121b7f88b
6 changed files with 93 additions and 16 deletions

View File

@@ -1,3 +1,4 @@
use std::collections::HashMap;
use auth_service::auth::auth_service_server::AuthServiceServer;
use auth_service::database_client::DatabaseClient;
use auth_service::database_client::DatabaseClientTrait;
@@ -38,12 +39,16 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Register service with Consul
let service_id = consul_registration::generate_service_id();
let tags = vec!["version-1.0".to_string()];
let mut meta = HashMap::new();
consul_registration::register_service(
&consul_url,
service_id.as_str(),
service_name.as_str(),
service_address,
service_port.parse().unwrap_or(50052),
tags,
meta,
&health_check_url,
)
.await?;
@@ -55,7 +60,7 @@ 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_address = db_nodes.get(0).unwrap();
let db_url = format!("http://{}:{}", db_address.0, db_address.1);
let db_url = format!("http://{}:{}", db_address.ServiceAddress, db_address.ServicePort);
let database_client = DatabaseClient::connect(&db_url).await?;
let full_addr = format!("{}:{}", &addr, port);