From e145bb5d607bd8205d34a7ed01c6f99c32602da8 Mon Sep 17 00:00:00 2001 From: Miguel Company Date: Wed, 11 Jun 2025 15:50:24 +0200 Subject: [PATCH 1/4] Refs #23325. Add RpcServer.hpp. Signed-off-by: Miguel Company --- include/fastdds/dds/rpc/interfaces.hpp | 1 + .../fastdds/dds/rpc/interfaces/RpcServer.hpp | 75 +++++++++++++++++++ 2 files changed, 76 insertions(+) create mode 100644 include/fastdds/dds/rpc/interfaces/RpcServer.hpp diff --git a/include/fastdds/dds/rpc/interfaces.hpp b/include/fastdds/dds/rpc/interfaces.hpp index b6e0a69aa4a..de9bfd7ac99 100644 --- a/include/fastdds/dds/rpc/interfaces.hpp +++ b/include/fastdds/dds/rpc/interfaces.hpp @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include diff --git a/include/fastdds/dds/rpc/interfaces/RpcServer.hpp b/include/fastdds/dds/rpc/interfaces/RpcServer.hpp new file mode 100644 index 00000000000..3749e42a2d7 --- /dev/null +++ b/include/fastdds/dds/rpc/interfaces/RpcServer.hpp @@ -0,0 +1,75 @@ +// Copyright 2025 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/** + * @file RpcServer.hpp + */ + +#ifndef FASTDDS_DDS_RPC_INTERFACES__RPCSERVER_HPP +#define FASTDDS_DDS_RPC_INTERFACES__RPCSERVER_HPP + +#include + +namespace eprosima { +namespace fastdds { +namespace dds { +namespace rpc { + +// Forward declaration of RpcRequest class. +class RpcRequest; + +/** + * An interface with generic RPC server functionality. + */ +class RpcServer +{ +public: + + /** + * Destructor. + */ + virtual ~RpcServer() noexcept = default; + + /** + * @brief Run the server. + * + * This method starts the server and begins processing requests. + * The method will block until the server is stopped. + */ + virtual void run() = 0; + + /** + * @brief Stop the server. + * + * This method stops the server and releases all resources. + * It will cancel all pending requests, and wait for all processing threads to finish before returning. + */ + virtual void stop() = 0; + + /** + * @brief Perform execution of a client request. + * + * @param request The client request to execute. + */ + virtual void execute_request( + const std::shared_ptr& request) = 0; + +}; + +} // namespace rpc +} // namespace dds +} // namespace fastdds +} // namespace eprosima + +#endif // FASTDDS_DDS_RPC_INTERFACES__RPCSERVER_HPP From 412191ca21bf0ef75f9c2b75d9eb0d38bfcfa8a2 Mon Sep 17 00:00:00 2001 From: Miguel Company Date: Wed, 11 Jun 2025 16:20:26 +0200 Subject: [PATCH 2/4] Refs #23325. Add RpcRequest.hpp. Signed-off-by: Miguel Company --- include/fastdds/dds/rpc/interfaces.hpp | 1 + .../fastdds/dds/rpc/interfaces/RpcRequest.hpp | 63 +++++++++++++++++++ 2 files changed, 64 insertions(+) create mode 100644 include/fastdds/dds/rpc/interfaces/RpcRequest.hpp diff --git a/include/fastdds/dds/rpc/interfaces.hpp b/include/fastdds/dds/rpc/interfaces.hpp index de9bfd7ac99..6c73e24f534 100644 --- a/include/fastdds/dds/rpc/interfaces.hpp +++ b/include/fastdds/dds/rpc/interfaces.hpp @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include diff --git a/include/fastdds/dds/rpc/interfaces/RpcRequest.hpp b/include/fastdds/dds/rpc/interfaces/RpcRequest.hpp new file mode 100644 index 00000000000..0eb0c7983d8 --- /dev/null +++ b/include/fastdds/dds/rpc/interfaces/RpcRequest.hpp @@ -0,0 +1,63 @@ +// Copyright 2025 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/** + * @file RpcRequest.hpp + */ + +#ifndef FASTDDS_DDS_RPC_INTERFACES__RPCREQUEST_HPP +#define FASTDDS_DDS_RPC_INTERFACES__RPCREQUEST_HPP + +#include +#include + +namespace eprosima { +namespace fastdds { +namespace dds { +namespace rpc { + +/** + * An interface with generic RPC requests functionality. + */ +class RpcRequest +{ +public: + + /** + * Destructor. + */ + virtual ~RpcRequest() noexcept = default; + + /** + * @brief Get the GUID of the client that made the request. + * + * @return The GUID of the client that made the request. + */ + virtual const eprosima::fastdds::rtps::GUID_t& get_client_id() const = 0; + + /** + * @brief Get the locators of the client that made the request. + * + * @return The locators of the client that made the request. + */ + virtual const eprosima::fastdds::rtps::RemoteLocatorList& get_client_locators() const = 0; + +}; + +} // namespace rpc +} // namespace dds +} // namespace fastdds +} // namespace eprosima + +#endif // FASTDDS_DDS_RPC_INTERFACES__RPCREQUEST_HPP From 805a6c5acef412720cef6a6d10d0dabc3bbb7f04 Mon Sep 17 00:00:00 2001 From: Miguel Company Date: Wed, 11 Jun 2025 16:26:20 +0200 Subject: [PATCH 3/4] Refs #23325. Add RpcServerSchedulingStrategy.hpp. Signed-off-by: Miguel Company --- include/fastdds/dds/rpc/interfaces.hpp | 1 + .../RpcServerSchedulingStrategy.hpp | 69 +++++++++++++++++++ 2 files changed, 70 insertions(+) create mode 100644 include/fastdds/dds/rpc/interfaces/RpcServerSchedulingStrategy.hpp diff --git a/include/fastdds/dds/rpc/interfaces.hpp b/include/fastdds/dds/rpc/interfaces.hpp index 6c73e24f534..5fd660e6f71 100644 --- a/include/fastdds/dds/rpc/interfaces.hpp +++ b/include/fastdds/dds/rpc/interfaces.hpp @@ -25,6 +25,7 @@ #include #include #include +#include #include #include diff --git a/include/fastdds/dds/rpc/interfaces/RpcServerSchedulingStrategy.hpp b/include/fastdds/dds/rpc/interfaces/RpcServerSchedulingStrategy.hpp new file mode 100644 index 00000000000..41cdb2f01a7 --- /dev/null +++ b/include/fastdds/dds/rpc/interfaces/RpcServerSchedulingStrategy.hpp @@ -0,0 +1,69 @@ +// Copyright 2025 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/** + * @file RpcServerSchedulingStrategy.hpp + */ + +#ifndef FASTDDS_DDS_RPC_INTERFACES__RPCSERVERSCHEDULINGSTRATEGY_HPP +#define FASTDDS_DDS_RPC_INTERFACES__RPCSERVERSCHEDULINGSTRATEGY_HPP + +#include + +namespace eprosima { +namespace fastdds { +namespace dds { +namespace rpc { + +class RpcRequest; +class RpcServer; + +/** + * An interface with generic RPC requests functionality. + */ +class RpcServerSchedulingStrategy +{ +public: + + /** + * Destructor. + */ + virtual ~RpcServerSchedulingStrategy() noexcept = default; + + /** + * @brief Schedule a request for processing. + * + * @param request The request to schedule. + * @param server The server instance that should process the request. + */ + virtual void schedule_request( + const std::shared_ptr& request, + const std::shared_ptr& server) = 0; + + /** + * @brief Informs that a server has been stopped and all its requests have been cancelled. + * + * @param server The server instance that has been stopped. + */ + virtual void server_stopped( + const std::shared_ptr& server) = 0; + +}; + +} // namespace rpc +} // namespace dds +} // namespace fastdds +} // namespace eprosima + +#endif // FASTDDS_DDS_RPC_INTERFACES__RPCSERVERSCHEDULINGSTRATEGY_HPP From 027249da16363358cecfc4da91b51ef4d29602ae Mon Sep 17 00:00:00 2001 From: Miguel Company Date: Mon, 16 Jun 2025 10:10:45 +0200 Subject: [PATCH 4/4] Apply suggestion Co-authored-by: Carlos Espinoza Curto <148376273+Carlosespicur@users.noreply.github.com> Signed-off-by: Miguel Company --- .../dds/rpc/interfaces/RpcServerSchedulingStrategy.hpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/include/fastdds/dds/rpc/interfaces/RpcServerSchedulingStrategy.hpp b/include/fastdds/dds/rpc/interfaces/RpcServerSchedulingStrategy.hpp index 41cdb2f01a7..de65f347965 100644 --- a/include/fastdds/dds/rpc/interfaces/RpcServerSchedulingStrategy.hpp +++ b/include/fastdds/dds/rpc/interfaces/RpcServerSchedulingStrategy.hpp @@ -44,6 +44,12 @@ class RpcServerSchedulingStrategy /** * @brief Schedule a request for processing. * + * This method is called when a request is received and should be processed by the server. + * The implementation should decide how to handle the request, whether to process it immediately, + * or to queue it for later processing. + * + * A call to server->execute_request(request) should eventually be made to process the request. + * * @param request The request to schedule. * @param server The server instance that should process the request. */