Zenoh - Load session configuration #733
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
🎉 New feature
Closes #698
Summary
This patch adds the ability to load a Zenoh configuration file. The Zenoh router is also supported.
Right now, you can set the configuration file with two methods:
Using the
ZENOH_CONFIG
environment variable. This is the option with the highest priority and we leverage zenoh::Config::from_env(), which looks for this environment variable. That's why we don't need to create a custom environment variable for it.Using the default configuration file under
$HOME/.gz/transport/gz_zenoh_session.json5
. The patch provides a default configuration file (it's actually this one from ROS RMW Zenoh) that it's installed. Whengz-transport
runs, the default config files are installed if they don't exist.If (1) isn't set and (2) failed, the default Zenoh configuration is used without any external file.
Note: The tests are expected to fail. See the Discussion section.
Test it
Follow these instructions to install the Zenoh router.
Discussion
Testing strategy. Right now, the default configuration files are based on ROS RMW Zenoh, which requires the Zenoh router to be running and multicast is disabled. Then, for testing, we should run the Zenoh router (not done in this patch) and distribute it. Alternatively, we could provide a separate configuration file with multicast enabled and not needing the Zenoh router. Another variant could be that our default configuration file has multicast enabled and doesn't require the router.
Order in which we look for the configuration file. Right now, the default configuration file is the last resort. We first check for an environment variable, and then, for the existence of the user configuration file. If we don't find the user config file, we install it. Unless something goes wrong, it's not possible to use a default configuration, we'll almost always load a config file. We could consider other alternatives:
2.1 Default config first unless we explicitly set ZENOH_CONFIG.
2.2 Default config unless we explicitly set ZENOH_CONFIG or a config file is present at the default location. We could decide not to install the user config ourselves.
Installable user config file. This patch installs a new user config file if it's not present in the default location (
~/.gz/transport
). My main concern is how to disitribute new versions of this file once the users already have an existing config file in their systems.I'm looking for some feedback on (1), (2) and (3).
I'm slightly leaning towards leaving this patch as it is but with the configuration file set with multicast enabled and not requiring the router. This way, the default experience is the same as right now, tests should work without extra work and users have an installed config file to play with and with the possibility of using the router if needed.
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
andGenerated-by
messages.