-
Notifications
You must be signed in to change notification settings - Fork 48
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
[#550] custom event ids #552
[#550] custom event ids #552
Conversation
/// Defines the event id value that is emitted after a new notifier was created. | ||
auto notifier_created_event() && -> iox::optional<size_t>; | ||
/// Sets the event id value that is emitted after a new notifier was created. | ||
void set_notifier_created_event(iox::optional<size_t> value) &&; |
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 this intentional to deviate from the Rust API or just an overlook?
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 is intentional. In the builder it is no longer an optional but for the global config and the config file it is an optional. Some = emit event, None = no event.
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.
Wouldn't it make sense to have the same API with disable
?
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.
No. In Rust the config is a struct where all members are public and can be set by the user directly. It is also serializable and stored in the iceoryx2.toml
file. This config entry is still an Option<EventId>
and it does not make sense to split it up into two fields since then we confuse the user and may have entries that are in contradiction to each other.
We require here a C++ API since we cannot access the struct members directly in C++. But the API shall reflect the underlying structure of the Rust structs/members. Therefore this method has still an optional.
/// If the [`Service`] is created it defines the event that shall be emitted by every newly | ||
/// created [`Notifier`]. | ||
IOX_BUILDER_OPTIONAL(EventId, notifier_created_event); | ||
|
||
/// If the [`Service`] is created it disables sending an event when a new notifier was created. | ||
IOX_BUILDER_SWITCH(disable_notifier_created_event); | ||
|
||
/// If the [`Service`] is created it defines the event that shall be emitted by every | ||
/// [`Notifier`] before it is dropped. If [`None`] is | ||
/// provided a [`Notifier`] will not emit an event. | ||
IOX_BUILDER_OPTIONAL(EventId, notifier_dropped_event); | ||
|
||
/// If the [`Service`] is created it disables sending an event when a notifier was dropped. | ||
IOX_BUILDER_SWITCH(disable_notifier_dropped_event); | ||
|
||
/// If the [`Service`] is created it defines the event that shall be emitted when a | ||
/// [`Notifier`] is identified as dead. If [`None`] is | ||
/// provided no event will be emitted. | ||
IOX_BUILDER_OPTIONAL(EventId, notifier_dead_event); | ||
|
||
/// If the [`Service`] is created it disables sending an event when a notifier was identified | ||
/// as dead. | ||
IOX_BUILDER_SWITCH(disable_notifier_dead_event); |
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.
/// If the [`Service`] is created it defines the event that shall be emitted by every newly | |
/// created [`Notifier`]. | |
IOX_BUILDER_OPTIONAL(EventId, notifier_created_event); | |
/// If the [`Service`] is created it disables sending an event when a new notifier was created. | |
IOX_BUILDER_SWITCH(disable_notifier_created_event); | |
/// If the [`Service`] is created it defines the event that shall be emitted by every | |
/// [`Notifier`] before it is dropped. If [`None`] is | |
/// provided a [`Notifier`] will not emit an event. | |
IOX_BUILDER_OPTIONAL(EventId, notifier_dropped_event); | |
/// If the [`Service`] is created it disables sending an event when a notifier was dropped. | |
IOX_BUILDER_SWITCH(disable_notifier_dropped_event); | |
/// If the [`Service`] is created it defines the event that shall be emitted when a | |
/// [`Notifier`] is identified as dead. If [`None`] is | |
/// provided no event will be emitted. | |
IOX_BUILDER_OPTIONAL(EventId, notifier_dead_event); | |
/// If the [`Service`] is created it disables sending an event when a notifier was identified | |
/// as dead. | |
IOX_BUILDER_SWITCH(disable_notifier_dead_event); | |
/// If the [`Service`] is created it defines the event that shall be emitted by every newly | |
/// created [`Notifier`]. | |
IOX_BUILDER_OPTIONAL(EventId, notifier_created_event); | |
/// If the [`Service`] is created it defines the event that shall be emitted by every | |
/// [`Notifier`] before it is dropped. If [`None`] is | |
/// provided a [`Notifier`] will not emit an event. | |
IOX_BUILDER_OPTIONAL(EventId, notifier_dropped_event); | |
/// If the [`Service`] is created it defines the event that shall be emitted when a | |
/// [`Notifier`] is identified as dead. If [`None`] is | |
/// provided no event will be emitted. | |
IOX_BUILDER_OPTIONAL(EventId, notifier_dead_event); | |
/// If the [`Service`] is created it disables sending an event when a new notifier was created. | |
void disable_notifier_created_event() { | |
m_notifier_created_event.reset(); | |
} | |
/// If the [`Service`] is created it disables sending an event when a notifier was dropped. | |
void disable_notifier_dropped_event() { | |
m_notifier_dropped_event.reset(); | |
} | |
/// If the [`Service`] is created it disables sending an event when a notifier was identified | |
/// as dead. | |
void disable_notifier_dead_event() { | |
m_notifier_dead_event.reset(); | |
} |
No need to make it unnecessary complicated. This will also simplify the logic in service_builder_event.cpp
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.
Actually, this does not work. When this is not called, the user has not set the requirement and takes whatever QoS the service is offering. As soon as you call disable or enable with a specific event, you set this as a requirement that is ensured when opening the service.
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.
Okay, then I do not understand what you want to achieve 😅
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 need to know if the user has called explicitly disable_notifier_dead_event
. If so, I need to check if the service has disabled them, since it is a user requirement.
When the user did not explicitly call it, I use whatever the service has configured.
By default m_notifier_dead_event
is set to iox::nullopt
since the user did not set any dead event.
With your suggestion I have no way to distinguish the use cases, if the user explicitly disabled the event or just never set it. And I need to know it to conclude if this is a requirement or not.
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.
Hmm, if it's three options, a new enum might indeed make sense
enum Event {
Default, // can be on or off; maybe Preconfigured
Custom{id},
Disabled,
}
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 can go that way, but then we need this for every builder option in every factory for all ports and services since it is always handled like this.
I think your suggestion is not bad at all, but would require a greater refactoring. My suggestion for now:
- Pursue the current approach and merge the PR
- Create an issue to track this and tackle this in v0.5 or later
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.
But you still need to adjust the builder, else there is a bug in service_builder_event.cpp
.
One can call disable_notifier_created_event
followed by notifier_created_event
and the logic for disable_notifier_created_event
will be executed
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.
@elBoberido I created the issue: #556
…y for dead node notification
00d0ee8
to
c7a1779
Compare
0c2c0b1
to
93734b4
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #552 +/- ##
==========================================
- Coverage 79.11% 79.10% -0.01%
==========================================
Files 203 203
Lines 25146 25293 +147
==========================================
+ Hits 19893 20008 +115
- Misses 5253 5285 +32
|
Notes for Reviewer
Pre-Review Checklist for the PR Author
Convert to draft
)SPDX-License-Identifier: Apache-2.0 OR MIT
iox2-123-introduce-posix-ipc-example
)[#123] Add posix ipc example
)task-list-completed
)Checklist for the PR Reviewer
Post-review Checklist for the PR Author
References
Closes #550