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

[core] redesign service server api #1849

Merged
merged 25 commits into from
Dec 13, 2024
Merged

Conversation

rex-schilasky
Copy link
Contributor

Description

Implement a new service server API (symmetrically to new service client API).

@rex-schilasky rex-schilasky marked this pull request as draft December 9, 2024 19:12
@rex-schilasky rex-schilasky added the cherry-pick-to-NONE Don't cherry-pick these changes label Dec 9, 2024
@rex-schilasky rex-schilasky changed the title redesign server api redesign service server api Dec 9, 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

There were too many comments to post at once. Showing the first 20 out of 89. Check the log or trigger a new build to see more.

*
* @param service_name_ Unique service name.
**/
ECAL_API_EXPORTED_MEMBER
explicit CServiceServer(const std::string& service_name_);
explicit CServiceServer(const std::string& service_name_, const ServerEventIDCallbackT event_callback_ = ServerEventIDCallbackT());
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: parameter 'event_callback_' is const-qualified in the function declaration; const-qualification of parameters only has an effect in function definitions [readability-avoid-const-params-in-decls]

Suggested change
explicit CServiceServer(const std::string& service_name_, const ServerEventIDCallbackT event_callback_ = ServerEventIDCallbackT());
explicit CServiceServer(const std::string& service_name_, ServerEventIDCallbackT event_callback_ = ServerEventIDCallbackT());

@@ -116,7 +76,7 @@
* @return True if successful.
**/
ECAL_API_EXPORTED_MEMBER
bool AddMethodCallback(const std::string& method_, const std::string& req_type_, const std::string& resp_type_, const MethodCallbackT& callback_);
bool AddMethodCallback(const std::string& method_, const SServiceMethodInformation& method_info_, const MethodCallbackT& callback_);
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: no header providing "eCAL::SServiceMethodInformation" is directly included [misc-include-cleaner]

ecal/core/include/ecal/ecal_server.h:26:

- #include <ecal/ecal_deprecate.h>
+ #include "ecal/ecal_types.h"
+ #include <ecal/ecal_deprecate.h>

#pragma once

#include <ecal/ecal_deprecate.h>
#include <ecal/ecal_os.h>
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: included header ecal_deprecate.h is not used directly [misc-include-cleaner]

Suggested change
#include <ecal/ecal_os.h>
#include <ecal/ecal_os.h>


#include <string>
#include <vector>
#include <memory>
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: included header vector is not used directly [misc-include-cleaner]

Suggested change
#include <memory>
#include <memory>

/**
* @brief Service Server wrapper class.
**/
class ECAL_API_CLASS CServiceServer
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: class 'CServiceServer' defines a destructor, a copy constructor and a copy assignment operator but does not define a move constructor or a move assignment operator [cppcoreguidelines-special-member-functions]

    class ECAL_API_CLASS CServiceServer
                         ^


