- 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:
@@ -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(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user