- add: uuid to generate service id for consul

- update: each service now generates a service id for registering with consul
This commit is contained in:
2024-12-10 13:31:35 -05:00
parent f847ec0896
commit 13d4b45859
5 changed files with 22 additions and 5 deletions

View File

@@ -37,8 +37,10 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
let health_check_endpoint_addr = format!("{}:{}", service_address, health_port);
// Register service with Consul
let service_id = consul_registration::generate_service_id();
consul_registration::register_service(
&consul_url,
service_id.as_str(),
service_name.as_str(),
service_address,
service_port.parse().unwrap_or(50052),
@@ -78,7 +80,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
_ = signal::ctrl_c() => {},
}
consul_registration::deregister_service(&consul_url, service_name.as_str()).await.expect("");
consul_registration::deregister_service(&consul_url, service_id.as_str()).await.expect("");
info!("service {} deregistered", service_name);
Ok(())
}