std::shared_ptr<CServiceServerImpl> CServiceServerImpl::CreateInstance(const std::string& service_name_)
// Factory method to create a new instance of CServiceClientImpl
std::shared_ptr<CServiceServerImpl> CServiceServerImpl::CreateInstance(
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: no header providing "std::shared_ptr" is directly included [misc-include-cleaner]

ecal/core/src/service/ecal_service_server_impl.cpp:27:

+ #include <memory>

std::shared_ptr<CServiceServerImpl> CServiceServerImpl::CreateInstance(const std::string& service_name_)
// Factory method to create a new instance of CServiceClientImpl
std::shared_ptr<CServiceServerImpl> CServiceServerImpl::CreateInstance(
const std::string& service_name_, const ServerEventIDCallbackT& event_callback_)
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: no header providing "eCAL::ServerEventIDCallbackT" is directly included [misc-include-cleaner]

ecal/core/src/service/ecal_service_server_impl.cpp:23:

- #include "ecal_global_accessors.h"
+ #include "ecal/ecal_callback.h"
+ #include "ecal_global_accessors.h"

std::shared_ptr<CServiceServerImpl> CServiceServerImpl::CreateInstance(const std::string& service_name_)
// Factory method to create a new instance of CServiceClientImpl
std::shared_ptr<CServiceServerImpl> CServiceServerImpl::CreateInstance(
const std::string& service_name_, const ServerEventIDCallbackT& event_callback_)
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: no header providing "std::string" is directly included [misc-include-cleaner]

ecal/core/src/service/ecal_service_server_impl.cpp:27:

+ #include <string>

{
const std::lock_guard<std::mutex> connected_lock(m_connected_mutex);
m_connected = false;
const std::lock_guard<std::mutex> lock(m_event_callback_mutex);
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: no header providing "std::lock_guard" is directly included [misc-include-cleaner]

ecal/core/src/service/ecal_service_server_impl.cpp:27:

+ #include <mutex>

{
const std::lock_guard<std::mutex> connected_lock(m_connected_mutex);
m_connected = false;
const std::lock_guard<std::mutex> lock(m_event_callback_mutex);
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: no header providing "std::mutex" is directly included [misc-include-cleaner]

      const std::lock_guard<std::mutex> lock(m_event_callback_mutex);
                                 ^

@rex-schilasky rex-schilasky marked this pull request as ready for review December 11, 2024 12:39
@rex-schilasky rex-schilasky changed the title redesign service server api [core] redesign service server api Dec 11, 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

There were too many comments to post at once. Showing the first 20 out of 95. Check the log or trigger a new build to see more.

#include <memory>
#include <string>
#include <vector>

Copy link
Contributor

Choose a reason for hiding this comment

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

warning: included header vector is not used directly [misc-include-cleaner]

Suggested change

{
Logging::Log(log_level_debug2, "v5::CServiceClientImpl: Initializing default service client implementation.");
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: no header providing "log_level_debug2" is directly included [misc-include-cleaner]

ecal/core/src/service/ecal_service_client_v5_impl.cpp:24:

- #include <ecal/ecal_log.h>
+ #include "ecal/ecal_log_level.h"
+ #include <ecal/ecal_log.h>

if (m_created) return false;
if (m_service_client_impl != nullptr)
{
Logging::Log(log_level_warning, "v5::CServiceClientImpl: Service client already created: " + service_name_);
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: no header providing "log_level_warning" is directly included [misc-include-cleaner]

        Logging::Log(log_level_warning, "v5::CServiceClientImpl: Service client already created: " + service_name_);
                     ^

return false;
}

Logging::Log(log_level_debug1, "v5::CServiceClientImpl: Creating service client with name: " + service_name_);
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: no header providing "log_level_debug1" is directly included [misc-include-cleaner]

      Logging::Log(log_level_debug1, "v5::CServiceClientImpl: Creating service client with name: " + service_name_);
                   ^

ClientEventIDCallbackT event_callback = [this](const Registration::SServiceMethodId& service_id_, const struct SClientEventCallbackData& data_)
{
Logging::Log(log_level_debug2, "v5::CServiceClientImpl: Event callback triggered for event type: " + std::to_string(data_.type));
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: no header providing "std::to_string" is directly included [misc-include-cleaner]

ecal/core/src/service/ecal_service_client_v5_impl.cpp:25:

+ #include <string>

std::shared_ptr<CServiceServerImpl> CServiceServerImpl::CreateInstance(const std::string& service_name_)
// Factory method to create a new instance of CServiceServerImpl
std::shared_ptr<CServiceServerImpl> CServiceServerImpl::CreateInstance(
const std::string& service_name_, const ServerEventIDCallbackT& event_callback_)
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: no header providing "std::string" is directly included [misc-include-cleaner]

ecal/core/src/service/ecal_service_server_impl.cpp:26:

+ #include <string>

{
auto instance = std::shared_ptr<CServiceServerImpl> (new CServiceServerImpl());
instance->Start(service_name_);
Logging::Log(log_level_debug1, "CServiceServerImpl::CreateInstance: Creating instance of CServiceServerImpl for service: " + service_name_);
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: no header providing "log_level_debug1" is directly included [misc-include-cleaner]

ecal/core/src/service/ecal_service_server_impl.cpp:27:

- #include "ecal_global_accessors.h"
+ #include "ecal/ecal_log_level.h"
+ #include "ecal_global_accessors.h"

Stop();
}

bool CServiceServerImpl::Start(const std::string& service_name_)
bool CServiceServerImpl::AddMethodCallback(const std::string& method_, const SServiceMethodInformation& method_info_, const MethodCallbackT& callback_)
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: no header providing "eCAL::MethodCallbackT" is directly included [misc-include-cleaner]

ecal/core/src/service/ecal_service_server_impl.cpp:27:

- #include "ecal_global_accessors.h"
+ #include "ecal/ecal_service_info.h"
+ #include "ecal_global_accessors.h"

Stop();
}

bool CServiceServerImpl::Start(const std::string& service_name_)
bool CServiceServerImpl::AddMethodCallback(const std::string& method_, const SServiceMethodInformation& method_info_, const MethodCallbackT& callback_)
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: no header providing "eCAL::SServiceMethodInformation" is directly included [misc-include-cleaner]

ecal/core/src/service/ecal_service_server_impl.cpp:27:

- #include "ecal_global_accessors.h"
+ #include "ecal/ecal_types.h"
+ #include "ecal_global_accessors.h"

// set service name
m_service_name = service_name_;
Logging::Log(log_level_debug1, "CServiceServerImpl: Adding method callback for method: " + method_);
std::lock_guard<std::mutex> const lock(m_method_map_mutex);
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: no header providing "std::lock_guard" is directly included [misc-include-cleaner]

ecal/core/src/service/ecal_service_server_impl.cpp:26:

+ #include <mutex>

Copy link
Contributor

@Peguen Peguen left a comment

Choose a reason for hiding this comment

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

🛸 abgespaced

// Call the stored response callback
m_response_callback(service_response_);
}
};

// Call the method asynchronously using the new API
return m_service_client_impl->CallWithCallbackAsync(method_name_, request_, wrapped_callback);
bool success = m_service_client_impl->CallWithCallbackAsync(method_name_, request_, wrapped_callback);
Logging::Log(log_level_debug1, "v5::CServiceClientImpl: Async call to method: " + method_name_ + " completed with success: " + std::to_string(success));
Copy link
Contributor

Choose a reason for hiding this comment

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

success cast to "true" or "false" in future

// Unregister server
if (g_servicegate() != nullptr)
{
//g_servicegate()->Unregister(m_service_server_impl->GetServiceName(), m_service_server_impl);
Copy link
Contributor

Choose a reason for hiding this comment

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

Please check this again

// Move data
m_service_server_impl = std::move(rhs.m_service_server_impl);

rhs.m_service_server_impl = nullptr;
Copy link
Contributor

Choose a reason for hiding this comment

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

resetting is redundant, can be deleted

instance->Start(service_name_);
Logging::Log(log_level_debug1, "CServiceServerImpl::CreateInstance: Creating instance of CServiceServerImpl for service: " + service_name_);
auto instance = std::shared_ptr<CServiceServerImpl>(new CServiceServerImpl(service_name_, event_callback_));
instance->Start();
Copy link
Contributor

Choose a reason for hiding this comment

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

Check if instance was created.

// Stop TCP server
if (m_tcp_server)
{
m_tcp_server->stop();
Copy link
Contributor

Choose a reason for hiding this comment

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

Check to reset shared ptr

@@ -39,7 +40,7 @@ int main()
eCAL::Initialize("minimal server");

// create minimal service server
eCAL::CServiceServer minimal_server("service1");
eCAL::v5::CServiceServer minimal_server("service1");
Copy link
Contributor

Choose a reason for hiding this comment

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

Samples move to V6

@@ -34,7 +35,7 @@ int main()
eCAL::Initialize("latency server");

// create latency service
eCAL::CServiceServer latency_service("latency");
eCAL::v5::CServiceServer latency_service("latency");
Copy link
Contributor

Choose a reason for hiding this comment

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

Move to V6

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 83. Check the log or trigger a new build to see more.

* @param event_callback_ Callback function for server events.
**/
ECAL_API_EXPORTED_MEMBER
explicit CServiceServer(const std::string& service_name_, const ServerEventIDCallbackT event_callback_ = ServerEventIDCallbackT());
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: parameter 'event_callback_' is const-qualified in the function declaration; const-qualification of parameters only has an effect in function definitions [readability-avoid-const-params-in-decls]

Suggested change
explicit CServiceServer(const std::string& service_name_, const ServerEventIDCallbackT event_callback_ = ServerEventIDCallbackT());
explicit CServiceServer(const std::string& service_name_, ServerEventIDCallbackT event_callback_ = ServerEventIDCallbackT());

return m_service_client_impl->GetServiceName();
}

Registration::SServiceMethodId CServiceClient::GetServiceId() const
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 'GetServiceId' can be made static [readability-convert-member-functions-to-static]

ecal/core/include/ecal/ecal_client.h:148:

-         Registration::SServiceMethodId GetServiceId() const;
+         static Registration::SServiceMethodId GetServiceId() ;
Suggested change
Registration::SServiceMethodId CServiceClient::GetServiceId() const
Registration::SServiceMethodId CServiceClient::GetServiceId()

return m_service_client_impl->GetServiceName();
}

Registration::SServiceMethodId CServiceClient::GetServiceId() const
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: no header providing "eCAL::Registration::SServiceMethodId" is directly included [misc-include-cleaner]

ecal/core/src/service/ecal_service_client.cpp:25:

- #include "ecal_clientgate.h"
+ #include "ecal/ecal_types.h"
+ #include "ecal_clientgate.h"

@@ -103,6 +103,7 @@ namespace
void ResponseError(const eCAL::Registration::SEntityId& entity_id_, const std::string& service_name_, const std::string& method_name_,
const std::string& error_message_, const eCAL::ResponseIDCallbackT& response_callback_)
{
eCAL::Logging::Log(log_level_error, "CServiceClientImpl: Response error for service: " + service_name_ + ", method: " + method_name_ + ", error: " + error_message_);
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: no header providing "eCAL::Logging::Log" is directly included [misc-include-cleaner]

ecal/core/src/service/ecal_service_client_impl.cpp:23:

- #include "ecal_global_accessors.h"
+ #include "ecal/ecal_log.h"
+ #include "ecal_global_accessors.h"

@@ -103,6 +103,7 @@
void ResponseError(const eCAL::Registration::SEntityId& entity_id_, const std::string& service_name_, const std::string& method_name_,
const std::string& error_message_, const eCAL::ResponseIDCallbackT& response_callback_)
{
eCAL::Logging::Log(log_level_error, "CServiceClientImpl: Response error for service: " + service_name_ + ", method: " + method_name_ + ", error: " + error_message_);
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: no header providing "log_level_error" is directly included [misc-include-cleaner]

ecal/core/src/service/ecal_service_client_impl.cpp:23:

- #include "ecal_global_accessors.h"
+ #include "ecal/ecal_log_level.h"
+ #include "ecal_global_accessors.h"

std::string req_desc;
std::string resp_desc;
// Create service ID
std::stringstream counter;
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: no header providing "std::stringstream" is directly included [misc-include-cleaner]

ecal/core/src/service/ecal_service_server_impl.cpp:26:

+ #include <sstream>

std::string resp_desc;
// Create service ID
std::stringstream counter;
counter << std::chrono::steady_clock::now().time_since_epoch().count();
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: no header providing "std::chrono::steady_clock" is directly included [misc-include-cleaner]

ecal/core/src/service/ecal_service_server_impl.cpp:23:

- #include <ecal/ecal_config.h>
+ #include <chrono>
+ #include <ecal/ecal_config.h>

method.callback = callback_;
m_method_map[method_] = method;
}
Logging::Log(log_level_error, "CServiceServerImpl: Failed to start service: Global server manager is unavailable or stopped for: " + m_service_name);
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: no header providing "log_level_error" is directly included [misc-include-cleaner]

      Logging::Log(log_level_error, "CServiceServerImpl: Failed to start service: Global server manager is unavailable or stopped for: " + m_service_name);
                   ^

return true;
}
// Create callback functions
const eCAL::service::Server::EventCallbackT event_callback =
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: no header providing "eCAL::service::Server" is directly included [misc-include-cleaner]

ecal/core/src/service/ecal_service_server_impl.cpp:27:

- #include "ecal_global_accessors.h"
+ #include "ecal/service/server.h"
+ #include "ecal_global_accessors.h"

}
// Create callback functions
const eCAL::service::Server::EventCallbackT event_callback =
[weak_me = std::weak_ptr<CServiceServerImpl>(shared_from_this())](eCAL::service::ServerEventType event, const std::string& message)
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: no header providing "eCAL::service::ServerEventType" is directly included [misc-include-cleaner]

ecal/core/src/service/ecal_service_server_impl.cpp:27:

- #include "ecal_global_accessors.h"
+ #include "ecal/service/server_session_types.h"
+ #include "ecal_global_accessors.h"

minimal warning fix in CDataReader (lock name change)
TODO's added for CServiceServer and CServiceClient
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 73. Check the log or trigger a new build to see more.

@@ -534,7 +534,7 @@ namespace eCAL
pub_info.process_id = topic_info_.pid;

// execute it
std::lock_guard<std::mutex> lock(m_connection_map_mtx);
std::lock_guard<std::mutex> exec_lock(m_connection_map_mtx);
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: variable 'exec_lock' of type 'std::lock_guardstd::mutex' can be declared 'const' [misc-const-correctness]

Suggested change
std::lock_guard<std::mutex> exec_lock(m_connection_map_mtx);
std::lock_guard<std::mutex> const exec_lock(m_connection_map_mtx);

return m_service_client_impl->GetServiceName();
}

