Skip to content
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

new publisher config API first draft #1561

Open
wants to merge 20 commits into
base: master
Choose a base branch
from

Conversation

rex-schilasky
Copy link
Contributor

Description

Draft implementation of a publisher configuration API in preparation of the new global eCAL configuration API.

@rex-schilasky rex-schilasky added the cherry-pick-to-NONE Don't cherry-pick these changes label Apr 23, 2024
Copy link
Contributor

@github-actions github-actions bot left a 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

ecal/core/include/ecal/msg/capnproto/publisher.h Outdated Show resolved Hide resolved
ecal/core/include/ecal/msg/publisher.h Outdated Show resolved Hide resolved
ecal/core/include/ecal/msg/publisher.h Outdated Show resolved Hide resolved
Copy link
Contributor

@github-actions github-actions bot left a 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

ecal/tests/cpp/pubsub_test/src/pubsub_multibuffer.cpp Outdated Show resolved Hide resolved
ecal/tests/cpp/pubsub_test/src/pubsub_test.cpp Outdated Show resolved Hide resolved
ecal/tests/cpp/pubsub_test/src/pubsub_test.cpp Outdated Show resolved Hide resolved
ecal/tests/cpp/pubsub_test/src/pubsub_test.cpp Outdated Show resolved Hide resolved
ecal/tests/cpp/pubsub_test/src/pubsub_test.cpp Outdated Show resolved Hide resolved
ecal/tests/cpp/pubsub_test/src/pubsub_test.cpp Outdated Show resolved Hide resolved
Copy link
Contributor

@github-actions github-actions bot left a 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

ecal/tests/cpp/pubsub_test/src/pubsub_test.cpp Outdated Show resolved Hide resolved
Copy link
Contributor

@github-actions github-actions bot left a 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 were too many comments to post at once. Showing the first 20 out of 26. Check the log or trigger a new build to see more.

ecal/tests/cpp/pubsub_test/src/pubsub_test_udp.cpp Outdated Show resolved Hide resolved
ecal/tests/cpp/pubsub_test/src/pubsub_test_udp.cpp Outdated Show resolved Hide resolved
ecal/tests/cpp/pubsub_test/src/pubsub_test_udp.cpp Outdated Show resolved Hide resolved
Copy link
Contributor

@github-actions github-actions bot left a 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

m_connected(false),
m_id(0),
m_clock(0),
m_frequency_calculator(3.0f),
m_frequency_calculator(0.0f),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this change on purpose?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


// tcp config
tcp.send_mode = eCAL::Config::GetPublisherTcpMode();
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This introduces a tight coupling between the publisher config, and eCAL::Config.
I'd prefer the constructor to have hardcoded values, but then an eCAL::Config::GetPublisherConfig which returns then config object, filled with the default values from eCAL::Config.

size_t m_buffering_shm;
bool m_zero_copy;
long long m_acknowledge_timeout_ms;
CPublisher::Config m_config;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am a bit unsure about this here. Suddenly, ecal_writer needs to know about CPublisher (you had to add an include), and then your low level implementations depends on the high level implementation.
If Publisher knows Writer, and Writer knows publisher, this leads to circular includes, which is a bad thing.

So there are two alternative options:

  1. he Configuration needs to be extracted from the publisher, into it's own header file.
  2. Actually the cleanest would be a WriterConfiguration. and then a function where the PublisherConfiguration is mapped to the WriterConfiguration, even if in our case they are exactly the same.

memory_file_attr.reserve = m_config.memfile_reserve_percent;
memory_file_attr.timeout_open_ms = PUB_MEMFILE_OPEN_TO;
memory_file_attr.timeout_ack_ms = m_config.acknowledge_timeout_ms;

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe extract this into its own function?

