-
Notifications
You must be signed in to change notification settings - Fork 181
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] protobuf service client to v6 #1981
base: master
Are you sure you want to change the base?
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
There were too many comments to post at once. Showing the first 20 out of 21. Check the log or trigger a new build to see more.
serialization/protobuf/protobuf/include/ecal/msg/protobuf/client.h
Outdated
Show resolved
Hide resolved
serialization/protobuf/protobuf/include/ecal/msg/protobuf/client.h
Outdated
Show resolved
Hide resolved
serialization/protobuf/protobuf/include/ecal/msg/protobuf/client.h
Outdated
Show resolved
Hide resolved
serialization/protobuf/protobuf/include/ecal/msg/protobuf/client.h
Outdated
Show resolved
Hide resolved
{ | ||
public: | ||
// Constructors | ||
CClientInstance(eCAL::CClientInstance&& base_instance_) noexcept |
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: rvalue reference parameter 'base_instance_' is never moved from inside the function body [cppcoreguidelines-rvalue-reference-param-not-moved]
CClientInstance(eCAL::CClientInstance&& base_instance_) noexcept
^
serialization/protobuf/protobuf/include/ecal/msg/protobuf/client_instance.h
Show resolved
Hide resolved
serialization/protobuf/protobuf/include/ecal/msg/protobuf/typed_response.h
Outdated
Show resolved
Hide resolved
serialization/protobuf/protobuf/include/ecal/msg/protobuf/typed_response.h
Outdated
Show resolved
Hide resolved
serialization/protobuf/samples/services/math_client/src/math_client.cpp
Outdated
Show resolved
Hide resolved
… means all host in legacy logic)
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
serialization/protobuf/protobuf/include/ecal/msg/protobuf/client_typed_response.h
Outdated
Show resolved
Hide resolved
serialization/protobuf/protobuf/include/ecal/msg/protobuf/client_typed_response.h
Outdated
Show resolved
Hide resolved
serialization/protobuf/samples/services/ping_client/src/ping_client.cpp
Outdated
Show resolved
Hide resolved
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
serialization/protobuf/protobuf/include/ecal/msg/protobuf/client.h
Outdated
Show resolved
Hide resolved
serialization/protobuf/protobuf/include/ecal/msg/protobuf/client.h
Outdated
Show resolved
Hide resolved
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
serialization/protobuf/protobuf/include/ecal/msg/protobuf/client_instance.h
Show resolved
Hide resolved
serialization/protobuf/protobuf/include/ecal/msg/protobuf/client_response_parser.h
Show resolved
Hide resolved
serialization/protobuf/protobuf/include/ecal/msg/protobuf/client_typed_response.h
Outdated
Show resolved
Hide resolved
… separate unit msg/protobuf/client_protobuf_utils.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.
clang-tidy made some suggestions
|
||
#pragma once | ||
|
||
#include <ecal/service/client.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: 'ecal/service/client.h' file not found [clang-diagnostic-error]
#include <ecal/service/client.h>
^
|
||
ServiceMethodInformationSetT method_information_set; | ||
CProtoDynDecoder dyn_decoder; | ||
std::string error_s; |
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 'error_s' is not initialized [cppcoreguidelines-init-variables]
std::string error_s; | |
std::string error_s = 0; |
const std::string& request_type_name = method_descriptor->input_type()->name(); | ||
const std::string& response_type_name = method_descriptor->output_type()->name(); | ||
|
||
std::string request_type_descriptor; |
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 'request_type_descriptor' is not initialized [cppcoreguidelines-init-variables]
std::string request_type_descriptor; | |
std::string request_type_descriptor = 0; |
const std::string& response_type_name = method_descriptor->output_type()->name(); | ||
|
||
std::string request_type_descriptor; | ||
std::string response_type_descriptor; |
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 'response_type_descriptor' is not initialized [cppcoreguidelines-init-variables]
std::string response_type_descriptor; | |
std::string response_type_descriptor = 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.
clang-tidy made some suggestions
|
||
static eCAL::rec::Error CallRemoteEcalrecService(const std::shared_ptr<eCAL::protobuf::CServiceClient<eCAL::pb::rec_server::EcalRecServerService>>& remote_ecalsys_service | ||
static eCAL::rec::Error CallRemoteEcalrecService(const std::shared_ptr<eCAL::protobuf::CServiceClientUntypedCallback<eCAL::pb::rec_server::EcalRecServerService>>& remote_ecalsys_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.
warning: function 'eCAL::rec_cli::command::Command::CallRemoteEcalrecService' has a definition with different parameter names [readability-inconsistent-declaration-parameter-name]
static eCAL::rec::Error CallRemoteEcalrecService(const std::shared_ptr<eCAL::protobuf::CServiceClientUntypedCallback<eCAL::pb::rec_server::EcalRecServerService>>& remote_ecalsys_service
^
Additional context
app/rec/rec_server_cli/src/commands/command.cpp:75: the definition seen here
eCAL::rec::Error Command::CallRemoteEcalrecService(const std::shared_ptr<eCAL::protobuf::CServiceClientUntypedCallback<eCAL::pb::rec_server::EcalRecServerService>>& remote_ecalrec_service
^
app/rec/rec_server_cli/src/commands/command.h:63: differing parameters are named here: ('remote_ecalsys_service'), in definition: ('remote_ecalrec_service')
static eCAL::rec::Error CallRemoteEcalrecService(const std::shared_ptr<eCAL::protobuf::CServiceClientUntypedCallback<eCAL::pb::rec_server::EcalRecServerService>>& remote_ecalsys_service
^
@@ -119,7 +119,7 @@ bool IsBuiltInFtpServerBusy(bool print_status = false); | |||
|
|||
// Rec Sever instance and rec_server_service. We will only use one of those, depending on the remote-control setting | |||
std::shared_ptr<eCAL::rec_server::RecServer> rec_server_instance; | |||
std::shared_ptr<eCAL::protobuf::CServiceClient<eCAL::pb::rec_server::EcalRecServerService>> remote_rec_server_service; | |||
std::shared_ptr<eCAL::protobuf::CServiceClientUntypedCallback<eCAL::pb::rec_server::EcalRecServerService>> remote_rec_server_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.
warning: variable 'remote_rec_server_service' is non-const and globally accessible, consider making it const [cppcoreguidelines-avoid-non-const-global-variables]
std::shared_ptr<eCAL::protobuf::CServiceClientUntypedCallback<eCAL::pb::rec_server::EcalRecServerService>> remote_rec_server_service;
^
@@ -29,15 +29,14 @@ int main() | |||
// initialize eCAL API | |||
eCAL::Initialize("orchestrator"); | |||
|
|||
eCAL::protobuf::CServiceClient<orchestrator::ComponentService> component1("component1"); | |||
eCAL::protobuf::CServiceClient<orchestrator::ComponentService> component2("component2"); | |||
eCAL::protobuf::CServiceClientTypedResponse<orchestrator::ComponentService> component1("component1"); |
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 'component1' of type 'eCAL::protobuf::CServiceClientTypedResponseorchestrator::ComponentService' can be declared 'const' [misc-const-correctness]
eCAL::protobuf::CServiceClientTypedResponse<orchestrator::ComponentService> component1("component1"); | |
eCAL::protobuf::CServiceClientTypedResponse<orchestrator::ComponentService> const component1("component1"); |
eCAL::protobuf::CServiceClient<orchestrator::ComponentService> component1("component1"); | ||
eCAL::protobuf::CServiceClient<orchestrator::ComponentService> component2("component2"); | ||
eCAL::protobuf::CServiceClientTypedResponse<orchestrator::ComponentService> component1("component1"); | ||
eCAL::protobuf::CServiceClientTypedResponse<orchestrator::ComponentService> component2("component2"); |
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 'component2' of type 'eCAL::protobuf::CServiceClientTypedResponseorchestrator::ComponentService' can be declared 'const' [misc-const-correctness]
eCAL::protobuf::CServiceClientTypedResponse<orchestrator::ComponentService> component2("component2"); | |
eCAL::protobuf::CServiceClientTypedResponse<orchestrator::ComponentService> const component2("component2"); |
@@ -89,8 +92,7 @@ int main() | |||
eCAL::Initialize("ecalplayer client"); | |||
|
|||
// create player service client | |||
eCAL::protobuf::CServiceClient<eCAL::pb::play::EcalPlayService> player_service; | |||
player_service.AddResponseCallback(OnPlayerResponse); | |||
eCAL::protobuf::CServiceClientUntypedCallback<eCAL::pb::play::EcalPlayService> player_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.
warning: variable 'player_service' of type 'eCAL::protobuf::CServiceClientUntypedCallbackeCAL::pb::play::EcalPlayService' can be declared 'const' [misc-const-correctness]
eCAL::protobuf::CServiceClientUntypedCallback<eCAL::pb::play::EcalPlayService> player_service; | |
eCAL::protobuf::CServiceClientUntypedCallback<eCAL::pb::play::EcalPlayService> const player_service; |
{ | ||
public: | ||
using CServiceClientBase<T>::CServiceClientBase; | ||
virtual ~CServiceClientCallbackBase() override = default; |
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: 'virtual' is redundant since the function is already declared 'override' [cppcoreguidelines-explicit-virtual-functions]
virtual ~CServiceClientCallbackBase() override = default; | |
; |
|
||
#pragma once | ||
|
||
#include <ecal/service/types.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: 'ecal/service/types.h' file not found [clang-diagnostic-error]
#include <ecal/service/types.h>
^
* @tparam ResponseT The expected protobuf response type. | ||
*/ | ||
template <typename ResponseT> | ||
struct TMsgServiceResponse |
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: constructor does not initialize these fields: server_id, service_method_information, error_msg [cppcoreguidelines-pro-type-member-init]
serialization/protobuf/protobuf/include/ecal/msg/protobuf/client_protobuf_types.h:50:
- SServiceId server_id; //!< Identifier of the server that executed the call
- SServiceMethodInformation service_method_information; //!< Information about the called method
+ SServiceId server_id{}; //!< Identifier of the server that executed the call
+ SServiceMethodInformation service_method_information{}; //!< Information about the called method
serialization/protobuf/protobuf/include/ecal/msg/protobuf/client_protobuf_types.h:54:
- std::string error_msg; //!< Error message if the call failed
+ std::string error_msg{}; //!< Error message if the call failed
* This class will serve as the parent for the typed and untyped variants. | ||
*/ | ||
template <typename T> | ||
class CServiceClientResponseBase : public CServiceClientBase<T> |
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: class 'CServiceClientResponseBase' defines a default destructor but does not define a copy constructor, a copy assignment operator, a move constructor or a move assignment operator [cppcoreguidelines-special-member-functions]
>
^
{ | ||
public: | ||
using CServiceClientBase<T>::CServiceClientBase; // Inherit constructors | ||
virtual ~CServiceClientResponseBase() override = default; |
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: 'virtual' is redundant since the function is already declared 'override' [cppcoreguidelines-explicit-virtual-functions]
virtual ~CServiceClientResponseBase() override = default; | |
s |
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
ecal/samples/cpp/orchestration/orchestrator/src/orchestrator.cpp
Outdated
Show resolved
Hide resolved
ecal/samples/cpp/orchestration/orchestrator/src/orchestrator.cpp
Outdated
Show resolved
Hide resolved
serialization/protobuf/protobuf/include/ecal/msg/protobuf/client.h
Outdated
Show resolved
Hide resolved
serialization/protobuf/protobuf/include/ecal/msg/protobuf/client_instance.h
Show resolved
Hide resolved
serialization/protobuf/protobuf/include/ecal/msg/protobuf/client_instance.h
Show resolved
Hide resolved
{ | ||
public: | ||
// Constructors | ||
CClientInstanceTyped(eCAL::CClientInstance&& base_instance_) noexcept |
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: rvalue reference parameter 'base_instance_' is never moved from inside the function body [cppcoreguidelines-rvalue-reference-param-not-moved]
CClientInstanceTyped(eCAL::CClientInstance&& base_instance_) noexcept
^
{ | ||
} | ||
|
||
CClientInstanceTyped(const SEntityId& entity_id_, const std::shared_ptr<eCAL::CServiceClientImpl>& service_client_impl_) |
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: constructor does not initialize these fields: m_instance [cppcoreguidelines-pro-type-member-init]
CClientInstanceTyped(const SEntityId& entity_id_, const std::shared_ptr<eCAL::CServiceClientImpl>& service_client_impl_)
^
* @tparam ResponseT The expected protobuf response type. | ||
*/ | ||
template <typename ResponseT> | ||
struct TMsgServiceResponse |
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: constructor does not initialize these fields: server_id, service_method_information, error_msg [cppcoreguidelines-pro-type-member-init]
serialization/protobuf/protobuf/include/ecal/msg/protobuf/client_protobuf_types.h:50:
- SServiceId server_id; //!< Identifier of the server that executed the call
- SServiceMethodInformation service_method_information; //!< Information about the called method
+ SServiceId server_id{}; //!< Identifier of the server that executed the call
+ SServiceMethodInformation service_method_information{}; //!< Information about the called method
serialization/protobuf/protobuf/include/ecal/msg/protobuf/client_protobuf_types.h:54:
- std::string error_msg; //!< Error message if the call failed
+ std::string error_msg{}; //!< Error message if the call failed
Description
This pull request overhauls the eCAL Protobuf service client API by replacing the legacy client implementation with a more modern, type-safe, and modular design. In the old API, the class
eCAL::protobuf::CServiceClient
was implemented as a thin wrapper around the eCAL v5 client and provided only a generic (untyped) call interface. The new design introduces several major improvements:Key Enhancements
1. Separation of Typed and Untyped APIs
Typed API:
TMsgServiceResponse<ResponseT>
, now encapsulates a strongly typed protobuf response along with metadata (call state, server ID, method information, return state, and error message).TMsgServiceResponseVecT<ResponseT>
, is provided to ease handling of responses from multiple service instances.CServiceClientTyped<T>
offers templated call methods (for both blocking and callback-based calls) that automatically parse the raw response into a typed response.Untyped API:
CServiceClient<T>
, which provides methods that return the rawSServiceResponse
. This retains compatibility for users who prefer to handle response parsing manually.2. Client Instance Refactoring
CServiceClient
implementation relied on a single client instance wrapper. The new design splits the functionality into two distinct client instance wrappers:Provides untyped call methods that directly return raw responses.
Provides templated call methods that parse and convert raw responses into strongly typed responses.
eCAL::CClientInstance
) rather than inheritance, which improves modularity and maintainability.3. Unified Base Class for Service Clients
CServiceClientBase<T, ClientInstanceT>
, has been introduced. It centralizes common functionality such as:ProcessInstances
) to uniformly iterate over and process all available client instances.CServiceClient<T>
) and typed (CServiceClientTyped<T>
) client classes derive from this new base class, passing inCClientInstanceUntyped<T>
orCClientInstanceTyped<T>
as the second template parameter, respectively.4. Enhanced Call Method Overloads
Blocking Calls:
CallWithResponse
methods return astd::pair<bool, std::vector<...>>
where:bool
indicates whether all client instances responded successfully.std::vector
contains responses from all matching service instances.TMsgServiceResponse<ResponseT>
.Callback Calls:
ResponseCallbackT
to deliver the raw response.TMsgResponseCallbackT<ResponseT>
so that the client callback receives an automatically parsed, strongly typed response.Internal helper functions (such as those used in
ProcessInstances
) have been refactored to minimize code duplication and simplify the overall implementation.5. Code Duplication Reduction and Better Maintainability
Backwards Compatibility
CServiceClient<T>
for untyped calls.CServiceClientTyped<T>
for strongly typed calls.Impact on Client Code
Client applications will now benefit from improved type safety and easier access to service responses. For example:
Using the Typed Service Client
// Using the CallWithCallback variant:
// Using the CallWithResponse (blocking) variant:
Iterating Over Client Instances
// Iterative CallWithCallback on each client instance:
// Iterative blocking calls:
Callback Example
Summary
Enhanced API:
The new design cleanly separates typed and untyped responses and introduces a unified base class for service clients.
Stronger Type Safety:
With templated call methods, client code can directly work with strongly typed responses.
Modular and Maintainable:
The client instance wrappers and common helper functions reduce code duplication and improve maintainability.
Seamless Migration:
Although the legacy API has been replaced, the overall behavior remains consistent. Existing client code can be updated by migrating to the new templated call methods.