Skip to content

Commit d680ff1

Browse files
sagikazarmarktillrohrmann
authored andcommitted
Add service name to service options
Signed-off-by: Mark Sagi-Kazar <mark.sagikazar@gmail.com>
1 parent c7397b5 commit d680ff1

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

src/discovery.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ impl OutputPayload {
5252
impl Service {
5353
pub(crate) fn apply_options(&mut self, options: ServiceOptions) {
5454
// Apply service options
55+
if let Some(name) = options.name {
56+
self.name = ServiceName::try_from(name).expect("Service name valid");
57+
}
5558
self.metadata.extend(options.metadata);
5659
self.inactivity_timeout = options.inactivity_timeout.map(|d| d.as_millis() as u64);
5760
self.abort_timeout = options.abort_timeout.map(|d| d.as_millis() as u64);

src/endpoint/builder.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ use std::time::Duration;
99
/// Various configuration options that can be provided when binding a service
1010
#[derive(Default, Debug, Clone)]
1111
pub struct ServiceOptions {
12+
/// When set, overrides the service name (defaults to trait name or `#[name]` attribute)
13+
pub(crate) name: Option<String>,
1214
pub(crate) metadata: HashMap<String, String>,
1315
pub(crate) inactivity_timeout: Option<Duration>,
1416
pub(crate) abort_timeout: Option<Duration>,

0 commit comments

Comments
 (0)