aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/rpc/consul_services.rs19
-rw-r--r--src/util/config.rs3
2 files changed, 15 insertions, 7 deletions
diff --git a/src/rpc/consul_services.rs b/src/rpc/consul_services.rs
index 928c7691..aaf3c4a1 100644
--- a/src/rpc/consul_services.rs
+++ b/src/rpc/consul_services.rs
@@ -129,17 +129,22 @@ impl ConsulServiceDiscovery {
]
.concat();
+ let mut meta = HashMap::from([
+ (format!("{}-pubkey", META_PREFIX), hex::encode(node_id)),
+ (format!("{}-hostname", META_PREFIX), hostname.to_string()),
+ ]);
+
+ if let Some(global_meta) = &self.config.meta {
+ for (key, value) in global_meta.into_iter() {
+ meta.insert(key.clone(), value.clone());
+ }
+ }
+
let advertisement: ConsulPublishService = ConsulPublishService {
service_id: node.clone(),
service_name: self.config.service_name.clone(),
tags,
- meta: [
- (format!("{}-pubkey", META_PREFIX), hex::encode(node_id)),
- (format!("{}-hostname", META_PREFIX), hostname.to_string()),
- ]
- .iter()
- .cloned()
- .collect(),
+ meta,
address: rpc_public_addr.ip(),
port: rpc_public_addr.port(),
};
diff --git a/src/util/config.rs b/src/util/config.rs
index 4b32f8ba..84a8e34f 100644
--- a/src/util/config.rs
+++ b/src/util/config.rs
@@ -168,6 +168,9 @@ pub struct ConsulServiceConfig {
// Additional tags to add to the service
#[serde(default)]
pub tags: Vec<String>,
+ // Additional service metadata to add
+ #[serde(default)]
+ pub meta: Option<std::collections::HashMap<String, String>>,
/// Skip TLS hostname verification
#[serde(default)]
pub tls_skip_verify: bool,