Loading src/common/api/admire_types.hpp +6 −0 Original line number Diff line number Diff line Loading @@ -92,6 +92,12 @@ struct error_code { std::string_view message() const; template <typename Archive> void serialize(Archive&& ar) { ar& m_value; } private: ADM_return_t m_value; }; Loading src/common/net/CMakeLists.txt +1 −1 Original line number Diff line number Diff line Loading @@ -35,7 +35,7 @@ set_property(TARGET _rpc_client PROPERTY POSITION_INDEPENDENT_CODE ON) add_library(_rpc_server STATIC) target_sources( _rpc_server INTERFACE server.hpp INTERFACE server.hpp request.hpp PRIVATE server.cpp ) Loading src/common/net/request.hpp 0 → 100644 +74 −0 Original line number Diff line number Diff line /****************************************************************************** * Copyright 2021-2023, Barcelona Supercomputing Center (BSC), Spain * * This software was partially supported by the EuroHPC-funded project ADMIRE * (Project ID: 956748, https://www.admire-eurohpc.eu). * * This file is part of scord. * * scord is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * scord is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with scord. If not, see <https://www.gnu.org/licenses/>. * * SPDX-License-Identifier: GPL-3.0-or-later *****************************************************************************/ #ifndef SCORD_NET_REQUEST_HPP #define SCORD_NET_REQUEST_HPP #include <thallium.hpp> #include "admire_types.hpp" namespace scord::network { using request = thallium::request; template <typename Request> inline std::string get_address(Request&& req) { return std::forward<Request>(req).get_endpoint(); } class generic_response { public: constexpr generic_response() noexcept = default; constexpr generic_response(std::uint64_t op_id, admire::error_code ec) noexcept : m_op_id(op_id), m_error_code(ec) {} constexpr std::uint64_t op_id() const noexcept { return m_op_id; } constexpr admire::error_code error_code() const noexcept { return m_error_code; } template <typename Archive> constexpr void serialize(Archive&& ar) { ar& m_op_id; ar& m_error_code; } private: std::uint64_t m_op_id; admire::error_code m_error_code; }; } // namespace scord::network #endif // SCORD_NET_REQUEST_HPP src/lib/admire.cpp +0 −1 Original line number Diff line number Diff line Loading @@ -23,7 +23,6 @@ *****************************************************************************/ #include <admire.hpp> #include <net/engine.hpp> #include <net/proto/rpc_types.h> #include <logger/logger.hpp> #include <utils/ctype_ptr.hpp> Loading src/lib/detail/impl.cpp +7 −4 Original line number Diff line number Diff line Loading @@ -181,7 +181,8 @@ ping(const server& srv) { const auto rpc_id = ::api::remote_procedure::new_id(); if(const auto lookup_rv = rpc_client.lookup(srv.address()); lookup_rv) { if(const auto lookup_rv = rpc_client.lookup(srv.address()); lookup_rv.has_value()) { const auto& endp = lookup_rv.value(); LOGGER_INFO("rpc id: {} name: {} from: {} => " Loading @@ -189,17 +190,19 @@ ping(const server& srv) { rpc_id, std::quoted("ADM_"s + __FUNCTION__), std::quoted(rpc_client.self_address().value_or("unknown"))); if(const auto call_rv = endp.call("ADM_"s + __FUNCTION__); call_rv) { if(const auto call_rv = endp.call("ADM_"s + __FUNCTION__); call_rv.has_value()) { const scord::network::generic_response resp{call_rv.value()}; LOGGER_INFO("rpc id: {} name: {} from: {} <= " LOGGER_EVAL(resp.error_code(), INFO, ERROR, "rpc id: {} name: {} from: {} <= " "body: {{retval: {}}} [op_id: {}]", rpc_id, std::quoted("ADM_"s + __FUNCTION__), std::quoted(endp.address()), resp.error_code(), resp.op_id()); return admire::error_code::success; return resp.error_code(); } } Loading Loading
src/common/api/admire_types.hpp +6 −0 Original line number Diff line number Diff line Loading @@ -92,6 +92,12 @@ struct error_code { std::string_view message() const; template <typename Archive> void serialize(Archive&& ar) { ar& m_value; } private: ADM_return_t m_value; }; Loading
src/common/net/CMakeLists.txt +1 −1 Original line number Diff line number Diff line Loading @@ -35,7 +35,7 @@ set_property(TARGET _rpc_client PROPERTY POSITION_INDEPENDENT_CODE ON) add_library(_rpc_server STATIC) target_sources( _rpc_server INTERFACE server.hpp INTERFACE server.hpp request.hpp PRIVATE server.cpp ) Loading
src/common/net/request.hpp 0 → 100644 +74 −0 Original line number Diff line number Diff line /****************************************************************************** * Copyright 2021-2023, Barcelona Supercomputing Center (BSC), Spain * * This software was partially supported by the EuroHPC-funded project ADMIRE * (Project ID: 956748, https://www.admire-eurohpc.eu). * * This file is part of scord. * * scord is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * scord is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with scord. If not, see <https://www.gnu.org/licenses/>. * * SPDX-License-Identifier: GPL-3.0-or-later *****************************************************************************/ #ifndef SCORD_NET_REQUEST_HPP #define SCORD_NET_REQUEST_HPP #include <thallium.hpp> #include "admire_types.hpp" namespace scord::network { using request = thallium::request; template <typename Request> inline std::string get_address(Request&& req) { return std::forward<Request>(req).get_endpoint(); } class generic_response { public: constexpr generic_response() noexcept = default; constexpr generic_response(std::uint64_t op_id, admire::error_code ec) noexcept : m_op_id(op_id), m_error_code(ec) {} constexpr std::uint64_t op_id() const noexcept { return m_op_id; } constexpr admire::error_code error_code() const noexcept { return m_error_code; } template <typename Archive> constexpr void serialize(Archive&& ar) { ar& m_op_id; ar& m_error_code; } private: std::uint64_t m_op_id; admire::error_code m_error_code; }; } // namespace scord::network #endif // SCORD_NET_REQUEST_HPP
src/lib/admire.cpp +0 −1 Original line number Diff line number Diff line Loading @@ -23,7 +23,6 @@ *****************************************************************************/ #include <admire.hpp> #include <net/engine.hpp> #include <net/proto/rpc_types.h> #include <logger/logger.hpp> #include <utils/ctype_ptr.hpp> Loading
src/lib/detail/impl.cpp +7 −4 Original line number Diff line number Diff line Loading @@ -181,7 +181,8 @@ ping(const server& srv) { const auto rpc_id = ::api::remote_procedure::new_id(); if(const auto lookup_rv = rpc_client.lookup(srv.address()); lookup_rv) { if(const auto lookup_rv = rpc_client.lookup(srv.address()); lookup_rv.has_value()) { const auto& endp = lookup_rv.value(); LOGGER_INFO("rpc id: {} name: {} from: {} => " Loading @@ -189,17 +190,19 @@ ping(const server& srv) { rpc_id, std::quoted("ADM_"s + __FUNCTION__), std::quoted(rpc_client.self_address().value_or("unknown"))); if(const auto call_rv = endp.call("ADM_"s + __FUNCTION__); call_rv) { if(const auto call_rv = endp.call("ADM_"s + __FUNCTION__); call_rv.has_value()) { const scord::network::generic_response resp{call_rv.value()}; LOGGER_INFO("rpc id: {} name: {} from: {} <= " LOGGER_EVAL(resp.error_code(), INFO, ERROR, "rpc id: {} name: {} from: {} <= " "body: {{retval: {}}} [op_id: {}]", rpc_id, std::quoted("ADM_"s + __FUNCTION__), std::quoted(endp.address()), resp.error_code(), resp.op_id()); return admire::error_code::success; return resp.error_code(); } } Loading