{
SetBufferCount(attr_.buffering);

// store new buffer count and flag change
m_buffer_count = attr_.buffering;
m_config.memfile_buffer_count = attr_.buffering;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it feels a bit wrong if you change the config internally? the config is set from outside, maybe here you need a variable "actual_buffer_count" or something?

Copy link
Contributor

@github-actions github-actions bot left a 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

ecal/core/include/ecal/ecal_publisher_config.h Outdated Show resolved Hide resolved
ecal/core/include/ecal/ecal_publisher_config.h Outdated Show resolved Hide resolved
ecal/core/include/ecal/ecal_publisher_config.h Outdated Show resolved Hide resolved
ecal/core/include/ecal/msg/flatbuffers/publisher.h Outdated Show resolved Hide resolved
ecal/core/include/ecal/msg/flatbuffers/publisher.h Outdated Show resolved Hide resolved
ecal/core/include/ecal/msg/publisher.h Outdated Show resolved Hide resolved
ecal/core/include/ecal/msg/publisher.h Outdated Show resolved Hide resolved
Copy link
Contributor

@github-actions github-actions bot left a 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

ecal/core/include/ecal/msg/capnproto/publisher.h Outdated Show resolved Hide resolved
ecal/tests/cpp/pubsub_test/src/pubsub_test.cpp Outdated Show resolved Hide resolved
ecal/tests/cpp/pubsub_test/src/pubsub_test.cpp Outdated Show resolved Hide resolved
ecal/tests/cpp/pubsub_test/src/pubsub_test.cpp Outdated Show resolved Hide resolved
ecal/tests/cpp/pubsub_test/src/pubsub_test.cpp Outdated Show resolved Hide resolved
SHMConfig -> Publisher::SHM::Configuration
UDPConfig -> Publisher::UDP::Configuration
TCPConfig -> Publisher::TCP::Configuration
Copy link
Contributor

@github-actions github-actions bot left a 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

**/
CPublisher(const std::string& topic_name_)
: eCAL::CPublisher(topic_name_, GetDataTypeInformation())
CPublisher(const std::string& topic_name_, const eCAL::Publisher::Configuration& config_ = {})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: constructor does not initialize these fields: builder [cppcoreguidelines-pro-type-member-init]

      CPublisher(const std::string& topic_name_, const eCAL::Publisher::Configuration& config_ = {})
      ^

**/
CMsgPublisher(const std::string& topic_name_, const struct SDataTypeInformation& topic_info_) : CPublisher(topic_name_, topic_info_)
CMsgPublisher(const std::string& topic_name_, const struct SDataTypeInformation& data_type_info_, const Publisher::Configuration& config_ = {}) : CPublisher(topic_name_, data_type_info_, config_)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: constructor does not initialize these fields: m_buffer [cppcoreguidelines-pro-type-member-init]

    CMsgPublisher(const std::string& topic_name_, const struct SDataTypeInformation& data_type_info_, const Publisher::Configuration& config_ = {}) : CPublisher(topic_name_, data_type_info_, config_)
    ^

**/
explicit CMsgPublisher(const std::string& topic_name_) : CMsgPublisher(topic_name_, GetDataTypeInformation())
explicit CMsgPublisher(const std::string& topic_name_, const Publisher::Configuration& config_ = {}) : CMsgPublisher(topic_name_, GetDataTypeInformation(), config_)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: constructor does not initialize these fields: m_buffer [cppcoreguidelines-pro-type-member-init]

    explicit CMsgPublisher(const std::string& topic_name_, const Publisher::Configuration& config_ = {}) : CMsgPublisher(topic_name_, GetDataTypeInformation(), config_)
    ^

@rex-schilasky rex-schilasky marked this pull request as ready for review May 6, 2024 12:34
Copy link
Contributor

@github-actions github-actions bot left a 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

@@ -1190,29 +863,23 @@ namespace eCAL
return is_internal_only;
}

void CDataWriter::LogSendMode(TLayer::eSendMode smode_, const std::string& base_msg_)
void CDataWriter::LogLayerState(bool state_, const std::string& base_msg_)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: method 'LogLayerState' can be made static [readability-convert-member-functions-to-static]

ecal/core/src/readwrite/ecal_writer.h:125:

-     void LogLayerState(bool state_, const std::string& base_msg_);
+     static void LogLayerState(bool state_, const std::string& base_msg_);

Copy link
Contributor

@github-actions github-actions bot left a 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

@@ -1190,33 +845,27 @@ namespace eCAL
return is_internal_only;
}

