-
Notifications
You must be signed in to change notification settings - Fork 175
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
[core] Make STopicId available in subscriber callbacks #1719
Conversation
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.
clang-tidy made some suggestions
13f952b
to
e2d035a
Compare
PID is currently not transferred correctly in UDP und TCP layer. Otherwise things look good. Might consider some renaming for the future, but all to be discussed. |
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.
clang-tidy made some suggestions
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.
clang-tidy made some suggestions
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.
clang-tidy made some suggestions
|
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.
clang-tidy made some suggestions
} | ||
} | ||
} | ||
|
||
size_t CSHMReaderLayer::OnNewShmFileContent(const std::string& topic_name_, const std::string& topic_id_, const char* buf_, size_t len_, long long id_, long long clock_, long long time_, size_t hash_) | ||
size_t CSHMReaderLayer::OnNewShmFileContent(const Payload::TopicInfo& topic_id_, const char* buf_, size_t len_, long long id_, long long clock_, long long time_, size_t hash_) |
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.
warning: method 'OnNewShmFileContent' can be made static [readability-convert-member-functions-to-static]
ecal/core/src/readwrite/shm/ecal_reader_shm.h:51:
- size_t OnNewShmFileContent(const Payload::TopicInfo& topic_id_, const char* buf_, size_t len_, long long id_, long long clock_, long long time_, size_t hash_);
+ static size_t OnNewShmFileContent(const Payload::TopicInfo& topic_id_, const char* buf_, size_t len_, long long id_, long long clock_, long long time_, size_t hash_);
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.
clang-tidy made some suggestions
} | ||
} | ||
} | ||
|
||
size_t CSHMReaderLayer::OnNewShmFileContent(const std::string& topic_name_, const std::string& topic_id_, const char* buf_, size_t len_, long long id_, long long clock_, long long time_, size_t hash_) | ||
size_t CSHMReaderLayer::OnNewShmFileContent(const Payload::TopicInfo& topic_info_, const char* buf_, size_t len_, long long id_, long long clock_, long long time_, size_t hash_) |
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.
warning: method 'OnNewShmFileContent' can be made static [readability-convert-member-functions-to-static]
ecal/core/src/readwrite/shm/ecal_reader_shm.h:51:
- size_t OnNewShmFileContent(const Payload::TopicInfo& topic_info_, const char* buf_, size_t len_, long long id_, long long clock_, long long time_, size_t hash_);
+ static size_t OnNewShmFileContent(const Payload::TopicInfo& topic_info_, const char* buf_, size_t len_, long long id_, long long clock_, long long time_, size_t hash_);
|
||
#include <atomic> | ||
#include <thread> | ||
#include <gtest/gtest.h> |
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.
warning: 'gtest/gtest.h' file not found [clang-diagnostic-error]
#include <gtest/gtest.h>
^
eCAL::Initialize(config, "callback_topic_id"); | ||
} | ||
|
||
void TearDown() override |
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.
warning: method 'TearDown' can be made static [readability-convert-member-functions-to-static]
void TearDown() override | |
static void TearDown() override |
} | ||
}; | ||
|
||
TEST_P(TestFixture, OnePubSub) |
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.
warning: all parameters should be named in a function [readability-named-parameter]
TEST_P(TestFixture, OnePubSub) | |
TEST_P(TestFixture /*unused*/, OnePubSub /*unused*/) |
EXPECT_EQ(callback_topic_id, pub_id); | ||
} | ||
|
||
TEST_P(TestFixture, MultiplePubSub) |
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.
warning: all parameters should be named in a function [readability-named-parameter]
TEST_P(TestFixture, MultiplePubSub) | |
TEST_P(TestFixture /*unused*/, MultiplePubSub /*unused*/) |
{ | ||
const int num_publishers = 4; | ||
|
||
std::vector<eCAL::CPublisher> publishers; |
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.
warning: variable 'publishers' is not initialized [cppcoreguidelines-init-variables]
std::vector<eCAL::CPublisher> publishers; | |
std::vector<eCAL::CPublisher> publishers = 0; |
|
||
#ifndef NDEBUG | ||
// log it | ||
Logging::Log(log_level_debug2, std::string("CMemFileObserver started (" + topic_name_ + ", " + topic_id_ + ")")); | ||
Logging::Log(log_level_debug2, std::string("CMemFileObserver started.")); | ||
#endif |
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.
Should we maybe log the memfile name (currently it's not, but we could make it a member variable)
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.
Thanks for making the adaptions.
I'm a bit undecided. The changes that you made will work, but it will introduce an incompatibility, if different eCAL versions now communicate. The callbackID will be "wrong" for anyone receiving messages send by an older eCAL version.
And what is even worse, if you will then want to look up the corresponding descriptors to this ID from the descgate, you will get missmatches, or no info.
I wonder if we can make adjustments based on what we know from registration only.
E.g. on registration layer we already receive the info... tid (our unique identifier) - relates to pid X, topic_name Y, host_name Z. ...
Thus the ecal_reader layers can keep track of the information, and based on the incoming tid fill the rest of the information. Then you do not have to send it over the layers together with the actual data.
proto_header_topic.tname = m_topic_name; | ||
proto_header_topic.tid = m_topic_id; | ||
proto_header_topic.pid = static_cast<int32_t>(Process::GetProcessID()); | ||
|
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.
Doesn't this "break compatibility" with older ecal versions? we're now filling the sample differently?
{ | ||
return std::make_tuple(false, false, true); | ||
} | ||
|
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.
hmhm I am not convinced. Let's pass Configs instead of tuples to the tests. We want to test based on different configs, not based on different tuples.
You can still create functions that return different Config objects.
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.
Maybe this shows, that we might want to create some helper functions, like "DisableAllLayers", "EnableSHM", "EnableUDP", ... which take reference to a Config object.
- Add new Callback Type which includes STopicId (ecal_callback.h) - Remove topic_name and topic_id from memfile_pool - Subgate applies Payload::TopicInfo - Provide new GetId function for publishers and subscribers (should add also for client / servers in different PR) - Add testcases to check correct IDs are received in callbacks. - Do not modify info being sent over the wire (for compatibility reasons). Instead modify == and < operators for STopicId.
2caf792
to
ab4f097
Compare
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.
Great
TODO: take care of PID for TCP and UDP layer.
Description
We don't yet have the information in callbacks about who sent a message, we only receive the topic name. This PR fixes this in a way that callbacks receive an
STopicID
containing both topic name and additional information (unique sender id).