Registration::SServiceMethodId CServiceClient::GetServiceId() const
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 'GetServiceId' can be made static [readability-convert-member-functions-to-static]

ecal/core/include/ecal/ecal_client.h:151:

-         Registration::SServiceMethodId GetServiceId() const;
+         static Registration::SServiceMethodId GetServiceId() ;
Suggested change
Registration::SServiceMethodId CServiceClient::GetServiceId() const
Registration::SServiceMethodId CServiceClient::GetServiceId()

* @return The service name.
**/
std::string CServiceServer::GetServiceName()
Registration::SServiceMethodId CServiceServer::GetServiceId() const
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 'GetServiceId' can be made static [readability-convert-member-functions-to-static]

Suggested change
Registration::SServiceMethodId CServiceServer::GetServiceId() const
Registration::SServiceMethodId CServiceServer::GetServiceId()

ecal/core/include/ecal/ecal_server.h:128:

-         Registration::SServiceMethodId GetServiceId() const;
+         static Registration::SServiceMethodId GetServiceId() ;

#ifndef NDEBUG
Logging::Log(log_level_debug1, "CServiceServerImpl::AddMethodCallback: Adding method callback for method: " + method_);
#endif
const std::lock_guard<std::mutex> lock(m_method_map_mutex);
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: no header providing "std::lock_guard" is directly included [misc-include-cleaner]

ecal/core/src/service/ecal_service_server_impl.cpp:26:

+ #include <mutex>

#ifndef NDEBUG
Logging::Log(log_level_debug1, "CServiceServerImpl::AddMethodCallback: Adding method callback for method: " + method_);
#endif
const std::lock_guard<std::mutex> lock(m_method_map_mutex);
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: no header providing "std::mutex" is directly included [misc-include-cleaner]

    const std::lock_guard<std::mutex> lock(m_method_map_mutex);
                               ^

int RequestCallback(const std::string& request_pb_, std::string& response_pb_);
void EventCallback(eCAL_Server_Event event_, const std::string& message_);
void NotifyEventCallback(const Registration::SServiceMethodId& service_id_, eCAL_Server_Event event_type_, const std::string& message_);
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: no header providing "eCAL::Registration::SServiceMethodId" is directly included [misc-include-cleaner]

    void NotifyEventCallback(const Registration::SServiceMethodId& service_id_, eCAL_Server_Event event_type_, const std::string& message_);
                                                 ^

int RequestCallback(const std::string& request_pb_, std::string& response_pb_);
void EventCallback(eCAL_Server_Event event_, const std::string& message_);
void NotifyEventCallback(const Registration::SServiceMethodId& service_id_, eCAL_Server_Event event_type_, const std::string& message_);
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: no header providing "eCAL_Server_Event" is directly included [misc-include-cleaner]

ecal/core/src/service/ecal_service_server_impl.h:29:

- #include "serialization/ecal_serialize_sample_registration.h"
+ #include "ecal/cimpl/ecal_callback_cimpl.h"
+ #include "serialization/ecal_serialize_sample_registration.h"

// Server connection state and synchronization
mutable std::mutex m_connected_mutex; // mutex protecting m_connected (modified by the event callbacks in another thread)
bool m_connected = false;
std::atomic<bool> m_created;
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: no header providing "std::atomic" is directly included [misc-include-cleaner]

ecal/core/src/service/ecal_service_server_impl.h:25:

- #include <ecal/ecal_callback.h>
+ #include <atomic>
+ #include <ecal/ecal_callback.h>

**/

#include <ecal/ecal.h>
#include <ecal/ecal_server_v5.h>
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: included header ecal.h is not used directly [misc-include-cleaner]

Suggested change
#include <ecal/ecal_server_v5.h>
#include <ecal/ecal_server_v5.h>

#include <string>

#include "ecal_servicegate.h"
#include "ecal_global_accessors.h"
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: included header ecal_servicegate.h is not used directly [misc-include-cleaner]

Suggested change
#include "ecal_global_accessors.h"
#include "ecal_global_accessors.h"

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 53. Check the log or trigger a new build to see more.