void CDataWriter::LogSendMode(TLayer::eSendMode smode_, const std::string& base_msg_)
void CDataWriter::LogLayerState(bool state_, const std::string& base_msg_)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: method 'LogLayerState' can be made static [readability-convert-member-functions-to-static]

ecal/core/src/readwrite/ecal_writer.h:133:

-     void LogLayerState(bool state_, const std::string& base_msg_);
+     static void LogLayerState(bool state_, const std::string& base_msg_);

@@ -53,83 +52,67 @@
#include <string>
#include <atomic>
#include <map>
#include <tuple>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: duplicate include [readability-duplicate-include]

ecal/core/src/readwrite/ecal_writer.h:53:

- #include <map>
- #include <tuple>
+ #include <map>

reader Create/Destroy replaced by Constructor/Destructor
Copy link
Contributor

@github-actions github-actions bot left a 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


// allow to share topic type
m_use_ttype = Config::IsTopicTypeSharingEnabled();
m_share_ttype = Config::IsTopicTypeSharingEnabled();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: 'm_share_ttype' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer]

ecal/core/src/readwrite/ecal_reader.cpp:73:

-                  m_created(false)
+                  m_share_ttype(Config::IsTopicTypeSharingEnabled()), m_created(false)
Suggested change
m_share_ttype = Config::IsTopicTypeSharingEnabled();


// allow to share topic description
m_use_tdesc = Config::IsTopicDescriptionSharingEnabled();
m_share_tdesc = Config::IsTopicDescriptionSharingEnabled();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: 'm_share_tdesc' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer]

ecal/core/src/readwrite/ecal_reader.cpp:73:

-                  m_created(false)
+                  m_share_tdesc(Config::IsTopicDescriptionSharingEnabled()), m_created(false)
Suggested change
m_share_tdesc = Config::IsTopicDescriptionSharingEnabled();

@@ -1190,33 +847,27 @@ namespace eCAL
return is_internal_only;
}

void CDataWriter::LogSendMode(TLayer::eSendMode smode_, const std::string& base_msg_)
void CDataWriter::LogLayerState(bool state_, const std::string& base_msg_)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: method 'LogLayerState' can be made static [readability-convert-member-functions-to-static]

ecal/core/src/readwrite/ecal_writer.h:131:

-     void LogLayerState(bool state_, const std::string& base_msg_);
+     static void LogLayerState(bool state_, const std::string& base_msg_);

…scriber, client, server)

Create/Destroy -> Start/Stop
Copy link
Contributor

@github-actions github-actions bot left a 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

}

void CSubGate::Create()
void CSubGate::Start()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: method 'Start' can be made static [readability-convert-member-functions-to-static]

ecal/core/src/pubsub/ecal_subgate.h:42:

-     void Start();
+     static void Start();

}

void CClientGate::Create()
void CClientGate::Start()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: method 'Start' can be made static [readability-convert-member-functions-to-static]

ecal/core/src/service/ecal_clientgate.h:47:

-     void Start();
+     static void Start();

bool Create(const std::string& service_name_, const ServiceMethodInformationMapT& method_information_map_);

bool Destroy();
bool Start(const std::string& service_name_, const ServiceMethodInformationMapT& method_information_map_);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: function 'eCAL::CServiceClientImpl::Start' has a definition with different parameter names [readability-inconsistent-declaration-parameter-name]

    bool Start(const std::string& service_name_, const ServiceMethodInformationMapT& method_information_map_);
         ^
Additional context

ecal/core/src/service/ecal_service_client_impl.cpp:68: the definition seen here

  bool CServiceClientImpl::Start(const std::string& service_name_, const ServiceMethodInformationMapT& methods_information_map_)
                           ^

ecal/core/src/service/ecal_service_client_impl.h:51: differing parameters are named here: ('method_information_map_'), in definition: ('methods_information_map_')

    bool Start(const std::string& service_name_, const ServiceMethodInformationMapT& method_information_map_);
         ^

}

void CServiceGate::Create()
void CServiceGate::Start()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: method 'Start' can be made static [readability-convert-member-functions-to-static]

ecal/core/src/service/ecal_servicegate.h:41:

-     void Start();
+     static void Start();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cherry-pick-to-NONE Don't cherry-pick these changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants