WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Conversation

@rexf
Copy link
Contributor

@rexf rexf commented Nov 5, 2024

fix bug: adding back prefix in service group creation

Currently, the prefix will be missing if we are creating group from group.
e.g.

let sg = service.group("level1");
sg.endpoint("endpoint1") ==> we can expect to see "level1.endpoint1"

let g2 = sg.group("level2:);
g2.endpoint("endpoint2") ==> now we will see "level2.endpoint2"

this patch is to fix and apply the prefix for the g2 endpoint such that the topic will become
level1.level2.endpoint2

Copy link
Member

@Jarema Jarema left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great catch!

Thanks!

Could you add a test for this case?

) -> Group {
Group {
prefix: prefix.to_string(),
prefix: format!("{}.{}", self.prefix.to_string(), prefix.to_string()),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not need to_string() call.

Suggested change
prefix: format!("{}.{}", self.prefix.to_string(), prefix.to_string()),
prefix: format!("{}.{}", self.prefix, prefix.to_string()),

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

@rexf
Copy link
Contributor Author

rexf commented Nov 12, 2024

Great catch!

Thanks!

Could you add a test for this case?

test case added.

@rexf rexf requested a review from Jarema November 12, 2024 15:48
@Jarema
Copy link
Member

Jarema commented Nov 13, 2024

Hm, I' not a fan of adding a test that starts a server in a unit test and we do not use this pattern across the client, but I can refactor it later myself based on your test, as you already did a lot.

Please fix fmt and it's good to merge.

Copy link
Member

@Jarema Jarema left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please fix fmt.

@rexf
Copy link
Contributor Author

rexf commented Nov 13, 2024

Thansk Jarema, cargo fmt applied.

@rexf rexf requested a review from Jarema November 13, 2024 08:30
Copy link
Member

@Jarema Jarema left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Thanks for your contribution!

@Jarema Jarema merged commit 79bf679 into nats-io:main Nov 13, 2024
12 checks passed
@rexf rexf deleted the bugfix/adding_back_prefix_in_servicegroup branch February 16, 2025 22:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants