-
Notifications
You must be signed in to change notification settings - Fork 42
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
Verify a zenoh router is available for the session #61
Conversation
Signed-off-by: Franco Cipollone <[email protected]>
89d5d00
to
f08031d
Compare
z_info_routers_zid(session, z_move(router_callback)); | ||
|
||
rmw_ret_t ret; | ||
if (*(static_cast<int *>(context)) == 0) { |
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'm trying to understand how the z_info_routers_zid()
API works.
/**
* Fetches the Zenoh IDs of all connected routers.
*
* `callback` will be called once for each ID, is guaranteed to never be called concurrently,
* and is guaranteed to be dropped before this function exits.
*
* Retuns 0 on success, negative values on failure.
*/
ZENOHC_API
int8_t z_info_routers_zid(struct z_session_t session,
struct z_owned_closure_zid_t *callback);
If it returns an int8_t
, is it a blocking function or will the function execute callbacks asynchronously? If its the former, we could just check if the return value is 0 and if so return RMW_RET_OK
? Unless we plan to parse the zids we receive in the callbacks to check if the zid matches that of the zenoh router we run (and not any other zenoh router)?
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.
is it a blocking function or will the function execute callbacks asynchronously?
It is a blocking function.
we could just check if the return value is 0 and if so return RMW_RET_OK?
It "returns 0 in success" but that doesn't convey whether there are or not available routers. It would return 0 even if the zenoh router is missing. This only states whether the execution was correct. (Just realized that we should return error in case there is a failure, adding that...)
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.
Unless we plan to parse the zids we receive in the callbacks to check if the zid matches that of the zenoh router we run (and not any other zenoh router)?
For the moment we need the callback to check that at least a router is connected to the session. I added the parsing of the id mainly for logging purposes. We could at some point verify the id to correctly assert that we are connected to the zenoh router we want. However it is a bit early for this I think, for the moment we don't have environments with more than one zenoh router.
Signed-off-by: Franco Cipollone <[email protected]>
Signed-off-by: Franco Cipollone <[email protected]>
* Verify zenoh router presence at rmw_init. * Fail when an error in z_info_routers_zid is found. Signed-off-by: Franco Cipollone <[email protected]>
Summary
Verify that there is a connection between the Zenoh session being initialized at rmw_init method and a Zenoh router.
In case there is no connected router then return with error.