- 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

@@ -36,8 +36,10 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
let db_address = get_service_address(&consul_url, "database-service").await?;
// 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),
@@ -71,7 +73,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(())
}