- add: service version to metadata when registering with consul

This commit is contained in:
2024-12-14 23:39:39 -05:00
parent 7194eb88fa
commit ff3f6b2148

View File

@@ -6,6 +6,8 @@ use std::net::ToSocketAddrs;
use uuid::Uuid;
use warp::Filter;
const VERSION: &'static str = env!("CARGO_PKG_VERSION");
#[derive(Serialize)]
struct ConsulRegistration {
id: String,
@@ -35,9 +37,11 @@ pub async fn register_service(
service_address: &str,
service_port: u16,
tags: Vec<String>,
meta: HashMap<String, String>,
mut meta: HashMap<String, String>,
health_check_url: &str,
) -> Result<(), Box<dyn std::error::Error>> {
meta.insert("version".to_string(), VERSION.to_string());
let registration = ConsulRegistration {
id: service_id.to_string(),
name: service_name.to_string(),