Verified Commit acc51766 authored by Alberto Miranda's avatar Alberto Miranda ♨️
Browse files

Add RPC examples

parent 99689b71
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -118,6 +118,8 @@ set(SCORD_BIND_PORT
)
message(STATUS "[${PROJECT_NAME}] server bind port: ${SCORD_BIND_PORT}")

option(SCORD_BUILD_EXAMPLES "Build examples (disabled by default)" OFF)

set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

# ##############################################################################
@@ -188,3 +190,7 @@ FetchContent_MakeAvailable(spdlog)
# ##############################################################################
add_subdirectory(etc)
add_subdirectory(src)

if(SCORD_BUILD_EXAMPLES)
  add_subdirectory(examples)
endif()
+28 −0
Original line number Diff line number Diff line
################################################################################
# Copyright 2021, 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                                    #
################################################################################

add_executable(ping)
target_sources(ping PRIVATE ping.cpp)

target_link_libraries(ping PUBLIC network_engine fmt::fmt)

examples/ping.cpp

0 → 100644
+47 −0
Original line number Diff line number Diff line
/******************************************************************************
 * Copyright 2021, 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
 *****************************************************************************/

#include <fmt/format.h>
#include <engine.hpp>

int
main(int argc, char* argv[]) {

    if(argc != 2) {
        fmt::print(stderr, "ERROR: no server address provided\n");
        fmt::print(stderr, "Usage: ping <SERVER_ADDRESS>\n");
        exit(EXIT_FAILURE);
    }

    scord::network::rpc_client rpc_client{"tcp"};
    rpc_client.register_rpcs();

    auto endp = rpc_client.lookup(argv[1]);

    fmt::print(stdout, "Calling PING remote procedure on {}...\n", argv[1]);

    endp.call("ping");

    fmt::print(stdout, "PING remote procedure completed successfully\n");
}