#include "ecal_servicegate.h"
#include "ecal_global_accessors.h"
#include "ecal_service_server_v5_impl.h"
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: included header ecal_global_accessors.h is not used directly [misc-include-cleaner]

Suggested change
#include "ecal_service_server_v5_impl.h"
#include "ecal_service_server_v5_impl.h"

bool CServiceServer::Create(const std::string& service_name_)
{
if (m_service_server_impl != nullptr) return false;
m_service_server_impl = std::make_shared<CServiceServerImpl>(service_name_);
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: no header providing "std::make_shared" is directly included [misc-include-cleaner]

ecal/core/src/service/ecal_service_server_v5.cpp:25:

- #include <string>
+ #include <memory>
+ #include <string>

return m_service_server_impl->AddDescription(method_, req_type_, req_desc_, resp_type_, resp_desc_);
}

bool CServiceServer::AddMethodCallback(const std::string& method_, const std::string& req_type_, const std::string& resp_type_, const MethodCallbackT& callback_)
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: no header providing "eCAL::MethodCallbackT" is directly included [misc-include-cleaner]

ecal/core/src/service/ecal_service_server_v5.cpp:27:

- #include "ecal_servicegate.h"
+ #include "ecal/ecal_service_info.h"
+ #include "ecal_servicegate.h"

return m_service_server_impl->RemMethodCallback(method_);
}

bool CServiceServer::AddEventCallback(eCAL_Server_Event type_, ServerEventCallbackT callback_)
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: no header providing "eCAL::ServerEventCallbackT" is directly included [misc-include-cleaner]

ecal/core/src/service/ecal_service_server_v5.cpp:27:

- #include "ecal_servicegate.h"
+ #include "ecal/ecal_callback.h"
+ #include "ecal_servicegate.h"

return m_service_server_impl->RemMethodCallback(method_);
}

bool CServiceServer::AddEventCallback(eCAL_Server_Event type_, ServerEventCallbackT callback_)
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: no header providing "eCAL_Server_Event" is directly included [misc-include-cleaner]

ecal/core/src/service/ecal_service_server_v5.cpp:27:

- #include "ecal_servicegate.h"
+ #include "ecal/cimpl/ecal_callback_cimpl.h"
+ #include "ecal_servicegate.h"

}
};

m_service_server_impl = std::make_shared<eCAL::CServiceServer>(service_name_, event_callback);
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: no header providing "eCAL::CServiceServer" is directly included [misc-include-cleaner]

ecal/core/src/service/ecal_service_server_v5_impl.cpp:26:

+ #include "ecal/ecal_server.h"

}
};

m_service_server_impl = std::make_shared<eCAL::CServiceServer>(service_name_, event_callback);
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: no header providing "std::make_shared" is directly included [misc-include-cleaner]

ecal/core/src/service/ecal_service_server_v5_impl.cpp:24:

+ #include <memory>

};

m_service_server_impl = std::make_shared<eCAL::CServiceServer>(service_name_, event_callback);
Logging::Log(log_level_debug1, "v5::CServiceServerImpl: Service server created with name: " + service_name_);
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: no header providing "log_level_debug1" is directly included [misc-include-cleaner]

      Logging::Log(log_level_debug1, "v5::CServiceServerImpl: Service server created with name: " + service_name_);
                   ^


if (!m_service_server_impl)
{
Logging::Log(log_level_error, "v5::CServiceServerImpl: Service server not initialized, cannot add description.");
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: no header providing "log_level_error" is directly included [misc-include-cleaner]

        Logging::Log(log_level_error, "v5::CServiceServerImpl: Service server not initialized, cannot add description.");
                     ^

return false;
}

SServiceMethodInformation method_info;
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: no header providing "eCAL::SServiceMethodInformation" is directly included [misc-include-cleaner]

      SServiceMethodInformation method_info;
      ^

@rex-schilasky rex-schilasky merged commit 9cdfe52 into master Dec 13, 2024
20 checks passed
@rex-schilasky rex-schilasky deleted the feature/redesign-service-api branch December 13, 2024 18:22
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.

2 participants