- add: service version to metadata when registering with consul
This commit is contained in:
@@ -6,6 +6,8 @@ use std::net::ToSocketAddrs;
|
|||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
use warp::Filter;
|
use warp::Filter;
|
||||||
|
|
||||||
|
const VERSION: &'static str = env!("CARGO_PKG_VERSION");
|
||||||
|
|
||||||
#[derive(Serialize)]
|
#[derive(Serialize)]
|
||||||
struct ConsulRegistration {
|
struct ConsulRegistration {
|
||||||
id: String,
|
id: String,
|
||||||
@@ -35,9 +37,11 @@ pub async fn register_service(
|
|||||||
service_address: &str,
|
service_address: &str,
|
||||||
service_port: u16,
|
service_port: u16,
|
||||||
tags: Vec<String>,
|
tags: Vec<String>,
|
||||||
meta: HashMap<String, String>,
|
mut meta: HashMap<String, String>,
|
||||||
health_check_url: &str,
|
health_check_url: &str,
|
||||||
) -> Result<(), Box<dyn std::error::Error>> {
|
) -> Result<(), Box<dyn std::error::Error>> {
|
||||||
|
|
||||||
|
meta.insert("version".to_string(), VERSION.to_string());
|
||||||
let registration = ConsulRegistration {
|
let registration = ConsulRegistration {
|
||||||
id: service_id.to_string(),
|
id: service_id.to_string(),
|
||||||
name: service_name.to_string(),
|
name: service_name.to_string(),
|
||||||
|
|||||||
Reference in New Issue
Block a user