From 45846411cbff51d4379632d9b263b2700d71abaa Mon Sep 17 00:00:00 2001 From: Mark Sagi-Kazar Date: Sat, 13 Dec 2025 03:28:43 +0100 Subject: [PATCH] Add service name to service options Signed-off-by: Mark Sagi-Kazar --- src/discovery.rs | 3 +++ src/endpoint/builder.rs | 2 ++ 2 files changed, 5 insertions(+) diff --git a/src/discovery.rs b/src/discovery.rs index d10e911..e569e69 100644 --- a/src/discovery.rs +++ b/src/discovery.rs @@ -52,6 +52,9 @@ impl OutputPayload { impl Service { pub(crate) fn apply_options(&mut self, options: ServiceOptions) { // Apply service options + if let Some(name) = options.name { + self.name = ServiceName::try_from(name).expect("Service name valid"); + } self.metadata.extend(options.metadata); self.inactivity_timeout = options.inactivity_timeout.map(|d| d.as_millis() as u64); self.abort_timeout = options.abort_timeout.map(|d| d.as_millis() as u64); diff --git a/src/endpoint/builder.rs b/src/endpoint/builder.rs index 2a91306..4983628 100644 --- a/src/endpoint/builder.rs +++ b/src/endpoint/builder.rs @@ -9,6 +9,8 @@ use std::time::Duration; /// Various configuration options that can be provided when binding a service #[derive(Default, Debug, Clone)] pub struct ServiceOptions { + /// When set, overrides the service name (defaults to trait name or `#[name]` attribute) + pub(crate) name: Option, pub(crate) metadata: HashMap, pub(crate) inactivity_timeout: Option, pub(crate) abort_timeout: Option,