-
Notifications
You must be signed in to change notification settings - Fork 44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow programmatic configuration of unicast relays. #497
Conversation
This change allows users to configure relays from code without having to `setenv(GZ_RELAY)`. Signed-off-by: Michael Beardsworth <[email protected]>
} | ||
|
||
sockaddr_in addr; | ||
memset(&addr, 0, sizeof(addr)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
include <cstring>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file already includes <string.h> - should I swap the include?
Signed-off-by: Michael Beardsworth <[email protected]>
df00e45
to
9b823d8
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## gz-transport13 #497 +/- ##
==================================================
- Coverage 87.69% 87.64% -0.05%
==================================================
Files 59 59
Lines 5704 5716 +12
==================================================
+ Hits 5002 5010 +8
- Misses 702 706 +4 ☔ View full report in Codecov by Sentry. |
Signed-off-by: Michael Beardsworth <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My main problem with this patch is that so far NodeOptions
are all options that affect a single node. However, adding relays will have a global impact in all the nodes.
I understand that we don't have a way to set global options besides using environment variables right now. Perhaps an alternative could be to not use NodeOptions
and just create an AddGlobalRelay()
/ GlobalRelays()
functions in Node
to preserve the semantics of NodeOptions
? What do you think?
@@ -1420,26 +1440,6 @@ namespace gz | |||
return true; | |||
} | |||
|
|||
/// \brief Register a new relay address. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you just moved this function. Out of curiosity, any reason for moving it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I moved it up to sit with the other public functions. ("Group similar declarations together, placing public parts earlier." https://google.github.io/styleguide/cppguide.html#Declaration_Order)
/// relays. | ||
/// \param[in] _relayIPs IPv4 addresses of unicast relays to add. | ||
/// \return True if the relay list is valid or false otherwise. | ||
public: bool SetRelays(const std::vector<std::string>& _relayIPs); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd rename this function to AddRelays()
to be more precise. You're not replacing the current relays, just adding extra ones.
|
||
/// \brief Gets the list of relay addresses specified in this NodeOptions. | ||
/// \return The list of relay addresses. | ||
public: const std::vector<std::string>& Relays() const; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have two options here:
- Do not create a member variable
this->dataPtr->relayIPs
when adding the relays. Then, just add the relays usingAddRelayAddress()
as you're doing it right now. Then, in this function, read the entire list of relays from Discovery. - Keep it as it's documenting that the returned vector of relays is the contribution from this node. Other relays could be happening.
I suspect (1) is going to be less confusing and will make debugging easier.
Agreed that this is weird / gross. I guess ideally I'd want to have accessors for the global Discovery instances, but threading that through seems difficult.
You're thinking something like the following?
|
Probably |
Done in #498 |
This change allows users to configure relays from code without having to
setenv(GZ_RELAY)
.🎉 New feature
Summary
This change allows users to configure relays from code without having to
setenv(GZ_RELAY)
.Test it
This can be tested by starting a Node across a boundary where multicast isn't enabled, and setting the relay IP via NodeOptions.
Checklist
codecheck
passed (See contributing)Note to maintainers: Remember to use Squash-Merge and edit the commit message to match the pull request summary while retaining
Signed-off-by
messages.