diff --git a/.github/workflows/reusable/cached-install/action.yml b/.github/workflows/reusable/cached-install/action.yml index 70dec94..f209a59 100644 --- a/.github/workflows/reusable/cached-install/action.yml +++ b/.github/workflows/reusable/cached-install/action.yml @@ -6,18 +6,18 @@ runs: steps: - name: cache homedir id: cache-homedir - uses: actions/cache@v4 + uses: actions/cache/restore@v4 with: key: cache-homedir-${{ hashFiles('./vcpkg.json') }} path: | - ~/.cache + ~/.cache/vcpkg/archives - name: cache vcpkg installed id: cache-vcpkg-installed - uses: actions/cache@v4 + uses: actions/cache/restore@v4 with: key: cache-vcpkg-installed-${{ hashFiles('./vcpkg.json') }} path: | - **/vcpkg_installed + ./build/vcpkg_installed - name: install-prerequisities run: source install-prerequisities.sh @@ -26,3 +26,20 @@ runs: run: ./install.sh shell: bash + - name: cache homedir save + id: cache-homedir-save + if: always() + uses: actions/cache/save@v4 + with: + key: cache-homedir-${{ hashFiles('./vcpkg.json') }} + path: | + ~/.cache/vcpkg/archives + - name: cache vcpkg installed save + id: cache-vcpkg-installed-save + if: always() + uses: actions/cache/save@v4 + with: + key: cache-vcpkg-installed-${{ hashFiles('./vcpkg.json') }} + path: | + ./build/vcpkg_installed + diff --git a/.gitignore b/.gitignore index cad7536..b856620 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ vcpkg_installed .vscode .trunk setenvs.sh +*.DS_Store* \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index cc371f8..4f7c4ac 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,11 @@ cmake_minimum_required(VERSION 3.22) +set(CMAKE_POLICY_DEFAULT_CMP0077 NEW) + +set(VCPKG_MANIFEST_INSTALL OFF) +set(VCPKG_INSTALLED_DIR ${CMAKE_CURRENT_SOURCE_DIR}/build/vcpkg_installed) + + +set (VCPKG_OVERLAY_TRIPLETS ENV{VCPKG_OVERLAY_TRIPLETS}) set(CMAKE_CXX_STANDARD 26) include(homebrewClang.cmake) diff --git a/clangd-tidy b/clangd-tidy index 4cbc11f..c827cc0 160000 --- a/clangd-tidy +++ b/clangd-tidy @@ -1 +1 @@ -Subproject commit 4cbc11f85a2b07317181709f9c1cae6da60c683b +Subproject commit c827cc0d69221dd0f3049b99402cbe9ed3d266c5 diff --git a/clean.sh b/clean.sh index d7ad407..007ae6f 100755 --- a/clean.sh +++ b/clean.sh @@ -1,5 +1,7 @@ #!/bin/bash +rm -rf ~/.cache/vcpkg + # Parse MonorepoPackages.cmake and loop through them for package in $(cat MonorepoPackages.cmake | grep -v "set(MonorepoPackages" | grep -v ")"); do cd packages/$package/build && ls -A | while read FILE; do echo "\"$FILE\""; done | grep -v ".gitignore" | xargs rm -rf && cd ../../.. diff --git a/homebrewClang.cmake b/homebrewClang.cmake index 41e7cac..7fb0426 100644 --- a/homebrewClang.cmake +++ b/homebrewClang.cmake @@ -1,7 +1,7 @@ if (${APPLE}) set(HOMEBREW_PREFIX $ENV{HOMEBREW_PREFIX}) - set(LLVM_PREFIX "${HOMEBREW_PREFIX}/opt/llvm") + set(LLVM_PREFIX "${HOMEBREW_PREFIX}") set(CMAKE_C_COMPILER "${LLVM_PREFIX}/bin/clang") set(CMAKE_CXX_COMPILER "${LLVM_PREFIX}/bin/clang++") set(ENV{CC} "${CMAKE_C_COMPILER}") @@ -20,7 +20,7 @@ if (${APPLE}) set(CMAKE_FIND_FRAMEWORK LAST) set(CMAKE_FIND_APPBUNDLE LAST) - add_link_options("-L/opt/homebrew/opt/llvm/lib/c++" "-Wl,-rpath,/opt/homebrew/opt/llvm/lib/c++") + add_link_options("-L/opt/homebrew/lib/c++" "-Wl,-rpath,/opt/homebrew/lib/c++") #set(CMAKE_FIND_USE_CMAKE_SYSTEM_PATH FALSE) #set(CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH FALSE) endif() diff --git a/install-prerequisities.sh b/install-prerequisities.sh index a5d38d1..b95a0a7 100644 --- a/install-prerequisities.sh +++ b/install-prerequisities.sh @@ -13,16 +13,19 @@ if [[ "$OSTYPE" == "darwin"* ]]; then xcode-select --install brew install jq - brew install llvm + brew uninstall llvm + brew install llvm@17 brew install cmake brew install pkg-config - rm -f $HOMEBREW_PREFIX/bin/clang-format - rm -f $HOMEBREW_PREFIX/bin/clangd - rm -f $HOMEBREW_PREFIX/bin/lldb - ln -s $HOMEBREW_PREFIX/opt/llvm/bin/clang-format $HOMEBREW_PREFIX/bin/clang-format - ln -s $HOMEBREW_PREFIX/opt/llvm/bin/clangd $HOMEBREW_PREFIX/bin/clangd - ln -s $HOMEBREW_PREFIX/opt/llvm/bin/lldb $HOMEBREW_PREFIX/bin/lldb + brew link --overwrite --force llvm@17 + #rm -f $HOMEBREW_PREFIX/bin/clang-format + #rm -f $HOMEBREW_PREFIX/bin/clangd + #rm -f $HOMEBREW_PREFIX/bin/lldb + #ln -s $HOMEBREW_PREFIX/bin/clang-format $HOMEBREW_PREFIX/bin/clang-format + #ln -s $HOMEBREW_PREFIX/bin/clangd $HOMEBREW_PREFIX/bin/clangd + #ln -s $HOMEBREW_PREFIX/bin/lldb $HOMEBREW_PREFIX/bin/lldb + rm -f $HOMEBREW_PREFIX/bin/clang-tidy else @@ -59,6 +62,16 @@ if [[ -n "$GITHUB_ENV" ]]; then echo "VCPKG_ROOT=$VCPKG_ROOT" >> $GITHUB_ENV fi +export VCPKG_OVERLAY_TRIPLETS=$(pwd)/overlaytriplets +if [[ -n "$GITHUB_ENV" ]]; then + echo "VCPKG_OVERLAY_TRIPLETS=$VCPKG_OVERLAY_TRIPLETS" >> $GITHUB_ENV +fi + +export VCPKG_OVERLAY_PORTS=$(pwd)/overlayports +if [[ -n "$GITHUB_ENV" ]]; then + echo "VCPKG_OVERLAY_PORTS=$VCPKG_OVERLAY_PORTS" >> $GITHUB_ENV +fi + if [[ ":$PATH:" != *":$VCPKG_ROOT:"* ]]; then export PATH=$PATH:$VCPKG_ROOT if [[ -n "$GITHUB_PATH" ]]; then @@ -72,6 +85,12 @@ TEMP_PROFILE_CONTENTS+="export VCPKG_ROOT=$(pwd)/vcpkg\n" # Add PATH environment variable to include VCPKG_ROOT TEMP_PROFILE_CONTENTS+="export PATH=\$VCPKG_ROOT:\$PATH\n" +# Add VCPKG_OVERLAY_TRIPLETS environment variable +TEMP_PROFILE_CONTENTS+="export VCPKG_OVERLAY_TRIPLETS=$(pwd)/overlaytriplets\n" + +# Add VCPKG_OVERLAY_PORTS environment variable +TEMP_PROFILE_CONTENTS+="export VCPKG_OVERLAY_PORTS=$(pwd)/overlayports\n" + echo $TEMP_PROFILE_CONTENTS touch $PROFILE_FILE diff --git a/install.sh b/install.sh index 71cc63c..32f62f1 100755 --- a/install.sh +++ b/install.sh @@ -1,5 +1,19 @@ #!/bin/bash +set -e + +# Check if VCPKG_ROOT is set and points to the correct directory +if [ -z "$VCPKG_ROOT" ]; then + echo "Error: VCPKG_ROOT is not set. Please run 'source install-prerequisities.sh' or 'source setenvs.sh' before running this script." + exit 1 +fi + +EXPECTED_VCPKG_ROOT="$(pwd)/vcpkg" +if [ "$VCPKG_ROOT" != "$EXPECTED_VCPKG_ROOT" ]; then + echo "Error: VCPKG_ROOT points to the vcpkg of another project '$VCPKG_ROOT'. Please run 'source install-prerequisities.sh' or 'source setenvs.sh' before running this script." + exit 1 +fi + # Parse command-line options PROD_BUILD=false @@ -21,6 +35,8 @@ fi git config core.hooksPath .githooks ./merge-dependencies.sh +vcpkg install --x-install-root=build/vcpkg_installed + # Call build for all monorepo packages in their own build directories for package in $(cat MonorepoPackages.cmake | grep -v "set(MonorepoPackages" | grep -v ")"); do cd packages/$package/build && cmake -DCMAKE_BUILD_TYPE=$BUILD_TYPE .. && cmake --build . && cd ../../.. @@ -29,3 +45,4 @@ done # Call build for the root project echo "Building root project" cd build && cmake -DCMAKE_BUILD_TYPE=$BUILD_TYPE .. && cmake --build . && cd .. + diff --git a/lint.sh b/lint.sh index 2c15d1e..66aa64b 100755 --- a/lint.sh +++ b/lint.sh @@ -2,7 +2,7 @@ set -e -FILES=$(find ./packages -type d \( -name src -o -name include -o -name test \) ! -path '*/build/*' -print0 | xargs -0 -I{} find {} -type f \( -name "*.hpp" -o -name "*.cpp" \) -print0 | xargs -0 echo) +FILES=$(find ./packages -type d \( -name src -o -name include -o -name test \) ! -path '*/build/*' ! -path '*/proto/*' -print0 | xargs -0 -I{} find {} -type f \( -name "*.hpp" -o -name "*.cpp" \) -print0 | xargs -0 echo) echo "Running clangd-tidy on $FILES" ./clangd-tidy/clangd-tidy -p ./build $FILES diff --git a/overlayports/magic-enum/portfile.cmake b/overlayports/magic-enum/portfile.cmake new file mode 100644 index 0000000..15c3bf4 --- /dev/null +++ b/overlayports/magic-enum/portfile.cmake @@ -0,0 +1,27 @@ +vcpkg_from_github( + OUT_SOURCE_PATH SOURCE_PATH + REPO Neargye/magic_enum + REF "v${VERSION}" + SHA512 fa3792e9c69c57e437d6325b7659cf25e6cbdda3326ffeaf0411d9838822095b15306f322ad2ebd5ec68b905ef2aed08880d2507e7d8a8559ab3c5be6c8ce99c + HEAD_REF master +) + +set(VCPKG_BUILD_TYPE release) # header-only port + +vcpkg_cmake_configure( + SOURCE_PATH "${SOURCE_PATH}" + OPTIONS + -DMAGIC_ENUM_OPT_BUILD_EXAMPLES=OFF + -DMAGIC_ENUM_OPT_BUILD_TESTS=OFF + -DMAGIC_ENUM_OPT_INSTALL=ON +) + +vcpkg_cmake_install() + +vcpkg_cmake_config_fixup(CONFIG_PATH lib/cmake/magic_enum PACKAGE_NAME magic_enum) + +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/lib") + +# Handle copyright +configure_file("${SOURCE_PATH}/LICENSE" "${CURRENT_PACKAGES_DIR}/share/${PORT}/copyright" COPYONLY) +file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}") diff --git a/overlayports/magic-enum/usage b/overlayports/magic-enum/usage new file mode 100644 index 0000000..3d3a94b --- /dev/null +++ b/overlayports/magic-enum/usage @@ -0,0 +1,4 @@ +magic-enum provides CMake targets: + + find_package(magic_enum CONFIG REQUIRED) + target_link_libraries(main PRIVATE magic_enum::magic_enum) diff --git a/overlayports/magic-enum/vcpkg.json b/overlayports/magic-enum/vcpkg.json new file mode 100644 index 0000000..806f787 --- /dev/null +++ b/overlayports/magic-enum/vcpkg.json @@ -0,0 +1,17 @@ +{ + "name": "magic-enum", + "version": "0.9.6", + "description": "Header-only C++17 library provides static reflection for enums, work with any enum type without any macro or boilerplate code.", + "homepage": "https://github.com/Neargye/magic_enum", + "license": "MIT", + "dependencies": [ + { + "name": "vcpkg-cmake", + "host": true + }, + { + "name": "vcpkg-cmake-config", + "host": true + } + ] +} diff --git a/overlaytriplets/arm64-ios.cmake b/overlaytriplets/arm64-ios.cmake new file mode 100644 index 0000000..b3bbab0 --- /dev/null +++ b/overlaytriplets/arm64-ios.cmake @@ -0,0 +1,20 @@ +set(VCPKG_TARGET_ARCHITECTURE arm64) +set(VCPKG_CRT_LINKAGE dynamic) +set(VCPKG_LIBRARY_LINKAGE static) +set(VCPKG_CMAKE_SYSTEM_NAME iOS) + +set(CMAKE_CXX_STANDARD 26) +set(HOMEBREW_PREFIX $ENV{HOMEBREW_PREFIX}) + +set(LLVM_PREFIX "${HOMEBREW_PREFIX}") +set(CMAKE_C_COMPILER "${LLVM_PREFIX}/bin/clang") +set(CMAKE_CXX_COMPILER "${LLVM_PREFIX}/bin/clang++") +set(ENV{CC} "${CMAKE_C_COMPILER}") +set(ENV{CXX} "${CMAKE_CXX_COMPILER}") + +set(VCPKG_CMAKE_CONFIGURE_OPTIONS -DCMAKE_C_COMPILER=${LLVM_PREFIX}/bin/clang -DCMAKE_CXX_COMPILER=${LLVM_PREFIX}/bin/clang++ -DCMAKE_CXX_STANDARD=26 -DGFLAGS_INTTYPES_FORMAT=C99 -DBUILD_gflags_LIB=OFF -DBUILD_gflags_nothreads_LIB=ON) + +set(VCPKG_CXX_FLAGS "-isystem /opt/homebrew/include/c++/v1") +set(VCPKG_C_FLAGS "-isystem /opt/homebrew/include/c++/v1") +set(VCPKG_LINKER_FLAGS "-L/opt/homebrew/lib/c++ -Wl,-rpath,/opt/homebrew/lib/c++") + diff --git a/overlaytriplets/arm64-osx.cmake b/overlaytriplets/arm64-osx.cmake new file mode 100644 index 0000000..0e2113f --- /dev/null +++ b/overlaytriplets/arm64-osx.cmake @@ -0,0 +1,23 @@ +set(VCPKG_TARGET_ARCHITECTURE arm64) +set(VCPKG_CRT_LINKAGE dynamic) +set(VCPKG_LIBRARY_LINKAGE static) + +set(VCPKG_CMAKE_SYSTEM_NAME Darwin) +set(VCPKG_OSX_ARCHITECTURES arm64) + +set(CMAKE_CXX_STANDARD 26) +set(HOMEBREW_PREFIX $ENV{HOMEBREW_PREFIX}) + +set(LLVM_PREFIX "${HOMEBREW_PREFIX}") +set(CMAKE_C_COMPILER "${LLVM_PREFIX}/bin/clang") +set(CMAKE_CXX_COMPILER "${LLVM_PREFIX}/bin/clang++") +set(ENV{CC} "${CMAKE_C_COMPILER}") +set(ENV{CXX} "${CMAKE_CXX_COMPILER}") + +set(VCPKG_CMAKE_CONFIGURE_OPTIONS -DCMAKE_C_COMPILER=${LLVM_PREFIX}/bin/clang -DCMAKE_CXX_COMPILER=${LLVM_PREFIX}/bin/clang++ -DCMAKE_CXX_STANDARD=26) + +set(VCPKG_CXX_FLAGS "-isystem /opt/homebrew/include/c++/v1") +set(VCPKG_C_FLAGS "-isystem /opt/homebrew/include/c++/v1") +set(VCPKG_LINKER_FLAGS "-L/opt/homebrew/lib/c++ -Wl,-rpath,/opt/homebrew/lib/c++") + +message(STATUS "OVERLAY TRIPLET arm64-osx loaded") diff --git a/overlaytriplets/x64-linux.cmake b/overlaytriplets/x64-linux.cmake new file mode 100644 index 0000000..ee0f63b --- /dev/null +++ b/overlaytriplets/x64-linux.cmake @@ -0,0 +1,12 @@ +set(VCPKG_TARGET_ARCHITECTURE x64) +set(VCPKG_CRT_LINKAGE dynamic) +set(VCPKG_LIBRARY_LINKAGE static) + +set(VCPKG_CMAKE_SYSTEM_NAME Linux) + +if(${PORT} MATCHES "folly") + message(STATUS "Port name is folly, setting build type to release") + set(VCPKG_BUILD_TYPE release) +endif() + +message(STATUS "OVERLAY TRIPLET x64-linux loaded") diff --git a/overlaytriplets/x64-osx.cmake b/overlaytriplets/x64-osx.cmake new file mode 100644 index 0000000..9fbd114 --- /dev/null +++ b/overlaytriplets/x64-osx.cmake @@ -0,0 +1,23 @@ +set(VCPKG_TARGET_ARCHITECTURE x64) +set(VCPKG_CRT_LINKAGE dynamic) +set(VCPKG_LIBRARY_LINKAGE static) + +set(VCPKG_CMAKE_SYSTEM_NAME Darwin) +set(VCPKG_OSX_ARCHITECTURES x86_64) + +set(CMAKE_CXX_STANDARD 26) +set(HOMEBREW_PREFIX $ENV{HOMEBREW_PREFIX}) + +set(LLVM_PREFIX "${HOMEBREW_PREFIX}") +set(CMAKE_C_COMPILER "${LLVM_PREFIX}/bin/clang") +set(CMAKE_CXX_COMPILER "${LLVM_PREFIX}/bin/clang++") +set(ENV{CC} "${CMAKE_C_COMPILER}") +set(ENV{CXX} "${CMAKE_CXX_COMPILER}") + +set(VCPKG_CMAKE_CONFIGURE_OPTIONS -DCMAKE_C_COMPILER=${LLVM_PREFIX}/bin/clang -DCMAKE_CXX_COMPILER=${LLVM_PREFIX}/bin/clang++ -DCMAKE_CXX_STANDARD=26) + +set(VCPKG_CXX_FLAGS "-isystem /opt/homebrew/include/c++/v1") +set(VCPKG_C_FLAGS "-isystem /opt/homebrew/include/c++/v1") +set(VCPKG_LINKER_FLAGS "-L/opt/homebrew/lib/c++ -Wl,-rpath,/opt/homebrew/lib/c++") + +message(STATUS "OVERLAY TRIPLET x64-osx loaded") diff --git a/packages/streamr-eventemitter/homebrewClang.cmake b/packages/streamr-eventemitter/homebrewClang.cmake index 41e7cac..7fb0426 100644 --- a/packages/streamr-eventemitter/homebrewClang.cmake +++ b/packages/streamr-eventemitter/homebrewClang.cmake @@ -1,7 +1,7 @@ if (${APPLE}) set(HOMEBREW_PREFIX $ENV{HOMEBREW_PREFIX}) - set(LLVM_PREFIX "${HOMEBREW_PREFIX}/opt/llvm") + set(LLVM_PREFIX "${HOMEBREW_PREFIX}") set(CMAKE_C_COMPILER "${LLVM_PREFIX}/bin/clang") set(CMAKE_CXX_COMPILER "${LLVM_PREFIX}/bin/clang++") set(ENV{CC} "${CMAKE_C_COMPILER}") @@ -20,7 +20,7 @@ if (${APPLE}) set(CMAKE_FIND_FRAMEWORK LAST) set(CMAKE_FIND_APPBUNDLE LAST) - add_link_options("-L/opt/homebrew/opt/llvm/lib/c++" "-Wl,-rpath,/opt/homebrew/opt/llvm/lib/c++") + add_link_options("-L/opt/homebrew/lib/c++" "-Wl,-rpath,/opt/homebrew/lib/c++") #set(CMAKE_FIND_USE_CMAKE_SYSTEM_PATH FALSE) #set(CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH FALSE) endif() diff --git a/packages/streamr-eventemitter/include/streamr-eventemitter/EventEmitter.hpp b/packages/streamr-eventemitter/include/streamr-eventemitter/EventEmitter.hpp index bd1bc99..670e7f7 100644 --- a/packages/streamr-eventemitter/include/streamr-eventemitter/EventEmitter.hpp +++ b/packages/streamr-eventemitter/include/streamr-eventemitter/EventEmitter.hpp @@ -51,12 +51,11 @@ struct Event { }; template -concept MatchingEventType = std::is_same::value; +concept MatchingEventType = std::is_same_v; template -concept MatchingCallbackType = - std::is_assignable:: - value; +concept MatchingCallbackType = std:: + is_assignable_v; // Immutable reference to a Handler. // This is needed because there is no way of checking the validity diff --git a/packages/streamr-eventemitter/monorepoPackage.cmake b/packages/streamr-eventemitter/monorepoPackage.cmake index 3df1f3b..58c93b9 100644 --- a/packages/streamr-eventemitter/monorepoPackage.cmake +++ b/packages/streamr-eventemitter/monorepoPackage.cmake @@ -1,7 +1,14 @@ +set(CMAKE_POLICY_DEFAULT_CMP0077 NEW) if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/../../MonorepoPackages.cmake) message(STATUS "In monorepo sub-package ${CMAKE_CURRENT_SOURCE_DIR}") - + + # if in monorepo, do not install vcpkg dependencies + set(VCPKG_MANIFEST_INSTALL OFF) + + # if in monorepo, use the vcpkg dependencies from the monorepo root + set(VCPKG_INSTALLED_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../build/vcpkg_installed) + # if in monorepo, use the monorepo deps from filesystem if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/vcpkg.json) file(READ ${CMAKE_CURRENT_SOURCE_DIR}/vcpkg.json VCPKG_JSON) diff --git a/packages/streamr-eventemitter/test/unit/EventEmitterTest.cpp b/packages/streamr-eventemitter/test/unit/EventEmitterTest.cpp index 35e8c7b..2d40ba6 100644 --- a/packages/streamr-eventemitter/test/unit/EventEmitterTest.cpp +++ b/packages/streamr-eventemitter/test/unit/EventEmitterTest.cpp @@ -98,11 +98,11 @@ TEST_F(EventEmitterTest, TestListenerCount) { EventEmitter eventEmitter; eventEmitter.on([](std::string_view message) -> void { - std::cout << "listener1: " << message << std::endl; + std::cout << "listener1: " << message << '\n'; }); eventEmitter.on([](std::string_view message) -> void { - std::cout << "listener2: " << message << std::endl; + std::cout << "listener2: " << message << '\n'; }); ASSERT_EQ(eventEmitter.listenerCount(), 2); @@ -115,11 +115,11 @@ TEST_F(EventEmitterTest, TestOff) { EventEmitter eventEmitter; auto listener1 = [](std::string_view message) -> void { - std::cout << "listener1: " << message << std::endl; + std::cout << "listener1: " << message << '\n'; }; auto listener2 = [](std::string_view message) -> void { - std::cout << "listener2: " << message << std::endl; + std::cout << "listener2: " << message << '\n'; }; auto listener1Reference = eventEmitter.on(listener1); @@ -158,11 +158,11 @@ TEST_F(EventEmitterTest, TestRemoveAllListeners) { EventEmitter eventEmitter; auto listener1 = [](std::string_view message) -> void { - std::cout << "listener1: " << message << std::endl; + std::cout << "listener1: " << message << '\n'; }; auto listener2 = [](std::string_view message) -> void { - std::cout << "listener2: " << message << std::endl; + std::cout << "listener2: " << message << '\n'; }; eventEmitter.on(listener1); @@ -183,11 +183,11 @@ TEST_F(EventEmitterTest, TestRemoveAllListenersWithoutEventType) { EventEmitter eventEmitter; auto listener1 = [](std::string_view message) -> void { - std::cout << "listener1: " << message << std::endl; + std::cout << "listener1: " << message << '\n'; }; auto listener2 = [](std::string_view message) -> void { - std::cout << "listener2: " << message << std::endl; + std::cout << "listener2: " << message << '\n'; }; eventEmitter.on(listener1); @@ -234,7 +234,7 @@ TEST_F(EventEmitterTest, TestOffCalledTwice) { EventEmitter eventEmitter; auto listener1 = [](std::string_view message) -> void { - std::cout << "listener1: " << message << std::endl; + std::cout << "listener1: " << message << '\n'; }; auto listener1Reference = eventEmitter.on(listener1); @@ -359,7 +359,7 @@ TEST_F(EventEmitterTest, EventsAreReceivedInOrderEvenIfListenersAreSlow) { &listenerBEventOrderMutex, &listenerBEventOrder](int eventNum) -> void { if (eventNum == 1) { - std::cout << "event1 arrived at listener B" << std::endl; + std::cout << "event1 arrived at listener B" << '\n'; std::lock_guard lock(listenerBEventOrderMutex); listenerBEventOrder.push_back(eventNum); promiseB1.set_value(); @@ -367,7 +367,7 @@ TEST_F(EventEmitterTest, EventsAreReceivedInOrderEvenIfListenersAreSlow) { // Without mutex lock, this event will arrive first // because there is a long delay for the firt event // at listenerA - std::cout << "event2 arrived at listener B" << std::endl; + std::cout << "event2 arrived at listener B" << '\n'; std::lock_guard lock(listenerBEventOrderMutex); listenerBEventOrder.push_back(eventNum); promiseB2.set_value(); diff --git a/packages/streamr-json/homebrewClang.cmake b/packages/streamr-json/homebrewClang.cmake index 41e7cac..7fb0426 100644 --- a/packages/streamr-json/homebrewClang.cmake +++ b/packages/streamr-json/homebrewClang.cmake @@ -1,7 +1,7 @@ if (${APPLE}) set(HOMEBREW_PREFIX $ENV{HOMEBREW_PREFIX}) - set(LLVM_PREFIX "${HOMEBREW_PREFIX}/opt/llvm") + set(LLVM_PREFIX "${HOMEBREW_PREFIX}") set(CMAKE_C_COMPILER "${LLVM_PREFIX}/bin/clang") set(CMAKE_CXX_COMPILER "${LLVM_PREFIX}/bin/clang++") set(ENV{CC} "${CMAKE_C_COMPILER}") @@ -20,7 +20,7 @@ if (${APPLE}) set(CMAKE_FIND_FRAMEWORK LAST) set(CMAKE_FIND_APPBUNDLE LAST) - add_link_options("-L/opt/homebrew/opt/llvm/lib/c++" "-Wl,-rpath,/opt/homebrew/opt/llvm/lib/c++") + add_link_options("-L/opt/homebrew/lib/c++" "-Wl,-rpath,/opt/homebrew/lib/c++") #set(CMAKE_FIND_USE_CMAKE_SYSTEM_PATH FALSE) #set(CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH FALSE) endif() diff --git a/packages/streamr-json/include/streamr-json/jsonConcepts.hpp b/packages/streamr-json/include/streamr-json/jsonConcepts.hpp index 4e3a2c5..c402da5 100644 --- a/packages/streamr-json/include/streamr-json/jsonConcepts.hpp +++ b/packages/streamr-json/include/streamr-json/jsonConcepts.hpp @@ -1,19 +1,21 @@ #ifndef STREAMR_JSON_JSONCONCEPTS_HPP #define STREAMR_JSON_JSONCONCEPTS_HPP -#include #include #include namespace streamr::json { +namespace suppresslint { // linter does not support concepts, and thinks this + // file is unused +using SuppressLint = void; +} // namespace suppresslint template -concept AssignableToNlohmannJson = - std::is_assignable::value; +concept AssignableToNlohmannJson = std::is_assignable_v; template -concept NotAssignableToNlohmannJson = - !std::is_assignable::value; +concept NotAssignableToNlohmannJson = !std::is_assignable_v; + template concept PointerLike = std::is_pointer_v || requires(Ptr p) { { *p }; @@ -52,8 +54,8 @@ concept InitializerList = requires(T) { template concept IterableType = requires(T container) { requires std::ranges::range; - requires(not std::is_same::value); - requires(not std::is_same::value); + requires(not std::is_same_v); + requires(not std::is_same_v); requires(not AssociativeType); requires(not AssignableToNlohmannJson); requires(not PointerType); diff --git a/packages/streamr-json/include/streamr-json/toJson.hpp b/packages/streamr-json/include/streamr-json/toJson.hpp index 8c96f0d..8b3431d 100644 --- a/packages/streamr-json/include/streamr-json/toJson.hpp +++ b/packages/streamr-json/include/streamr-json/toJson.hpp @@ -12,9 +12,9 @@ #include #include "streamr-json/jsonConcepts.hpp" - namespace streamr::json { - +using suppresslint::SuppressLint; // otherwise linter thinks jsonConcepts.hpp + // is unused using json = nlohmann::json; using JsonInitializerList = nlohmann::json::initializer_list_t; @@ -227,7 +227,7 @@ class JsonBuilder { template concept AssignableToJsonBuilder = - std::is_same, T>::value; + std::is_same_v, T>; /** * @brief Specialization to initializer_lists. The initializer lists should be diff --git a/packages/streamr-json/include/streamr-json/toString.hpp b/packages/streamr-json/include/streamr-json/toString.hpp index a450bc7..a195d91 100644 --- a/packages/streamr-json/include/streamr-json/toString.hpp +++ b/packages/streamr-json/include/streamr-json/toString.hpp @@ -5,12 +5,13 @@ * Convert (almost) any struct to string in C++20. **/ -// #include "streamr-json/JsonBuilder.hpp" #include "streamr-json/jsonConcepts.hpp" #include "streamr-json/toJson.hpp" namespace streamr::json { +using suppresslint::SuppressLint; // otherwise linter thinks jsonConcepts.hpp + // is unused template concept TypeWithToString = requires(T obj) { { obj.toString() } -> std::same_as; diff --git a/packages/streamr-json/monorepoPackage.cmake b/packages/streamr-json/monorepoPackage.cmake index 3df1f3b..58c93b9 100644 --- a/packages/streamr-json/monorepoPackage.cmake +++ b/packages/streamr-json/monorepoPackage.cmake @@ -1,7 +1,14 @@ +set(CMAKE_POLICY_DEFAULT_CMP0077 NEW) if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/../../MonorepoPackages.cmake) message(STATUS "In monorepo sub-package ${CMAKE_CURRENT_SOURCE_DIR}") - + + # if in monorepo, do not install vcpkg dependencies + set(VCPKG_MANIFEST_INSTALL OFF) + + # if in monorepo, use the vcpkg dependencies from the monorepo root + set(VCPKG_INSTALLED_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../build/vcpkg_installed) + # if in monorepo, use the monorepo deps from filesystem if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/vcpkg.json) file(READ ${CMAKE_CURRENT_SOURCE_DIR}/vcpkg.json VCPKG_JSON) diff --git a/packages/streamr-json/src/examples/JsonExample.cpp b/packages/streamr-json/src/examples/JsonExample.cpp index f4b675e..ce1aa68 100644 --- a/packages/streamr-json/src/examples/JsonExample.cpp +++ b/packages/streamr-json/src/examples/JsonExample.cpp @@ -53,20 +53,20 @@ int main() { nlohmann::json json = toJson(s); // outputs: {"x":1,"y":"hello"} - std::cout << json << std::endl; + std::cout << json << '\n'; // Converting an initializer list containing a struct to a json object nlohmann::json json2 = toJson({{"data", s}}); // outputs: {"data":{"x":1,"y":"hello"}} - std::cout << json2 << std::endl; + std::cout << json2 << '\n'; // Converting struct to a string std::string str = toString(s); // outputs: {"x":1,"y":"hello"} - std::cout << str << std::endl; + std::cout << str << '\n'; // Calling a template function that forwards parameters to toJson() // Only works if the template function has the right default type parameter @@ -77,12 +77,12 @@ int main() { ClassWithPrivateSection c{1, "hello"}; nlohmann::json json3 = toJson(c); // outputs: {"data":1,"name":"hello"} - std::cout << json3 << std::endl; + std::cout << json3 << '\n'; // Converting a class with a private section to a string std::string str2 = toString(c); // outputs: {"data":1,"name":"hello"} - std::cout << str2 << std::endl; + std::cout << str2 << '\n'; return 0; } \ No newline at end of file diff --git a/packages/streamr-logger/README.md b/packages/streamr-logger/README.md index 283d445..8b025c8 100644 --- a/packages/streamr-logger/README.md +++ b/packages/streamr-logger/README.md @@ -51,9 +51,15 @@ logger.info("Hello, world!"); Logging with metadata given as JSON that contains a struct ```cpp +<<<<<<< HEAD +#include + +using Logger = streamr::logger::Logger; +======= #include using SLogger = streamr::logger::SLogger; +>>>>>>> module1 struct MyDataStruct { std::string name; @@ -61,7 +67,11 @@ struct MyDataStruct { }; auto data = MyDataStruct{"count", 9}; +<<<<<<< HEAD +Logger::instance().info("Program state", {{"data", data}}); +======= SLogger::info("Program state", {{"data", data}}); +>>>>>>> module1 ``` ## Implementation details diff --git a/packages/streamr-logger/homebrewClang.cmake b/packages/streamr-logger/homebrewClang.cmake index 41e7cac..7fb0426 100644 --- a/packages/streamr-logger/homebrewClang.cmake +++ b/packages/streamr-logger/homebrewClang.cmake @@ -1,7 +1,7 @@ if (${APPLE}) set(HOMEBREW_PREFIX $ENV{HOMEBREW_PREFIX}) - set(LLVM_PREFIX "${HOMEBREW_PREFIX}/opt/llvm") + set(LLVM_PREFIX "${HOMEBREW_PREFIX}") set(CMAKE_C_COMPILER "${LLVM_PREFIX}/bin/clang") set(CMAKE_CXX_COMPILER "${LLVM_PREFIX}/bin/clang++") set(ENV{CC} "${CMAKE_C_COMPILER}") @@ -20,7 +20,7 @@ if (${APPLE}) set(CMAKE_FIND_FRAMEWORK LAST) set(CMAKE_FIND_APPBUNDLE LAST) - add_link_options("-L/opt/homebrew/opt/llvm/lib/c++" "-Wl,-rpath,/opt/homebrew/opt/llvm/lib/c++") + add_link_options("-L/opt/homebrew/lib/c++" "-Wl,-rpath,/opt/homebrew/lib/c++") #set(CMAKE_FIND_USE_CMAKE_SYSTEM_PATH FALSE) #set(CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH FALSE) endif() diff --git a/packages/streamr-logger/include/streamr-logger/Logger.hpp b/packages/streamr-logger/include/streamr-logger/Logger.hpp index 08f0527..e100e13 100644 --- a/packages/streamr-logger/include/streamr-logger/Logger.hpp +++ b/packages/streamr-logger/include/streamr-logger/Logger.hpp @@ -1,7 +1,6 @@ #ifndef STREAMER_LOGGER_LOGGER_HPP #define STREAMER_LOGGER_LOGGER_HPP -#include #include #include #include @@ -185,7 +184,7 @@ class Logger { return element; } if (element.is_null() || - (element.is_string() && element.get() == "")) { + (element.is_string() && element.get().empty())) { return nlohmann::json::object({}); } return nlohmann::json::object({{key, element}}); diff --git a/packages/streamr-logger/monorepoPackage.cmake b/packages/streamr-logger/monorepoPackage.cmake index 3df1f3b..58c93b9 100644 --- a/packages/streamr-logger/monorepoPackage.cmake +++ b/packages/streamr-logger/monorepoPackage.cmake @@ -1,7 +1,14 @@ +set(CMAKE_POLICY_DEFAULT_CMP0077 NEW) if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/../../MonorepoPackages.cmake) message(STATUS "In monorepo sub-package ${CMAKE_CURRENT_SOURCE_DIR}") - + + # if in monorepo, do not install vcpkg dependencies + set(VCPKG_MANIFEST_INSTALL OFF) + + # if in monorepo, use the vcpkg dependencies from the monorepo root + set(VCPKG_INSTALLED_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../build/vcpkg_installed) + # if in monorepo, use the monorepo deps from filesystem if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/vcpkg.json) file(READ ${CMAKE_CURRENT_SOURCE_DIR}/vcpkg.json VCPKG_JSON) diff --git a/packages/streamr-proto-rpc/CMakeLists.txt b/packages/streamr-proto-rpc/CMakeLists.txt index cb77249..f158c7c 100644 --- a/packages/streamr-proto-rpc/CMakeLists.txt +++ b/packages/streamr-proto-rpc/CMakeLists.txt @@ -6,15 +6,137 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON) # makes the current package a monorepo package include(${CMAKE_CURRENT_SOURCE_DIR}/monorepoPackage.cmake) +set (VCPKG_OVERLAY_TRIPLETS ENV{VCPKG_OVERLAY_TRIPLETS}) set(CMAKE_TOOLCHAIN_FILE "$ENV{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake") project(proto-rpc CXX) find_package(streamr-logger CONFIG REQUIRED) -#find_package(streamr-utils CONFIG REQUIRED) +find_package(streamr-eventemitter CONFIG REQUIRED) +find_package(Protobuf REQUIRED) +find_package(Boost CONFIG REQUIRED) +find_package(magic_enum CONFIG REQUIRED) +find_package(folly REQUIRED) -add_executable(proto-rpc src/main.cpp) +if(NOT TARGET Boost::uuid) + add_library(Boost::uuid INTERFACE IMPORTED) + set_target_properties(Boost::uuid PROPERTIES INTERFACE_INCLUDE_DIRECTORIES ${Boost_INCLUDE_DIRS}) +endif() -target_link_libraries(proto-rpc - PRIVATE streamr::streamr-logger) +add_library(streamr-proto-rpc) +set_property(TARGET streamr-proto-rpc PROPERTY CXX_STANDARD 26) +add_library(streamr::streamr-proto-rpc ALIAS streamr-proto-rpc) +target_include_directories(streamr-proto-rpc + PUBLIC $ + PUBLIC $ + PUBLIC $ + ) + +target_sources(streamr-proto-rpc + PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src/proto/ProtoRpc.pb.cc) + +target_link_libraries(streamr-proto-rpc + INTERFACE streamr::streamr-logger + INTERFACE streamr::streamr-eventemitter + PRIVATE protobuf::libprotobuf + PRIVATE protobuf::libprotoc + INTERFACE Boost::uuid + PRIVATE magic_enum::magic_enum + PUBLIC Folly::folly + ) + +add_executable(protobuf-streamr-plugin src/PluginCodeGeneratorMain.cpp include/streamr-proto-rpc/PluginCodeGenerator.hpp) + +target_include_directories( + protobuf-streamr-plugin PRIVATE $ + $) + +target_link_libraries(protobuf-streamr-plugin + PRIVATE protobuf::libprotobuf protobuf::libprotoc) + +enable_testing() +find_package(GTest CONFIG REQUIRED) + +add_library(streamr-proto-rpc-test-main + src/CustomGtestMain.cpp +) + +target_link_libraries(streamr-proto-rpc-test-main + PUBLIC Folly::folly + PUBLIC GTest::gtest +) + +add_executable(streamr-proto-rpc-test-unit + test/proto/HelloRpc.pb.cc + test/proto/TestProtos.pb.cc + test/proto/WakeUpRpc.pb.cc + test/unit/ServerRegistryTest.cpp + test/unit/RpcCommunicatorTest.cpp +) + +target_include_directories(streamr-proto-rpc-test-unit + PUBLIC $ +) + +target_link_libraries(streamr-proto-rpc-test-unit + PUBLIC streamr-proto-rpc + PUBLIC GTest::gtest + PUBLIC streamr-proto-rpc-test-main + PUBLIC GTest::gmock + PUBLIC Folly::folly + ) + +include(GoogleTest) +gtest_discover_tests(streamr-proto-rpc-test-unit) + +add_executable(streamr-proto-rpc-test-integration + test/proto/HelloRpc.pb.cc + test/proto/HelloRpc.client.pb.h + test/proto/TestProtos.pb.cc + test/proto/WakeUpRpc.pb.cc + test/integration/ProtoRpcTest.cpp +) + +target_include_directories(streamr-proto-rpc-test-integration + PUBLIC $ +) + +target_link_libraries(streamr-proto-rpc-test-integration + PUBLIC streamr-proto-rpc + PUBLIC GTest::gtest + PUBLIC streamr-proto-rpc-test-main + PUBLIC GTest::gmock + PUBLIC Folly::folly + ) + +include(GoogleTest) +gtest_discover_tests(streamr-proto-rpc-test-integration) + +add_executable(streamr-proto-rpc-example-hello + examples/hello/hello.cpp + examples/hello/proto/HelloRpc.pb.cc +) + +target_link_libraries(streamr-proto-rpc-example-hello + PUBLIC streamr-proto-rpc + PUBLIC Folly::folly +) + +target_include_directories(streamr-proto-rpc-example-hello + PUBLIC $ +) + +add_executable(streamr-proto-rpc-example-routed-hello + examples/routed-hello/routedhello.cpp + examples/routed-hello/proto/RoutedHelloRpc.pb.cc +) + +target_link_libraries(streamr-proto-rpc-example-routed-hello + PUBLIC streamr-proto-rpc + PUBLIC Folly::folly +) + +target_include_directories(streamr-proto-rpc-example-routed-hello + PUBLIC $ +) diff --git a/packages/streamr-proto-rpc/README.md b/packages/streamr-proto-rpc/README.md new file mode 100644 index 0000000..0554277 --- /dev/null +++ b/packages/streamr-proto-rpc/README.md @@ -0,0 +1,58 @@ +# Streamr Proto-RPC + +This is the C++ implementation of the [Streamr Proto-RPC library](https://github.com/streamr-dev/network/tree/main/packages/proto-rpc) originally written in TypeScript. + +Streamr Proto-RPC is a transport-independent [protobuf](https://developers.google.com/protocol-buffers) RPC library that can be used as a binary alternative for JSON-RPC. + +## Introduction + +Streamr proto-rpc is intended for situations where one would normally use JSON-RPC, but would like to switch to a binary protocol with autogenerated, typesafe code. + +Unlike existing protobuf RPC frameworks such as gRPC, gRPC-web and twirp, proto-rpc is totally transport-independent; it simply produces `Uint8Arrays` and transporting them to the recipient is up to you! You can use Websockets, peer-to-peer networks, WebRTC, UDP, or TCP for the transport, just to name a few. + +## Differences from the typescript version + +* Generates its own clients and servers using an own protoc plugin +* Does not emit events for outgoing messages (this was a redundant feature) +* outgoingMessageListener has been universally reanmed to outgoinMessageCallback +* Server-side timeouts are not supported + +## Usage Examples + +Usage examples can be found in the [examples](examples) directory. Example [hello](examples/hello/hello.cpp) demonstrates a simple RPC call between a client and a server. Example [routed-hello](examples/routed-hello/routedhello.cpp) demonstrates how to pass context information through the RPC stack to route messages to the correct recipient. + +## Advanced topics + +### Passing context information (eg. for routing) + +You can pass context information through the RpcCommunicator between the clients, RPC methods and the event handlers. This is +especially useful in case you wish to use a single RpcCommunicator as a server for multiple clients, and need to figure out +where to route the Rpc messagesoutput by the RpcCommunicator. + +For a complete code example of passing context information, see [routed-hello](examples/routed-hello/routedhello.cpp) + +### Notifications + +Unlike gRPC, proto-rpc supports JSON-RPC style notifications (RPC functions that return nothing). + +- In the .proto service definitions, the notification functions need to have `google.protobuf.Empty` as their return type. + +```proto +service WakeUpRpcService { + rpc wakeUp (WakeUpRequest) returns (google.protobuf.Empty); +} +``` + +### Errors + +All standard errors in the library can be found the [src/Errors.hpp](include/streamr-proto-rpc/Errors.hpp) file. + +- `RpcTimeout` is thrown by default whenever the client or server times out its operations. +- `RpcRequestError` is thrown by the server to be sent as an error response back to the client if the request fails. +- `FailedToParse` is thrown whenever parsing a protobuf message fails. +- `FailedToSerialize` is thrown whenever serializing a protobuf message fails. +- `UnknownRcMethod` is thrown whenever a server receives an RPC call for a method that it has not registered + +### Timeouts + +Client side timeouts can be set along side requests via the ProtoCallContext parameter. By default the client side timeout is `5000` milliseconds. diff --git a/packages/streamr-proto-rpc/examples/hello/HelloRpc.proto b/packages/streamr-proto-rpc/examples/hello/HelloRpc.proto new file mode 100644 index 0000000..9f39953 --- /dev/null +++ b/packages/streamr-proto-rpc/examples/hello/HelloRpc.proto @@ -0,0 +1,17 @@ +// This file is a copy of +// https://github.com/streamr-dev/network/blob/b267dcfb1e98fa2b882fa21a41a279f3a8658f50/packages/proto-rpc/examples/hello/HelloRpc.proto + +syntax = "proto3"; +option optimize_for = CODE_SIZE; + +service HelloRpcService { + rpc sayHello (HelloRequest) returns (HelloResponse); +} + +message HelloRequest { + string myName = 1; + } + +message HelloResponse { + string greeting = 1; + } \ No newline at end of file diff --git a/packages/streamr-proto-rpc/examples/hello/hello.cpp b/packages/streamr-proto-rpc/examples/hello/hello.cpp new file mode 100644 index 0000000..338e51c --- /dev/null +++ b/packages/streamr-proto-rpc/examples/hello/hello.cpp @@ -0,0 +1,69 @@ +#include +#include +#include "HelloRpc.client.pb.h" +#include "HelloRpc.pb.h" +#include "HelloRpc.server.pb.h" +#include "streamr-proto-rpc/ProtoCallContext.hpp" +#include "streamr-proto-rpc/RpcCommunicator.hpp" + +using streamr::protorpc::HelloRpcService; +using streamr::protorpc::HelloRpcServiceClient; +using streamr::protorpc::ProtoCallContext; +using streamr::protorpc::RpcCommunicator; +using streamr::protorpc::RpcMessage; + +class HelloService : public HelloRpcService { +public: + HelloResponse sayHello( + const HelloRequest& request, + const ProtoCallContext& /* callContext */) override { + HelloResponse response; + response.set_greeting("Hello, " + request.myname()); + return response; + } +}; + +int main() { + // Setup server + RpcCommunicator communicator1; + HelloService helloService; + + communicator1.registerRpcMethod( + "sayHello", + std::bind( // NOLINT(modernize-avoid-bind) + &HelloService::sayHello, + &helloService, + std::placeholders::_1, + std::placeholders::_2)); + + // Setup client + RpcCommunicator communicator2; + HelloRpcServiceClient helloClient(communicator2); + + // Simulate a network connection between the client and server + communicator1.setOutgoingMessageCallback( + [&communicator2]( + const RpcMessage& message, + const std::string& /* requestId */, + const ProtoCallContext& /* context */) -> void { + communicator2.handleIncomingMessage(message, ProtoCallContext()); + }); + + communicator2.setOutgoingMessageCallback( + [&communicator1]( + const RpcMessage& message, + const std::string& /* requestId */, + const ProtoCallContext& /* context */) -> void { + communicator1.handleIncomingMessage(message, ProtoCallContext()); + }); + + // Make the RPC call + + HelloRequest request; + request.set_myname("Alice"); + auto response = folly::coro::blockingWait( + helloClient.sayHello(request, ProtoCallContext())); + std::cout << response.greeting() << "\n"; + + return 0; +} diff --git a/packages/streamr-proto-rpc/examples/hello/proto/HelloRpc.client.pb.h b/packages/streamr-proto-rpc/examples/hello/proto/HelloRpc.client.pb.h new file mode 100644 index 0000000..222d435 --- /dev/null +++ b/packages/streamr-proto-rpc/examples/hello/proto/HelloRpc.client.pb.h @@ -0,0 +1,26 @@ +// generated by the protocol buffer streamr pluging. DO NOT EDIT! +// generated from protobuf file "HelloRpc.proto" + +#ifndef STREAMR_PROTORPC_HELLORPC_CLIENT_PB_H +#define STREAMR_PROTORPC_HELLORPC_CLIENT_PB_H + +#include +#include "HelloRpc.pb.h" // NOLINT +#include "streamr-proto-rpc/ProtoCallContext.hpp" +#include "streamr-proto-rpc/RpcCommunicator.hpp" + + +namespace streamr::protorpc { +class HelloRpcServiceClient { +private: +RpcCommunicator& communicator; +public: + HelloRpcServiceClient(RpcCommunicator& communicator) : communicator(communicator) {} + folly::coro::Task sayHello(const HelloRequest& request, const ProtoCallContext& callContext) { + return communicator.request("sayHello", request, callContext); + } +}; // class HelloRpcServiceClient +}; // namespace streamr::protorpc + +#endif // STREAMR_PROTORPC_HELLORPC_CLIENT_PB_H + diff --git a/packages/streamr-proto-rpc/examples/hello/proto/HelloRpc.pb.cc b/packages/streamr-proto-rpc/examples/hello/proto/HelloRpc.pb.cc new file mode 100644 index 0000000..13ea014 --- /dev/null +++ b/packages/streamr-proto-rpc/examples/hello/proto/HelloRpc.pb.cc @@ -0,0 +1,270 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: HelloRpc.proto + +#include "HelloRpc.pb.h" + +#include +#include "google/protobuf/io/coded_stream.h" +#include "google/protobuf/extension_set.h" +#include "google/protobuf/wire_format_lite.h" +#include "google/protobuf/descriptor.h" +#include "google/protobuf/generated_message_reflection.h" +#include "google/protobuf/reflection_ops.h" +#include "google/protobuf/wire_format.h" +// @@protoc_insertion_point(includes) + +// Must be included last. +#include "google/protobuf/port_def.inc" +PROTOBUF_PRAGMA_INIT_SEG +namespace _pb = ::google::protobuf; +namespace _pbi = ::google::protobuf::internal; + +inline constexpr HelloResponse::Impl_::Impl_( + ::_pbi::ConstantInitialized) noexcept + : greeting_( + &::google::protobuf::internal::fixed_address_empty_string, + ::_pbi::ConstantInitialized()), + _cached_size_{0} {} + +template +PROTOBUF_CONSTEXPR HelloResponse::HelloResponse(::_pbi::ConstantInitialized) + : _impl_(::_pbi::ConstantInitialized()) {} +struct HelloResponseDefaultTypeInternal { + PROTOBUF_CONSTEXPR HelloResponseDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} + ~HelloResponseDefaultTypeInternal() {} + union { + HelloResponse _instance; + }; +}; + +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT + PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 HelloResponseDefaultTypeInternal _HelloResponse_default_instance_; + +inline constexpr HelloRequest::Impl_::Impl_( + ::_pbi::ConstantInitialized) noexcept + : myname_( + &::google::protobuf::internal::fixed_address_empty_string, + ::_pbi::ConstantInitialized()), + _cached_size_{0} {} + +template +PROTOBUF_CONSTEXPR HelloRequest::HelloRequest(::_pbi::ConstantInitialized) + : _impl_(::_pbi::ConstantInitialized()) {} +struct HelloRequestDefaultTypeInternal { + PROTOBUF_CONSTEXPR HelloRequestDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} + ~HelloRequestDefaultTypeInternal() {} + union { + HelloRequest _instance; + }; +}; + +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT + PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 HelloRequestDefaultTypeInternal _HelloRequest_default_instance_; +static ::_pb::Metadata file_level_metadata_HelloRpc_2eproto[2]; +static constexpr const ::_pb::EnumDescriptor** + file_level_enum_descriptors_HelloRpc_2eproto = nullptr; +static constexpr const ::_pb::ServiceDescriptor** + file_level_service_descriptors_HelloRpc_2eproto = nullptr; +const ::uint32_t TableStruct_HelloRpc_2eproto::offsets[] PROTOBUF_SECTION_VARIABLE( + protodesc_cold) = { + ~0u, // no _has_bits_ + PROTOBUF_FIELD_OFFSET(::HelloRequest, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) + PROTOBUF_FIELD_OFFSET(::HelloRequest, _impl_.myname_), + ~0u, // no _has_bits_ + PROTOBUF_FIELD_OFFSET(::HelloResponse, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) + PROTOBUF_FIELD_OFFSET(::HelloResponse, _impl_.greeting_), +}; + +static const ::_pbi::MigrationSchema + schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { + {0, -1, -1, sizeof(::HelloRequest)}, + {9, -1, -1, sizeof(::HelloResponse)}, +}; + +static const ::_pb::Message* const file_default_instances[] = { + &::_HelloRequest_default_instance_._instance, + &::_HelloResponse_default_instance_._instance, +}; +const char descriptor_table_protodef_HelloRpc_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { + "\n\016HelloRpc.proto\"\036\n\014HelloRequest\022\016\n\006myNa" + "me\030\001 \001(\t\"!\n\rHelloResponse\022\020\n\010greeting\030\001 " + "\001(\t2<\n\017HelloRpcService\022)\n\010sayHello\022\r.Hel" + "loRequest\032\016.HelloResponseB\002H\002b\006proto3" +}; +static ::absl::once_flag descriptor_table_HelloRpc_2eproto_once; +const ::_pbi::DescriptorTable descriptor_table_HelloRpc_2eproto = { + false, + false, + 157, + descriptor_table_protodef_HelloRpc_2eproto, + "HelloRpc.proto", + &descriptor_table_HelloRpc_2eproto_once, + nullptr, + 0, + 2, + schemas, + file_default_instances, + TableStruct_HelloRpc_2eproto::offsets, + file_level_metadata_HelloRpc_2eproto, + file_level_enum_descriptors_HelloRpc_2eproto, + file_level_service_descriptors_HelloRpc_2eproto, +}; + +// This function exists to be marked as weak. +// It can significantly speed up compilation by breaking up LLVM's SCC +// in the .pb.cc translation units. Large translation units see a +// reduction of more than 35% of walltime for optimized builds. Without +// the weak attribute all the messages in the file, including all the +// vtables and everything they use become part of the same SCC through +// a cycle like: +// GetMetadata -> descriptor table -> default instances -> +// vtables -> GetMetadata +// By adding a weak function here we break the connection from the +// individual vtables back into the descriptor table. +PROTOBUF_ATTRIBUTE_WEAK const ::_pbi::DescriptorTable* descriptor_table_HelloRpc_2eproto_getter() { + return &descriptor_table_HelloRpc_2eproto; +} +// Force running AddDescriptors() at dynamic initialization time. +PROTOBUF_ATTRIBUTE_INIT_PRIORITY2 +static ::_pbi::AddDescriptorsRunner dynamic_init_dummy_HelloRpc_2eproto(&descriptor_table_HelloRpc_2eproto); +// =================================================================== + +class HelloRequest::_Internal { + public: +}; + +HelloRequest::HelloRequest(::google::protobuf::Arena* arena) + : ::google::protobuf::Message(arena) { + SharedCtor(arena); + // @@protoc_insertion_point(arena_constructor:HelloRequest) +} +inline PROTOBUF_NDEBUG_INLINE HelloRequest::Impl_::Impl_( + ::google::protobuf::internal::InternalVisibility visibility, ::google::protobuf::Arena* arena, + const Impl_& from) + : myname_(arena, from.myname_), + _cached_size_{0} {} + +HelloRequest::HelloRequest( + ::google::protobuf::Arena* arena, + const HelloRequest& from) + : ::google::protobuf::Message(arena) { + HelloRequest* const _this = this; + (void)_this; + _internal_metadata_.MergeFrom<::google::protobuf::UnknownFieldSet>( + from._internal_metadata_); + new (&_impl_) Impl_(internal_visibility(), arena, from._impl_); + + // @@protoc_insertion_point(copy_constructor:HelloRequest) +} +inline PROTOBUF_NDEBUG_INLINE HelloRequest::Impl_::Impl_( + ::google::protobuf::internal::InternalVisibility visibility, + ::google::protobuf::Arena* arena) + : myname_(arena), + _cached_size_{0} {} + +inline void HelloRequest::SharedCtor(::_pb::Arena* arena) { + new (&_impl_) Impl_(internal_visibility(), arena); +} +HelloRequest::~HelloRequest() { + // @@protoc_insertion_point(destructor:HelloRequest) + _internal_metadata_.Delete<::google::protobuf::UnknownFieldSet>(); + SharedDtor(); +} +inline void HelloRequest::SharedDtor() { + ABSL_DCHECK(GetArena() == nullptr); + _impl_.myname_.Destroy(); + _impl_.~Impl_(); +} + +::_pbi::CachedSize* HelloRequest::AccessCachedSize() const { + return &_impl_._cached_size_; +} +void HelloRequest::InternalSwap(HelloRequest* PROTOBUF_RESTRICT other) { + using std::swap; + GetReflection()->Swap(this, other);} + +::google::protobuf::Metadata HelloRequest::GetMetadata() const { + return ::_pbi::AssignDescriptors( + &descriptor_table_HelloRpc_2eproto_getter, &descriptor_table_HelloRpc_2eproto_once, + file_level_metadata_HelloRpc_2eproto[0]); +} +// =================================================================== + +class HelloResponse::_Internal { + public: +}; + +HelloResponse::HelloResponse(::google::protobuf::Arena* arena) + : ::google::protobuf::Message(arena) { + SharedCtor(arena); + // @@protoc_insertion_point(arena_constructor:HelloResponse) +} +inline PROTOBUF_NDEBUG_INLINE HelloResponse::Impl_::Impl_( + ::google::protobuf::internal::InternalVisibility visibility, ::google::protobuf::Arena* arena, + const Impl_& from) + : greeting_(arena, from.greeting_), + _cached_size_{0} {} + +HelloResponse::HelloResponse( + ::google::protobuf::Arena* arena, + const HelloResponse& from) + : ::google::protobuf::Message(arena) { + HelloResponse* const _this = this; + (void)_this; + _internal_metadata_.MergeFrom<::google::protobuf::UnknownFieldSet>( + from._internal_metadata_); + new (&_impl_) Impl_(internal_visibility(), arena, from._impl_); + + // @@protoc_insertion_point(copy_constructor:HelloResponse) +} +inline PROTOBUF_NDEBUG_INLINE HelloResponse::Impl_::Impl_( + ::google::protobuf::internal::InternalVisibility visibility, + ::google::protobuf::Arena* arena) + : greeting_(arena), + _cached_size_{0} {} + +inline void HelloResponse::SharedCtor(::_pb::Arena* arena) { + new (&_impl_) Impl_(internal_visibility(), arena); +} +HelloResponse::~HelloResponse() { + // @@protoc_insertion_point(destructor:HelloResponse) + _internal_metadata_.Delete<::google::protobuf::UnknownFieldSet>(); + SharedDtor(); +} +inline void HelloResponse::SharedDtor() { + ABSL_DCHECK(GetArena() == nullptr); + _impl_.greeting_.Destroy(); + _impl_.~Impl_(); +} + +::_pbi::CachedSize* HelloResponse::AccessCachedSize() const { + return &_impl_._cached_size_; +} +void HelloResponse::InternalSwap(HelloResponse* PROTOBUF_RESTRICT other) { + using std::swap; + GetReflection()->Swap(this, other);} + +::google::protobuf::Metadata HelloResponse::GetMetadata() const { + return ::_pbi::AssignDescriptors( + &descriptor_table_HelloRpc_2eproto_getter, &descriptor_table_HelloRpc_2eproto_once, + file_level_metadata_HelloRpc_2eproto[1]); +} +// @@protoc_insertion_point(namespace_scope) +namespace google { +namespace protobuf { +} // namespace protobuf +} // namespace google +// @@protoc_insertion_point(global_scope) +#include "google/protobuf/port_undef.inc" diff --git a/packages/streamr-proto-rpc/examples/hello/proto/HelloRpc.pb.h b/packages/streamr-proto-rpc/examples/hello/proto/HelloRpc.pb.h new file mode 100644 index 0000000..894d25a --- /dev/null +++ b/packages/streamr-proto-rpc/examples/hello/proto/HelloRpc.pb.h @@ -0,0 +1,525 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: HelloRpc.proto +// Protobuf C++ Version: 4.25.1 + +#ifndef GOOGLE_PROTOBUF_INCLUDED_HelloRpc_2eproto_2epb_2eh +#define GOOGLE_PROTOBUF_INCLUDED_HelloRpc_2eproto_2epb_2eh + +#include +#include +#include +#include + +#include "google/protobuf/port_def.inc" +#if PROTOBUF_VERSION < 4025000 +#error "This file was generated by a newer version of protoc which is" +#error "incompatible with your Protocol Buffer headers. Please update" +#error "your headers." +#endif // PROTOBUF_VERSION + +#if 4025001 < PROTOBUF_MIN_PROTOC_VERSION +#error "This file was generated by an older version of protoc which is" +#error "incompatible with your Protocol Buffer headers. Please" +#error "regenerate this file with a newer version of protoc." +#endif // PROTOBUF_MIN_PROTOC_VERSION +#include "google/protobuf/port_undef.inc" +#include "google/protobuf/io/coded_stream.h" +#include "google/protobuf/arena.h" +#include "google/protobuf/arenastring.h" +#include "google/protobuf/generated_message_util.h" +#include "google/protobuf/metadata_lite.h" +#include "google/protobuf/generated_message_reflection.h" +#include "google/protobuf/message.h" +#include "google/protobuf/repeated_field.h" // IWYU pragma: export +#include "google/protobuf/extension_set.h" // IWYU pragma: export +#include "google/protobuf/unknown_field_set.h" +// @@protoc_insertion_point(includes) + +// Must be included last. +#include "google/protobuf/port_def.inc" + +#define PROTOBUF_INTERNAL_EXPORT_HelloRpc_2eproto + +namespace google { +namespace protobuf { +namespace internal { +class AnyMetadata; +} // namespace internal +} // namespace protobuf +} // namespace google + +// Internal implementation detail -- do not use these members. +struct TableStruct_HelloRpc_2eproto { + static const ::uint32_t offsets[]; +}; +extern const ::google::protobuf::internal::DescriptorTable + descriptor_table_HelloRpc_2eproto; +class HelloRequest; +struct HelloRequestDefaultTypeInternal; +extern HelloRequestDefaultTypeInternal _HelloRequest_default_instance_; +class HelloResponse; +struct HelloResponseDefaultTypeInternal; +extern HelloResponseDefaultTypeInternal _HelloResponse_default_instance_; +namespace google { +namespace protobuf { +} // namespace protobuf +} // namespace google + + +// =================================================================== + + +// ------------------------------------------------------------------- + +class HelloResponse final : + public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:HelloResponse) */ { + public: + inline HelloResponse() : HelloResponse(nullptr) {} + ~HelloResponse() override; + template + explicit PROTOBUF_CONSTEXPR HelloResponse(::google::protobuf::internal::ConstantInitialized); + + inline HelloResponse(const HelloResponse& from) + : HelloResponse(nullptr, from) {} + HelloResponse(HelloResponse&& from) noexcept + : HelloResponse() { + *this = ::std::move(from); + } + + inline HelloResponse& operator=(const HelloResponse& from) { + CopyFrom(from); + return *this; + } + inline HelloResponse& operator=(HelloResponse&& from) noexcept { + if (this == &from) return *this; + if (GetArena() == from.GetArena() + #ifdef PROTOBUF_FORCE_COPY_IN_MOVE + && GetArena() != nullptr + #endif // !PROTOBUF_FORCE_COPY_IN_MOVE + ) { + InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + + inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const + ABSL_ATTRIBUTE_LIFETIME_BOUND { + return _internal_metadata_.unknown_fields<::google::protobuf::UnknownFieldSet>(::google::protobuf::UnknownFieldSet::default_instance); + } + inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() + ABSL_ATTRIBUTE_LIFETIME_BOUND { + return _internal_metadata_.mutable_unknown_fields<::google::protobuf::UnknownFieldSet>(); + } + + static const ::google::protobuf::Descriptor* descriptor() { + return GetDescriptor(); + } + static const ::google::protobuf::Descriptor* GetDescriptor() { + return default_instance().GetMetadata().descriptor; + } + static const ::google::protobuf::Reflection* GetReflection() { + return default_instance().GetMetadata().reflection; + } + static const HelloResponse& default_instance() { + return *internal_default_instance(); + } + static inline const HelloResponse* internal_default_instance() { + return reinterpret_cast( + &_HelloResponse_default_instance_); + } + static constexpr int kIndexInFileMessages = + 1; + + friend void swap(HelloResponse& a, HelloResponse& b) { + a.Swap(&b); + } + inline void Swap(HelloResponse* other) { + if (other == this) return; + #ifdef PROTOBUF_FORCE_COPY_IN_SWAP + if (GetArena() != nullptr && + GetArena() == other->GetArena()) { + #else // PROTOBUF_FORCE_COPY_IN_SWAP + if (GetArena() == other->GetArena()) { + #endif // !PROTOBUF_FORCE_COPY_IN_SWAP + InternalSwap(other); + } else { + ::google::protobuf::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(HelloResponse* other) { + if (other == this) return; + ABSL_DCHECK(GetArena() == other->GetArena()); + InternalSwap(other); + } + + // implements Message ---------------------------------------------- + + HelloResponse* New(::google::protobuf::Arena* arena = nullptr) const final { + return CreateMaybeMessage(arena); + } + int GetCachedSize() const { return _impl_._cached_size_.Get(); } + + private: + ::google::protobuf::internal::CachedSize* AccessCachedSize() const final; + void SharedCtor(::google::protobuf::Arena* arena); + void SharedDtor(); + void InternalSwap(HelloResponse* other); + + private: + friend class ::google::protobuf::internal::AnyMetadata; + static ::absl::string_view FullMessageName() { + return "HelloResponse"; + } + protected: + explicit HelloResponse(::google::protobuf::Arena* arena); + HelloResponse(::google::protobuf::Arena* arena, const HelloResponse& from); + public: + + ::google::protobuf::Metadata GetMetadata() const final; + + // nested types ---------------------------------------------------- + + // accessors ------------------------------------------------------- + + enum : int { + kGreetingFieldNumber = 1, + }; + // string greeting = 1; + void clear_greeting() ; + const std::string& greeting() const; + template + void set_greeting(Arg_&& arg, Args_... args); + std::string* mutable_greeting(); + PROTOBUF_NODISCARD std::string* release_greeting(); + void set_allocated_greeting(std::string* value); + + private: + const std::string& _internal_greeting() const; + inline PROTOBUF_ALWAYS_INLINE void _internal_set_greeting( + const std::string& value); + std::string* _internal_mutable_greeting(); + + public: + // @@protoc_insertion_point(class_scope:HelloResponse) + private: + class _Internal; + + friend class ::google::protobuf::MessageLite; + friend class ::google::protobuf::Arena; + template + friend class ::google::protobuf::Arena::InternalHelper; + using InternalArenaConstructable_ = void; + using DestructorSkippable_ = void; + struct Impl_ { + + inline explicit constexpr Impl_( + ::google::protobuf::internal::ConstantInitialized) noexcept; + inline explicit Impl_(::google::protobuf::internal::InternalVisibility visibility, + ::google::protobuf::Arena* arena); + inline explicit Impl_(::google::protobuf::internal::InternalVisibility visibility, + ::google::protobuf::Arena* arena, const Impl_& from); + ::google::protobuf::internal::ArenaStringPtr greeting_; + mutable ::google::protobuf::internal::CachedSize _cached_size_; + PROTOBUF_TSAN_DECLARE_MEMBER + }; + union { Impl_ _impl_; }; + friend struct ::TableStruct_HelloRpc_2eproto; +};// ------------------------------------------------------------------- + +class HelloRequest final : + public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:HelloRequest) */ { + public: + inline HelloRequest() : HelloRequest(nullptr) {} + ~HelloRequest() override; + template + explicit PROTOBUF_CONSTEXPR HelloRequest(::google::protobuf::internal::ConstantInitialized); + + inline HelloRequest(const HelloRequest& from) + : HelloRequest(nullptr, from) {} + HelloRequest(HelloRequest&& from) noexcept + : HelloRequest() { + *this = ::std::move(from); + } + + inline HelloRequest& operator=(const HelloRequest& from) { + CopyFrom(from); + return *this; + } + inline HelloRequest& operator=(HelloRequest&& from) noexcept { + if (this == &from) return *this; + if (GetArena() == from.GetArena() + #ifdef PROTOBUF_FORCE_COPY_IN_MOVE + && GetArena() != nullptr + #endif // !PROTOBUF_FORCE_COPY_IN_MOVE + ) { + InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + + inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const + ABSL_ATTRIBUTE_LIFETIME_BOUND { + return _internal_metadata_.unknown_fields<::google::protobuf::UnknownFieldSet>(::google::protobuf::UnknownFieldSet::default_instance); + } + inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() + ABSL_ATTRIBUTE_LIFETIME_BOUND { + return _internal_metadata_.mutable_unknown_fields<::google::protobuf::UnknownFieldSet>(); + } + + static const ::google::protobuf::Descriptor* descriptor() { + return GetDescriptor(); + } + static const ::google::protobuf::Descriptor* GetDescriptor() { + return default_instance().GetMetadata().descriptor; + } + static const ::google::protobuf::Reflection* GetReflection() { + return default_instance().GetMetadata().reflection; + } + static const HelloRequest& default_instance() { + return *internal_default_instance(); + } + static inline const HelloRequest* internal_default_instance() { + return reinterpret_cast( + &_HelloRequest_default_instance_); + } + static constexpr int kIndexInFileMessages = + 0; + + friend void swap(HelloRequest& a, HelloRequest& b) { + a.Swap(&b); + } + inline void Swap(HelloRequest* other) { + if (other == this) return; + #ifdef PROTOBUF_FORCE_COPY_IN_SWAP + if (GetArena() != nullptr && + GetArena() == other->GetArena()) { + #else // PROTOBUF_FORCE_COPY_IN_SWAP + if (GetArena() == other->GetArena()) { + #endif // !PROTOBUF_FORCE_COPY_IN_SWAP + InternalSwap(other); + } else { + ::google::protobuf::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(HelloRequest* other) { + if (other == this) return; + ABSL_DCHECK(GetArena() == other->GetArena()); + InternalSwap(other); + } + + // implements Message ---------------------------------------------- + + HelloRequest* New(::google::protobuf::Arena* arena = nullptr) const final { + return CreateMaybeMessage(arena); + } + int GetCachedSize() const { return _impl_._cached_size_.Get(); } + + private: + ::google::protobuf::internal::CachedSize* AccessCachedSize() const final; + void SharedCtor(::google::protobuf::Arena* arena); + void SharedDtor(); + void InternalSwap(HelloRequest* other); + + private: + friend class ::google::protobuf::internal::AnyMetadata; + static ::absl::string_view FullMessageName() { + return "HelloRequest"; + } + protected: + explicit HelloRequest(::google::protobuf::Arena* arena); + HelloRequest(::google::protobuf::Arena* arena, const HelloRequest& from); + public: + + ::google::protobuf::Metadata GetMetadata() const final; + + // nested types ---------------------------------------------------- + + // accessors ------------------------------------------------------- + + enum : int { + kMyNameFieldNumber = 1, + }; + // string myName = 1; + void clear_myname() ; + const std::string& myname() const; + template + void set_myname(Arg_&& arg, Args_... args); + std::string* mutable_myname(); + PROTOBUF_NODISCARD std::string* release_myname(); + void set_allocated_myname(std::string* value); + + private: + const std::string& _internal_myname() const; + inline PROTOBUF_ALWAYS_INLINE void _internal_set_myname( + const std::string& value); + std::string* _internal_mutable_myname(); + + public: + // @@protoc_insertion_point(class_scope:HelloRequest) + private: + class _Internal; + + friend class ::google::protobuf::MessageLite; + friend class ::google::protobuf::Arena; + template + friend class ::google::protobuf::Arena::InternalHelper; + using InternalArenaConstructable_ = void; + using DestructorSkippable_ = void; + struct Impl_ { + + inline explicit constexpr Impl_( + ::google::protobuf::internal::ConstantInitialized) noexcept; + inline explicit Impl_(::google::protobuf::internal::InternalVisibility visibility, + ::google::protobuf::Arena* arena); + inline explicit Impl_(::google::protobuf::internal::InternalVisibility visibility, + ::google::protobuf::Arena* arena, const Impl_& from); + ::google::protobuf::internal::ArenaStringPtr myname_; + mutable ::google::protobuf::internal::CachedSize _cached_size_; + PROTOBUF_TSAN_DECLARE_MEMBER + }; + union { Impl_ _impl_; }; + friend struct ::TableStruct_HelloRpc_2eproto; +}; + +// =================================================================== + + + + +// =================================================================== + + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wstrict-aliasing" +#endif // __GNUC__ +// ------------------------------------------------------------------- + +// HelloRequest + +// string myName = 1; +inline void HelloRequest::clear_myname() { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + _impl_.myname_.ClearToEmpty(); +} +inline const std::string& HelloRequest::myname() const + ABSL_ATTRIBUTE_LIFETIME_BOUND { + // @@protoc_insertion_point(field_get:HelloRequest.myName) + return _internal_myname(); +} +template +inline PROTOBUF_ALWAYS_INLINE void HelloRequest::set_myname(Arg_&& arg, + Args_... args) { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + ; + _impl_.myname_.Set(static_cast(arg), args..., GetArena()); + // @@protoc_insertion_point(field_set:HelloRequest.myName) +} +inline std::string* HelloRequest::mutable_myname() ABSL_ATTRIBUTE_LIFETIME_BOUND { + std::string* _s = _internal_mutable_myname(); + // @@protoc_insertion_point(field_mutable:HelloRequest.myName) + return _s; +} +inline const std::string& HelloRequest::_internal_myname() const { + PROTOBUF_TSAN_READ(&_impl_._tsan_detect_race); + return _impl_.myname_.Get(); +} +inline void HelloRequest::_internal_set_myname(const std::string& value) { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + ; + _impl_.myname_.Set(value, GetArena()); +} +inline std::string* HelloRequest::_internal_mutable_myname() { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + ; + return _impl_.myname_.Mutable( GetArena()); +} +inline std::string* HelloRequest::release_myname() { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + // @@protoc_insertion_point(field_release:HelloRequest.myName) + return _impl_.myname_.Release(); +} +inline void HelloRequest::set_allocated_myname(std::string* value) { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + _impl_.myname_.SetAllocated(value, GetArena()); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (_impl_.myname_.IsDefault()) { + _impl_.myname_.Set("", GetArena()); + } + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + // @@protoc_insertion_point(field_set_allocated:HelloRequest.myName) +} + +// ------------------------------------------------------------------- + +// HelloResponse + +// string greeting = 1; +inline void HelloResponse::clear_greeting() { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + _impl_.greeting_.ClearToEmpty(); +} +inline const std::string& HelloResponse::greeting() const + ABSL_ATTRIBUTE_LIFETIME_BOUND { + // @@protoc_insertion_point(field_get:HelloResponse.greeting) + return _internal_greeting(); +} +template +inline PROTOBUF_ALWAYS_INLINE void HelloResponse::set_greeting(Arg_&& arg, + Args_... args) { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + ; + _impl_.greeting_.Set(static_cast(arg), args..., GetArena()); + // @@protoc_insertion_point(field_set:HelloResponse.greeting) +} +inline std::string* HelloResponse::mutable_greeting() ABSL_ATTRIBUTE_LIFETIME_BOUND { + std::string* _s = _internal_mutable_greeting(); + // @@protoc_insertion_point(field_mutable:HelloResponse.greeting) + return _s; +} +inline const std::string& HelloResponse::_internal_greeting() const { + PROTOBUF_TSAN_READ(&_impl_._tsan_detect_race); + return _impl_.greeting_.Get(); +} +inline void HelloResponse::_internal_set_greeting(const std::string& value) { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + ; + _impl_.greeting_.Set(value, GetArena()); +} +inline std::string* HelloResponse::_internal_mutable_greeting() { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + ; + return _impl_.greeting_.Mutable( GetArena()); +} +inline std::string* HelloResponse::release_greeting() { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + // @@protoc_insertion_point(field_release:HelloResponse.greeting) + return _impl_.greeting_.Release(); +} +inline void HelloResponse::set_allocated_greeting(std::string* value) { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + _impl_.greeting_.SetAllocated(value, GetArena()); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (_impl_.greeting_.IsDefault()) { + _impl_.greeting_.Set("", GetArena()); + } + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + // @@protoc_insertion_point(field_set_allocated:HelloResponse.greeting) +} + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif // __GNUC__ + +// @@protoc_insertion_point(namespace_scope) + + +// @@protoc_insertion_point(global_scope) + +#include "google/protobuf/port_undef.inc" + +#endif // GOOGLE_PROTOBUF_INCLUDED_HelloRpc_2eproto_2epb_2eh diff --git a/packages/streamr-proto-rpc/examples/hello/proto/HelloRpc.server.pb.h b/packages/streamr-proto-rpc/examples/hello/proto/HelloRpc.server.pb.h new file mode 100644 index 0000000..be6e45e --- /dev/null +++ b/packages/streamr-proto-rpc/examples/hello/proto/HelloRpc.server.pb.h @@ -0,0 +1,19 @@ +// Generated by the protocol buffer streamr pluging. DO NOT EDIT! +// Generated from protobuf file "HelloRpc.proto" + +#ifndef STREAMR_PROTORPC_HELLORPC_SERVER_PB_H +#define STREAMR_PROTORPC_HELLORPC_SERVER_PB_H + +#include "HelloRpc.pb.h" // NOLINT +#include + +namespace streamr::protorpc { +class HelloRpcService { +public: + virtual ~HelloRpcService() = default; + virtual HelloResponse sayHello(const HelloRequest& request, const ProtoCallContext& callContext) = 0; +}; // class HelloRpcService +}; // namespace streamr::protorpc + +#endif // STREAMR_PROTORPC_HELLORPC_SERVER_PB_H + diff --git a/packages/streamr-proto-rpc/examples/routed-hello/RoutedHelloRpc.proto b/packages/streamr-proto-rpc/examples/routed-hello/RoutedHelloRpc.proto new file mode 100644 index 0000000..3e601ba --- /dev/null +++ b/packages/streamr-proto-rpc/examples/routed-hello/RoutedHelloRpc.proto @@ -0,0 +1,17 @@ +// This file is a copy of +// https://github.com/streamr-dev/network/blob/b267dcfb1e98fa2b882fa21a41a279f3a8658f50/packages/proto-rpc/examples/routed-hello/RoutedHelloRpc.proto + +syntax = "proto3"; +option optimize_for = CODE_SIZE; + +service RoutedHelloRpcService { + rpc sayHello (RoutedHelloRequest) returns (RoutedHelloResponse); +} + +message RoutedHelloRequest { + string myName = 1; + } + +message RoutedHelloResponse { + string greeting = 1; + } \ No newline at end of file diff --git a/packages/streamr-proto-rpc/examples/routed-hello/proto/RoutedHelloRpc.client.pb.h b/packages/streamr-proto-rpc/examples/routed-hello/proto/RoutedHelloRpc.client.pb.h new file mode 100644 index 0000000..d2f421e --- /dev/null +++ b/packages/streamr-proto-rpc/examples/routed-hello/proto/RoutedHelloRpc.client.pb.h @@ -0,0 +1,26 @@ +// generated by the protocol buffer streamr pluging. DO NOT EDIT! +// generated from protobuf file "RoutedHelloRpc.proto" + +#ifndef STREAMR_PROTORPC_ROUTEDHELLORPC_CLIENT_PB_H +#define STREAMR_PROTORPC_ROUTEDHELLORPC_CLIENT_PB_H + +#include +#include "RoutedHelloRpc.pb.h" // NOLINT +#include "streamr-proto-rpc/ProtoCallContext.hpp" +#include "streamr-proto-rpc/RpcCommunicator.hpp" + + +namespace streamr::protorpc { +class RoutedHelloRpcServiceClient { +private: +RpcCommunicator& communicator; +public: + RoutedHelloRpcServiceClient(RpcCommunicator& communicator) : communicator(communicator) {} + folly::coro::Task sayHello(const RoutedHelloRequest& request, const ProtoCallContext& callContext) { + return communicator.request("sayHello", request, callContext); + } +}; // class RoutedHelloRpcServiceClient +}; // namespace streamr::protorpc + +#endif // STREAMR_PROTORPC_ROUTEDHELLORPC_CLIENT_PB_H + diff --git a/packages/streamr-proto-rpc/examples/routed-hello/proto/RoutedHelloRpc.pb.cc b/packages/streamr-proto-rpc/examples/routed-hello/proto/RoutedHelloRpc.pb.cc new file mode 100644 index 0000000..f913a43 --- /dev/null +++ b/packages/streamr-proto-rpc/examples/routed-hello/proto/RoutedHelloRpc.pb.cc @@ -0,0 +1,271 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: RoutedHelloRpc.proto + +#include "RoutedHelloRpc.pb.h" + +#include +#include "google/protobuf/io/coded_stream.h" +#include "google/protobuf/extension_set.h" +#include "google/protobuf/wire_format_lite.h" +#include "google/protobuf/descriptor.h" +#include "google/protobuf/generated_message_reflection.h" +#include "google/protobuf/reflection_ops.h" +#include "google/protobuf/wire_format.h" +// @@protoc_insertion_point(includes) + +// Must be included last. +#include "google/protobuf/port_def.inc" +PROTOBUF_PRAGMA_INIT_SEG +namespace _pb = ::google::protobuf; +namespace _pbi = ::google::protobuf::internal; + +inline constexpr RoutedHelloResponse::Impl_::Impl_( + ::_pbi::ConstantInitialized) noexcept + : greeting_( + &::google::protobuf::internal::fixed_address_empty_string, + ::_pbi::ConstantInitialized()), + _cached_size_{0} {} + +template +PROTOBUF_CONSTEXPR RoutedHelloResponse::RoutedHelloResponse(::_pbi::ConstantInitialized) + : _impl_(::_pbi::ConstantInitialized()) {} +struct RoutedHelloResponseDefaultTypeInternal { + PROTOBUF_CONSTEXPR RoutedHelloResponseDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} + ~RoutedHelloResponseDefaultTypeInternal() {} + union { + RoutedHelloResponse _instance; + }; +}; + +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT + PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 RoutedHelloResponseDefaultTypeInternal _RoutedHelloResponse_default_instance_; + +inline constexpr RoutedHelloRequest::Impl_::Impl_( + ::_pbi::ConstantInitialized) noexcept + : myname_( + &::google::protobuf::internal::fixed_address_empty_string, + ::_pbi::ConstantInitialized()), + _cached_size_{0} {} + +template +PROTOBUF_CONSTEXPR RoutedHelloRequest::RoutedHelloRequest(::_pbi::ConstantInitialized) + : _impl_(::_pbi::ConstantInitialized()) {} +struct RoutedHelloRequestDefaultTypeInternal { + PROTOBUF_CONSTEXPR RoutedHelloRequestDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} + ~RoutedHelloRequestDefaultTypeInternal() {} + union { + RoutedHelloRequest _instance; + }; +}; + +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT + PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 RoutedHelloRequestDefaultTypeInternal _RoutedHelloRequest_default_instance_; +static ::_pb::Metadata file_level_metadata_RoutedHelloRpc_2eproto[2]; +static constexpr const ::_pb::EnumDescriptor** + file_level_enum_descriptors_RoutedHelloRpc_2eproto = nullptr; +static constexpr const ::_pb::ServiceDescriptor** + file_level_service_descriptors_RoutedHelloRpc_2eproto = nullptr; +const ::uint32_t TableStruct_RoutedHelloRpc_2eproto::offsets[] PROTOBUF_SECTION_VARIABLE( + protodesc_cold) = { + ~0u, // no _has_bits_ + PROTOBUF_FIELD_OFFSET(::RoutedHelloRequest, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) + PROTOBUF_FIELD_OFFSET(::RoutedHelloRequest, _impl_.myname_), + ~0u, // no _has_bits_ + PROTOBUF_FIELD_OFFSET(::RoutedHelloResponse, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) + PROTOBUF_FIELD_OFFSET(::RoutedHelloResponse, _impl_.greeting_), +}; + +static const ::_pbi::MigrationSchema + schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { + {0, -1, -1, sizeof(::RoutedHelloRequest)}, + {9, -1, -1, sizeof(::RoutedHelloResponse)}, +}; + +static const ::_pb::Message* const file_default_instances[] = { + &::_RoutedHelloRequest_default_instance_._instance, + &::_RoutedHelloResponse_default_instance_._instance, +}; +const char descriptor_table_protodef_RoutedHelloRpc_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { + "\n\024RoutedHelloRpc.proto\"$\n\022RoutedHelloReq" + "uest\022\016\n\006myName\030\001 \001(\t\"\'\n\023RoutedHelloRespo" + "nse\022\020\n\010greeting\030\001 \001(\t2N\n\025RoutedHelloRpcS" + "ervice\0225\n\010sayHello\022\023.RoutedHelloRequest\032" + "\024.RoutedHelloResponseB\002H\002b\006proto3" +}; +static ::absl::once_flag descriptor_table_RoutedHelloRpc_2eproto_once; +const ::_pbi::DescriptorTable descriptor_table_RoutedHelloRpc_2eproto = { + false, + false, + 193, + descriptor_table_protodef_RoutedHelloRpc_2eproto, + "RoutedHelloRpc.proto", + &descriptor_table_RoutedHelloRpc_2eproto_once, + nullptr, + 0, + 2, + schemas, + file_default_instances, + TableStruct_RoutedHelloRpc_2eproto::offsets, + file_level_metadata_RoutedHelloRpc_2eproto, + file_level_enum_descriptors_RoutedHelloRpc_2eproto, + file_level_service_descriptors_RoutedHelloRpc_2eproto, +}; + +// This function exists to be marked as weak. +// It can significantly speed up compilation by breaking up LLVM's SCC +// in the .pb.cc translation units. Large translation units see a +// reduction of more than 35% of walltime for optimized builds. Without +// the weak attribute all the messages in the file, including all the +// vtables and everything they use become part of the same SCC through +// a cycle like: +// GetMetadata -> descriptor table -> default instances -> +// vtables -> GetMetadata +// By adding a weak function here we break the connection from the +// individual vtables back into the descriptor table. +PROTOBUF_ATTRIBUTE_WEAK const ::_pbi::DescriptorTable* descriptor_table_RoutedHelloRpc_2eproto_getter() { + return &descriptor_table_RoutedHelloRpc_2eproto; +} +// Force running AddDescriptors() at dynamic initialization time. +PROTOBUF_ATTRIBUTE_INIT_PRIORITY2 +static ::_pbi::AddDescriptorsRunner dynamic_init_dummy_RoutedHelloRpc_2eproto(&descriptor_table_RoutedHelloRpc_2eproto); +// =================================================================== + +class RoutedHelloRequest::_Internal { + public: +}; + +RoutedHelloRequest::RoutedHelloRequest(::google::protobuf::Arena* arena) + : ::google::protobuf::Message(arena) { + SharedCtor(arena); + // @@protoc_insertion_point(arena_constructor:RoutedHelloRequest) +} +inline PROTOBUF_NDEBUG_INLINE RoutedHelloRequest::Impl_::Impl_( + ::google::protobuf::internal::InternalVisibility visibility, ::google::protobuf::Arena* arena, + const Impl_& from) + : myname_(arena, from.myname_), + _cached_size_{0} {} + +RoutedHelloRequest::RoutedHelloRequest( + ::google::protobuf::Arena* arena, + const RoutedHelloRequest& from) + : ::google::protobuf::Message(arena) { + RoutedHelloRequest* const _this = this; + (void)_this; + _internal_metadata_.MergeFrom<::google::protobuf::UnknownFieldSet>( + from._internal_metadata_); + new (&_impl_) Impl_(internal_visibility(), arena, from._impl_); + + // @@protoc_insertion_point(copy_constructor:RoutedHelloRequest) +} +inline PROTOBUF_NDEBUG_INLINE RoutedHelloRequest::Impl_::Impl_( + ::google::protobuf::internal::InternalVisibility visibility, + ::google::protobuf::Arena* arena) + : myname_(arena), + _cached_size_{0} {} + +inline void RoutedHelloRequest::SharedCtor(::_pb::Arena* arena) { + new (&_impl_) Impl_(internal_visibility(), arena); +} +RoutedHelloRequest::~RoutedHelloRequest() { + // @@protoc_insertion_point(destructor:RoutedHelloRequest) + _internal_metadata_.Delete<::google::protobuf::UnknownFieldSet>(); + SharedDtor(); +} +inline void RoutedHelloRequest::SharedDtor() { + ABSL_DCHECK(GetArena() == nullptr); + _impl_.myname_.Destroy(); + _impl_.~Impl_(); +} + +::_pbi::CachedSize* RoutedHelloRequest::AccessCachedSize() const { + return &_impl_._cached_size_; +} +void RoutedHelloRequest::InternalSwap(RoutedHelloRequest* PROTOBUF_RESTRICT other) { + using std::swap; + GetReflection()->Swap(this, other);} + +::google::protobuf::Metadata RoutedHelloRequest::GetMetadata() const { + return ::_pbi::AssignDescriptors( + &descriptor_table_RoutedHelloRpc_2eproto_getter, &descriptor_table_RoutedHelloRpc_2eproto_once, + file_level_metadata_RoutedHelloRpc_2eproto[0]); +} +// =================================================================== + +class RoutedHelloResponse::_Internal { + public: +}; + +RoutedHelloResponse::RoutedHelloResponse(::google::protobuf::Arena* arena) + : ::google::protobuf::Message(arena) { + SharedCtor(arena); + // @@protoc_insertion_point(arena_constructor:RoutedHelloResponse) +} +inline PROTOBUF_NDEBUG_INLINE RoutedHelloResponse::Impl_::Impl_( + ::google::protobuf::internal::InternalVisibility visibility, ::google::protobuf::Arena* arena, + const Impl_& from) + : greeting_(arena, from.greeting_), + _cached_size_{0} {} + +RoutedHelloResponse::RoutedHelloResponse( + ::google::protobuf::Arena* arena, + const RoutedHelloResponse& from) + : ::google::protobuf::Message(arena) { + RoutedHelloResponse* const _this = this; + (void)_this; + _internal_metadata_.MergeFrom<::google::protobuf::UnknownFieldSet>( + from._internal_metadata_); + new (&_impl_) Impl_(internal_visibility(), arena, from._impl_); + + // @@protoc_insertion_point(copy_constructor:RoutedHelloResponse) +} +inline PROTOBUF_NDEBUG_INLINE RoutedHelloResponse::Impl_::Impl_( + ::google::protobuf::internal::InternalVisibility visibility, + ::google::protobuf::Arena* arena) + : greeting_(arena), + _cached_size_{0} {} + +inline void RoutedHelloResponse::SharedCtor(::_pb::Arena* arena) { + new (&_impl_) Impl_(internal_visibility(), arena); +} +RoutedHelloResponse::~RoutedHelloResponse() { + // @@protoc_insertion_point(destructor:RoutedHelloResponse) + _internal_metadata_.Delete<::google::protobuf::UnknownFieldSet>(); + SharedDtor(); +} +inline void RoutedHelloResponse::SharedDtor() { + ABSL_DCHECK(GetArena() == nullptr); + _impl_.greeting_.Destroy(); + _impl_.~Impl_(); +} + +::_pbi::CachedSize* RoutedHelloResponse::AccessCachedSize() const { + return &_impl_._cached_size_; +} +void RoutedHelloResponse::InternalSwap(RoutedHelloResponse* PROTOBUF_RESTRICT other) { + using std::swap; + GetReflection()->Swap(this, other);} + +::google::protobuf::Metadata RoutedHelloResponse::GetMetadata() const { + return ::_pbi::AssignDescriptors( + &descriptor_table_RoutedHelloRpc_2eproto_getter, &descriptor_table_RoutedHelloRpc_2eproto_once, + file_level_metadata_RoutedHelloRpc_2eproto[1]); +} +// @@protoc_insertion_point(namespace_scope) +namespace google { +namespace protobuf { +} // namespace protobuf +} // namespace google +// @@protoc_insertion_point(global_scope) +#include "google/protobuf/port_undef.inc" diff --git a/packages/streamr-proto-rpc/examples/routed-hello/proto/RoutedHelloRpc.pb.h b/packages/streamr-proto-rpc/examples/routed-hello/proto/RoutedHelloRpc.pb.h new file mode 100644 index 0000000..777b0c3 --- /dev/null +++ b/packages/streamr-proto-rpc/examples/routed-hello/proto/RoutedHelloRpc.pb.h @@ -0,0 +1,525 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: RoutedHelloRpc.proto +// Protobuf C++ Version: 4.25.1 + +#ifndef GOOGLE_PROTOBUF_INCLUDED_RoutedHelloRpc_2eproto_2epb_2eh +#define GOOGLE_PROTOBUF_INCLUDED_RoutedHelloRpc_2eproto_2epb_2eh + +#include +#include +#include +#include + +#include "google/protobuf/port_def.inc" +#if PROTOBUF_VERSION < 4025000 +#error "This file was generated by a newer version of protoc which is" +#error "incompatible with your Protocol Buffer headers. Please update" +#error "your headers." +#endif // PROTOBUF_VERSION + +#if 4025001 < PROTOBUF_MIN_PROTOC_VERSION +#error "This file was generated by an older version of protoc which is" +#error "incompatible with your Protocol Buffer headers. Please" +#error "regenerate this file with a newer version of protoc." +#endif // PROTOBUF_MIN_PROTOC_VERSION +#include "google/protobuf/port_undef.inc" +#include "google/protobuf/io/coded_stream.h" +#include "google/protobuf/arena.h" +#include "google/protobuf/arenastring.h" +#include "google/protobuf/generated_message_util.h" +#include "google/protobuf/metadata_lite.h" +#include "google/protobuf/generated_message_reflection.h" +#include "google/protobuf/message.h" +#include "google/protobuf/repeated_field.h" // IWYU pragma: export +#include "google/protobuf/extension_set.h" // IWYU pragma: export +#include "google/protobuf/unknown_field_set.h" +// @@protoc_insertion_point(includes) + +// Must be included last. +#include "google/protobuf/port_def.inc" + +#define PROTOBUF_INTERNAL_EXPORT_RoutedHelloRpc_2eproto + +namespace google { +namespace protobuf { +namespace internal { +class AnyMetadata; +} // namespace internal +} // namespace protobuf +} // namespace google + +// Internal implementation detail -- do not use these members. +struct TableStruct_RoutedHelloRpc_2eproto { + static const ::uint32_t offsets[]; +}; +extern const ::google::protobuf::internal::DescriptorTable + descriptor_table_RoutedHelloRpc_2eproto; +class RoutedHelloRequest; +struct RoutedHelloRequestDefaultTypeInternal; +extern RoutedHelloRequestDefaultTypeInternal _RoutedHelloRequest_default_instance_; +class RoutedHelloResponse; +struct RoutedHelloResponseDefaultTypeInternal; +extern RoutedHelloResponseDefaultTypeInternal _RoutedHelloResponse_default_instance_; +namespace google { +namespace protobuf { +} // namespace protobuf +} // namespace google + + +// =================================================================== + + +// ------------------------------------------------------------------- + +class RoutedHelloResponse final : + public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:RoutedHelloResponse) */ { + public: + inline RoutedHelloResponse() : RoutedHelloResponse(nullptr) {} + ~RoutedHelloResponse() override; + template + explicit PROTOBUF_CONSTEXPR RoutedHelloResponse(::google::protobuf::internal::ConstantInitialized); + + inline RoutedHelloResponse(const RoutedHelloResponse& from) + : RoutedHelloResponse(nullptr, from) {} + RoutedHelloResponse(RoutedHelloResponse&& from) noexcept + : RoutedHelloResponse() { + *this = ::std::move(from); + } + + inline RoutedHelloResponse& operator=(const RoutedHelloResponse& from) { + CopyFrom(from); + return *this; + } + inline RoutedHelloResponse& operator=(RoutedHelloResponse&& from) noexcept { + if (this == &from) return *this; + if (GetArena() == from.GetArena() + #ifdef PROTOBUF_FORCE_COPY_IN_MOVE + && GetArena() != nullptr + #endif // !PROTOBUF_FORCE_COPY_IN_MOVE + ) { + InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + + inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const + ABSL_ATTRIBUTE_LIFETIME_BOUND { + return _internal_metadata_.unknown_fields<::google::protobuf::UnknownFieldSet>(::google::protobuf::UnknownFieldSet::default_instance); + } + inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() + ABSL_ATTRIBUTE_LIFETIME_BOUND { + return _internal_metadata_.mutable_unknown_fields<::google::protobuf::UnknownFieldSet>(); + } + + static const ::google::protobuf::Descriptor* descriptor() { + return GetDescriptor(); + } + static const ::google::protobuf::Descriptor* GetDescriptor() { + return default_instance().GetMetadata().descriptor; + } + static const ::google::protobuf::Reflection* GetReflection() { + return default_instance().GetMetadata().reflection; + } + static const RoutedHelloResponse& default_instance() { + return *internal_default_instance(); + } + static inline const RoutedHelloResponse* internal_default_instance() { + return reinterpret_cast( + &_RoutedHelloResponse_default_instance_); + } + static constexpr int kIndexInFileMessages = + 1; + + friend void swap(RoutedHelloResponse& a, RoutedHelloResponse& b) { + a.Swap(&b); + } + inline void Swap(RoutedHelloResponse* other) { + if (other == this) return; + #ifdef PROTOBUF_FORCE_COPY_IN_SWAP + if (GetArena() != nullptr && + GetArena() == other->GetArena()) { + #else // PROTOBUF_FORCE_COPY_IN_SWAP + if (GetArena() == other->GetArena()) { + #endif // !PROTOBUF_FORCE_COPY_IN_SWAP + InternalSwap(other); + } else { + ::google::protobuf::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(RoutedHelloResponse* other) { + if (other == this) return; + ABSL_DCHECK(GetArena() == other->GetArena()); + InternalSwap(other); + } + + // implements Message ---------------------------------------------- + + RoutedHelloResponse* New(::google::protobuf::Arena* arena = nullptr) const final { + return CreateMaybeMessage(arena); + } + int GetCachedSize() const { return _impl_._cached_size_.Get(); } + + private: + ::google::protobuf::internal::CachedSize* AccessCachedSize() const final; + void SharedCtor(::google::protobuf::Arena* arena); + void SharedDtor(); + void InternalSwap(RoutedHelloResponse* other); + + private: + friend class ::google::protobuf::internal::AnyMetadata; + static ::absl::string_view FullMessageName() { + return "RoutedHelloResponse"; + } + protected: + explicit RoutedHelloResponse(::google::protobuf::Arena* arena); + RoutedHelloResponse(::google::protobuf::Arena* arena, const RoutedHelloResponse& from); + public: + + ::google::protobuf::Metadata GetMetadata() const final; + + // nested types ---------------------------------------------------- + + // accessors ------------------------------------------------------- + + enum : int { + kGreetingFieldNumber = 1, + }; + // string greeting = 1; + void clear_greeting() ; + const std::string& greeting() const; + template + void set_greeting(Arg_&& arg, Args_... args); + std::string* mutable_greeting(); + PROTOBUF_NODISCARD std::string* release_greeting(); + void set_allocated_greeting(std::string* value); + + private: + const std::string& _internal_greeting() const; + inline PROTOBUF_ALWAYS_INLINE void _internal_set_greeting( + const std::string& value); + std::string* _internal_mutable_greeting(); + + public: + // @@protoc_insertion_point(class_scope:RoutedHelloResponse) + private: + class _Internal; + + friend class ::google::protobuf::MessageLite; + friend class ::google::protobuf::Arena; + template + friend class ::google::protobuf::Arena::InternalHelper; + using InternalArenaConstructable_ = void; + using DestructorSkippable_ = void; + struct Impl_ { + + inline explicit constexpr Impl_( + ::google::protobuf::internal::ConstantInitialized) noexcept; + inline explicit Impl_(::google::protobuf::internal::InternalVisibility visibility, + ::google::protobuf::Arena* arena); + inline explicit Impl_(::google::protobuf::internal::InternalVisibility visibility, + ::google::protobuf::Arena* arena, const Impl_& from); + ::google::protobuf::internal::ArenaStringPtr greeting_; + mutable ::google::protobuf::internal::CachedSize _cached_size_; + PROTOBUF_TSAN_DECLARE_MEMBER + }; + union { Impl_ _impl_; }; + friend struct ::TableStruct_RoutedHelloRpc_2eproto; +};// ------------------------------------------------------------------- + +class RoutedHelloRequest final : + public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:RoutedHelloRequest) */ { + public: + inline RoutedHelloRequest() : RoutedHelloRequest(nullptr) {} + ~RoutedHelloRequest() override; + template + explicit PROTOBUF_CONSTEXPR RoutedHelloRequest(::google::protobuf::internal::ConstantInitialized); + + inline RoutedHelloRequest(const RoutedHelloRequest& from) + : RoutedHelloRequest(nullptr, from) {} + RoutedHelloRequest(RoutedHelloRequest&& from) noexcept + : RoutedHelloRequest() { + *this = ::std::move(from); + } + + inline RoutedHelloRequest& operator=(const RoutedHelloRequest& from) { + CopyFrom(from); + return *this; + } + inline RoutedHelloRequest& operator=(RoutedHelloRequest&& from) noexcept { + if (this == &from) return *this; + if (GetArena() == from.GetArena() + #ifdef PROTOBUF_FORCE_COPY_IN_MOVE + && GetArena() != nullptr + #endif // !PROTOBUF_FORCE_COPY_IN_MOVE + ) { + InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + + inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const + ABSL_ATTRIBUTE_LIFETIME_BOUND { + return _internal_metadata_.unknown_fields<::google::protobuf::UnknownFieldSet>(::google::protobuf::UnknownFieldSet::default_instance); + } + inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() + ABSL_ATTRIBUTE_LIFETIME_BOUND { + return _internal_metadata_.mutable_unknown_fields<::google::protobuf::UnknownFieldSet>(); + } + + static const ::google::protobuf::Descriptor* descriptor() { + return GetDescriptor(); + } + static const ::google::protobuf::Descriptor* GetDescriptor() { + return default_instance().GetMetadata().descriptor; + } + static const ::google::protobuf::Reflection* GetReflection() { + return default_instance().GetMetadata().reflection; + } + static const RoutedHelloRequest& default_instance() { + return *internal_default_instance(); + } + static inline const RoutedHelloRequest* internal_default_instance() { + return reinterpret_cast( + &_RoutedHelloRequest_default_instance_); + } + static constexpr int kIndexInFileMessages = + 0; + + friend void swap(RoutedHelloRequest& a, RoutedHelloRequest& b) { + a.Swap(&b); + } + inline void Swap(RoutedHelloRequest* other) { + if (other == this) return; + #ifdef PROTOBUF_FORCE_COPY_IN_SWAP + if (GetArena() != nullptr && + GetArena() == other->GetArena()) { + #else // PROTOBUF_FORCE_COPY_IN_SWAP + if (GetArena() == other->GetArena()) { + #endif // !PROTOBUF_FORCE_COPY_IN_SWAP + InternalSwap(other); + } else { + ::google::protobuf::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(RoutedHelloRequest* other) { + if (other == this) return; + ABSL_DCHECK(GetArena() == other->GetArena()); + InternalSwap(other); + } + + // implements Message ---------------------------------------------- + + RoutedHelloRequest* New(::google::protobuf::Arena* arena = nullptr) const final { + return CreateMaybeMessage(arena); + } + int GetCachedSize() const { return _impl_._cached_size_.Get(); } + + private: + ::google::protobuf::internal::CachedSize* AccessCachedSize() const final; + void SharedCtor(::google::protobuf::Arena* arena); + void SharedDtor(); + void InternalSwap(RoutedHelloRequest* other); + + private: + friend class ::google::protobuf::internal::AnyMetadata; + static ::absl::string_view FullMessageName() { + return "RoutedHelloRequest"; + } + protected: + explicit RoutedHelloRequest(::google::protobuf::Arena* arena); + RoutedHelloRequest(::google::protobuf::Arena* arena, const RoutedHelloRequest& from); + public: + + ::google::protobuf::Metadata GetMetadata() const final; + + // nested types ---------------------------------------------------- + + // accessors ------------------------------------------------------- + + enum : int { + kMyNameFieldNumber = 1, + }; + // string myName = 1; + void clear_myname() ; + const std::string& myname() const; + template + void set_myname(Arg_&& arg, Args_... args); + std::string* mutable_myname(); + PROTOBUF_NODISCARD std::string* release_myname(); + void set_allocated_myname(std::string* value); + + private: + const std::string& _internal_myname() const; + inline PROTOBUF_ALWAYS_INLINE void _internal_set_myname( + const std::string& value); + std::string* _internal_mutable_myname(); + + public: + // @@protoc_insertion_point(class_scope:RoutedHelloRequest) + private: + class _Internal; + + friend class ::google::protobuf::MessageLite; + friend class ::google::protobuf::Arena; + template + friend class ::google::protobuf::Arena::InternalHelper; + using InternalArenaConstructable_ = void; + using DestructorSkippable_ = void; + struct Impl_ { + + inline explicit constexpr Impl_( + ::google::protobuf::internal::ConstantInitialized) noexcept; + inline explicit Impl_(::google::protobuf::internal::InternalVisibility visibility, + ::google::protobuf::Arena* arena); + inline explicit Impl_(::google::protobuf::internal::InternalVisibility visibility, + ::google::protobuf::Arena* arena, const Impl_& from); + ::google::protobuf::internal::ArenaStringPtr myname_; + mutable ::google::protobuf::internal::CachedSize _cached_size_; + PROTOBUF_TSAN_DECLARE_MEMBER + }; + union { Impl_ _impl_; }; + friend struct ::TableStruct_RoutedHelloRpc_2eproto; +}; + +// =================================================================== + + + + +// =================================================================== + + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wstrict-aliasing" +#endif // __GNUC__ +// ------------------------------------------------------------------- + +// RoutedHelloRequest + +// string myName = 1; +inline void RoutedHelloRequest::clear_myname() { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + _impl_.myname_.ClearToEmpty(); +} +inline const std::string& RoutedHelloRequest::myname() const + ABSL_ATTRIBUTE_LIFETIME_BOUND { + // @@protoc_insertion_point(field_get:RoutedHelloRequest.myName) + return _internal_myname(); +} +template +inline PROTOBUF_ALWAYS_INLINE void RoutedHelloRequest::set_myname(Arg_&& arg, + Args_... args) { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + ; + _impl_.myname_.Set(static_cast(arg), args..., GetArena()); + // @@protoc_insertion_point(field_set:RoutedHelloRequest.myName) +} +inline std::string* RoutedHelloRequest::mutable_myname() ABSL_ATTRIBUTE_LIFETIME_BOUND { + std::string* _s = _internal_mutable_myname(); + // @@protoc_insertion_point(field_mutable:RoutedHelloRequest.myName) + return _s; +} +inline const std::string& RoutedHelloRequest::_internal_myname() const { + PROTOBUF_TSAN_READ(&_impl_._tsan_detect_race); + return _impl_.myname_.Get(); +} +inline void RoutedHelloRequest::_internal_set_myname(const std::string& value) { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + ; + _impl_.myname_.Set(value, GetArena()); +} +inline std::string* RoutedHelloRequest::_internal_mutable_myname() { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + ; + return _impl_.myname_.Mutable( GetArena()); +} +inline std::string* RoutedHelloRequest::release_myname() { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + // @@protoc_insertion_point(field_release:RoutedHelloRequest.myName) + return _impl_.myname_.Release(); +} +inline void RoutedHelloRequest::set_allocated_myname(std::string* value) { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + _impl_.myname_.SetAllocated(value, GetArena()); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (_impl_.myname_.IsDefault()) { + _impl_.myname_.Set("", GetArena()); + } + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + // @@protoc_insertion_point(field_set_allocated:RoutedHelloRequest.myName) +} + +// ------------------------------------------------------------------- + +// RoutedHelloResponse + +// string greeting = 1; +inline void RoutedHelloResponse::clear_greeting() { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + _impl_.greeting_.ClearToEmpty(); +} +inline const std::string& RoutedHelloResponse::greeting() const + ABSL_ATTRIBUTE_LIFETIME_BOUND { + // @@protoc_insertion_point(field_get:RoutedHelloResponse.greeting) + return _internal_greeting(); +} +template +inline PROTOBUF_ALWAYS_INLINE void RoutedHelloResponse::set_greeting(Arg_&& arg, + Args_... args) { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + ; + _impl_.greeting_.Set(static_cast(arg), args..., GetArena()); + // @@protoc_insertion_point(field_set:RoutedHelloResponse.greeting) +} +inline std::string* RoutedHelloResponse::mutable_greeting() ABSL_ATTRIBUTE_LIFETIME_BOUND { + std::string* _s = _internal_mutable_greeting(); + // @@protoc_insertion_point(field_mutable:RoutedHelloResponse.greeting) + return _s; +} +inline const std::string& RoutedHelloResponse::_internal_greeting() const { + PROTOBUF_TSAN_READ(&_impl_._tsan_detect_race); + return _impl_.greeting_.Get(); +} +inline void RoutedHelloResponse::_internal_set_greeting(const std::string& value) { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + ; + _impl_.greeting_.Set(value, GetArena()); +} +inline std::string* RoutedHelloResponse::_internal_mutable_greeting() { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + ; + return _impl_.greeting_.Mutable( GetArena()); +} +inline std::string* RoutedHelloResponse::release_greeting() { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + // @@protoc_insertion_point(field_release:RoutedHelloResponse.greeting) + return _impl_.greeting_.Release(); +} +inline void RoutedHelloResponse::set_allocated_greeting(std::string* value) { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + _impl_.greeting_.SetAllocated(value, GetArena()); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (_impl_.greeting_.IsDefault()) { + _impl_.greeting_.Set("", GetArena()); + } + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + // @@protoc_insertion_point(field_set_allocated:RoutedHelloResponse.greeting) +} + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif // __GNUC__ + +// @@protoc_insertion_point(namespace_scope) + + +// @@protoc_insertion_point(global_scope) + +#include "google/protobuf/port_undef.inc" + +#endif // GOOGLE_PROTOBUF_INCLUDED_RoutedHelloRpc_2eproto_2epb_2eh diff --git a/packages/streamr-proto-rpc/examples/routed-hello/proto/RoutedHelloRpc.server.pb.h b/packages/streamr-proto-rpc/examples/routed-hello/proto/RoutedHelloRpc.server.pb.h new file mode 100644 index 0000000..cb73135 --- /dev/null +++ b/packages/streamr-proto-rpc/examples/routed-hello/proto/RoutedHelloRpc.server.pb.h @@ -0,0 +1,19 @@ +// Generated by the protocol buffer streamr pluging. DO NOT EDIT! +// Generated from protobuf file "RoutedHelloRpc.proto" + +#ifndef STREAMR_PROTORPC_ROUTEDHELLORPC_SERVER_PB_H +#define STREAMR_PROTORPC_ROUTEDHELLORPC_SERVER_PB_H + +#include "RoutedHelloRpc.pb.h" // NOLINT +#include + +namespace streamr::protorpc { +class RoutedHelloRpcService { +public: + virtual ~RoutedHelloRpcService() = default; + virtual RoutedHelloResponse sayHello(const RoutedHelloRequest& request, const ProtoCallContext& callContext) = 0; +}; // class RoutedHelloRpcService +}; // namespace streamr::protorpc + +#endif // STREAMR_PROTORPC_ROUTEDHELLORPC_SERVER_PB_H + diff --git a/packages/streamr-proto-rpc/examples/routed-hello/routedhello.cpp b/packages/streamr-proto-rpc/examples/routed-hello/routedhello.cpp new file mode 100644 index 0000000..a58b3ab --- /dev/null +++ b/packages/streamr-proto-rpc/examples/routed-hello/routedhello.cpp @@ -0,0 +1,189 @@ +#include +#include +#include +#include +#include "RoutedHelloRpc.client.pb.h" +#include "RoutedHelloRpc.pb.h" +#include "RoutedHelloRpc.server.pb.h" +#include "streamr-proto-rpc/ProtoCallContext.hpp" +#include "streamr-proto-rpc/RpcCommunicator.hpp" + +using streamr::protorpc::ProtoCallContext; +using ::RoutedHelloResponse; +using streamr::protorpc::RoutedHelloRpcService; +using streamr::protorpc::RoutedHelloRpcServiceClient; +using streamr::protorpc::RpcCommunicator; +using streamr::protorpc::RpcMessage; +class RoutedHelloService : public RoutedHelloRpcService { +private: + std::string mServiceId; + +public: + explicit RoutedHelloService(std::string_view serviceId) + : mServiceId(std::string(serviceId)) {} + + RoutedHelloResponse sayHello( + const RoutedHelloRequest& request, + const ProtoCallContext& callContext) override { + RoutedHelloResponse response; + std::string sourceId = callContext.at("sourceId"); + std::cout << "sayHello() called on server " << mServiceId + << " with context parameter sourceId " << sourceId << "\n"; + response.set_greeting("Hello, " + request.myname() + "!"); + return response; + } + [[nodiscard]] std::string getServiceId() const { return mServiceId; } +}; + +int main() { + std::map> + clientCommunicators; + + // Setup server + + RpcCommunicator serverCommunicator1; + RoutedHelloService helloService1("1"); + + serverCommunicator1 + .registerRpcMethod( + "sayHello", + std::bind( // NOLINT(modernize-avoid-bind) + &RoutedHelloService::sayHello, + &helloService1, + std::placeholders::_1, + std::placeholders::_2)); + + // Setup server 2 + + RpcCommunicator serverCommunicator2; + RoutedHelloService helloService2("2"); + + serverCommunicator2 + .registerRpcMethod( + "sayHello", + std::bind( // NOLINT(modernize-avoid-bind) + &RoutedHelloService::sayHello, + &helloService2, + std::placeholders::_1, + std::placeholders::_2)); + + // Setup client1 + + auto communicator1 = std::make_shared(); + RoutedHelloRpcServiceClient helloClient1(*communicator1); + clientCommunicators["1"] = communicator1; + + // Setup client2 + + auto communicator2 = std::make_shared(); + RoutedHelloRpcServiceClient helloClient2(*communicator2); + clientCommunicators["2"] = communicator2; + + // Simulate a network connections + + serverCommunicator1.setOutgoingMessageCallback( + [&clientCommunicators]( + const RpcMessage& message, + const std::string& /* requestId */, + const ProtoCallContext& context) -> void { + // Send the reply message to the calling client based on + // sourceId passed + // through the network stack in the context information + const std::string sourceId = context.at("sourceId"); + clientCommunicators[sourceId]->handleIncomingMessage( + message, context); + }); + + serverCommunicator2.setOutgoingMessageCallback( + [&clientCommunicators]( + const RpcMessage& message, + const std::string& /* requestId */, + const ProtoCallContext& context) -> void { + const std::string sourceId = context.at("sourceId"); + clientCommunicators[sourceId]->handleIncomingMessage( + message, context); + }); + + communicator1->setOutgoingMessageCallback( + [&clientCommunicators, &serverCommunicator1, &serverCommunicator2]( + const RpcMessage& message, + const std::string& /* requestId */, + const ProtoCallContext& context) -> void { + // Choose the server to send the message to based on context + // information passed through the RPC stack as client context + // information + RpcCommunicator* server; + std::string targetServerId = context.at("targetServerId"); + + if (targetServerId == "2") { + server = &serverCommunicator2; + } else { + server = &serverCommunicator1; + } + + // Here you would transport the msgBody over network to the server + // ... + // At the server you would pass the id of the calling client as + // context information to the server. The server is free to choose + // what to use as the id of the calling client; it might use, for + // example, the id of the network socket, something negotiated + // during connection handshake, or something passed on in every + // network payload. + // + // The context information gets passed uncahged through the RPC + // stack, so the reply message can be routed to the correct client. + + ProtoCallContext serverContext; + serverContext["sourceId"] = "1"; + + server->handleIncomingMessage(message, serverContext); + }); + + communicator2->setOutgoingMessageCallback( + [&clientCommunicators, &serverCommunicator1, &serverCommunicator2]( + const RpcMessage& message, + const std::string& /* requestId */, + const ProtoCallContext& context) -> void { + RpcCommunicator* server; + std::string targetServerId = context.at("targetServerId"); + + if (targetServerId == "2") { + server = &serverCommunicator2; + } else { + server = &serverCommunicator1; + } + + ProtoCallContext serverContext; + serverContext["sourceId"] = "2"; + + server->handleIncomingMessage(message, serverContext); + }); + + // Make some RPC calls + + RoutedHelloRequest request; + request.set_myname("Alice"); + ProtoCallContext context; + context["targetServerId"] = "2"; + + auto response = + folly::coro::blockingWait(helloClient1.sayHello(request, context)); + + std::cout << "Client 1 (Alice) got message from server: " + + response.greeting() + << "\n"; + + RoutedHelloRequest request2; + request2.set_myname("Bob"); + ProtoCallContext context2; + context2["targetServerId"] = "1"; + + auto response2 = + folly::coro::blockingWait(helloClient2.sayHello(request2, context2)); + + std::cout << "Client 2 (Bob) got message from server: " + + response2.greeting() + << "\n"; + + return 0; +} diff --git a/packages/streamr-proto-rpc/homebrewClang.cmake b/packages/streamr-proto-rpc/homebrewClang.cmake index 41e7cac..7fb0426 100644 --- a/packages/streamr-proto-rpc/homebrewClang.cmake +++ b/packages/streamr-proto-rpc/homebrewClang.cmake @@ -1,7 +1,7 @@ if (${APPLE}) set(HOMEBREW_PREFIX $ENV{HOMEBREW_PREFIX}) - set(LLVM_PREFIX "${HOMEBREW_PREFIX}/opt/llvm") + set(LLVM_PREFIX "${HOMEBREW_PREFIX}") set(CMAKE_C_COMPILER "${LLVM_PREFIX}/bin/clang") set(CMAKE_CXX_COMPILER "${LLVM_PREFIX}/bin/clang++") set(ENV{CC} "${CMAKE_C_COMPILER}") @@ -20,7 +20,7 @@ if (${APPLE}) set(CMAKE_FIND_FRAMEWORK LAST) set(CMAKE_FIND_APPBUNDLE LAST) - add_link_options("-L/opt/homebrew/opt/llvm/lib/c++" "-Wl,-rpath,/opt/homebrew/opt/llvm/lib/c++") + add_link_options("-L/opt/homebrew/lib/c++" "-Wl,-rpath,/opt/homebrew/lib/c++") #set(CMAKE_FIND_USE_CMAKE_SYSTEM_PATH FALSE) #set(CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH FALSE) endif() diff --git a/packages/streamr-proto-rpc/include/streamr-proto-rpc/Errors.hpp b/packages/streamr-proto-rpc/include/streamr-proto-rpc/Errors.hpp new file mode 100644 index 0000000..8ac175c --- /dev/null +++ b/packages/streamr-proto-rpc/include/streamr-proto-rpc/Errors.hpp @@ -0,0 +1,177 @@ +#ifndef STREAMR_PROTO_RPC_ERRORS_HPP +#define STREAMR_PROTO_RPC_ERRORS_HPP + +#include +#include +#include +#include +#include + +namespace streamr::protorpc { + +// NOLINTBEGIN +enum class ErrorCode { + RPC_TIMEOUT, + RPC_REQUEST, + RPC_SERVER_ERROR, + RPC_CLIENT_ERROR, + NOT_IMPLEMENTED, + UNKNOWN_RPC_METHOD, + FAILED_TO_PARSE, + FAILED_TO_SERIALIZE +}; +// NOLINTEND + +class Err : public std::runtime_error { +public: + ErrorCode code; // NOLINT + std::string message; // NOLINT + std::optional originalErrorInfo; // NOLINT + + Err(ErrorCode code, + const std::string& message, + const std::optional& originalErrorInfo = std::nullopt) + : std::runtime_error(message), + code(code), + message(message), + originalErrorInfo(originalErrorInfo) { + createStringRepresentation(); + } + + [[nodiscard]] virtual std::string toString() const { + return stringRepresentation; + } + + [[nodiscard]] const char* what() const noexcept override { + return stringRepresentation.c_str(); + } + +private: + std::string stringRepresentation; // NOLINT + + void createStringRepresentation() { + stringRepresentation = + "code: " + std::string(magic_enum::enum_name(code)); + stringRepresentation += ", message: " + message; + if (originalErrorInfo.has_value()) { + stringRepresentation += + ", originalErrorInfo: " + originalErrorInfo.value(); + } + } +}; + +struct RpcTimeout : public Err { + explicit RpcTimeout( + const std::string& message, + const std::optional& originalErrorInfo = std::nullopt) + : Err(ErrorCode::RPC_TIMEOUT, message, originalErrorInfo) {} +}; + +struct FailedToParse : public Err { + explicit FailedToParse( + const std::string& message, + const std::optional& originalErrorInfo = std::nullopt) + : Err(ErrorCode::FAILED_TO_PARSE, message, originalErrorInfo) {} +}; + +struct FailedToSerialize : public Err { + explicit FailedToSerialize( + const std::string& message, + const std::optional& originalErrorInfo = std::nullopt) + : Err(ErrorCode::FAILED_TO_SERIALIZE, message, originalErrorInfo) {} +}; + +struct UnknownRpcMethod : public Err { + explicit UnknownRpcMethod( + const std::string& message, + const std::optional& originalErrorInfo = std::nullopt) + : Err(ErrorCode::UNKNOWN_RPC_METHOD, message, originalErrorInfo) {} +}; + +struct RpcRequestError : public Err { + explicit RpcRequestError( + const std::string& message, + const std::optional& originalErrorInfo = std::nullopt) + : Err(ErrorCode::RPC_REQUEST, message, originalErrorInfo) {} +}; + +struct RpcClientError : public Err { + explicit RpcClientError( + const std::string& message, + const std::optional& originalErrorInfo = std::nullopt) + : Err(ErrorCode::RPC_CLIENT_ERROR, message, originalErrorInfo) {} +}; + +class RpcServerError : public Err { +public: + std::string errorClassName; // NOLINT + std::string errorCode; // NOLINT + + RpcServerError( + const std::string& errorMessage, // NOLINT + const std::string& errorClassName, // NOLINT + const std::string& errorCode) // NOLINT + : Err(ErrorCode::RPC_SERVER_ERROR, errorMessage), + errorClassName(errorClassName), + errorCode(errorCode) { + createStringRepresentation(); + } + + [[nodiscard]] std::string toString() const override { + return stringRepresentation; + } + + [[nodiscard]] const char* what() const noexcept override { + return stringRepresentation.c_str(); + } + +private: + std::string stringRepresentation; // NOLINT + + void createStringRepresentation() { + stringRepresentation = Err::toString(); + stringRepresentation += ", errorClassName: " + errorClassName; + stringRepresentation += ", errorCode: " + errorCode; + } +}; + +using RpcException = std::variant< + RpcTimeout, + RpcRequestError, + RpcServerError, + RpcClientError, + UnknownRpcMethod, + FailedToParse, + FailedToSerialize>; + +/* +export class RpcTimeout extends Err { constructor(message?: string, +originalError?: Error | string) { super(ErrorCode.RPC_TIMEOUT, message, +originalError) } } export class RpcRequest extends Err { constructor(message?: +string, originalError?: Error | string) { super(ErrorCode.RPC_REQUEST, message, +originalError) } } export class RpcServerError extends Err { public +errorClassName?: string public errorCode?: string + + constructor(errorMessage?: string, errorClassName?: string, errorCode?: +string) { super(ErrorCode.RPC_SERVER_ERROR, errorMessage) this.errorClassName = +errorClassName this.errorCode = errorCode + } +} +export class RpcClientError extends Err { constructor(message?: string, +originalError?: Error | string) { super(ErrorCode.RPC_CLIENT_ERROR, message, +originalError) } } export class NotImplemented extends Err { +constructor(message?: string, originalError?: Error | string) { +super(ErrorCode.NOT_IMPLEMENTED, message, originalError) } } export class +UnknownRpcMethod extends Err { constructor(message?: string, originalError?: +Error | string) { super(ErrorCode.UNKNOWN_RPC_METHOD, message, originalError) } +} export class FailedToParse extends Err { constructor(message?: string, +originalError?: Error | string) { super(ErrorCode.FAILED_TO_PARSE, message, +originalError) } } export class FailedToSerialize extends Err { +constructor(message?: string, originalError?: Error | string) { +super(ErrorCode.FAILED_TO_SERIALIZE, message, originalError) } } + +*/ + +} // namespace streamr::protorpc + +#endif // STREAMR_PROTO_RPC_ERRORS_HPP diff --git a/packages/streamr-proto-rpc/include/streamr-proto-rpc/PluginCodeGenerator.hpp b/packages/streamr-proto-rpc/include/streamr-proto-rpc/PluginCodeGenerator.hpp new file mode 100644 index 0000000..ce2602b --- /dev/null +++ b/packages/streamr-proto-rpc/include/streamr-proto-rpc/PluginCodeGenerator.hpp @@ -0,0 +1,322 @@ +#ifndef STREAMER_PROTORPC_PLUGIN_CODE_GENERATOR_HPP +#define STREAMER_PROTORPC_PLUGIN_CODE_GENERATOR_HPP + +#include +#include +#include +#include +#include +#include +#include +#include +#include "streamr-proto-rpc/StreamPrinter.hpp" + +namespace streamr::protorpc { + +class PluginCodeGenerator : public google::protobuf::compiler::CodeGenerator { +public: + PluginCodeGenerator() = default; + ~PluginCodeGenerator() override = default; + + bool Generate( + const google::protobuf::FileDescriptor* file, + const std::string& parameter, + google::protobuf::compiler::GeneratorContext* generatorContext, + std::string* error) const override { + return GenerateHeader(file, parameter, generatorContext, error) && + GenerateSource(file, parameter, generatorContext, error); + } + + uint64_t GetSupportedFeatures() const override { // NOLINT + // Indicate that this code generator supports proto3 optional fields. + // (Note: don't release your code generator with this flag set until you + // have actually added and tested your proto3 support!) + return FEATURE_PROTO3_OPTIONAL; + } + +private: + [[nodiscard]] static std::string toUpperCase(const std::string& str) { + std::string result = str; + std::transform(result.begin(), result.end(), result.begin(), ::toupper); + return result; + } + + [[nodiscard]] static std::string getFilenameWithoutExtension( + const std::string& filepath) { + // Find the last directory separator + size_t lastSlash = filepath.find_last_of("/\\"); + std::string filename = filepath.substr(lastSlash + 1); + + // Find the last dot in the filename + size_t lastDot = filename.find_last_of('.'); + if (lastDot == std::string::npos) { + return filename; // No extension found + } + return filename.substr(0, lastDot); + } + + bool GenerateServerHeader( // NOLINT + const google::protobuf::FileDescriptor* file, + const std::string& /* parameter */, + google::protobuf::compiler::GeneratorContext* generatorContext, + std::string* /* error */) const { + bool emptyIncluded = false; + const std::string& protoFilename = file->name(); + const std::string protoFilenameWe = + getFilenameWithoutExtension(protoFilename); + const std::string headerFilename = protoFilenameWe + ".server.pb.h"; + const std::string typesFilename = protoFilenameWe + ".pb.h"; + const std::string headerGuard = + "STREAMR_PROTORPC_" + toUpperCase(protoFilenameWe) + "_SERVER_PB_H"; + + std::stringstream headerSs; + + headerSs + << "// Generated by the protocol buffer streamr pluging. DO NOT EDIT!\n"; + headerSs << "// Generated from protobuf file \"" << protoFilename + << "\"\n"; + headerSs << "\n"; + headerSs << "#ifndef " << headerGuard << "\n"; + headerSs << "#define " << headerGuard << "\n\n"; + headerSs << "#include \"" << typesFilename << "\" // NOLINT \n"; + headerSs << "#include \n"; + + std::stringstream sourceSs; + + if (file->package().empty()) { + sourceSs << "namespace streamr::protorpc {\n"; + } else { + sourceSs << "namespace " << file->package() << " {\n"; + } + + // for each services + int numServices = file->service_count(); + for (int i = 0; i < numServices; i++) { + const google::protobuf::ServiceDescriptor* service = + file->service(i); + const std::string serviceFullname = service->full_name(); + const std::string& serviceName = service->name(); + + sourceSs << "class " << serviceName << " {\n"; + sourceSs << "public:\n"; + sourceSs << " virtual ~" << serviceName << "() = default;\n"; + // sourceSs << " \n"; + // for each methods + int numMethods = service->method_count(); + for (int j = 0; j < numMethods; j++) { + const google::protobuf::MethodDescriptor* method = + service->method(j); + const std::string methodFullname = method->full_name(); + const std::string& methodName = method->name(); + + const google::protobuf::Descriptor* methodInput = + method->input_type(); + const std::string methodInputFullname = + methodInput->full_name(); + std::string methodInputName = methodInput->name(); + + const google::protobuf::Descriptor* methodOutput = + method->output_type(); + + if (methodInput->name() == "Empty") { + if (!emptyIncluded) { + headerSs << "#include \n"; + emptyIncluded = true; + } + methodInputName = "google::protobuf::Empty"; + } + + const std::string methodOutputFullname = + methodOutput->full_name(); + std::string methodOutputName = methodOutput->name(); + + if (methodOutputName == "Empty") { + methodOutputName = "void"; + } + + sourceSs + << " virtual " << methodOutputName + " " << methodName + << "(const " << methodInputName + << "& request, const ProtoCallContext& callContext) = 0;\n"; + } + sourceSs << "}; // class " << serviceName << "\n"; + } + + if (file->package().empty()) { + sourceSs << "}; // namespace streamr::protorpc\n"; + } else { + sourceSs << "}; // namespace " << file->package() << "\n"; + } + + sourceSs << "\n"; + sourceSs << "#endif // " << headerGuard << "\n"; + // output to header file + google::protobuf::io::ZeroCopyOutputStream* stream = + generatorContext->Open(headerFilename); + StreamPrinter printer( + stream); // StreamPrinter takes ownership of the Stream + const std::string headerBuffer = headerSs.str() + "\n"; + const std::string sourceBuffer = sourceSs.str() + "\n"; + + printer.print( + reinterpret_cast(headerBuffer.c_str()), + std::ssize(headerBuffer)); + printer.print( + reinterpret_cast(sourceBuffer.c_str()), + std::ssize(sourceBuffer)); + return true; + } + + bool GenerateClientHeader( // NOLINT + const google::protobuf::FileDescriptor* file, + const std::string& /* parameter */, + google::protobuf::compiler::GeneratorContext* generatorContext, + std::string* /* error */) const { + bool emptyIncluded = false; + const std::string& protoFilename = file->name(); + const std::string protoFilenameWe = + getFilenameWithoutExtension(protoFilename); + const std::string headerFilename = protoFilenameWe + ".client.pb.h"; + const std::string typesFilename = protoFilenameWe + ".pb.h"; + const std::string headerGuard = + "STREAMR_PROTORPC_" + toUpperCase(protoFilenameWe) + "_CLIENT_PB_H"; + + std::stringstream headerSs; + + headerSs + << "// generated by the protocol buffer streamr pluging. DO NOT EDIT!\n"; + headerSs << "// generated from protobuf file \"" << protoFilename + << "\"\n"; + headerSs << "\n"; + headerSs << "#ifndef " << headerGuard << "\n"; + headerSs << "#define " << headerGuard << "\n\n"; + headerSs << "#include \n"; + headerSs << "#include \"" << typesFilename << "\" // NOLINT\n"; + headerSs << "#include \"streamr-proto-rpc/ProtoCallContext.hpp\"\n"; + headerSs << "#include \"streamr-proto-rpc/RpcCommunicator.hpp\"\n"; + + headerSs << "\n"; + + std::stringstream sourceSs; + + if (file->package().empty()) { + sourceSs << "namespace streamr::protorpc {\n"; + } else { + sourceSs << "namespace " << file->package() << " {\n"; + } + + // for each services + int numServices = file->service_count(); + for (int i = 0; i < numServices; i++) { + const google::protobuf::ServiceDescriptor* service = + file->service(i); + const std::string serviceFullname = service->full_name(); + const std::string& serviceName = service->name(); + sourceSs << "class " << serviceName << "Client" + << " {\n"; + sourceSs << "private:\n"; + sourceSs << "RpcCommunicator& communicator;\n"; + sourceSs << "public:\n"; + sourceSs + << " " << serviceName + << "Client(RpcCommunicator& communicator) : communicator(communicator) {}\n"; + // sourceSs << " \n"; + // for each methods + int numMethods = service->method_count(); + for (int j = 0; j < numMethods; j++) { + const google::protobuf::MethodDescriptor* method = + service->method(j); + const std::string methodFullname = method->full_name(); + const std::string& methodName = method->name(); + + const google::protobuf::Descriptor* methodInput = + method->input_type(); + const std::string methodInputFullname = + methodInput->full_name(); + std::string methodInputName = methodInput->name(); + + const google::protobuf::Descriptor* methodOutput = + method->output_type(); + + if (methodInput->name() == "Empty") { + if (!emptyIncluded) { + headerSs << "#include \n"; + emptyIncluded = true; + } + methodInputName = "google::protobuf::Empty"; + } + + const std::string methodOutputFullname = + methodOutput->full_name(); + std::string methodOutputName = methodOutput->name(); + + if (methodOutputName == "Empty") { + methodOutputName = "void"; + } + + sourceSs + << " folly::coro::Task<" + methodOutputName + "> " + << methodName << "(const " << methodInputName + << "& request, const ProtoCallContext& callContext) {\n"; + sourceSs << " return communicator."; + if (methodOutputName == "void") { + sourceSs << "notify<" << methodInputName << ">"; + } else { + sourceSs << "request<" << methodOutputName << ", " + << methodInputName << ">"; + } + sourceSs << "(\"" << methodName + << "\", request, callContext);\n"; + sourceSs << " }\n"; + } + sourceSs << "}; // class " << serviceName << "Client\n"; + } + + if (file->package().empty()) { + sourceSs << "}; // namespace streamr::protorpc\n"; + } else { + sourceSs << "}; // namespace " << file->package() << "\n"; + } + + sourceSs << "\n"; + sourceSs << "#endif // " << headerGuard << "\n"; + // output to header file + google::protobuf::io::ZeroCopyOutputStream* stream = + generatorContext->Open(headerFilename); + StreamPrinter printer( + stream); // StreamPrinter takes ownership of the Stream + const std::string headerBuffer = headerSs.str() + "\n"; + const std::string sourceBuffer = sourceSs.str() + "\n"; + + printer.print( + reinterpret_cast(headerBuffer.c_str()), + std::ssize(headerBuffer)); + printer.print( + reinterpret_cast(sourceBuffer.c_str()), + std::ssize(sourceBuffer)); + return true; + } + + bool GenerateHeader( // NOLINT + const google::protobuf::FileDescriptor* file, + const std::string& parameter, + google::protobuf::compiler::GeneratorContext* generatorContext, + std::string* error) const { + std::cerr << "GenerateHeader()" + << "\n"; + return GenerateServerHeader(file, parameter, generatorContext, error) && + GenerateClientHeader(file, parameter, generatorContext, error); + } + + bool GenerateSource( // NOLINT + const google::protobuf::FileDescriptor* /* file */, + const std::string& /* parameter */, + google::protobuf::compiler::GeneratorContext* /* generatorContext */, + std::string* /* error */) const { + std::cerr << "GenerateSource()" + << "\n"; + return true; + } +}; +}; // namespace streamr::protorpc +#endif // PROTOBUF_STREAMR_PLUGIN_PLUGIN_CODE_GENERATOR_HPP \ No newline at end of file diff --git a/packages/streamr-proto-rpc/include/streamr-proto-rpc/ProtoCallContext.hpp b/packages/streamr-proto-rpc/include/streamr-proto-rpc/ProtoCallContext.hpp new file mode 100644 index 0000000..f0382c2 --- /dev/null +++ b/packages/streamr-proto-rpc/include/streamr-proto-rpc/ProtoCallContext.hpp @@ -0,0 +1,17 @@ +#ifndef STREAMR_PROTO_RPC_PROTO_CALL_CONTEXT_HPP +#define STREAMR_PROTO_RPC_PROTO_CALL_CONTEXT_HPP + +#include +#include +#include + +namespace streamr::protorpc { + +struct ProtoCallContext : public std::map { + std::optional timeout; + bool notification = false; +}; + +} // namespace streamr::protorpc + +#endif // STREAMR_PROTO_RPC_PROTO_CALL_CONTEXT_HPP \ No newline at end of file diff --git a/packages/streamr-proto-rpc/include/streamr-proto-rpc/RpcCommunicator.hpp b/packages/streamr-proto-rpc/include/streamr-proto-rpc/RpcCommunicator.hpp new file mode 100644 index 0000000..fe23298 --- /dev/null +++ b/packages/streamr-proto-rpc/include/streamr-proto-rpc/RpcCommunicator.hpp @@ -0,0 +1,194 @@ +#ifndef STREAMR_PROTO_RPC_RPC_COMMUNICATOR_HPP +#define STREAMR_PROTO_RPC_RPC_COMMUNICATOR_HPP + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include "ProtoCallContext.hpp" +#include "ProtoRpc.pb.h" +#include "RpcCommunicatorClientApi.hpp" +#include "RpcCommunicatorServerApi.hpp" +#include "ServerRegistry.hpp" + +#include "streamr-logger/SLogger.hpp" + +namespace streamr::protorpc { + +using google::protobuf::Any; +using streamr::logger::SLogger; +using RpcMessage = ::protorpc::RpcMessage; +using RpcErrorType = ::protorpc::RpcErrorType; +using folly::coro::Task; +using OutgoingMessageCallbackType = + RpcCommunicatorClientApi::OutgoingMessageCallbackType; + +constexpr size_t defaultRpcRequestTimeout = 5000; + +// NOLINTBEGIN +enum class StatusCode { OK, STOPPED, DEADLINE_EXCEEDED, SERVER_ERROR }; +// NOLINTEND + +struct RpcCommunicatorConfig { + size_t rpcRequestTimeout; +}; +class RpcCommunicator { +private: + RpcCommunicatorClientApi mRpcCommunicatorClientApi; + RpcCommunicatorServerApi mRpcCommunicatorServerApi; + +public: + explicit RpcCommunicator( + std::optional config = std::nullopt) + : mRpcCommunicatorClientApi( + config.has_value() ? config.value().rpcRequestTimeout + : defaultRpcRequestTimeout) {} + + // Messaging API + + /** + * @brief Handle a message incoming from the network + * + * @param message message received from the network + * @param callContext call context such as routing information + */ + + void handleIncomingMessage( + const RpcMessage& message, const ProtoCallContext& callContext) { + this->onIncomingMessage(message, callContext); + } + + /** + * @brief Set a callback for sending outgoing messages to the network + * + * @param callback callback to be called when a message is ready to be sent. + * The callback may throw exeptions which will be forwarded through the + * RpcCommunicator + * + */ + + template + requires std::is_assignable_v + void setOutgoingMessageCallback(F&& callback) { + mRpcCommunicatorClientApi.setOutgoingMessageCallback( + std::forward(callback)); + mRpcCommunicatorServerApi.setOutgoingMessageCallback( + std::forward(callback)); + } + + // Client-side API + + /** + * @brief [A method to be called by auto-generated clients] Make a RPC + * request to a remote method + * + * @param methodName name of the method to be called + * @param methodParam parameter to be passed to the method + * @param callContext call context such as routing information + * @return Task + */ + + template + Task request( + const std::string& methodName, + const RequestType& methodParam, + const ProtoCallContext& callContext) { + return mRpcCommunicatorClientApi.request( + methodName, methodParam, callContext); + } + + /** + * @brief [A method to be called by auto-generated clients] Make a + * remote RPC notification + * + * @param notificationName name of the notification to be called + * @param notificationParam parameter to be passed to the notification + * @param callContext call context such as routing information + * @return Task + */ + + template + Task notify( + const std::string_view notificationName, + const RequestType& notificationParam, + const ProtoCallContext& callContext) { + return mRpcCommunicatorClientApi.notify( + notificationName, notificationParam, callContext); + } + + // Server-side API + + /** + * @brief Register a method to be called by remote clients + * + * @param name name of the method + * @param fn function to be registered + * @param options options for the method + */ + + template + requires std::is_assignable_v< + std::function, + F> + void registerRpcMethod( + const std::string& name, const F& fn, MethodOptions options = {}) { + mRpcCommunicatorServerApi.registerRpcMethod( + name, fn, options); + } + + /** + * @brief Register a notification to be called by remote clients + * + * @param name name of the notification + * @param fn function to be registered + * @param options options for the notification + */ + + template + requires std::is_assignable_v< + std::function, + F> + void registerRpcNotification( + const std::string& name, const F& fn, MethodOptions options = {}) { + mRpcCommunicatorServerApi.registerRpcNotification( + name, fn, options); + } + +private: + void onIncomingMessage( + const RpcMessage& rpcMessage, const ProtoCallContext& callContext) { + SLogger::trace("onIncomingMessage", rpcMessage.DebugString()); + + const auto& header = rpcMessage.header(); + + SLogger::trace("onIncomingMessage() requestId", rpcMessage.requestid()); + + if (header.find("response") != header.end()) { + mRpcCommunicatorClientApi.onIncomingMessage( + rpcMessage, callContext); + } else if ( + header.find("request") != header.end() && + header.find("method") != header.end()) { + mRpcCommunicatorServerApi.onIncomingMessage( + rpcMessage, callContext); + } else { + SLogger::debug( + "onIncomingMessage() message is not a valid request or response"); + } + } + // Client-side functions +}; + +} // namespace streamr::protorpc + +#endif // STREAMR_PROTO_RPC_RPC_COMMUNICATOR_HPP \ No newline at end of file diff --git a/packages/streamr-proto-rpc/include/streamr-proto-rpc/RpcCommunicatorClientApi.hpp b/packages/streamr-proto-rpc/include/streamr-proto-rpc/RpcCommunicatorClientApi.hpp new file mode 100644 index 0000000..6c78cea --- /dev/null +++ b/packages/streamr-proto-rpc/include/streamr-proto-rpc/RpcCommunicatorClientApi.hpp @@ -0,0 +1,359 @@ +#ifndef STREAMR_PROTO_RPC_RPC_COMMUNICATOR_CLIENT_API_HPP +#define STREAMR_PROTO_RPC_RPC_COMMUNICATOR_CLIENT_API_HPP + +#include +#include +#include +#include +#include +#include +#include +#include "Errors.hpp" +#include "ProtoCallContext.hpp" +#include "ProtoRpc.pb.h" +#include "streamr-logger/SLogger.hpp" +namespace streamr::protorpc { + +using google::protobuf::Any; +using streamr::logger::SLogger; +using RpcMessage = ::protorpc::RpcMessage; +using RpcErrorType = ::protorpc::RpcErrorType; +using folly::coro::Task; + +constexpr size_t threadPoolSize = 20; + +class RpcCommunicatorClientApi { +public: + using OutgoingMessageCallbackType = std::function; + +private: + class OngoingRequestBase { + public: + virtual ~OngoingRequestBase() = default; + virtual void resolveRequest(const RpcMessage& response) = 0; + virtual void resolveNotification() = 0; + virtual void rejectRequest(const RpcException& error) = 0; + }; + + template + class OngoingRequest : public OngoingRequestBase { + private: + std::pair< + folly::coro::Promise, + folly::coro::Future> + mPromiseContract; + + public: + OngoingRequest() + : mPromiseContract(folly::coro::makePromiseContract()) { + } + + folly::coro::Promise& getPromise() { + return mPromiseContract.first; + } + + folly::coro::Future&& getFuture() { + return std::move(mPromiseContract.second); + } + + void resolveRequest(const RpcMessage& response) override { + this->resolvePromise(response); + } + + void resolveNotification() override { + mPromiseContract.first.setValue(); + } + + void rejectRequest(const RpcException& error) override { + std::visit( + [this](auto&& arg) { + SLogger::trace( + "rejectRequest()", + arg.originalErrorInfo.has_value() + ? arg.originalErrorInfo.value() + : ""); + this->mPromiseContract.first.setException(arg); + }, + error); + } + + private: + void resolvePromise(const RpcMessage& response) { + try { + ResultType result; + response.body().UnpackTo(&result); + + mPromiseContract.first.setValue(result); + } catch (const std::exception& err) { + SLogger::debug( + "Could not parse response, Failed to parse received response, \ + network protocol version is probably incompatible"); + + auto error = FailedToParse( + "Failed to parse received response, network protocol version \ + is likely incompatible"); + + mPromiseContract.first.setException(error); + } + } + }; + + OutgoingMessageCallbackType mOutgoingMessageCallback; + std::unordered_map> + mOngoingRequests; + std::recursive_mutex mOngoingRequestsMutex; + size_t mRpcRequestTimeout; + folly::CPUThreadPoolExecutor mExecutor; + +public: + explicit RpcCommunicatorClientApi(size_t rpcRequestTimeout) + : mRpcRequestTimeout(rpcRequestTimeout), mExecutor(threadPoolSize) {} + + template + requires std::is_assignable_v + void setOutgoingMessageCallback(F&& callback) { + mOutgoingMessageCallback = std::forward(callback); + } + + void onIncomingMessage( + const RpcMessage& rpcMessage, + const ProtoCallContext& /* callContext */) { + std::lock_guard lock(mOngoingRequestsMutex); + + const auto& header = rpcMessage.header(); + if (header.find("response") != header.end()) { + SLogger::trace("onIncomingMessage() message is a response"); + if (mOngoingRequests.find(rpcMessage.requestid()) != + mOngoingRequests.end()) { + SLogger::trace("onIncomingMessage() ongoing request found"); + if (rpcMessage.has_errortype()) { + SLogger::trace( + "onIncomingMessage() rejecting ongoing request"); + this->rejectOngoingRequest(rpcMessage); + } else { + SLogger::trace( + "onIncomingMessage() resolving ongoing request"); + this->resolveOngoingRequest(rpcMessage); + } + } else { + SLogger::trace( + "onIncomingMessage() no ongoing request found for requestId, probably the request has timed out"); + } + } else { + SLogger::error( + "onIncomingMessage() a message that is not a response was sent to RpcCommunicatorClientApi"); + } + } + + // To be called by auto-generated clients through RpcCommunicator + + template + Task request( + const std::string& methodName, + const RequestType& methodParam, + const ProtoCallContext& callContext) { + SLogger::trace("request(): methodName:", methodName); + + size_t timeout = mRpcRequestTimeout; + if (callContext.timeout.has_value()) { + timeout = callContext.timeout.value(); + } + + auto requestMessage = + this->createRequestRpcMessage(methodName, methodParam); + + auto task = folly::coro::co_invoke( + [requestMessage, callContext, timeout, this]() + -> folly::coro::Task { + auto callMakingTask = folly::coro::co_invoke( + [requestMessage, + callContext, + this]() -> folly::coro::Task { + auto ongoingRequest = this->makeRpcRequest( + requestMessage, callContext); + co_return co_await std::move( + ongoingRequest->getFuture()); + }); + + try { + co_return co_await folly::coro::timeout( + folly::coro::detachOnCancel( + std::move(callMakingTask).scheduleOn(&mExecutor)), + std::chrono::milliseconds(timeout)); + } catch (const folly::FutureTimeout& e) { + SLogger::trace( + "request() caught folly::FutureTimeout", e.what()); + std::lock_guard lock(mOngoingRequestsMutex); + mOngoingRequests.erase(requestMessage.requestid()); + throw RpcTimeout("request() timed out"); + } catch (...) { + SLogger::trace("request() caught other exception"); + std::lock_guard lock(mOngoingRequestsMutex); + mOngoingRequests.erase(requestMessage.requestid()); + throw; + } + }); + + return task; + } + + // To be called by auto-generated clients through RpcCommunicator + template + Task notify( + const std::string_view notificationName, + const RequestType& notificationParam, + const ProtoCallContext& callContext) { + SLogger::trace("notify() notificationName:", notificationName); + + size_t timeout = mRpcRequestTimeout; + if (callContext.timeout.has_value()) { + timeout = callContext.timeout.value(); + } + + SLogger::trace( + "notify() creating request message, notificationName:", + notificationName); + auto requestMessage = this->createRequestRpcMessage( + notificationName, notificationParam, true); + auto&& promiseContract = folly::coro::makePromiseContract(); + + try { + mExecutor.add( + [requestMessage, + callContext, + promise = std::move(promiseContract.first), + outgoingMessageCallback = + std::move(mOutgoingMessageCallback)]() mutable -> void { + try { + outgoingMessageCallback( + requestMessage, + requestMessage.requestid(), + callContext); + promise.setValue(); + } catch (const std::exception& clientSideException) { + SLogger::debug( + "Error when calling outgoing message callback from client for sending notification", + clientSideException.what()); + promise.setException(RpcClientError( + "Error when calling outgoing message callback from client for sending notification", + clientSideException.what())); + } + }); + co_return co_await folly::coro::timeout( + folly::coro::detachOnCancel(std::move(promiseContract.second)) + .scheduleOn(&mExecutor), + std::chrono::milliseconds(timeout)); + } catch (const folly::FutureTimeout& e) { + SLogger::trace("notify() timed out"); + throw RpcTimeout("notify() timed out"); + } catch (...) { + SLogger::trace("notify() caught other exception"); + throw; + } + } + + void handleClientError( + const std::string& requestId, const RpcException& error) { + std::lock_guard lock(mOngoingRequestsMutex); + const auto& ongoingRequest = mOngoingRequests.at(requestId); + + if (ongoingRequest) { + ongoingRequest->rejectRequest(error); + mOngoingRequests.erase(requestId); + } + } + +private: + template + std::shared_ptr> makeRpcRequest( + const RpcMessage& requestMessage, const ProtoCallContext& callContext) { + auto ongoingRequest = std::make_shared>(); + { + std::lock_guard lock(mOngoingRequestsMutex); + this->mOngoingRequests.emplace( + requestMessage.requestid(), ongoingRequest); + } + if (mOutgoingMessageCallback) { + try { + mOutgoingMessageCallback( + requestMessage, requestMessage.requestid(), callContext); + } catch (const std::exception& clientSideException) { + std::lock_guard lock(mOngoingRequestsMutex); + if (mOngoingRequests.find(requestMessage.requestid()) != + mOngoingRequests.end()) { + SLogger::debug( + "Error when calling outgoing message callback from client", + clientSideException.what()); + RpcClientError error( + "Error when calling outgoing message callback from client", + clientSideException.what()); + + SLogger::debug("Old exception:", error.originalErrorInfo); + + this->handleClientError(requestMessage.requestid(), error); + } + } + } + return ongoingRequest; + } + + template + RpcMessage createRequestRpcMessage( + const std::string_view methodName, + const RequestType& request, + bool notification = false) { + RpcMessage ret; + const auto& header = ret.mutable_header(); + header->insert({"request", "request"}); + header->insert({"method", std::string(methodName)}); + SLogger::trace("createRequestRpcMessage() methodName:", methodName); + if (notification) { + header->insert({"notification", "notification"}); + } + Any* body = new Any(); + body->PackFrom(request); + ret.set_allocated_body(body); // protobuf will take ownership + SLogger::trace( + "createRequestRpcMessage() printed request Any: ", + body->DebugString()); + boost::uuids::uuid uuid; + ret.set_requestid(boost::uuids::to_string(uuid)); + return ret; + } + + void resolveOngoingRequest(const RpcMessage& response) { + std::lock_guard lock(mOngoingRequestsMutex); + auto& ongoingRequest = mOngoingRequests.at(response.requestid()); + ongoingRequest->resolveRequest(response); + mOngoingRequests.erase(response.requestid()); + } + + void rejectOngoingRequest(const RpcMessage& response) { + SLogger::trace("rejectOngoingRequest()", response.DebugString()); + std::lock_guard lock(mOngoingRequestsMutex); + + const auto& ongoingRequest = mOngoingRequests.at(response.requestid()); + + const auto& header = response.header(); + + if (response.errortype() == RpcErrorType::SERVER_TIMEOUT) { + ongoingRequest->rejectRequest( + RpcTimeout("Server timed out on request")); + } else if (response.errortype() == RpcErrorType::UNKNOWN_RPC_METHOD) { + ongoingRequest->rejectRequest(UnknownRpcMethod( + "Server does not implement method " + header.at("method"))); + } else if (response.errortype() == RpcErrorType::SERVER_ERROR) { + ongoingRequest->rejectRequest(RpcServerError( + response.has_errormessage() ? response.errormessage() : "", + response.has_errorclassname() ? response.errorclassname() : "", + response.has_errorcode() ? response.errorcode() : "")); + } else { + ongoingRequest->rejectRequest(RpcRequestError("Unknown RPC Error")); + } + mOngoingRequests.erase(response.requestid()); + } +}; + +} // namespace streamr::protorpc +#endif // STREAMR_PROTO_RPC_RPC_COMMUNICATOR_CLIENT_API_HPP \ No newline at end of file diff --git a/packages/streamr-proto-rpc/include/streamr-proto-rpc/RpcCommunicatorServerApi.hpp b/packages/streamr-proto-rpc/include/streamr-proto-rpc/RpcCommunicatorServerApi.hpp new file mode 100644 index 0000000..a684dfb --- /dev/null +++ b/packages/streamr-proto-rpc/include/streamr-proto-rpc/RpcCommunicatorServerApi.hpp @@ -0,0 +1,176 @@ +#ifndef STREAMR_PROTO_RPC_RPC_COMMUNICATOR_SERVER_API_HPP +#define STREAMR_PROTO_RPC_RPC_COMMUNICATOR_SERVER_API_HPP + +#include "Errors.hpp" +#include "ProtoCallContext.hpp" +#include "ServerRegistry.hpp" + +namespace streamr::protorpc { +using RpcMessage = ::protorpc::RpcMessage; +using RpcErrorType = ::protorpc::RpcErrorType; + +class RpcCommunicatorServerApi { +public: + using OutgoingMessageCallbackType = std::function; + +private: + ServerRegistry mServerRegistry; + OutgoingMessageCallbackType mOutgoingMessageCallback; + + struct RpcResponseParams { + RpcMessage request; + std::optional body; + std::optional<::protorpc::RpcErrorType> errorType; + std::optional errorClassName; + std::optional errorCode; + std::optional errorMessage; + }; + + static RpcMessage createResponseRpcMessage( + const RpcResponseParams& params) { + SLogger::trace("createResponseRpcMessage()"); + RpcMessage ret; + + if (params.body.has_value()) { + SLogger::trace( + "createResponseRpcMessage() body has value", + params.body->DebugString()); + auto* body = new Any(params.body.value()); + ret.set_allocated_body(body); // protobuf will take ownership + } + + ret.mutable_header()->insert({"response", "response"}); + ret.mutable_header()->insert( + {"method", params.request.header().at("method")}); + + ret.set_requestid(params.request.requestid()); + + if (params.errorType.has_value()) { + ret.set_errortype(params.errorType.value()); + } + if (params.errorClassName.has_value()) { + ret.set_errorclassname(params.errorClassName.value()); + } + if (params.errorCode.has_value()) { + ret.set_errorcode(params.errorCode.value()); + } + if (params.errorMessage.has_value()) { + ret.set_errormessage(params.errorMessage.value()); + } + + return ret; + } + + void handleRequest( + const RpcMessage& rpcMessage, const ProtoCallContext& callContext) { + RpcMessage response; + try { + SLogger::trace("handleRequest()"); + auto bytes = mServerRegistry.handleRequest(rpcMessage, callContext); + response = createResponseRpcMessage( + {.request = rpcMessage, .body = bytes}); + } catch (const Err& err) { + SLogger::debug("handleRequest() exception ", err.what()); + RpcResponseParams errorParams = {.request = rpcMessage}; + if (err.code == ErrorCode::UNKNOWN_RPC_METHOD) { + errorParams.errorType = RpcErrorType::UNKNOWN_RPC_METHOD; + } else if (err.code == ErrorCode::RPC_TIMEOUT) { + errorParams.errorType = RpcErrorType::SERVER_TIMEOUT; + } else { + errorParams.errorType = RpcErrorType::SERVER_ERROR; + errorParams.errorClassName = typeid(err).name(); + errorParams.errorCode = magic_enum::enum_name(err.code); + errorParams.errorMessage = err.what(); + } + SLogger::trace( + "handleRequest() creating response message for error"); + response = createResponseRpcMessage(errorParams); + } catch (const std::exception& err) { + SLogger::debug( + "Non-RpcCommunicator error when handling request", err.what()); + RpcResponseParams errorParams = {.request = rpcMessage}; + errorParams.errorType = RpcErrorType::SERVER_ERROR; + errorParams.errorClassName = typeid(err).name(); + errorParams.errorCode = + magic_enum::enum_name(ErrorCode::RPC_SERVER_ERROR); + errorParams.errorMessage = err.what(); + response = createResponseRpcMessage(errorParams); + } + + if (mOutgoingMessageCallback) { + try { + mOutgoingMessageCallback( + response, response.requestid(), callContext); + } catch (const std::exception& clientSideException) { + SLogger::debug( + "error when calling outgoing message callback from server", + clientSideException.what()); + } + } + } + + void handleNotification( + const RpcMessage& rpcMessage, const ProtoCallContext& callContext) { + try { + mServerRegistry.handleNotification(rpcMessage, callContext); + } catch (const std::exception& err) { + SLogger::debug("error", err.what()); + } + } + +public: + void onIncomingMessage( + const RpcMessage& rpcMessage, const ProtoCallContext& callContext) { + const auto& header = rpcMessage.header(); + + if (header.find("request") != header.end() && + header.find("method") != header.end()) { + SLogger::trace("onIncomingMessage() message is a request"); + if (header.find("notification") != header.end()) { + SLogger::trace( + "onIncomingMessage() calling handleNotification()"); + this->handleNotification(rpcMessage, callContext); + SLogger::trace( + "onIncomingMessage() handleNotification() called"); + + } else { + SLogger::trace("onIncomingMessage() calling handleRequest()"); + this->handleRequest(rpcMessage, callContext); + } + } else { + SLogger::error( + "onIncomingMessage() a message that is not a request was sent to RpcCommunicatorServerApi"); + } + } + + template + requires std::is_assignable_v + void setOutgoingMessageCallback(F&& callback) { + mOutgoingMessageCallback = std::forward(callback); + } + + template + requires std::is_assignable_v< + std::function, + F> + void registerRpcMethod( + const std::string& name, const F& fn, MethodOptions options = {}) { + mServerRegistry.registerRpcMethod( + name, fn, options); + } + + template + requires std::is_assignable_v< + std::function, + F> + void registerRpcNotification( + const std::string& name, const F& fn, MethodOptions options = {}) { + mServerRegistry.registerRpcNotification( + name, fn, options); + } +}; + +} // namespace streamr::protorpc + +#endif // STREAMR_PROTO_RPC_RPC_COMMUNICATOR_SERVER_API_HPP \ No newline at end of file diff --git a/packages/streamr-proto-rpc/include/streamr-proto-rpc/ServerRegistry.hpp b/packages/streamr-proto-rpc/include/streamr-proto-rpc/ServerRegistry.hpp new file mode 100644 index 0000000..ffd097f --- /dev/null +++ b/packages/streamr-proto-rpc/include/streamr-proto-rpc/ServerRegistry.hpp @@ -0,0 +1,128 @@ +#ifndef STREAMR_PROTO_RPC_SERVER_REGISTRY_HPP +#define STREAMR_PROTO_RPC_SERVER_REGISTRY_HPP + +#include +#include +#include +#include "ProtoRpc.pb.h" +#include "streamr-logger/SLogger.hpp" +#include "streamr-proto-rpc/Errors.hpp" +#include "streamr-proto-rpc/ProtoCallContext.hpp" + +namespace streamr::protorpc { + +using Any = google::protobuf::Any; +using Empty = google::protobuf::Empty; + +using RpcMessage = ::protorpc::RpcMessage; +using SLogger = streamr::logger::SLogger; + +using RpcMethodType = + std::function; + +using RpcNotificationType = + std::function; + +template +concept AssignableToRpcMethod = std::is_assignable_v; + +template +concept AssignableToRpcNotification = + std::is_assignable_v; +struct MethodOptions { + size_t timeout = 0; +}; + +struct RegisteredMethod { + RpcMethodType fn; + MethodOptions options; +}; + +struct RegisteredNotification { + RpcNotificationType fn; + MethodOptions options; +}; + +class ServerRegistry { +private: + std::map mMethods; + std::map mNotifications; + + template + T getImplementation( + const RpcMessage& rpcMessage, const std::map& map) { + const auto& header = rpcMessage.header(); + if (!header.contains("method")) { + throw UnknownRpcMethod( + "Header \"method\" missing from RPC message"); + } + const auto& method = header.at("method"); + if (map.find(method) == map.end()) { + throw UnknownRpcMethod("RPC Method " + method + " is not provided"); + } + return map.at(method); + } + +public: + template + static void wrappedParseAny(TargetType& target, const Any& any) { + try { + any.UnpackTo(&target); + } catch (...) { + throw FailedToParse("Could not parse binary to JSON-object"); + } + } + + Any handleRequest( + const RpcMessage& rpcMessage, const ProtoCallContext& callContext) { + SLogger::trace( + ("Server processing RPC call " + rpcMessage.requestid()).c_str()); + auto implementation = getImplementation(rpcMessage, mMethods); + return implementation.fn(rpcMessage.body(), callContext); + } + + Empty handleNotification( + const RpcMessage& rpcMessage, const ProtoCallContext& callContext) { + SLogger::trace( + ("Server processing RPC notification " + rpcMessage.requestid()) + .c_str()); + auto implementation = getImplementation(rpcMessage, mNotifications); + return implementation.fn(rpcMessage.body(), callContext); + } + + template + void registerRpcMethod( + const std::string& name, const F& fn, MethodOptions options = {}) { + RegisteredMethod method = { + .fn = [fn](const Any& data, const ProtoCallContext& callContext) + -> Any { + RequestType request; + ServerRegistry::wrappedParseAny(request, data); + auto response = fn(request, callContext); + Any responseAny; + responseAny.PackFrom(response); + return responseAny; + }, + .options = options}; + mMethods[name] = method; + } + + template + void registerRpcNotification( + const std::string& name, const F& fn, MethodOptions options = {}) { + RegisteredNotification notification = { + .fn = [fn](const Any& data, const ProtoCallContext& callContext) + -> Empty { + RequestType request; + ServerRegistry::wrappedParseAny(request, data); + fn(request, callContext); + return Empty(); + }, + .options = options}; + mNotifications[name] = notification; + } +}; + +} // namespace streamr::protorpc + +#endif // STREAMR_PROTO_RPC_SERVER_REGISTRY_HPP \ No newline at end of file diff --git a/packages/streamr-proto-rpc/include/streamr-proto-rpc/StreamPrinter.hpp b/packages/streamr-proto-rpc/include/streamr-proto-rpc/StreamPrinter.hpp new file mode 100644 index 0000000..53953ca --- /dev/null +++ b/packages/streamr-proto-rpc/include/streamr-proto-rpc/StreamPrinter.hpp @@ -0,0 +1,51 @@ +#ifndef STREAMER_PROTORPC_PLUGIN_STREAM_PRINTER_HPP +#define STREAMER_PROTORPC_PLUGIN_STREAM_PRINTER_HPP + +#include + +namespace streamr::protorpc { + +// Logic copied from +// https://github.com/end2endzone/protobuf-pbop-plugin/blob/master/src/protobuf-pbop-plugin/StreamPrinter.cpp +// Changed size_t to int64_t +class StreamPrinter { +private: + google::protobuf::io::ZeroCopyOutputStream* mStream; + +public: + explicit StreamPrinter(google::protobuf::io::ZeroCopyOutputStream* iStream) + : mStream(iStream) {} + + void print(const unsigned char* iValue, int64_t iLength) { + int64_t dumpIndex = 0; + + while (dumpIndex < iLength) { + // get a buffer from the stream + void* buffer = nullptr; + int bufferSize = 0; + mStream->Next(&buffer, &bufferSize); + + if (buffer && bufferSize > 0) { + // compute dumpsize + int64_t dumpSize = iLength - dumpIndex; + if (dumpSize > bufferSize) { + dumpSize = bufferSize; + } + + // dump + const unsigned char* dumpData = &iValue[dumpIndex]; + memcpy(buffer, dumpData, dumpSize); + + if (dumpSize < bufferSize) { + int backupSize = bufferSize - dumpSize; // NOLINT + mStream->BackUp(backupSize); + } + + dumpIndex += dumpSize; + } + } + } +}; + +}; // namespace streamr::protorpc +#endif // PROTOBUF_STREAMR_PLUGIN_PLUGIN_CODE_GENERATOR_HPP \ No newline at end of file diff --git a/packages/streamr-proto-rpc/include/streamr-proto-rpc/concepts.hpp b/packages/streamr-proto-rpc/include/streamr-proto-rpc/concepts.hpp new file mode 100644 index 0000000..e69de29 diff --git a/packages/streamr-proto-rpc/monorepoPackage.cmake b/packages/streamr-proto-rpc/monorepoPackage.cmake index 3df1f3b..58c93b9 100644 --- a/packages/streamr-proto-rpc/monorepoPackage.cmake +++ b/packages/streamr-proto-rpc/monorepoPackage.cmake @@ -1,7 +1,14 @@ +set(CMAKE_POLICY_DEFAULT_CMP0077 NEW) if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/../../MonorepoPackages.cmake) message(STATUS "In monorepo sub-package ${CMAKE_CURRENT_SOURCE_DIR}") - + + # if in monorepo, do not install vcpkg dependencies + set(VCPKG_MANIFEST_INSTALL OFF) + + # if in monorepo, use the vcpkg dependencies from the monorepo root + set(VCPKG_INSTALLED_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../build/vcpkg_installed) + # if in monorepo, use the monorepo deps from filesystem if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/vcpkg.json) file(READ ${CMAKE_CURRENT_SOURCE_DIR}/vcpkg.json VCPKG_JSON) diff --git a/packages/streamr-proto-rpc/proto.sh b/packages/streamr-proto-rpc/proto.sh new file mode 100755 index 0000000..dc0b223 --- /dev/null +++ b/packages/streamr-proto-rpc/proto.sh @@ -0,0 +1,15 @@ +PROTOC=build/vcpkg_installed/arm64-osx/tools/protobuf/protoc +mkdir -p ./src/proto +${PROTOC} -I=protos --cpp_out=src/proto protos/ProtoRpc.proto --experimental_allow_proto3_optional + +mkdir -p ./test/proto +${PROTOC} -I=test/protos --cpp_out=./test/proto test/protos/*.proto --experimental_allow_proto3_optional +${PROTOC} --plugin=protoc-gen-streamr=./build/protobuf-streamr-plugin --streamr_out=./test/proto --proto_path=test/protos test/protos/*.proto --experimental_allow_proto3_optional + +mkdir -p ./examples/hello/proto +${PROTOC} -I=examples/hello --cpp_out=./examples/hello/proto examples/hello/*.proto --experimental_allow_proto3_optional +${PROTOC} --plugin=protoc-gen-streamr=./build/protobuf-streamr-plugin --streamr_out=./examples/hello/proto --proto_path=examples/hello examples/hello/*.proto --experimental_allow_proto3_optional + +mkdir -p ./examples/routed-hello/proto +${PROTOC} -I=examples/routed-hello --cpp_out=./examples/routed-hello/proto examples/routed-hello/*.proto --experimental_allow_proto3_optional +${PROTOC} --plugin=protoc-gen-streamr=./build/protobuf-streamr-plugin --streamr_out=./examples/routed-hello/proto --proto_path=examples/routed-hello examples/routed-hello/*.proto --experimental_allow_proto3_optional diff --git a/packages/streamr-proto-rpc/protos/ProtoRpc.proto b/packages/streamr-proto-rpc/protos/ProtoRpc.proto new file mode 100644 index 0000000..b9dff55 --- /dev/null +++ b/packages/streamr-proto-rpc/protos/ProtoRpc.proto @@ -0,0 +1,35 @@ +// This file is a copy of +// https://github.com/streamr-dev/network/blob/b267dcfb1e98fa2b882fa21a41a279f3a8658f50/packages/proto-rpc/protos/ProtoRpc.proto + +syntax = "proto3"; +option optimize_for = CODE_SIZE; + +package protorpc; + +import "google/protobuf/empty.proto"; +import "google/protobuf/any.proto"; + +enum RpcErrorType { + SERVER_TIMEOUT = 0; + CLIENT_TIMEOUT = 1; + UNKNOWN_RPC_METHOD = 2; + CLIENT_ERROR = 3; + SERVER_ERROR = 4; + } + +message RpcMessage { + map header = 1; + google.protobuf.Any body = 2; + string requestId = 3; + optional RpcErrorType errorType = 4; + optional string errorClassName = 5; + optional string errorCode = 6; + optional string errorMessage = 7; + } + +// Dummy message to force the generation of the typescript class "google.prototype.Empty" +// We need this generated class in RpcCommunicator + +message Mnfo2uhnf92hvqi2nviouq2hv9puhq { + google.protobuf.Empty empty = 1; +} \ No newline at end of file diff --git a/packages/streamr-proto-rpc/src/CustomGtestMain.cpp b/packages/streamr-proto-rpc/src/CustomGtestMain.cpp new file mode 100644 index 0000000..5807b6a --- /dev/null +++ b/packages/streamr-proto-rpc/src/CustomGtestMain.cpp @@ -0,0 +1,48 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * 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. + */ + +#include + +#include +#include +#include +#include +#include +#include + +namespace { +// A counter to help confirm that our getBaseLoggingConfigCalled() was invoked +// rather than the default implementation that folly exports as a weak symbol. +unsigned int getBaseLoggingConfigCalled; +} // namespace + +namespace folly { + +const char* getBaseLoggingConfig() { + ++getBaseLoggingConfigCalled; + return "folly=INFO; default:stream=stdout"; +} + +} // namespace folly + +// We use our custom main() to ensure that folly::initLogging() has +// not been called yet when we start running the tests. +int main(int argc, char** argv) { + ::testing::InitGoogleTest(&argc, argv); + gflags::ParseCommandLineFlags(&argc, &argv, /* remove_flags = */ true); + folly::Init init(&argc, &argv); + return RUN_ALL_TESTS(); +} diff --git a/packages/streamr-proto-rpc/src/PluginCodeGeneratorMain.cpp b/packages/streamr-proto-rpc/src/PluginCodeGeneratorMain.cpp new file mode 100644 index 0000000..45e66c3 --- /dev/null +++ b/packages/streamr-proto-rpc/src/PluginCodeGeneratorMain.cpp @@ -0,0 +1,7 @@ +#include +#include "streamr-proto-rpc/PluginCodeGenerator.hpp" + +int main(int argc, char** argv) { + streamr::protorpc::PluginCodeGenerator generator; + return google::protobuf::compiler::PluginMain(argc, argv, &generator); +} diff --git a/packages/streamr-proto-rpc/src/main.cpp b/packages/streamr-proto-rpc/src/main.cpp deleted file mode 100644 index 7488851..0000000 --- a/packages/streamr-proto-rpc/src/main.cpp +++ /dev/null @@ -1,9 +0,0 @@ -// #include - -int main() - -{ - // Logger logger; - // logger.log("Hello, world!"); - return 0; -} diff --git a/packages/streamr-proto-rpc/src/proto/.clang-tidy b/packages/streamr-proto-rpc/src/proto/.clang-tidy new file mode 100644 index 0000000..e69de29 diff --git a/packages/streamr-proto-rpc/src/proto/ProtoRpc.pb.cc b/packages/streamr-proto-rpc/src/proto/ProtoRpc.pb.cc new file mode 100644 index 0000000..ce6fc9c --- /dev/null +++ b/packages/streamr-proto-rpc/src/proto/ProtoRpc.pb.cc @@ -0,0 +1,430 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: ProtoRpc.proto + +#include "ProtoRpc.pb.h" + +#include +#include "google/protobuf/io/coded_stream.h" +#include "google/protobuf/extension_set.h" +#include "google/protobuf/wire_format_lite.h" +#include "google/protobuf/descriptor.h" +#include "google/protobuf/generated_message_reflection.h" +#include "google/protobuf/reflection_ops.h" +#include "google/protobuf/wire_format.h" +// @@protoc_insertion_point(includes) + +// Must be included last. +#include "google/protobuf/port_def.inc" +PROTOBUF_PRAGMA_INIT_SEG +namespace _pb = ::google::protobuf; +namespace _pbi = ::google::protobuf::internal; +namespace protorpc { + template +PROTOBUF_CONSTEXPR RpcMessage_HeaderEntry_DoNotUse::RpcMessage_HeaderEntry_DoNotUse(::_pbi::ConstantInitialized) {} +struct RpcMessage_HeaderEntry_DoNotUseDefaultTypeInternal { + PROTOBUF_CONSTEXPR RpcMessage_HeaderEntry_DoNotUseDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} + ~RpcMessage_HeaderEntry_DoNotUseDefaultTypeInternal() {} + union { + RpcMessage_HeaderEntry_DoNotUse _instance; + }; +}; + +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT + PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 RpcMessage_HeaderEntry_DoNotUseDefaultTypeInternal _RpcMessage_HeaderEntry_DoNotUse_default_instance_; + +inline constexpr RpcMessage::Impl_::Impl_( + ::_pbi::ConstantInitialized) noexcept + : _cached_size_{0}, + header_{}, + requestid_( + &::google::protobuf::internal::fixed_address_empty_string, + ::_pbi::ConstantInitialized()), + errorclassname_( + &::google::protobuf::internal::fixed_address_empty_string, + ::_pbi::ConstantInitialized()), + errorcode_( + &::google::protobuf::internal::fixed_address_empty_string, + ::_pbi::ConstantInitialized()), + errormessage_( + &::google::protobuf::internal::fixed_address_empty_string, + ::_pbi::ConstantInitialized()), + body_{nullptr}, + errortype_{static_cast< ::protorpc::RpcErrorType >(0)} {} + +template +PROTOBUF_CONSTEXPR RpcMessage::RpcMessage(::_pbi::ConstantInitialized) + : _impl_(::_pbi::ConstantInitialized()) {} +struct RpcMessageDefaultTypeInternal { + PROTOBUF_CONSTEXPR RpcMessageDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} + ~RpcMessageDefaultTypeInternal() {} + union { + RpcMessage _instance; + }; +}; + +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT + PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 RpcMessageDefaultTypeInternal _RpcMessage_default_instance_; + +inline constexpr Mnfo2uhnf92hvqi2nviouq2hv9puhq::Impl_::Impl_( + ::_pbi::ConstantInitialized) noexcept + : _cached_size_{0}, + empty_{nullptr} {} + +template +PROTOBUF_CONSTEXPR Mnfo2uhnf92hvqi2nviouq2hv9puhq::Mnfo2uhnf92hvqi2nviouq2hv9puhq(::_pbi::ConstantInitialized) + : _impl_(::_pbi::ConstantInitialized()) {} +struct Mnfo2uhnf92hvqi2nviouq2hv9puhqDefaultTypeInternal { + PROTOBUF_CONSTEXPR Mnfo2uhnf92hvqi2nviouq2hv9puhqDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} + ~Mnfo2uhnf92hvqi2nviouq2hv9puhqDefaultTypeInternal() {} + union { + Mnfo2uhnf92hvqi2nviouq2hv9puhq _instance; + }; +}; + +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT + PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 Mnfo2uhnf92hvqi2nviouq2hv9puhqDefaultTypeInternal _Mnfo2uhnf92hvqi2nviouq2hv9puhq_default_instance_; +} // namespace protorpc +static ::_pb::Metadata file_level_metadata_ProtoRpc_2eproto[3]; +static const ::_pb::EnumDescriptor* file_level_enum_descriptors_ProtoRpc_2eproto[1]; +static constexpr const ::_pb::ServiceDescriptor** + file_level_service_descriptors_ProtoRpc_2eproto = nullptr; +const ::uint32_t TableStruct_ProtoRpc_2eproto::offsets[] PROTOBUF_SECTION_VARIABLE( + protodesc_cold) = { + PROTOBUF_FIELD_OFFSET(::protorpc::RpcMessage_HeaderEntry_DoNotUse, _has_bits_), + PROTOBUF_FIELD_OFFSET(::protorpc::RpcMessage_HeaderEntry_DoNotUse, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) + PROTOBUF_FIELD_OFFSET(::protorpc::RpcMessage_HeaderEntry_DoNotUse, key_), + PROTOBUF_FIELD_OFFSET(::protorpc::RpcMessage_HeaderEntry_DoNotUse, value_), + 0, + 1, + PROTOBUF_FIELD_OFFSET(::protorpc::RpcMessage, _impl_._has_bits_), + PROTOBUF_FIELD_OFFSET(::protorpc::RpcMessage, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) + PROTOBUF_FIELD_OFFSET(::protorpc::RpcMessage, _impl_.header_), + PROTOBUF_FIELD_OFFSET(::protorpc::RpcMessage, _impl_.body_), + PROTOBUF_FIELD_OFFSET(::protorpc::RpcMessage, _impl_.requestid_), + PROTOBUF_FIELD_OFFSET(::protorpc::RpcMessage, _impl_.errortype_), + PROTOBUF_FIELD_OFFSET(::protorpc::RpcMessage, _impl_.errorclassname_), + PROTOBUF_FIELD_OFFSET(::protorpc::RpcMessage, _impl_.errorcode_), + PROTOBUF_FIELD_OFFSET(::protorpc::RpcMessage, _impl_.errormessage_), + ~0u, + 3, + ~0u, + 4, + 0, + 1, + 2, + PROTOBUF_FIELD_OFFSET(::protorpc::Mnfo2uhnf92hvqi2nviouq2hv9puhq, _impl_._has_bits_), + PROTOBUF_FIELD_OFFSET(::protorpc::Mnfo2uhnf92hvqi2nviouq2hv9puhq, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) + PROTOBUF_FIELD_OFFSET(::protorpc::Mnfo2uhnf92hvqi2nviouq2hv9puhq, _impl_.empty_), + 0, +}; + +static const ::_pbi::MigrationSchema + schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { + {0, 10, -1, sizeof(::protorpc::RpcMessage_HeaderEntry_DoNotUse)}, + {12, 27, -1, sizeof(::protorpc::RpcMessage)}, + {34, 43, -1, sizeof(::protorpc::Mnfo2uhnf92hvqi2nviouq2hv9puhq)}, +}; + +static const ::_pb::Message* const file_default_instances[] = { + &::protorpc::_RpcMessage_HeaderEntry_DoNotUse_default_instance_._instance, + &::protorpc::_RpcMessage_default_instance_._instance, + &::protorpc::_Mnfo2uhnf92hvqi2nviouq2hv9puhq_default_instance_._instance, +}; +const char descriptor_table_protodef_ProtoRpc_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { + "\n\016ProtoRpc.proto\022\010protorpc\032\033google/proto" + "buf/empty.proto\032\031google/protobuf/any.pro" + "to\"\344\002\n\nRpcMessage\0220\n\006header\030\001 \003(\0132 .prot" + "orpc.RpcMessage.HeaderEntry\022\"\n\004body\030\002 \001(" + "\0132\024.google.protobuf.Any\022\021\n\trequestId\030\003 \001" + "(\t\022.\n\terrorType\030\004 \001(\0162\026.protorpc.RpcErro" + "rTypeH\000\210\001\001\022\033\n\016errorClassName\030\005 \001(\tH\001\210\001\001\022" + "\026\n\terrorCode\030\006 \001(\tH\002\210\001\001\022\031\n\014errorMessage\030" + "\007 \001(\tH\003\210\001\001\032-\n\013HeaderEntry\022\013\n\003key\030\001 \001(\t\022\r" + "\n\005value\030\002 \001(\t:\0028\001B\014\n\n_errorTypeB\021\n\017_erro" + "rClassNameB\014\n\n_errorCodeB\017\n\r_errorMessag" + "e\"G\n\036Mnfo2uhnf92hvqi2nviouq2hv9puhq\022%\n\005e" + "mpty\030\001 \001(\0132\026.google.protobuf.Empty*r\n\014Rp" + "cErrorType\022\022\n\016SERVER_TIMEOUT\020\000\022\022\n\016CLIENT" + "_TIMEOUT\020\001\022\026\n\022UNKNOWN_RPC_METHOD\020\002\022\020\n\014CL" + "IENT_ERROR\020\003\022\020\n\014SERVER_ERROR\020\004B\002H\002b\006prot" + "o3" +}; +static const ::_pbi::DescriptorTable* const descriptor_table_ProtoRpc_2eproto_deps[2] = + { + &::descriptor_table_google_2fprotobuf_2fany_2eproto, + &::descriptor_table_google_2fprotobuf_2fempty_2eproto, +}; +static ::absl::once_flag descriptor_table_ProtoRpc_2eproto_once; +const ::_pbi::DescriptorTable descriptor_table_ProtoRpc_2eproto = { + false, + false, + 642, + descriptor_table_protodef_ProtoRpc_2eproto, + "ProtoRpc.proto", + &descriptor_table_ProtoRpc_2eproto_once, + descriptor_table_ProtoRpc_2eproto_deps, + 2, + 3, + schemas, + file_default_instances, + TableStruct_ProtoRpc_2eproto::offsets, + file_level_metadata_ProtoRpc_2eproto, + file_level_enum_descriptors_ProtoRpc_2eproto, + file_level_service_descriptors_ProtoRpc_2eproto, +}; + +// This function exists to be marked as weak. +// It can significantly speed up compilation by breaking up LLVM's SCC +// in the .pb.cc translation units. Large translation units see a +// reduction of more than 35% of walltime for optimized builds. Without +// the weak attribute all the messages in the file, including all the +// vtables and everything they use become part of the same SCC through +// a cycle like: +// GetMetadata -> descriptor table -> default instances -> +// vtables -> GetMetadata +// By adding a weak function here we break the connection from the +// individual vtables back into the descriptor table. +PROTOBUF_ATTRIBUTE_WEAK const ::_pbi::DescriptorTable* descriptor_table_ProtoRpc_2eproto_getter() { + return &descriptor_table_ProtoRpc_2eproto; +} +// Force running AddDescriptors() at dynamic initialization time. +PROTOBUF_ATTRIBUTE_INIT_PRIORITY2 +static ::_pbi::AddDescriptorsRunner dynamic_init_dummy_ProtoRpc_2eproto(&descriptor_table_ProtoRpc_2eproto); +namespace protorpc { +const ::google::protobuf::EnumDescriptor* RpcErrorType_descriptor() { + ::google::protobuf::internal::AssignDescriptors(&descriptor_table_ProtoRpc_2eproto); + return file_level_enum_descriptors_ProtoRpc_2eproto[0]; +} +PROTOBUF_CONSTINIT const uint32_t RpcErrorType_internal_data_[] = { + 327680u, 0u, }; +bool RpcErrorType_IsValid(int value) { + return 0 <= value && value <= 4; +} +// =================================================================== + +RpcMessage_HeaderEntry_DoNotUse::RpcMessage_HeaderEntry_DoNotUse() {} +RpcMessage_HeaderEntry_DoNotUse::RpcMessage_HeaderEntry_DoNotUse(::google::protobuf::Arena* arena) + : SuperType(arena) {} +::google::protobuf::Metadata RpcMessage_HeaderEntry_DoNotUse::GetMetadata() const { + return ::_pbi::AssignDescriptors( + &descriptor_table_ProtoRpc_2eproto_getter, &descriptor_table_ProtoRpc_2eproto_once, + file_level_metadata_ProtoRpc_2eproto[0]); +} +// =================================================================== + +class RpcMessage::_Internal { + public: + using HasBits = decltype(std::declval()._impl_._has_bits_); + static constexpr ::int32_t kHasBitsOffset = + 8 * PROTOBUF_FIELD_OFFSET(RpcMessage, _impl_._has_bits_); + static const ::google::protobuf::Any& body(const RpcMessage* msg); + static void set_has_body(HasBits* has_bits) { + (*has_bits)[0] |= 8u; + } + static void set_has_errortype(HasBits* has_bits) { + (*has_bits)[0] |= 16u; + } + static void set_has_errorclassname(HasBits* has_bits) { + (*has_bits)[0] |= 1u; + } + static void set_has_errorcode(HasBits* has_bits) { + (*has_bits)[0] |= 2u; + } + static void set_has_errormessage(HasBits* has_bits) { + (*has_bits)[0] |= 4u; + } +}; + +const ::google::protobuf::Any& RpcMessage::_Internal::body(const RpcMessage* msg) { + return *msg->_impl_.body_; +} +void RpcMessage::clear_body() { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + if (_impl_.body_ != nullptr) _impl_.body_->Clear(); + _impl_._has_bits_[0] &= ~0x00000008u; +} +RpcMessage::RpcMessage(::google::protobuf::Arena* arena) + : ::google::protobuf::Message(arena) { + SharedCtor(arena); + // @@protoc_insertion_point(arena_constructor:protorpc.RpcMessage) +} +inline PROTOBUF_NDEBUG_INLINE RpcMessage::Impl_::Impl_( + ::google::protobuf::internal::InternalVisibility visibility, ::google::protobuf::Arena* arena, + const Impl_& from) + : _has_bits_{from._has_bits_}, + _cached_size_{0}, + header_{visibility, arena, from.header_}, + requestid_(arena, from.requestid_), + errorclassname_(arena, from.errorclassname_), + errorcode_(arena, from.errorcode_), + errormessage_(arena, from.errormessage_) {} + +RpcMessage::RpcMessage( + ::google::protobuf::Arena* arena, + const RpcMessage& from) + : ::google::protobuf::Message(arena) { + RpcMessage* const _this = this; + (void)_this; + _internal_metadata_.MergeFrom<::google::protobuf::UnknownFieldSet>( + from._internal_metadata_); + new (&_impl_) Impl_(internal_visibility(), arena, from._impl_); + ::uint32_t cached_has_bits = _impl_._has_bits_[0]; + _impl_.body_ = (cached_has_bits & 0x00000008u) + ? CreateMaybeMessage<::google::protobuf::Any>(arena, *from._impl_.body_) + : nullptr; + _impl_.errortype_ = from._impl_.errortype_; + + // @@protoc_insertion_point(copy_constructor:protorpc.RpcMessage) +} +inline PROTOBUF_NDEBUG_INLINE RpcMessage::Impl_::Impl_( + ::google::protobuf::internal::InternalVisibility visibility, + ::google::protobuf::Arena* arena) + : _cached_size_{0}, + header_{visibility, arena}, + requestid_(arena), + errorclassname_(arena), + errorcode_(arena), + errormessage_(arena) {} + +inline void RpcMessage::SharedCtor(::_pb::Arena* arena) { + new (&_impl_) Impl_(internal_visibility(), arena); + ::memset(reinterpret_cast(&_impl_) + + offsetof(Impl_, body_), + 0, + offsetof(Impl_, errortype_) - + offsetof(Impl_, body_) + + sizeof(Impl_::errortype_)); +} +RpcMessage::~RpcMessage() { + // @@protoc_insertion_point(destructor:protorpc.RpcMessage) + _internal_metadata_.Delete<::google::protobuf::UnknownFieldSet>(); + SharedDtor(); +} +inline void RpcMessage::SharedDtor() { + ABSL_DCHECK(GetArena() == nullptr); + _impl_.requestid_.Destroy(); + _impl_.errorclassname_.Destroy(); + _impl_.errorcode_.Destroy(); + _impl_.errormessage_.Destroy(); + delete _impl_.body_; + _impl_.~Impl_(); +} + +::_pbi::CachedSize* RpcMessage::AccessCachedSize() const { + return &_impl_._cached_size_; +} +void RpcMessage::InternalSwap(RpcMessage* PROTOBUF_RESTRICT other) { + using std::swap; + GetReflection()->Swap(this, other);} + +::google::protobuf::Metadata RpcMessage::GetMetadata() const { + return ::_pbi::AssignDescriptors( + &descriptor_table_ProtoRpc_2eproto_getter, &descriptor_table_ProtoRpc_2eproto_once, + file_level_metadata_ProtoRpc_2eproto[1]); +} +// =================================================================== + +class Mnfo2uhnf92hvqi2nviouq2hv9puhq::_Internal { + public: + using HasBits = decltype(std::declval()._impl_._has_bits_); + static constexpr ::int32_t kHasBitsOffset = + 8 * PROTOBUF_FIELD_OFFSET(Mnfo2uhnf92hvqi2nviouq2hv9puhq, _impl_._has_bits_); + static const ::google::protobuf::Empty& empty(const Mnfo2uhnf92hvqi2nviouq2hv9puhq* msg); + static void set_has_empty(HasBits* has_bits) { + (*has_bits)[0] |= 1u; + } +}; + +const ::google::protobuf::Empty& Mnfo2uhnf92hvqi2nviouq2hv9puhq::_Internal::empty(const Mnfo2uhnf92hvqi2nviouq2hv9puhq* msg) { + return *msg->_impl_.empty_; +} +void Mnfo2uhnf92hvqi2nviouq2hv9puhq::clear_empty() { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + if (_impl_.empty_ != nullptr) _impl_.empty_->Clear(); + _impl_._has_bits_[0] &= ~0x00000001u; +} +Mnfo2uhnf92hvqi2nviouq2hv9puhq::Mnfo2uhnf92hvqi2nviouq2hv9puhq(::google::protobuf::Arena* arena) + : ::google::protobuf::Message(arena) { + SharedCtor(arena); + // @@protoc_insertion_point(arena_constructor:protorpc.Mnfo2uhnf92hvqi2nviouq2hv9puhq) +} +inline PROTOBUF_NDEBUG_INLINE Mnfo2uhnf92hvqi2nviouq2hv9puhq::Impl_::Impl_( + ::google::protobuf::internal::InternalVisibility visibility, ::google::protobuf::Arena* arena, + const Impl_& from) + : _has_bits_{from._has_bits_}, + _cached_size_{0} {} + +Mnfo2uhnf92hvqi2nviouq2hv9puhq::Mnfo2uhnf92hvqi2nviouq2hv9puhq( + ::google::protobuf::Arena* arena, + const Mnfo2uhnf92hvqi2nviouq2hv9puhq& from) + : ::google::protobuf::Message(arena) { + Mnfo2uhnf92hvqi2nviouq2hv9puhq* const _this = this; + (void)_this; + _internal_metadata_.MergeFrom<::google::protobuf::UnknownFieldSet>( + from._internal_metadata_); + new (&_impl_) Impl_(internal_visibility(), arena, from._impl_); + ::uint32_t cached_has_bits = _impl_._has_bits_[0]; + _impl_.empty_ = (cached_has_bits & 0x00000001u) + ? CreateMaybeMessage<::google::protobuf::Empty>(arena, *from._impl_.empty_) + : nullptr; + + // @@protoc_insertion_point(copy_constructor:protorpc.Mnfo2uhnf92hvqi2nviouq2hv9puhq) +} +inline PROTOBUF_NDEBUG_INLINE Mnfo2uhnf92hvqi2nviouq2hv9puhq::Impl_::Impl_( + ::google::protobuf::internal::InternalVisibility visibility, + ::google::protobuf::Arena* arena) + : _cached_size_{0} {} + +inline void Mnfo2uhnf92hvqi2nviouq2hv9puhq::SharedCtor(::_pb::Arena* arena) { + new (&_impl_) Impl_(internal_visibility(), arena); + _impl_.empty_ = {}; +} +Mnfo2uhnf92hvqi2nviouq2hv9puhq::~Mnfo2uhnf92hvqi2nviouq2hv9puhq() { + // @@protoc_insertion_point(destructor:protorpc.Mnfo2uhnf92hvqi2nviouq2hv9puhq) + _internal_metadata_.Delete<::google::protobuf::UnknownFieldSet>(); + SharedDtor(); +} +inline void Mnfo2uhnf92hvqi2nviouq2hv9puhq::SharedDtor() { + ABSL_DCHECK(GetArena() == nullptr); + delete _impl_.empty_; + _impl_.~Impl_(); +} + +::_pbi::CachedSize* Mnfo2uhnf92hvqi2nviouq2hv9puhq::AccessCachedSize() const { + return &_impl_._cached_size_; +} +void Mnfo2uhnf92hvqi2nviouq2hv9puhq::InternalSwap(Mnfo2uhnf92hvqi2nviouq2hv9puhq* PROTOBUF_RESTRICT other) { + using std::swap; + GetReflection()->Swap(this, other);} + +::google::protobuf::Metadata Mnfo2uhnf92hvqi2nviouq2hv9puhq::GetMetadata() const { + return ::_pbi::AssignDescriptors( + &descriptor_table_ProtoRpc_2eproto_getter, &descriptor_table_ProtoRpc_2eproto_once, + file_level_metadata_ProtoRpc_2eproto[2]); +} +// @@protoc_insertion_point(namespace_scope) +} // namespace protorpc +namespace google { +namespace protobuf { +} // namespace protobuf +} // namespace google +// @@protoc_insertion_point(global_scope) +#include "google/protobuf/port_undef.inc" diff --git a/packages/streamr-proto-rpc/src/proto/ProtoRpc.pb.h b/packages/streamr-proto-rpc/src/proto/ProtoRpc.pb.h new file mode 100644 index 0000000..29b981b --- /dev/null +++ b/packages/streamr-proto-rpc/src/proto/ProtoRpc.pb.h @@ -0,0 +1,1126 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: ProtoRpc.proto +// Protobuf C++ Version: 4.25.1 + +#ifndef GOOGLE_PROTOBUF_INCLUDED_ProtoRpc_2eproto_2epb_2eh +#define GOOGLE_PROTOBUF_INCLUDED_ProtoRpc_2eproto_2epb_2eh + +#include +#include +#include +#include + +#include "google/protobuf/port_def.inc" +#if PROTOBUF_VERSION < 4025000 +#error "This file was generated by a newer version of protoc which is" +#error "incompatible with your Protocol Buffer headers. Please update" +#error "your headers." +#endif // PROTOBUF_VERSION + +#if 4025001 < PROTOBUF_MIN_PROTOC_VERSION +#error "This file was generated by an older version of protoc which is" +#error "incompatible with your Protocol Buffer headers. Please" +#error "regenerate this file with a newer version of protoc." +#endif // PROTOBUF_MIN_PROTOC_VERSION +#include "google/protobuf/port_undef.inc" +#include "google/protobuf/io/coded_stream.h" +#include "google/protobuf/arena.h" +#include "google/protobuf/arenastring.h" +#include "google/protobuf/generated_message_util.h" +#include "google/protobuf/metadata_lite.h" +#include "google/protobuf/generated_message_reflection.h" +#include "google/protobuf/message.h" +#include "google/protobuf/repeated_field.h" // IWYU pragma: export +#include "google/protobuf/extension_set.h" // IWYU pragma: export +#include "google/protobuf/map.h" // IWYU pragma: export +#include "google/protobuf/map_entry.h" +#include "google/protobuf/map_field_inl.h" +#include "google/protobuf/generated_enum_reflection.h" +#include "google/protobuf/unknown_field_set.h" +#include "google/protobuf/empty.pb.h" +#include "google/protobuf/any.pb.h" +// @@protoc_insertion_point(includes) + +// Must be included last. +#include "google/protobuf/port_def.inc" + +#define PROTOBUF_INTERNAL_EXPORT_ProtoRpc_2eproto + +namespace google { +namespace protobuf { +namespace internal { +class AnyMetadata; +} // namespace internal +} // namespace protobuf +} // namespace google + +// Internal implementation detail -- do not use these members. +struct TableStruct_ProtoRpc_2eproto { + static const ::uint32_t offsets[]; +}; +extern const ::google::protobuf::internal::DescriptorTable + descriptor_table_ProtoRpc_2eproto; +namespace protorpc { +class Mnfo2uhnf92hvqi2nviouq2hv9puhq; +struct Mnfo2uhnf92hvqi2nviouq2hv9puhqDefaultTypeInternal; +extern Mnfo2uhnf92hvqi2nviouq2hv9puhqDefaultTypeInternal _Mnfo2uhnf92hvqi2nviouq2hv9puhq_default_instance_; +class RpcMessage; +struct RpcMessageDefaultTypeInternal; +extern RpcMessageDefaultTypeInternal _RpcMessage_default_instance_; +class RpcMessage_HeaderEntry_DoNotUse; +struct RpcMessage_HeaderEntry_DoNotUseDefaultTypeInternal; +extern RpcMessage_HeaderEntry_DoNotUseDefaultTypeInternal _RpcMessage_HeaderEntry_DoNotUse_default_instance_; +} // namespace protorpc +namespace google { +namespace protobuf { +} // namespace protobuf +} // namespace google + +namespace protorpc { +enum RpcErrorType : int { + SERVER_TIMEOUT = 0, + CLIENT_TIMEOUT = 1, + UNKNOWN_RPC_METHOD = 2, + CLIENT_ERROR = 3, + SERVER_ERROR = 4, + RpcErrorType_INT_MIN_SENTINEL_DO_NOT_USE_ = + std::numeric_limits<::int32_t>::min(), + RpcErrorType_INT_MAX_SENTINEL_DO_NOT_USE_ = + std::numeric_limits<::int32_t>::max(), +}; + +bool RpcErrorType_IsValid(int value); +extern const uint32_t RpcErrorType_internal_data_[]; +constexpr RpcErrorType RpcErrorType_MIN = static_cast(0); +constexpr RpcErrorType RpcErrorType_MAX = static_cast(4); +constexpr int RpcErrorType_ARRAYSIZE = 4 + 1; +const ::google::protobuf::EnumDescriptor* +RpcErrorType_descriptor(); +template +const std::string& RpcErrorType_Name(T value) { + static_assert(std::is_same::value || + std::is_integral::value, + "Incorrect type passed to RpcErrorType_Name()."); + return RpcErrorType_Name(static_cast(value)); +} +template <> +inline const std::string& RpcErrorType_Name(RpcErrorType value) { + return ::google::protobuf::internal::NameOfDenseEnum( + static_cast(value)); +} +inline bool RpcErrorType_Parse(absl::string_view name, RpcErrorType* value) { + return ::google::protobuf::internal::ParseNamedEnum( + RpcErrorType_descriptor(), name, value); +} + +// =================================================================== + + +// ------------------------------------------------------------------- + +class RpcMessage_HeaderEntry_DoNotUse final + : public ::google::protobuf::internal::MapEntry< + RpcMessage_HeaderEntry_DoNotUse, std::string, std::string, + ::google::protobuf::internal::WireFormatLite::TYPE_STRING, + ::google::protobuf::internal::WireFormatLite::TYPE_STRING> { + public: + using SuperType = ::google::protobuf::internal::MapEntry< + RpcMessage_HeaderEntry_DoNotUse, std::string, std::string, + ::google::protobuf::internal::WireFormatLite::TYPE_STRING, + ::google::protobuf::internal::WireFormatLite::TYPE_STRING>; + RpcMessage_HeaderEntry_DoNotUse(); + template + explicit PROTOBUF_CONSTEXPR RpcMessage_HeaderEntry_DoNotUse( + ::google::protobuf::internal::ConstantInitialized); + explicit RpcMessage_HeaderEntry_DoNotUse(::google::protobuf::Arena* arena); + static const RpcMessage_HeaderEntry_DoNotUse* internal_default_instance() { + return reinterpret_cast( + &_RpcMessage_HeaderEntry_DoNotUse_default_instance_); + } + static bool ValidateKey(std::string* s) { + return ::google::protobuf::internal::WireFormatLite::VerifyUtf8String(s->data(), static_cast(s->size()), ::google::protobuf::internal::WireFormatLite::PARSE, "protorpc.RpcMessage.HeaderEntry.key"); + } + static bool ValidateValue(std::string* s) { + return ::google::protobuf::internal::WireFormatLite::VerifyUtf8String(s->data(), static_cast(s->size()), ::google::protobuf::internal::WireFormatLite::PARSE, "protorpc.RpcMessage.HeaderEntry.value"); + } + ::google::protobuf::Metadata GetMetadata() const final; + friend struct ::TableStruct_ProtoRpc_2eproto; +}; +// ------------------------------------------------------------------- + +class RpcMessage final : + public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:protorpc.RpcMessage) */ { + public: + inline RpcMessage() : RpcMessage(nullptr) {} + ~RpcMessage() override; + template + explicit PROTOBUF_CONSTEXPR RpcMessage(::google::protobuf::internal::ConstantInitialized); + + inline RpcMessage(const RpcMessage& from) + : RpcMessage(nullptr, from) {} + RpcMessage(RpcMessage&& from) noexcept + : RpcMessage() { + *this = ::std::move(from); + } + + inline RpcMessage& operator=(const RpcMessage& from) { + CopyFrom(from); + return *this; + } + inline RpcMessage& operator=(RpcMessage&& from) noexcept { + if (this == &from) return *this; + if (GetArena() == from.GetArena() + #ifdef PROTOBUF_FORCE_COPY_IN_MOVE + && GetArena() != nullptr + #endif // !PROTOBUF_FORCE_COPY_IN_MOVE + ) { + InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + + inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const + ABSL_ATTRIBUTE_LIFETIME_BOUND { + return _internal_metadata_.unknown_fields<::google::protobuf::UnknownFieldSet>(::google::protobuf::UnknownFieldSet::default_instance); + } + inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() + ABSL_ATTRIBUTE_LIFETIME_BOUND { + return _internal_metadata_.mutable_unknown_fields<::google::protobuf::UnknownFieldSet>(); + } + + static const ::google::protobuf::Descriptor* descriptor() { + return GetDescriptor(); + } + static const ::google::protobuf::Descriptor* GetDescriptor() { + return default_instance().GetMetadata().descriptor; + } + static const ::google::protobuf::Reflection* GetReflection() { + return default_instance().GetMetadata().reflection; + } + static const RpcMessage& default_instance() { + return *internal_default_instance(); + } + static inline const RpcMessage* internal_default_instance() { + return reinterpret_cast( + &_RpcMessage_default_instance_); + } + static constexpr int kIndexInFileMessages = + 1; + + friend void swap(RpcMessage& a, RpcMessage& b) { + a.Swap(&b); + } + inline void Swap(RpcMessage* other) { + if (other == this) return; + #ifdef PROTOBUF_FORCE_COPY_IN_SWAP + if (GetArena() != nullptr && + GetArena() == other->GetArena()) { + #else // PROTOBUF_FORCE_COPY_IN_SWAP + if (GetArena() == other->GetArena()) { + #endif // !PROTOBUF_FORCE_COPY_IN_SWAP + InternalSwap(other); + } else { + ::google::protobuf::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(RpcMessage* other) { + if (other == this) return; + ABSL_DCHECK(GetArena() == other->GetArena()); + InternalSwap(other); + } + + // implements Message ---------------------------------------------- + + RpcMessage* New(::google::protobuf::Arena* arena = nullptr) const final { + return CreateMaybeMessage(arena); + } + int GetCachedSize() const { return _impl_._cached_size_.Get(); } + + private: + ::google::protobuf::internal::CachedSize* AccessCachedSize() const final; + void SharedCtor(::google::protobuf::Arena* arena); + void SharedDtor(); + void InternalSwap(RpcMessage* other); + + private: + friend class ::google::protobuf::internal::AnyMetadata; + static ::absl::string_view FullMessageName() { + return "protorpc.RpcMessage"; + } + protected: + explicit RpcMessage(::google::protobuf::Arena* arena); + RpcMessage(::google::protobuf::Arena* arena, const RpcMessage& from); + public: + + ::google::protobuf::Metadata GetMetadata() const final; + + // nested types ---------------------------------------------------- + + + // accessors ------------------------------------------------------- + + enum : int { + kHeaderFieldNumber = 1, + kRequestIdFieldNumber = 3, + kErrorClassNameFieldNumber = 5, + kErrorCodeFieldNumber = 6, + kErrorMessageFieldNumber = 7, + kBodyFieldNumber = 2, + kErrorTypeFieldNumber = 4, + }; + // map header = 1; + int header_size() const; + private: + int _internal_header_size() const; + + public: + void clear_header() ; + const ::google::protobuf::Map& header() const; + ::google::protobuf::Map* mutable_header(); + + private: + const ::google::protobuf::Map& _internal_header() const; + ::google::protobuf::Map* _internal_mutable_header(); + + public: + // string requestId = 3; + void clear_requestid() ; + const std::string& requestid() const; + template + void set_requestid(Arg_&& arg, Args_... args); + std::string* mutable_requestid(); + PROTOBUF_NODISCARD std::string* release_requestid(); + void set_allocated_requestid(std::string* value); + + private: + const std::string& _internal_requestid() const; + inline PROTOBUF_ALWAYS_INLINE void _internal_set_requestid( + const std::string& value); + std::string* _internal_mutable_requestid(); + + public: + // optional string errorClassName = 5; + bool has_errorclassname() const; + void clear_errorclassname() ; + const std::string& errorclassname() const; + template + void set_errorclassname(Arg_&& arg, Args_... args); + std::string* mutable_errorclassname(); + PROTOBUF_NODISCARD std::string* release_errorclassname(); + void set_allocated_errorclassname(std::string* value); + + private: + const std::string& _internal_errorclassname() const; + inline PROTOBUF_ALWAYS_INLINE void _internal_set_errorclassname( + const std::string& value); + std::string* _internal_mutable_errorclassname(); + + public: + // optional string errorCode = 6; + bool has_errorcode() const; + void clear_errorcode() ; + const std::string& errorcode() const; + template + void set_errorcode(Arg_&& arg, Args_... args); + std::string* mutable_errorcode(); + PROTOBUF_NODISCARD std::string* release_errorcode(); + void set_allocated_errorcode(std::string* value); + + private: + const std::string& _internal_errorcode() const; + inline PROTOBUF_ALWAYS_INLINE void _internal_set_errorcode( + const std::string& value); + std::string* _internal_mutable_errorcode(); + + public: + // optional string errorMessage = 7; + bool has_errormessage() const; + void clear_errormessage() ; + const std::string& errormessage() const; + template + void set_errormessage(Arg_&& arg, Args_... args); + std::string* mutable_errormessage(); + PROTOBUF_NODISCARD std::string* release_errormessage(); + void set_allocated_errormessage(std::string* value); + + private: + const std::string& _internal_errormessage() const; + inline PROTOBUF_ALWAYS_INLINE void _internal_set_errormessage( + const std::string& value); + std::string* _internal_mutable_errormessage(); + + public: + // .google.protobuf.Any body = 2; + bool has_body() const; + void clear_body() ; + const ::google::protobuf::Any& body() const; + PROTOBUF_NODISCARD ::google::protobuf::Any* release_body(); + ::google::protobuf::Any* mutable_body(); + void set_allocated_body(::google::protobuf::Any* value); + void unsafe_arena_set_allocated_body(::google::protobuf::Any* value); + ::google::protobuf::Any* unsafe_arena_release_body(); + + private: + const ::google::protobuf::Any& _internal_body() const; + ::google::protobuf::Any* _internal_mutable_body(); + + public: + // optional .protorpc.RpcErrorType errorType = 4; + bool has_errortype() const; + void clear_errortype() ; + ::protorpc::RpcErrorType errortype() const; + void set_errortype(::protorpc::RpcErrorType value); + + private: + ::protorpc::RpcErrorType _internal_errortype() const; + void _internal_set_errortype(::protorpc::RpcErrorType value); + + public: + // @@protoc_insertion_point(class_scope:protorpc.RpcMessage) + private: + class _Internal; + + friend class ::google::protobuf::MessageLite; + friend class ::google::protobuf::Arena; + template + friend class ::google::protobuf::Arena::InternalHelper; + using InternalArenaConstructable_ = void; + using DestructorSkippable_ = void; + struct Impl_ { + + inline explicit constexpr Impl_( + ::google::protobuf::internal::ConstantInitialized) noexcept; + inline explicit Impl_(::google::protobuf::internal::InternalVisibility visibility, + ::google::protobuf::Arena* arena); + inline explicit Impl_(::google::protobuf::internal::InternalVisibility visibility, + ::google::protobuf::Arena* arena, const Impl_& from); + ::google::protobuf::internal::HasBits<1> _has_bits_; + mutable ::google::protobuf::internal::CachedSize _cached_size_; + ::google::protobuf::internal::MapField + header_; + ::google::protobuf::internal::ArenaStringPtr requestid_; + ::google::protobuf::internal::ArenaStringPtr errorclassname_; + ::google::protobuf::internal::ArenaStringPtr errorcode_; + ::google::protobuf::internal::ArenaStringPtr errormessage_; + ::google::protobuf::Any* body_; + int errortype_; + PROTOBUF_TSAN_DECLARE_MEMBER + }; + union { Impl_ _impl_; }; + friend struct ::TableStruct_ProtoRpc_2eproto; +};// ------------------------------------------------------------------- + +class Mnfo2uhnf92hvqi2nviouq2hv9puhq final : + public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:protorpc.Mnfo2uhnf92hvqi2nviouq2hv9puhq) */ { + public: + inline Mnfo2uhnf92hvqi2nviouq2hv9puhq() : Mnfo2uhnf92hvqi2nviouq2hv9puhq(nullptr) {} + ~Mnfo2uhnf92hvqi2nviouq2hv9puhq() override; + template + explicit PROTOBUF_CONSTEXPR Mnfo2uhnf92hvqi2nviouq2hv9puhq(::google::protobuf::internal::ConstantInitialized); + + inline Mnfo2uhnf92hvqi2nviouq2hv9puhq(const Mnfo2uhnf92hvqi2nviouq2hv9puhq& from) + : Mnfo2uhnf92hvqi2nviouq2hv9puhq(nullptr, from) {} + Mnfo2uhnf92hvqi2nviouq2hv9puhq(Mnfo2uhnf92hvqi2nviouq2hv9puhq&& from) noexcept + : Mnfo2uhnf92hvqi2nviouq2hv9puhq() { + *this = ::std::move(from); + } + + inline Mnfo2uhnf92hvqi2nviouq2hv9puhq& operator=(const Mnfo2uhnf92hvqi2nviouq2hv9puhq& from) { + CopyFrom(from); + return *this; + } + inline Mnfo2uhnf92hvqi2nviouq2hv9puhq& operator=(Mnfo2uhnf92hvqi2nviouq2hv9puhq&& from) noexcept { + if (this == &from) return *this; + if (GetArena() == from.GetArena() + #ifdef PROTOBUF_FORCE_COPY_IN_MOVE + && GetArena() != nullptr + #endif // !PROTOBUF_FORCE_COPY_IN_MOVE + ) { + InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + + inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const + ABSL_ATTRIBUTE_LIFETIME_BOUND { + return _internal_metadata_.unknown_fields<::google::protobuf::UnknownFieldSet>(::google::protobuf::UnknownFieldSet::default_instance); + } + inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() + ABSL_ATTRIBUTE_LIFETIME_BOUND { + return _internal_metadata_.mutable_unknown_fields<::google::protobuf::UnknownFieldSet>(); + } + + static const ::google::protobuf::Descriptor* descriptor() { + return GetDescriptor(); + } + static const ::google::protobuf::Descriptor* GetDescriptor() { + return default_instance().GetMetadata().descriptor; + } + static const ::google::protobuf::Reflection* GetReflection() { + return default_instance().GetMetadata().reflection; + } + static const Mnfo2uhnf92hvqi2nviouq2hv9puhq& default_instance() { + return *internal_default_instance(); + } + static inline const Mnfo2uhnf92hvqi2nviouq2hv9puhq* internal_default_instance() { + return reinterpret_cast( + &_Mnfo2uhnf92hvqi2nviouq2hv9puhq_default_instance_); + } + static constexpr int kIndexInFileMessages = + 2; + + friend void swap(Mnfo2uhnf92hvqi2nviouq2hv9puhq& a, Mnfo2uhnf92hvqi2nviouq2hv9puhq& b) { + a.Swap(&b); + } + inline void Swap(Mnfo2uhnf92hvqi2nviouq2hv9puhq* other) { + if (other == this) return; + #ifdef PROTOBUF_FORCE_COPY_IN_SWAP + if (GetArena() != nullptr && + GetArena() == other->GetArena()) { + #else // PROTOBUF_FORCE_COPY_IN_SWAP + if (GetArena() == other->GetArena()) { + #endif // !PROTOBUF_FORCE_COPY_IN_SWAP + InternalSwap(other); + } else { + ::google::protobuf::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(Mnfo2uhnf92hvqi2nviouq2hv9puhq* other) { + if (other == this) return; + ABSL_DCHECK(GetArena() == other->GetArena()); + InternalSwap(other); + } + + // implements Message ---------------------------------------------- + + Mnfo2uhnf92hvqi2nviouq2hv9puhq* New(::google::protobuf::Arena* arena = nullptr) const final { + return CreateMaybeMessage(arena); + } + int GetCachedSize() const { return _impl_._cached_size_.Get(); } + + private: + ::google::protobuf::internal::CachedSize* AccessCachedSize() const final; + void SharedCtor(::google::protobuf::Arena* arena); + void SharedDtor(); + void InternalSwap(Mnfo2uhnf92hvqi2nviouq2hv9puhq* other); + + private: + friend class ::google::protobuf::internal::AnyMetadata; + static ::absl::string_view FullMessageName() { + return "protorpc.Mnfo2uhnf92hvqi2nviouq2hv9puhq"; + } + protected: + explicit Mnfo2uhnf92hvqi2nviouq2hv9puhq(::google::protobuf::Arena* arena); + Mnfo2uhnf92hvqi2nviouq2hv9puhq(::google::protobuf::Arena* arena, const Mnfo2uhnf92hvqi2nviouq2hv9puhq& from); + public: + + ::google::protobuf::Metadata GetMetadata() const final; + + // nested types ---------------------------------------------------- + + // accessors ------------------------------------------------------- + + enum : int { + kEmptyFieldNumber = 1, + }; + // .google.protobuf.Empty empty = 1; + bool has_empty() const; + void clear_empty() ; + const ::google::protobuf::Empty& empty() const; + PROTOBUF_NODISCARD ::google::protobuf::Empty* release_empty(); + ::google::protobuf::Empty* mutable_empty(); + void set_allocated_empty(::google::protobuf::Empty* value); + void unsafe_arena_set_allocated_empty(::google::protobuf::Empty* value); + ::google::protobuf::Empty* unsafe_arena_release_empty(); + + private: + const ::google::protobuf::Empty& _internal_empty() const; + ::google::protobuf::Empty* _internal_mutable_empty(); + + public: + // @@protoc_insertion_point(class_scope:protorpc.Mnfo2uhnf92hvqi2nviouq2hv9puhq) + private: + class _Internal; + + friend class ::google::protobuf::MessageLite; + friend class ::google::protobuf::Arena; + template + friend class ::google::protobuf::Arena::InternalHelper; + using InternalArenaConstructable_ = void; + using DestructorSkippable_ = void; + struct Impl_ { + + inline explicit constexpr Impl_( + ::google::protobuf::internal::ConstantInitialized) noexcept; + inline explicit Impl_(::google::protobuf::internal::InternalVisibility visibility, + ::google::protobuf::Arena* arena); + inline explicit Impl_(::google::protobuf::internal::InternalVisibility visibility, + ::google::protobuf::Arena* arena, const Impl_& from); + ::google::protobuf::internal::HasBits<1> _has_bits_; + mutable ::google::protobuf::internal::CachedSize _cached_size_; + ::google::protobuf::Empty* empty_; + PROTOBUF_TSAN_DECLARE_MEMBER + }; + union { Impl_ _impl_; }; + friend struct ::TableStruct_ProtoRpc_2eproto; +}; + +// =================================================================== + + + + +// =================================================================== + + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wstrict-aliasing" +#endif // __GNUC__ +// ------------------------------------------------------------------- + +// ------------------------------------------------------------------- + +// RpcMessage + +// map header = 1; +inline int RpcMessage::_internal_header_size() const { + return _internal_header().size(); +} +inline int RpcMessage::header_size() const { + return _internal_header_size(); +} +inline void RpcMessage::clear_header() { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + _impl_.header_.Clear(); +} +inline const ::google::protobuf::Map& RpcMessage::_internal_header() const { + PROTOBUF_TSAN_READ(&_impl_._tsan_detect_race); + return _impl_.header_.GetMap(); +} +inline const ::google::protobuf::Map& RpcMessage::header() const ABSL_ATTRIBUTE_LIFETIME_BOUND { + // @@protoc_insertion_point(field_map:protorpc.RpcMessage.header) + return _internal_header(); +} +inline ::google::protobuf::Map* RpcMessage::_internal_mutable_header() { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + return _impl_.header_.MutableMap(); +} +inline ::google::protobuf::Map* RpcMessage::mutable_header() ABSL_ATTRIBUTE_LIFETIME_BOUND { + // @@protoc_insertion_point(field_mutable_map:protorpc.RpcMessage.header) + return _internal_mutable_header(); +} + +// .google.protobuf.Any body = 2; +inline bool RpcMessage::has_body() const { + bool value = (_impl_._has_bits_[0] & 0x00000008u) != 0; + PROTOBUF_ASSUME(!value || _impl_.body_ != nullptr); + return value; +} +inline const ::google::protobuf::Any& RpcMessage::_internal_body() const { + PROTOBUF_TSAN_READ(&_impl_._tsan_detect_race); + const ::google::protobuf::Any* p = _impl_.body_; + return p != nullptr ? *p : reinterpret_cast(::google::protobuf::_Any_default_instance_); +} +inline const ::google::protobuf::Any& RpcMessage::body() const ABSL_ATTRIBUTE_LIFETIME_BOUND { + // @@protoc_insertion_point(field_get:protorpc.RpcMessage.body) + return _internal_body(); +} +inline void RpcMessage::unsafe_arena_set_allocated_body(::google::protobuf::Any* value) { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + if (GetArena() == nullptr) { + delete reinterpret_cast<::google::protobuf::MessageLite*>(_impl_.body_); + } + _impl_.body_ = reinterpret_cast<::google::protobuf::Any*>(value); + if (value != nullptr) { + _impl_._has_bits_[0] |= 0x00000008u; + } else { + _impl_._has_bits_[0] &= ~0x00000008u; + } + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:protorpc.RpcMessage.body) +} +inline ::google::protobuf::Any* RpcMessage::release_body() { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + + _impl_._has_bits_[0] &= ~0x00000008u; + ::google::protobuf::Any* released = _impl_.body_; + _impl_.body_ = nullptr; +#ifdef PROTOBUF_FORCE_COPY_IN_RELEASE + auto* old = reinterpret_cast<::google::protobuf::MessageLite*>(released); + released = ::google::protobuf::internal::DuplicateIfNonNull(released); + if (GetArena() == nullptr) { + delete old; + } +#else // PROTOBUF_FORCE_COPY_IN_RELEASE + if (GetArena() != nullptr) { + released = ::google::protobuf::internal::DuplicateIfNonNull(released); + } +#endif // !PROTOBUF_FORCE_COPY_IN_RELEASE + return released; +} +inline ::google::protobuf::Any* RpcMessage::unsafe_arena_release_body() { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + // @@protoc_insertion_point(field_release:protorpc.RpcMessage.body) + + _impl_._has_bits_[0] &= ~0x00000008u; + ::google::protobuf::Any* temp = _impl_.body_; + _impl_.body_ = nullptr; + return temp; +} +inline ::google::protobuf::Any* RpcMessage::_internal_mutable_body() { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + _impl_._has_bits_[0] |= 0x00000008u; + if (_impl_.body_ == nullptr) { + auto* p = CreateMaybeMessage<::google::protobuf::Any>(GetArena()); + _impl_.body_ = reinterpret_cast<::google::protobuf::Any*>(p); + } + return _impl_.body_; +} +inline ::google::protobuf::Any* RpcMessage::mutable_body() ABSL_ATTRIBUTE_LIFETIME_BOUND { + ::google::protobuf::Any* _msg = _internal_mutable_body(); + // @@protoc_insertion_point(field_mutable:protorpc.RpcMessage.body) + return _msg; +} +inline void RpcMessage::set_allocated_body(::google::protobuf::Any* value) { + ::google::protobuf::Arena* message_arena = GetArena(); + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + if (message_arena == nullptr) { + delete reinterpret_cast<::google::protobuf::MessageLite*>(_impl_.body_); + } + + if (value != nullptr) { + ::google::protobuf::Arena* submessage_arena = reinterpret_cast<::google::protobuf::MessageLite*>(value)->GetArena(); + if (message_arena != submessage_arena) { + value = ::google::protobuf::internal::GetOwnedMessage(message_arena, value, submessage_arena); + } + _impl_._has_bits_[0] |= 0x00000008u; + } else { + _impl_._has_bits_[0] &= ~0x00000008u; + } + + _impl_.body_ = reinterpret_cast<::google::protobuf::Any*>(value); + // @@protoc_insertion_point(field_set_allocated:protorpc.RpcMessage.body) +} + +// string requestId = 3; +inline void RpcMessage::clear_requestid() { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + _impl_.requestid_.ClearToEmpty(); +} +inline const std::string& RpcMessage::requestid() const + ABSL_ATTRIBUTE_LIFETIME_BOUND { + // @@protoc_insertion_point(field_get:protorpc.RpcMessage.requestId) + return _internal_requestid(); +} +template +inline PROTOBUF_ALWAYS_INLINE void RpcMessage::set_requestid(Arg_&& arg, + Args_... args) { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + ; + _impl_.requestid_.Set(static_cast(arg), args..., GetArena()); + // @@protoc_insertion_point(field_set:protorpc.RpcMessage.requestId) +} +inline std::string* RpcMessage::mutable_requestid() ABSL_ATTRIBUTE_LIFETIME_BOUND { + std::string* _s = _internal_mutable_requestid(); + // @@protoc_insertion_point(field_mutable:protorpc.RpcMessage.requestId) + return _s; +} +inline const std::string& RpcMessage::_internal_requestid() const { + PROTOBUF_TSAN_READ(&_impl_._tsan_detect_race); + return _impl_.requestid_.Get(); +} +inline void RpcMessage::_internal_set_requestid(const std::string& value) { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + ; + _impl_.requestid_.Set(value, GetArena()); +} +inline std::string* RpcMessage::_internal_mutable_requestid() { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + ; + return _impl_.requestid_.Mutable( GetArena()); +} +inline std::string* RpcMessage::release_requestid() { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + // @@protoc_insertion_point(field_release:protorpc.RpcMessage.requestId) + return _impl_.requestid_.Release(); +} +inline void RpcMessage::set_allocated_requestid(std::string* value) { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + _impl_.requestid_.SetAllocated(value, GetArena()); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (_impl_.requestid_.IsDefault()) { + _impl_.requestid_.Set("", GetArena()); + } + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + // @@protoc_insertion_point(field_set_allocated:protorpc.RpcMessage.requestId) +} + +// optional .protorpc.RpcErrorType errorType = 4; +inline bool RpcMessage::has_errortype() const { + bool value = (_impl_._has_bits_[0] & 0x00000010u) != 0; + return value; +} +inline void RpcMessage::clear_errortype() { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + _impl_.errortype_ = 0; + _impl_._has_bits_[0] &= ~0x00000010u; +} +inline ::protorpc::RpcErrorType RpcMessage::errortype() const { + // @@protoc_insertion_point(field_get:protorpc.RpcMessage.errorType) + return _internal_errortype(); +} +inline void RpcMessage::set_errortype(::protorpc::RpcErrorType value) { + _internal_set_errortype(value); + // @@protoc_insertion_point(field_set:protorpc.RpcMessage.errorType) +} +inline ::protorpc::RpcErrorType RpcMessage::_internal_errortype() const { + PROTOBUF_TSAN_READ(&_impl_._tsan_detect_race); + return static_cast<::protorpc::RpcErrorType>(_impl_.errortype_); +} +inline void RpcMessage::_internal_set_errortype(::protorpc::RpcErrorType value) { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + _impl_._has_bits_[0] |= 0x00000010u; + _impl_.errortype_ = value; +} + +// optional string errorClassName = 5; +inline bool RpcMessage::has_errorclassname() const { + bool value = (_impl_._has_bits_[0] & 0x00000001u) != 0; + return value; +} +inline void RpcMessage::clear_errorclassname() { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + _impl_.errorclassname_.ClearToEmpty(); + _impl_._has_bits_[0] &= ~0x00000001u; +} +inline const std::string& RpcMessage::errorclassname() const + ABSL_ATTRIBUTE_LIFETIME_BOUND { + // @@protoc_insertion_point(field_get:protorpc.RpcMessage.errorClassName) + return _internal_errorclassname(); +} +template +inline PROTOBUF_ALWAYS_INLINE void RpcMessage::set_errorclassname(Arg_&& arg, + Args_... args) { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + _impl_._has_bits_[0] |= 0x00000001u; + _impl_.errorclassname_.Set(static_cast(arg), args..., GetArena()); + // @@protoc_insertion_point(field_set:protorpc.RpcMessage.errorClassName) +} +inline std::string* RpcMessage::mutable_errorclassname() ABSL_ATTRIBUTE_LIFETIME_BOUND { + std::string* _s = _internal_mutable_errorclassname(); + // @@protoc_insertion_point(field_mutable:protorpc.RpcMessage.errorClassName) + return _s; +} +inline const std::string& RpcMessage::_internal_errorclassname() const { + PROTOBUF_TSAN_READ(&_impl_._tsan_detect_race); + return _impl_.errorclassname_.Get(); +} +inline void RpcMessage::_internal_set_errorclassname(const std::string& value) { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + _impl_._has_bits_[0] |= 0x00000001u; + _impl_.errorclassname_.Set(value, GetArena()); +} +inline std::string* RpcMessage::_internal_mutable_errorclassname() { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + _impl_._has_bits_[0] |= 0x00000001u; + return _impl_.errorclassname_.Mutable( GetArena()); +} +inline std::string* RpcMessage::release_errorclassname() { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + // @@protoc_insertion_point(field_release:protorpc.RpcMessage.errorClassName) + if ((_impl_._has_bits_[0] & 0x00000001u) == 0) { + return nullptr; + } + _impl_._has_bits_[0] &= ~0x00000001u; + auto* released = _impl_.errorclassname_.Release(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.errorclassname_.Set("", GetArena()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + return released; +} +inline void RpcMessage::set_allocated_errorclassname(std::string* value) { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + if (value != nullptr) { + _impl_._has_bits_[0] |= 0x00000001u; + } else { + _impl_._has_bits_[0] &= ~0x00000001u; + } + _impl_.errorclassname_.SetAllocated(value, GetArena()); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (_impl_.errorclassname_.IsDefault()) { + _impl_.errorclassname_.Set("", GetArena()); + } + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + // @@protoc_insertion_point(field_set_allocated:protorpc.RpcMessage.errorClassName) +} + +// optional string errorCode = 6; +inline bool RpcMessage::has_errorcode() const { + bool value = (_impl_._has_bits_[0] & 0x00000002u) != 0; + return value; +} +inline void RpcMessage::clear_errorcode() { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + _impl_.errorcode_.ClearToEmpty(); + _impl_._has_bits_[0] &= ~0x00000002u; +} +inline const std::string& RpcMessage::errorcode() const + ABSL_ATTRIBUTE_LIFETIME_BOUND { + // @@protoc_insertion_point(field_get:protorpc.RpcMessage.errorCode) + return _internal_errorcode(); +} +template +inline PROTOBUF_ALWAYS_INLINE void RpcMessage::set_errorcode(Arg_&& arg, + Args_... args) { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + _impl_._has_bits_[0] |= 0x00000002u; + _impl_.errorcode_.Set(static_cast(arg), args..., GetArena()); + // @@protoc_insertion_point(field_set:protorpc.RpcMessage.errorCode) +} +inline std::string* RpcMessage::mutable_errorcode() ABSL_ATTRIBUTE_LIFETIME_BOUND { + std::string* _s = _internal_mutable_errorcode(); + // @@protoc_insertion_point(field_mutable:protorpc.RpcMessage.errorCode) + return _s; +} +inline const std::string& RpcMessage::_internal_errorcode() const { + PROTOBUF_TSAN_READ(&_impl_._tsan_detect_race); + return _impl_.errorcode_.Get(); +} +inline void RpcMessage::_internal_set_errorcode(const std::string& value) { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + _impl_._has_bits_[0] |= 0x00000002u; + _impl_.errorcode_.Set(value, GetArena()); +} +inline std::string* RpcMessage::_internal_mutable_errorcode() { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + _impl_._has_bits_[0] |= 0x00000002u; + return _impl_.errorcode_.Mutable( GetArena()); +} +inline std::string* RpcMessage::release_errorcode() { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + // @@protoc_insertion_point(field_release:protorpc.RpcMessage.errorCode) + if ((_impl_._has_bits_[0] & 0x00000002u) == 0) { + return nullptr; + } + _impl_._has_bits_[0] &= ~0x00000002u; + auto* released = _impl_.errorcode_.Release(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.errorcode_.Set("", GetArena()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + return released; +} +inline void RpcMessage::set_allocated_errorcode(std::string* value) { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + if (value != nullptr) { + _impl_._has_bits_[0] |= 0x00000002u; + } else { + _impl_._has_bits_[0] &= ~0x00000002u; + } + _impl_.errorcode_.SetAllocated(value, GetArena()); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (_impl_.errorcode_.IsDefault()) { + _impl_.errorcode_.Set("", GetArena()); + } + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + // @@protoc_insertion_point(field_set_allocated:protorpc.RpcMessage.errorCode) +} + +// optional string errorMessage = 7; +inline bool RpcMessage::has_errormessage() const { + bool value = (_impl_._has_bits_[0] & 0x00000004u) != 0; + return value; +} +inline void RpcMessage::clear_errormessage() { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + _impl_.errormessage_.ClearToEmpty(); + _impl_._has_bits_[0] &= ~0x00000004u; +} +inline const std::string& RpcMessage::errormessage() const + ABSL_ATTRIBUTE_LIFETIME_BOUND { + // @@protoc_insertion_point(field_get:protorpc.RpcMessage.errorMessage) + return _internal_errormessage(); +} +template +inline PROTOBUF_ALWAYS_INLINE void RpcMessage::set_errormessage(Arg_&& arg, + Args_... args) { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + _impl_._has_bits_[0] |= 0x00000004u; + _impl_.errormessage_.Set(static_cast(arg), args..., GetArena()); + // @@protoc_insertion_point(field_set:protorpc.RpcMessage.errorMessage) +} +inline std::string* RpcMessage::mutable_errormessage() ABSL_ATTRIBUTE_LIFETIME_BOUND { + std::string* _s = _internal_mutable_errormessage(); + // @@protoc_insertion_point(field_mutable:protorpc.RpcMessage.errorMessage) + return _s; +} +inline const std::string& RpcMessage::_internal_errormessage() const { + PROTOBUF_TSAN_READ(&_impl_._tsan_detect_race); + return _impl_.errormessage_.Get(); +} +inline void RpcMessage::_internal_set_errormessage(const std::string& value) { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + _impl_._has_bits_[0] |= 0x00000004u; + _impl_.errormessage_.Set(value, GetArena()); +} +inline std::string* RpcMessage::_internal_mutable_errormessage() { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + _impl_._has_bits_[0] |= 0x00000004u; + return _impl_.errormessage_.Mutable( GetArena()); +} +inline std::string* RpcMessage::release_errormessage() { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + // @@protoc_insertion_point(field_release:protorpc.RpcMessage.errorMessage) + if ((_impl_._has_bits_[0] & 0x00000004u) == 0) { + return nullptr; + } + _impl_._has_bits_[0] &= ~0x00000004u; + auto* released = _impl_.errormessage_.Release(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.errormessage_.Set("", GetArena()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + return released; +} +inline void RpcMessage::set_allocated_errormessage(std::string* value) { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + if (value != nullptr) { + _impl_._has_bits_[0] |= 0x00000004u; + } else { + _impl_._has_bits_[0] &= ~0x00000004u; + } + _impl_.errormessage_.SetAllocated(value, GetArena()); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (_impl_.errormessage_.IsDefault()) { + _impl_.errormessage_.Set("", GetArena()); + } + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + // @@protoc_insertion_point(field_set_allocated:protorpc.RpcMessage.errorMessage) +} + +// ------------------------------------------------------------------- + +// Mnfo2uhnf92hvqi2nviouq2hv9puhq + +// .google.protobuf.Empty empty = 1; +inline bool Mnfo2uhnf92hvqi2nviouq2hv9puhq::has_empty() const { + bool value = (_impl_._has_bits_[0] & 0x00000001u) != 0; + PROTOBUF_ASSUME(!value || _impl_.empty_ != nullptr); + return value; +} +inline const ::google::protobuf::Empty& Mnfo2uhnf92hvqi2nviouq2hv9puhq::_internal_empty() const { + PROTOBUF_TSAN_READ(&_impl_._tsan_detect_race); + const ::google::protobuf::Empty* p = _impl_.empty_; + return p != nullptr ? *p : reinterpret_cast(::google::protobuf::_Empty_default_instance_); +} +inline const ::google::protobuf::Empty& Mnfo2uhnf92hvqi2nviouq2hv9puhq::empty() const ABSL_ATTRIBUTE_LIFETIME_BOUND { + // @@protoc_insertion_point(field_get:protorpc.Mnfo2uhnf92hvqi2nviouq2hv9puhq.empty) + return _internal_empty(); +} +inline void Mnfo2uhnf92hvqi2nviouq2hv9puhq::unsafe_arena_set_allocated_empty(::google::protobuf::Empty* value) { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + if (GetArena() == nullptr) { + delete reinterpret_cast<::google::protobuf::MessageLite*>(_impl_.empty_); + } + _impl_.empty_ = reinterpret_cast<::google::protobuf::Empty*>(value); + if (value != nullptr) { + _impl_._has_bits_[0] |= 0x00000001u; + } else { + _impl_._has_bits_[0] &= ~0x00000001u; + } + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:protorpc.Mnfo2uhnf92hvqi2nviouq2hv9puhq.empty) +} +inline ::google::protobuf::Empty* Mnfo2uhnf92hvqi2nviouq2hv9puhq::release_empty() { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + + _impl_._has_bits_[0] &= ~0x00000001u; + ::google::protobuf::Empty* released = _impl_.empty_; + _impl_.empty_ = nullptr; +#ifdef PROTOBUF_FORCE_COPY_IN_RELEASE + auto* old = reinterpret_cast<::google::protobuf::MessageLite*>(released); + released = ::google::protobuf::internal::DuplicateIfNonNull(released); + if (GetArena() == nullptr) { + delete old; + } +#else // PROTOBUF_FORCE_COPY_IN_RELEASE + if (GetArena() != nullptr) { + released = ::google::protobuf::internal::DuplicateIfNonNull(released); + } +#endif // !PROTOBUF_FORCE_COPY_IN_RELEASE + return released; +} +inline ::google::protobuf::Empty* Mnfo2uhnf92hvqi2nviouq2hv9puhq::unsafe_arena_release_empty() { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + // @@protoc_insertion_point(field_release:protorpc.Mnfo2uhnf92hvqi2nviouq2hv9puhq.empty) + + _impl_._has_bits_[0] &= ~0x00000001u; + ::google::protobuf::Empty* temp = _impl_.empty_; + _impl_.empty_ = nullptr; + return temp; +} +inline ::google::protobuf::Empty* Mnfo2uhnf92hvqi2nviouq2hv9puhq::_internal_mutable_empty() { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + _impl_._has_bits_[0] |= 0x00000001u; + if (_impl_.empty_ == nullptr) { + auto* p = CreateMaybeMessage<::google::protobuf::Empty>(GetArena()); + _impl_.empty_ = reinterpret_cast<::google::protobuf::Empty*>(p); + } + return _impl_.empty_; +} +inline ::google::protobuf::Empty* Mnfo2uhnf92hvqi2nviouq2hv9puhq::mutable_empty() ABSL_ATTRIBUTE_LIFETIME_BOUND { + ::google::protobuf::Empty* _msg = _internal_mutable_empty(); + // @@protoc_insertion_point(field_mutable:protorpc.Mnfo2uhnf92hvqi2nviouq2hv9puhq.empty) + return _msg; +} +inline void Mnfo2uhnf92hvqi2nviouq2hv9puhq::set_allocated_empty(::google::protobuf::Empty* value) { + ::google::protobuf::Arena* message_arena = GetArena(); + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + if (message_arena == nullptr) { + delete reinterpret_cast<::google::protobuf::MessageLite*>(_impl_.empty_); + } + + if (value != nullptr) { + ::google::protobuf::Arena* submessage_arena = reinterpret_cast<::google::protobuf::MessageLite*>(value)->GetArena(); + if (message_arena != submessage_arena) { + value = ::google::protobuf::internal::GetOwnedMessage(message_arena, value, submessage_arena); + } + _impl_._has_bits_[0] |= 0x00000001u; + } else { + _impl_._has_bits_[0] &= ~0x00000001u; + } + + _impl_.empty_ = reinterpret_cast<::google::protobuf::Empty*>(value); + // @@protoc_insertion_point(field_set_allocated:protorpc.Mnfo2uhnf92hvqi2nviouq2hv9puhq.empty) +} + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif // __GNUC__ + +// @@protoc_insertion_point(namespace_scope) +} // namespace protorpc + + +namespace google { +namespace protobuf { + +template <> +struct is_proto_enum<::protorpc::RpcErrorType> : std::true_type {}; +template <> +inline const EnumDescriptor* GetEnumDescriptor<::protorpc::RpcErrorType>() { + return ::protorpc::RpcErrorType_descriptor(); +} + +} // namespace protobuf +} // namespace google + +// @@protoc_insertion_point(global_scope) + +#include "google/protobuf/port_undef.inc" + +#endif // GOOGLE_PROTOBUF_INCLUDED_ProtoRpc_2eproto_2epb_2eh diff --git a/packages/streamr-proto-rpc/test.sh b/packages/streamr-proto-rpc/test.sh index b7cfd67..18d7615 100755 --- a/packages/streamr-proto-rpc/test.sh +++ b/packages/streamr-proto-rpc/test.sh @@ -2,7 +2,7 @@ cmake --build build cd build - +export LOG_LEVEL=trace if [ "$#" -gt 0 ]; then ctest -V -R "$@" else diff --git a/packages/streamr-proto-rpc/test/integration/ProtoRpcTest.cpp b/packages/streamr-proto-rpc/test/integration/ProtoRpcTest.cpp new file mode 100644 index 0000000..1443a6f --- /dev/null +++ b/packages/streamr-proto-rpc/test/integration/ProtoRpcTest.cpp @@ -0,0 +1,178 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "HelloRpc.client.pb.h" +#include "TestProtos.client.pb.h" +#include "WakeUpRpc.client.pb.h" +#include "WakeUpRpc.server.pb.h" +#include "streamr-eventemitter/EventEmitter.hpp" +#include "streamr-proto-rpc/ProtoCallContext.hpp" + +namespace streamr::protorpc { + +template +void setOutgoingCallbackWithException(RpcCommunicator& sender) { + sender.setOutgoingMessageCallback( + [](const RpcMessage& /* message */, + const std::string& /* requestId */, + const ProtoCallContext& /* context */) -> void { + SLogger::info("onOutgoingMessageCallback() throws"); + throw T("TestException"); + }); +} + +void verifyClientError( + const RpcClientError& ex, + const ErrorCode expectedErrorCode, + const std::string& expectedOriginalErrorInfo) { + SLogger::info("Caught RpcClientError", ex.what()); + EXPECT_EQ(ex.code, expectedErrorCode); + EXPECT_TRUE(ex.originalErrorInfo.has_value()); + EXPECT_EQ(ex.originalErrorInfo.value(), expectedOriginalErrorInfo); +} +using streamr::eventemitter::Event; +using streamr::eventemitter::EventEmitter; + +struct WakeUpCalled : public Event {}; +using WakeUpEvents = std::tuple; + +class WakeUpRpcServiceImpl : public WakeUpRpcService, + public EventEmitter { +public: + void wakeUp( + const WakeUpRequest& request, + const ProtoCallContext& /* callContext */) override { + this->emit(request.reason()); + } +}; + +class ProtoRpcClientTest : public ::testing::Test { +protected: + RpcCommunicator communicator1; // NOLINT + RpcCommunicator communicator2; // NOLINT + + void SetUp() override {} + + void setCallbacks(bool isMethod = true) { + communicator2.setOutgoingMessageCallback( + [this]( + const RpcMessage& message, + const std::string& /* requestId */, + const ProtoCallContext& /* context */) -> void { + SLogger::info("onOutgoingMessageCallback()"); + communicator1.handleIncomingMessage( + message, ProtoCallContext()); + }); + if (isMethod) { + communicator1.setOutgoingMessageCallback( + [this]( + const RpcMessage& message, + const std::string& /* requestId */, + const ProtoCallContext& /* context */) -> void { + SLogger::info("onOutgoingMessageCallback()"); + communicator2.handleIncomingMessage( + message, ProtoCallContext()); + }); + } + } +}; + +void registerTestRcpMethod(RpcCommunicator& communicator) { + communicator.registerRpcMethod( + "sayHello", + [](const HelloRequest& request, + const ProtoCallContext& /* context */) -> HelloResponse { + HelloResponse response; + SLogger::info( + "registerTestRcpMethod request.myname():", request.myname()); + response.set_greeting("Hello, " + request.myname()); + return response; + }); +} + +void registerTestRcpMethodWithOptionalFields(RpcCommunicator& communicator) { + communicator.registerRpcMethod( + "getOptional", + [](const OptionalRequest& /* request */, + const ProtoCallContext& /* context */) -> OptionalResponse { + OptionalResponse response; + return response; + }); +} + +TEST_F(ProtoRpcClientTest, TestCanMakeRpcCall) { + registerTestRcpMethod(communicator1); + setCallbacks(); + HelloRpcServiceClient client(communicator2); + HelloRequest request; + request.set_myname("Test"); + auto result = + folly::coro::blockingWait(client.sayHello(request, ProtoCallContext())); + EXPECT_EQ("Hello, Test", result.greeting()); +} + +TEST_F(ProtoRpcClientTest, TestCanMakeRpcNotification) { + WakeUpRpcServiceImpl wakeUpService; + communicator1.registerRpcNotification( + "wakeUp", + [&wakeUpService]( + const WakeUpRequest& request, const ProtoCallContext& context) { + return wakeUpService.wakeUp(request, context); + }); + setCallbacks(false); + std::promise promise; + wakeUpService.on( + [&promise](const std::string& reason) -> void { + SLogger::info("wakeUpService: called with", reason); + promise.set_value(reason); + }); + WakeUpRpcServiceClient client(communicator2); + WakeUpRequest request; + request.set_reason("School"); + folly::coro::blockingWait(client.wakeUp(request, ProtoCallContext())); + EXPECT_EQ("School", promise.get_future().get()); +} + +TEST_F(ProtoRpcClientTest, TestCanMakeRpcCallWithOptionalFields) { + registerTestRcpMethodWithOptionalFields(communicator1); + setCallbacks(); + OptionalServiceClient client(communicator2); + OptionalRequest request; + request.set_someoptionalfield("something"); + auto result = folly::coro::blockingWait( + client.getOptional(request, ProtoCallContext())); + EXPECT_EQ(false, result.has_someoptionalfield()); +} + +TEST_F( + ProtoRpcClientTest, + TestHandlesClientSideExceptionOnRPCCallsWithRuntimeError) { + registerTestRcpMethod(communicator1); + setOutgoingCallbackWithException(communicator2); + HelloRpcServiceClient client(communicator2); + HelloRequest request; + request.set_myname("Test"); + try { + folly::coro::blockingWait(client.sayHello(request, ProtoCallContext())); + // Test fails here + EXPECT_TRUE(false); + } catch (const RpcClientError& ex) { + verifyClientError(ex, ErrorCode::RPC_CLIENT_ERROR, "TestException"); + } catch (...) { + EXPECT_TRUE(false); + } +} + +} // namespace streamr::protorpc diff --git a/packages/streamr-proto-rpc/test/proto/HelloRpc.client.pb.h b/packages/streamr-proto-rpc/test/proto/HelloRpc.client.pb.h new file mode 100644 index 0000000..222d435 --- /dev/null +++ b/packages/streamr-proto-rpc/test/proto/HelloRpc.client.pb.h @@ -0,0 +1,26 @@ +// generated by the protocol buffer streamr pluging. DO NOT EDIT! +// generated from protobuf file "HelloRpc.proto" + +#ifndef STREAMR_PROTORPC_HELLORPC_CLIENT_PB_H +#define STREAMR_PROTORPC_HELLORPC_CLIENT_PB_H + +#include +#include "HelloRpc.pb.h" // NOLINT +#include "streamr-proto-rpc/ProtoCallContext.hpp" +#include "streamr-proto-rpc/RpcCommunicator.hpp" + + +namespace streamr::protorpc { +class HelloRpcServiceClient { +private: +RpcCommunicator& communicator; +public: + HelloRpcServiceClient(RpcCommunicator& communicator) : communicator(communicator) {} + folly::coro::Task sayHello(const HelloRequest& request, const ProtoCallContext& callContext) { + return communicator.request("sayHello", request, callContext); + } +}; // class HelloRpcServiceClient +}; // namespace streamr::protorpc + +#endif // STREAMR_PROTORPC_HELLORPC_CLIENT_PB_H + diff --git a/packages/streamr-proto-rpc/test/proto/HelloRpc.pb.cc b/packages/streamr-proto-rpc/test/proto/HelloRpc.pb.cc new file mode 100644 index 0000000..13ea014 --- /dev/null +++ b/packages/streamr-proto-rpc/test/proto/HelloRpc.pb.cc @@ -0,0 +1,270 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: HelloRpc.proto + +#include "HelloRpc.pb.h" + +#include +#include "google/protobuf/io/coded_stream.h" +#include "google/protobuf/extension_set.h" +#include "google/protobuf/wire_format_lite.h" +#include "google/protobuf/descriptor.h" +#include "google/protobuf/generated_message_reflection.h" +#include "google/protobuf/reflection_ops.h" +#include "google/protobuf/wire_format.h" +// @@protoc_insertion_point(includes) + +// Must be included last. +#include "google/protobuf/port_def.inc" +PROTOBUF_PRAGMA_INIT_SEG +namespace _pb = ::google::protobuf; +namespace _pbi = ::google::protobuf::internal; + +inline constexpr HelloResponse::Impl_::Impl_( + ::_pbi::ConstantInitialized) noexcept + : greeting_( + &::google::protobuf::internal::fixed_address_empty_string, + ::_pbi::ConstantInitialized()), + _cached_size_{0} {} + +template +PROTOBUF_CONSTEXPR HelloResponse::HelloResponse(::_pbi::ConstantInitialized) + : _impl_(::_pbi::ConstantInitialized()) {} +struct HelloResponseDefaultTypeInternal { + PROTOBUF_CONSTEXPR HelloResponseDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} + ~HelloResponseDefaultTypeInternal() {} + union { + HelloResponse _instance; + }; +}; + +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT + PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 HelloResponseDefaultTypeInternal _HelloResponse_default_instance_; + +inline constexpr HelloRequest::Impl_::Impl_( + ::_pbi::ConstantInitialized) noexcept + : myname_( + &::google::protobuf::internal::fixed_address_empty_string, + ::_pbi::ConstantInitialized()), + _cached_size_{0} {} + +template +PROTOBUF_CONSTEXPR HelloRequest::HelloRequest(::_pbi::ConstantInitialized) + : _impl_(::_pbi::ConstantInitialized()) {} +struct HelloRequestDefaultTypeInternal { + PROTOBUF_CONSTEXPR HelloRequestDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} + ~HelloRequestDefaultTypeInternal() {} + union { + HelloRequest _instance; + }; +}; + +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT + PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 HelloRequestDefaultTypeInternal _HelloRequest_default_instance_; +static ::_pb::Metadata file_level_metadata_HelloRpc_2eproto[2]; +static constexpr const ::_pb::EnumDescriptor** + file_level_enum_descriptors_HelloRpc_2eproto = nullptr; +static constexpr const ::_pb::ServiceDescriptor** + file_level_service_descriptors_HelloRpc_2eproto = nullptr; +const ::uint32_t TableStruct_HelloRpc_2eproto::offsets[] PROTOBUF_SECTION_VARIABLE( + protodesc_cold) = { + ~0u, // no _has_bits_ + PROTOBUF_FIELD_OFFSET(::HelloRequest, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) + PROTOBUF_FIELD_OFFSET(::HelloRequest, _impl_.myname_), + ~0u, // no _has_bits_ + PROTOBUF_FIELD_OFFSET(::HelloResponse, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) + PROTOBUF_FIELD_OFFSET(::HelloResponse, _impl_.greeting_), +}; + +static const ::_pbi::MigrationSchema + schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { + {0, -1, -1, sizeof(::HelloRequest)}, + {9, -1, -1, sizeof(::HelloResponse)}, +}; + +static const ::_pb::Message* const file_default_instances[] = { + &::_HelloRequest_default_instance_._instance, + &::_HelloResponse_default_instance_._instance, +}; +const char descriptor_table_protodef_HelloRpc_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { + "\n\016HelloRpc.proto\"\036\n\014HelloRequest\022\016\n\006myNa" + "me\030\001 \001(\t\"!\n\rHelloResponse\022\020\n\010greeting\030\001 " + "\001(\t2<\n\017HelloRpcService\022)\n\010sayHello\022\r.Hel" + "loRequest\032\016.HelloResponseB\002H\002b\006proto3" +}; +static ::absl::once_flag descriptor_table_HelloRpc_2eproto_once; +const ::_pbi::DescriptorTable descriptor_table_HelloRpc_2eproto = { + false, + false, + 157, + descriptor_table_protodef_HelloRpc_2eproto, + "HelloRpc.proto", + &descriptor_table_HelloRpc_2eproto_once, + nullptr, + 0, + 2, + schemas, + file_default_instances, + TableStruct_HelloRpc_2eproto::offsets, + file_level_metadata_HelloRpc_2eproto, + file_level_enum_descriptors_HelloRpc_2eproto, + file_level_service_descriptors_HelloRpc_2eproto, +}; + +// This function exists to be marked as weak. +// It can significantly speed up compilation by breaking up LLVM's SCC +// in the .pb.cc translation units. Large translation units see a +// reduction of more than 35% of walltime for optimized builds. Without +// the weak attribute all the messages in the file, including all the +// vtables and everything they use become part of the same SCC through +// a cycle like: +// GetMetadata -> descriptor table -> default instances -> +// vtables -> GetMetadata +// By adding a weak function here we break the connection from the +// individual vtables back into the descriptor table. +PROTOBUF_ATTRIBUTE_WEAK const ::_pbi::DescriptorTable* descriptor_table_HelloRpc_2eproto_getter() { + return &descriptor_table_HelloRpc_2eproto; +} +// Force running AddDescriptors() at dynamic initialization time. +PROTOBUF_ATTRIBUTE_INIT_PRIORITY2 +static ::_pbi::AddDescriptorsRunner dynamic_init_dummy_HelloRpc_2eproto(&descriptor_table_HelloRpc_2eproto); +// =================================================================== + +class HelloRequest::_Internal { + public: +}; + +HelloRequest::HelloRequest(::google::protobuf::Arena* arena) + : ::google::protobuf::Message(arena) { + SharedCtor(arena); + // @@protoc_insertion_point(arena_constructor:HelloRequest) +} +inline PROTOBUF_NDEBUG_INLINE HelloRequest::Impl_::Impl_( + ::google::protobuf::internal::InternalVisibility visibility, ::google::protobuf::Arena* arena, + const Impl_& from) + : myname_(arena, from.myname_), + _cached_size_{0} {} + +HelloRequest::HelloRequest( + ::google::protobuf::Arena* arena, + const HelloRequest& from) + : ::google::protobuf::Message(arena) { + HelloRequest* const _this = this; + (void)_this; + _internal_metadata_.MergeFrom<::google::protobuf::UnknownFieldSet>( + from._internal_metadata_); + new (&_impl_) Impl_(internal_visibility(), arena, from._impl_); + + // @@protoc_insertion_point(copy_constructor:HelloRequest) +} +inline PROTOBUF_NDEBUG_INLINE HelloRequest::Impl_::Impl_( + ::google::protobuf::internal::InternalVisibility visibility, + ::google::protobuf::Arena* arena) + : myname_(arena), + _cached_size_{0} {} + +inline void HelloRequest::SharedCtor(::_pb::Arena* arena) { + new (&_impl_) Impl_(internal_visibility(), arena); +} +HelloRequest::~HelloRequest() { + // @@protoc_insertion_point(destructor:HelloRequest) + _internal_metadata_.Delete<::google::protobuf::UnknownFieldSet>(); + SharedDtor(); +} +inline void HelloRequest::SharedDtor() { + ABSL_DCHECK(GetArena() == nullptr); + _impl_.myname_.Destroy(); + _impl_.~Impl_(); +} + +::_pbi::CachedSize* HelloRequest::AccessCachedSize() const { + return &_impl_._cached_size_; +} +void HelloRequest::InternalSwap(HelloRequest* PROTOBUF_RESTRICT other) { + using std::swap; + GetReflection()->Swap(this, other);} + +::google::protobuf::Metadata HelloRequest::GetMetadata() const { + return ::_pbi::AssignDescriptors( + &descriptor_table_HelloRpc_2eproto_getter, &descriptor_table_HelloRpc_2eproto_once, + file_level_metadata_HelloRpc_2eproto[0]); +} +// =================================================================== + +class HelloResponse::_Internal { + public: +}; + +HelloResponse::HelloResponse(::google::protobuf::Arena* arena) + : ::google::protobuf::Message(arena) { + SharedCtor(arena); + // @@protoc_insertion_point(arena_constructor:HelloResponse) +} +inline PROTOBUF_NDEBUG_INLINE HelloResponse::Impl_::Impl_( + ::google::protobuf::internal::InternalVisibility visibility, ::google::protobuf::Arena* arena, + const Impl_& from) + : greeting_(arena, from.greeting_), + _cached_size_{0} {} + +HelloResponse::HelloResponse( + ::google::protobuf::Arena* arena, + const HelloResponse& from) + : ::google::protobuf::Message(arena) { + HelloResponse* const _this = this; + (void)_this; + _internal_metadata_.MergeFrom<::google::protobuf::UnknownFieldSet>( + from._internal_metadata_); + new (&_impl_) Impl_(internal_visibility(), arena, from._impl_); + + // @@protoc_insertion_point(copy_constructor:HelloResponse) +} +inline PROTOBUF_NDEBUG_INLINE HelloResponse::Impl_::Impl_( + ::google::protobuf::internal::InternalVisibility visibility, + ::google::protobuf::Arena* arena) + : greeting_(arena), + _cached_size_{0} {} + +inline void HelloResponse::SharedCtor(::_pb::Arena* arena) { + new (&_impl_) Impl_(internal_visibility(), arena); +} +HelloResponse::~HelloResponse() { + // @@protoc_insertion_point(destructor:HelloResponse) + _internal_metadata_.Delete<::google::protobuf::UnknownFieldSet>(); + SharedDtor(); +} +inline void HelloResponse::SharedDtor() { + ABSL_DCHECK(GetArena() == nullptr); + _impl_.greeting_.Destroy(); + _impl_.~Impl_(); +} + +::_pbi::CachedSize* HelloResponse::AccessCachedSize() const { + return &_impl_._cached_size_; +} +void HelloResponse::InternalSwap(HelloResponse* PROTOBUF_RESTRICT other) { + using std::swap; + GetReflection()->Swap(this, other);} + +::google::protobuf::Metadata HelloResponse::GetMetadata() const { + return ::_pbi::AssignDescriptors( + &descriptor_table_HelloRpc_2eproto_getter, &descriptor_table_HelloRpc_2eproto_once, + file_level_metadata_HelloRpc_2eproto[1]); +} +// @@protoc_insertion_point(namespace_scope) +namespace google { +namespace protobuf { +} // namespace protobuf +} // namespace google +// @@protoc_insertion_point(global_scope) +#include "google/protobuf/port_undef.inc" diff --git a/packages/streamr-proto-rpc/test/proto/HelloRpc.pb.h b/packages/streamr-proto-rpc/test/proto/HelloRpc.pb.h new file mode 100644 index 0000000..894d25a --- /dev/null +++ b/packages/streamr-proto-rpc/test/proto/HelloRpc.pb.h @@ -0,0 +1,525 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: HelloRpc.proto +// Protobuf C++ Version: 4.25.1 + +#ifndef GOOGLE_PROTOBUF_INCLUDED_HelloRpc_2eproto_2epb_2eh +#define GOOGLE_PROTOBUF_INCLUDED_HelloRpc_2eproto_2epb_2eh + +#include +#include +#include +#include + +#include "google/protobuf/port_def.inc" +#if PROTOBUF_VERSION < 4025000 +#error "This file was generated by a newer version of protoc which is" +#error "incompatible with your Protocol Buffer headers. Please update" +#error "your headers." +#endif // PROTOBUF_VERSION + +#if 4025001 < PROTOBUF_MIN_PROTOC_VERSION +#error "This file was generated by an older version of protoc which is" +#error "incompatible with your Protocol Buffer headers. Please" +#error "regenerate this file with a newer version of protoc." +#endif // PROTOBUF_MIN_PROTOC_VERSION +#include "google/protobuf/port_undef.inc" +#include "google/protobuf/io/coded_stream.h" +#include "google/protobuf/arena.h" +#include "google/protobuf/arenastring.h" +#include "google/protobuf/generated_message_util.h" +#include "google/protobuf/metadata_lite.h" +#include "google/protobuf/generated_message_reflection.h" +#include "google/protobuf/message.h" +#include "google/protobuf/repeated_field.h" // IWYU pragma: export +#include "google/protobuf/extension_set.h" // IWYU pragma: export +#include "google/protobuf/unknown_field_set.h" +// @@protoc_insertion_point(includes) + +// Must be included last. +#include "google/protobuf/port_def.inc" + +#define PROTOBUF_INTERNAL_EXPORT_HelloRpc_2eproto + +namespace google { +namespace protobuf { +namespace internal { +class AnyMetadata; +} // namespace internal +} // namespace protobuf +} // namespace google + +// Internal implementation detail -- do not use these members. +struct TableStruct_HelloRpc_2eproto { + static const ::uint32_t offsets[]; +}; +extern const ::google::protobuf::internal::DescriptorTable + descriptor_table_HelloRpc_2eproto; +class HelloRequest; +struct HelloRequestDefaultTypeInternal; +extern HelloRequestDefaultTypeInternal _HelloRequest_default_instance_; +class HelloResponse; +struct HelloResponseDefaultTypeInternal; +extern HelloResponseDefaultTypeInternal _HelloResponse_default_instance_; +namespace google { +namespace protobuf { +} // namespace protobuf +} // namespace google + + +// =================================================================== + + +// ------------------------------------------------------------------- + +class HelloResponse final : + public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:HelloResponse) */ { + public: + inline HelloResponse() : HelloResponse(nullptr) {} + ~HelloResponse() override; + template + explicit PROTOBUF_CONSTEXPR HelloResponse(::google::protobuf::internal::ConstantInitialized); + + inline HelloResponse(const HelloResponse& from) + : HelloResponse(nullptr, from) {} + HelloResponse(HelloResponse&& from) noexcept + : HelloResponse() { + *this = ::std::move(from); + } + + inline HelloResponse& operator=(const HelloResponse& from) { + CopyFrom(from); + return *this; + } + inline HelloResponse& operator=(HelloResponse&& from) noexcept { + if (this == &from) return *this; + if (GetArena() == from.GetArena() + #ifdef PROTOBUF_FORCE_COPY_IN_MOVE + && GetArena() != nullptr + #endif // !PROTOBUF_FORCE_COPY_IN_MOVE + ) { + InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + + inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const + ABSL_ATTRIBUTE_LIFETIME_BOUND { + return _internal_metadata_.unknown_fields<::google::protobuf::UnknownFieldSet>(::google::protobuf::UnknownFieldSet::default_instance); + } + inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() + ABSL_ATTRIBUTE_LIFETIME_BOUND { + return _internal_metadata_.mutable_unknown_fields<::google::protobuf::UnknownFieldSet>(); + } + + static const ::google::protobuf::Descriptor* descriptor() { + return GetDescriptor(); + } + static const ::google::protobuf::Descriptor* GetDescriptor() { + return default_instance().GetMetadata().descriptor; + } + static const ::google::protobuf::Reflection* GetReflection() { + return default_instance().GetMetadata().reflection; + } + static const HelloResponse& default_instance() { + return *internal_default_instance(); + } + static inline const HelloResponse* internal_default_instance() { + return reinterpret_cast( + &_HelloResponse_default_instance_); + } + static constexpr int kIndexInFileMessages = + 1; + + friend void swap(HelloResponse& a, HelloResponse& b) { + a.Swap(&b); + } + inline void Swap(HelloResponse* other) { + if (other == this) return; + #ifdef PROTOBUF_FORCE_COPY_IN_SWAP + if (GetArena() != nullptr && + GetArena() == other->GetArena()) { + #else // PROTOBUF_FORCE_COPY_IN_SWAP + if (GetArena() == other->GetArena()) { + #endif // !PROTOBUF_FORCE_COPY_IN_SWAP + InternalSwap(other); + } else { + ::google::protobuf::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(HelloResponse* other) { + if (other == this) return; + ABSL_DCHECK(GetArena() == other->GetArena()); + InternalSwap(other); + } + + // implements Message ---------------------------------------------- + + HelloResponse* New(::google::protobuf::Arena* arena = nullptr) const final { + return CreateMaybeMessage(arena); + } + int GetCachedSize() const { return _impl_._cached_size_.Get(); } + + private: + ::google::protobuf::internal::CachedSize* AccessCachedSize() const final; + void SharedCtor(::google::protobuf::Arena* arena); + void SharedDtor(); + void InternalSwap(HelloResponse* other); + + private: + friend class ::google::protobuf::internal::AnyMetadata; + static ::absl::string_view FullMessageName() { + return "HelloResponse"; + } + protected: + explicit HelloResponse(::google::protobuf::Arena* arena); + HelloResponse(::google::protobuf::Arena* arena, const HelloResponse& from); + public: + + ::google::protobuf::Metadata GetMetadata() const final; + + // nested types ---------------------------------------------------- + + // accessors ------------------------------------------------------- + + enum : int { + kGreetingFieldNumber = 1, + }; + // string greeting = 1; + void clear_greeting() ; + const std::string& greeting() const; + template + void set_greeting(Arg_&& arg, Args_... args); + std::string* mutable_greeting(); + PROTOBUF_NODISCARD std::string* release_greeting(); + void set_allocated_greeting(std::string* value); + + private: + const std::string& _internal_greeting() const; + inline PROTOBUF_ALWAYS_INLINE void _internal_set_greeting( + const std::string& value); + std::string* _internal_mutable_greeting(); + + public: + // @@protoc_insertion_point(class_scope:HelloResponse) + private: + class _Internal; + + friend class ::google::protobuf::MessageLite; + friend class ::google::protobuf::Arena; + template + friend class ::google::protobuf::Arena::InternalHelper; + using InternalArenaConstructable_ = void; + using DestructorSkippable_ = void; + struct Impl_ { + + inline explicit constexpr Impl_( + ::google::protobuf::internal::ConstantInitialized) noexcept; + inline explicit Impl_(::google::protobuf::internal::InternalVisibility visibility, + ::google::protobuf::Arena* arena); + inline explicit Impl_(::google::protobuf::internal::InternalVisibility visibility, + ::google::protobuf::Arena* arena, const Impl_& from); + ::google::protobuf::internal::ArenaStringPtr greeting_; + mutable ::google::protobuf::internal::CachedSize _cached_size_; + PROTOBUF_TSAN_DECLARE_MEMBER + }; + union { Impl_ _impl_; }; + friend struct ::TableStruct_HelloRpc_2eproto; +};// ------------------------------------------------------------------- + +class HelloRequest final : + public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:HelloRequest) */ { + public: + inline HelloRequest() : HelloRequest(nullptr) {} + ~HelloRequest() override; + template + explicit PROTOBUF_CONSTEXPR HelloRequest(::google::protobuf::internal::ConstantInitialized); + + inline HelloRequest(const HelloRequest& from) + : HelloRequest(nullptr, from) {} + HelloRequest(HelloRequest&& from) noexcept + : HelloRequest() { + *this = ::std::move(from); + } + + inline HelloRequest& operator=(const HelloRequest& from) { + CopyFrom(from); + return *this; + } + inline HelloRequest& operator=(HelloRequest&& from) noexcept { + if (this == &from) return *this; + if (GetArena() == from.GetArena() + #ifdef PROTOBUF_FORCE_COPY_IN_MOVE + && GetArena() != nullptr + #endif // !PROTOBUF_FORCE_COPY_IN_MOVE + ) { + InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + + inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const + ABSL_ATTRIBUTE_LIFETIME_BOUND { + return _internal_metadata_.unknown_fields<::google::protobuf::UnknownFieldSet>(::google::protobuf::UnknownFieldSet::default_instance); + } + inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() + ABSL_ATTRIBUTE_LIFETIME_BOUND { + return _internal_metadata_.mutable_unknown_fields<::google::protobuf::UnknownFieldSet>(); + } + + static const ::google::protobuf::Descriptor* descriptor() { + return GetDescriptor(); + } + static const ::google::protobuf::Descriptor* GetDescriptor() { + return default_instance().GetMetadata().descriptor; + } + static const ::google::protobuf::Reflection* GetReflection() { + return default_instance().GetMetadata().reflection; + } + static const HelloRequest& default_instance() { + return *internal_default_instance(); + } + static inline const HelloRequest* internal_default_instance() { + return reinterpret_cast( + &_HelloRequest_default_instance_); + } + static constexpr int kIndexInFileMessages = + 0; + + friend void swap(HelloRequest& a, HelloRequest& b) { + a.Swap(&b); + } + inline void Swap(HelloRequest* other) { + if (other == this) return; + #ifdef PROTOBUF_FORCE_COPY_IN_SWAP + if (GetArena() != nullptr && + GetArena() == other->GetArena()) { + #else // PROTOBUF_FORCE_COPY_IN_SWAP + if (GetArena() == other->GetArena()) { + #endif // !PROTOBUF_FORCE_COPY_IN_SWAP + InternalSwap(other); + } else { + ::google::protobuf::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(HelloRequest* other) { + if (other == this) return; + ABSL_DCHECK(GetArena() == other->GetArena()); + InternalSwap(other); + } + + // implements Message ---------------------------------------------- + + HelloRequest* New(::google::protobuf::Arena* arena = nullptr) const final { + return CreateMaybeMessage(arena); + } + int GetCachedSize() const { return _impl_._cached_size_.Get(); } + + private: + ::google::protobuf::internal::CachedSize* AccessCachedSize() const final; + void SharedCtor(::google::protobuf::Arena* arena); + void SharedDtor(); + void InternalSwap(HelloRequest* other); + + private: + friend class ::google::protobuf::internal::AnyMetadata; + static ::absl::string_view FullMessageName() { + return "HelloRequest"; + } + protected: + explicit HelloRequest(::google::protobuf::Arena* arena); + HelloRequest(::google::protobuf::Arena* arena, const HelloRequest& from); + public: + + ::google::protobuf::Metadata GetMetadata() const final; + + // nested types ---------------------------------------------------- + + // accessors ------------------------------------------------------- + + enum : int { + kMyNameFieldNumber = 1, + }; + // string myName = 1; + void clear_myname() ; + const std::string& myname() const; + template + void set_myname(Arg_&& arg, Args_... args); + std::string* mutable_myname(); + PROTOBUF_NODISCARD std::string* release_myname(); + void set_allocated_myname(std::string* value); + + private: + const std::string& _internal_myname() const; + inline PROTOBUF_ALWAYS_INLINE void _internal_set_myname( + const std::string& value); + std::string* _internal_mutable_myname(); + + public: + // @@protoc_insertion_point(class_scope:HelloRequest) + private: + class _Internal; + + friend class ::google::protobuf::MessageLite; + friend class ::google::protobuf::Arena; + template + friend class ::google::protobuf::Arena::InternalHelper; + using InternalArenaConstructable_ = void; + using DestructorSkippable_ = void; + struct Impl_ { + + inline explicit constexpr Impl_( + ::google::protobuf::internal::ConstantInitialized) noexcept; + inline explicit Impl_(::google::protobuf::internal::InternalVisibility visibility, + ::google::protobuf::Arena* arena); + inline explicit Impl_(::google::protobuf::internal::InternalVisibility visibility, + ::google::protobuf::Arena* arena, const Impl_& from); + ::google::protobuf::internal::ArenaStringPtr myname_; + mutable ::google::protobuf::internal::CachedSize _cached_size_; + PROTOBUF_TSAN_DECLARE_MEMBER + }; + union { Impl_ _impl_; }; + friend struct ::TableStruct_HelloRpc_2eproto; +}; + +// =================================================================== + + + + +// =================================================================== + + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wstrict-aliasing" +#endif // __GNUC__ +// ------------------------------------------------------------------- + +// HelloRequest + +// string myName = 1; +inline void HelloRequest::clear_myname() { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + _impl_.myname_.ClearToEmpty(); +} +inline const std::string& HelloRequest::myname() const + ABSL_ATTRIBUTE_LIFETIME_BOUND { + // @@protoc_insertion_point(field_get:HelloRequest.myName) + return _internal_myname(); +} +template +inline PROTOBUF_ALWAYS_INLINE void HelloRequest::set_myname(Arg_&& arg, + Args_... args) { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + ; + _impl_.myname_.Set(static_cast(arg), args..., GetArena()); + // @@protoc_insertion_point(field_set:HelloRequest.myName) +} +inline std::string* HelloRequest::mutable_myname() ABSL_ATTRIBUTE_LIFETIME_BOUND { + std::string* _s = _internal_mutable_myname(); + // @@protoc_insertion_point(field_mutable:HelloRequest.myName) + return _s; +} +inline const std::string& HelloRequest::_internal_myname() const { + PROTOBUF_TSAN_READ(&_impl_._tsan_detect_race); + return _impl_.myname_.Get(); +} +inline void HelloRequest::_internal_set_myname(const std::string& value) { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + ; + _impl_.myname_.Set(value, GetArena()); +} +inline std::string* HelloRequest::_internal_mutable_myname() { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + ; + return _impl_.myname_.Mutable( GetArena()); +} +inline std::string* HelloRequest::release_myname() { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + // @@protoc_insertion_point(field_release:HelloRequest.myName) + return _impl_.myname_.Release(); +} +inline void HelloRequest::set_allocated_myname(std::string* value) { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + _impl_.myname_.SetAllocated(value, GetArena()); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (_impl_.myname_.IsDefault()) { + _impl_.myname_.Set("", GetArena()); + } + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + // @@protoc_insertion_point(field_set_allocated:HelloRequest.myName) +} + +// ------------------------------------------------------------------- + +// HelloResponse + +// string greeting = 1; +inline void HelloResponse::clear_greeting() { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + _impl_.greeting_.ClearToEmpty(); +} +inline const std::string& HelloResponse::greeting() const + ABSL_ATTRIBUTE_LIFETIME_BOUND { + // @@protoc_insertion_point(field_get:HelloResponse.greeting) + return _internal_greeting(); +} +template +inline PROTOBUF_ALWAYS_INLINE void HelloResponse::set_greeting(Arg_&& arg, + Args_... args) { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + ; + _impl_.greeting_.Set(static_cast(arg), args..., GetArena()); + // @@protoc_insertion_point(field_set:HelloResponse.greeting) +} +inline std::string* HelloResponse::mutable_greeting() ABSL_ATTRIBUTE_LIFETIME_BOUND { + std::string* _s = _internal_mutable_greeting(); + // @@protoc_insertion_point(field_mutable:HelloResponse.greeting) + return _s; +} +inline const std::string& HelloResponse::_internal_greeting() const { + PROTOBUF_TSAN_READ(&_impl_._tsan_detect_race); + return _impl_.greeting_.Get(); +} +inline void HelloResponse::_internal_set_greeting(const std::string& value) { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + ; + _impl_.greeting_.Set(value, GetArena()); +} +inline std::string* HelloResponse::_internal_mutable_greeting() { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + ; + return _impl_.greeting_.Mutable( GetArena()); +} +inline std::string* HelloResponse::release_greeting() { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + // @@protoc_insertion_point(field_release:HelloResponse.greeting) + return _impl_.greeting_.Release(); +} +inline void HelloResponse::set_allocated_greeting(std::string* value) { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + _impl_.greeting_.SetAllocated(value, GetArena()); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (_impl_.greeting_.IsDefault()) { + _impl_.greeting_.Set("", GetArena()); + } + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + // @@protoc_insertion_point(field_set_allocated:HelloResponse.greeting) +} + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif // __GNUC__ + +// @@protoc_insertion_point(namespace_scope) + + +// @@protoc_insertion_point(global_scope) + +#include "google/protobuf/port_undef.inc" + +#endif // GOOGLE_PROTOBUF_INCLUDED_HelloRpc_2eproto_2epb_2eh diff --git a/packages/streamr-proto-rpc/test/proto/HelloRpc.server.pb.h b/packages/streamr-proto-rpc/test/proto/HelloRpc.server.pb.h new file mode 100644 index 0000000..be6e45e --- /dev/null +++ b/packages/streamr-proto-rpc/test/proto/HelloRpc.server.pb.h @@ -0,0 +1,19 @@ +// Generated by the protocol buffer streamr pluging. DO NOT EDIT! +// Generated from protobuf file "HelloRpc.proto" + +#ifndef STREAMR_PROTORPC_HELLORPC_SERVER_PB_H +#define STREAMR_PROTORPC_HELLORPC_SERVER_PB_H + +#include "HelloRpc.pb.h" // NOLINT +#include + +namespace streamr::protorpc { +class HelloRpcService { +public: + virtual ~HelloRpcService() = default; + virtual HelloResponse sayHello(const HelloRequest& request, const ProtoCallContext& callContext) = 0; +}; // class HelloRpcService +}; // namespace streamr::protorpc + +#endif // STREAMR_PROTORPC_HELLORPC_SERVER_PB_H + diff --git a/packages/streamr-proto-rpc/test/proto/TestProtos.client.pb.h b/packages/streamr-proto-rpc/test/proto/TestProtos.client.pb.h new file mode 100644 index 0000000..560adb9 --- /dev/null +++ b/packages/streamr-proto-rpc/test/proto/TestProtos.client.pb.h @@ -0,0 +1,41 @@ +// generated by the protocol buffer streamr pluging. DO NOT EDIT! +// generated from protobuf file "TestProtos.proto" + +#ifndef STREAMR_PROTORPC_TESTPROTOS_CLIENT_PB_H +#define STREAMR_PROTORPC_TESTPROTOS_CLIENT_PB_H + +#include +#include "TestProtos.pb.h" // NOLINT +#include "streamr-proto-rpc/ProtoCallContext.hpp" +#include "streamr-proto-rpc/RpcCommunicator.hpp" + + +namespace streamr::protorpc { +class DhtRpcServiceClient { +private: +RpcCommunicator& communicator; +public: + DhtRpcServiceClient(RpcCommunicator& communicator) : communicator(communicator) {} + folly::coro::Task getClosestPeers(const ClosestPeersRequest& request, const ProtoCallContext& callContext) { + return communicator.request("getClosestPeers", request, callContext); + } + folly::coro::Task ping(const PingRequest& request, const ProtoCallContext& callContext) { + return communicator.request("ping", request, callContext); + } + folly::coro::Task routeMessage(const RouteMessageWrapper& request, const ProtoCallContext& callContext) { + return communicator.request("routeMessage", request, callContext); + } +}; // class DhtRpcServiceClient +class OptionalServiceClient { +private: +RpcCommunicator& communicator; +public: + OptionalServiceClient(RpcCommunicator& communicator) : communicator(communicator) {} + folly::coro::Task getOptional(const OptionalRequest& request, const ProtoCallContext& callContext) { + return communicator.request("getOptional", request, callContext); + } +}; // class OptionalServiceClient +}; // namespace streamr::protorpc + +#endif // STREAMR_PROTORPC_TESTPROTOS_CLIENT_PB_H + diff --git a/packages/streamr-proto-rpc/test/proto/TestProtos.pb.cc b/packages/streamr-proto-rpc/test/proto/TestProtos.pb.cc new file mode 100644 index 0000000..bdc8b04 --- /dev/null +++ b/packages/streamr-proto-rpc/test/proto/TestProtos.pb.cc @@ -0,0 +1,1275 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: TestProtos.proto + +#include "TestProtos.pb.h" + +#include +#include "google/protobuf/io/coded_stream.h" +#include "google/protobuf/extension_set.h" +#include "google/protobuf/wire_format_lite.h" +#include "google/protobuf/descriptor.h" +#include "google/protobuf/generated_message_reflection.h" +#include "google/protobuf/reflection_ops.h" +#include "google/protobuf/wire_format.h" +// @@protoc_insertion_point(includes) + +// Must be included last. +#include "google/protobuf/port_def.inc" +PROTOBUF_PRAGMA_INIT_SEG +namespace _pb = ::google::protobuf; +namespace _pbi = ::google::protobuf::internal; + +inline constexpr PingResponse::Impl_::Impl_( + ::_pbi::ConstantInitialized) noexcept + : requestid_( + &::google::protobuf::internal::fixed_address_empty_string, + ::_pbi::ConstantInitialized()), + _cached_size_{0} {} + +template +PROTOBUF_CONSTEXPR PingResponse::PingResponse(::_pbi::ConstantInitialized) + : _impl_(::_pbi::ConstantInitialized()) {} +struct PingResponseDefaultTypeInternal { + PROTOBUF_CONSTEXPR PingResponseDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} + ~PingResponseDefaultTypeInternal() {} + union { + PingResponse _instance; + }; +}; + +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT + PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 PingResponseDefaultTypeInternal _PingResponse_default_instance_; + +inline constexpr PingRequest::Impl_::Impl_( + ::_pbi::ConstantInitialized) noexcept + : requestid_( + &::google::protobuf::internal::fixed_address_empty_string, + ::_pbi::ConstantInitialized()), + _cached_size_{0} {} + +template +PROTOBUF_CONSTEXPR PingRequest::PingRequest(::_pbi::ConstantInitialized) + : _impl_(::_pbi::ConstantInitialized()) {} +struct PingRequestDefaultTypeInternal { + PROTOBUF_CONSTEXPR PingRequestDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} + ~PingRequestDefaultTypeInternal() {} + union { + PingRequest _instance; + }; +}; + +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT + PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 PingRequestDefaultTypeInternal _PingRequest_default_instance_; + +inline constexpr OptionalResponse::Impl_::Impl_( + ::_pbi::ConstantInitialized) noexcept + : _cached_size_{0}, + someoptionalfield_( + &::google::protobuf::internal::fixed_address_empty_string, + ::_pbi::ConstantInitialized()) {} + +template +PROTOBUF_CONSTEXPR OptionalResponse::OptionalResponse(::_pbi::ConstantInitialized) + : _impl_(::_pbi::ConstantInitialized()) {} +struct OptionalResponseDefaultTypeInternal { + PROTOBUF_CONSTEXPR OptionalResponseDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} + ~OptionalResponseDefaultTypeInternal() {} + union { + OptionalResponse _instance; + }; +}; + +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT + PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 OptionalResponseDefaultTypeInternal _OptionalResponse_default_instance_; + +inline constexpr OptionalRequest::Impl_::Impl_( + ::_pbi::ConstantInitialized) noexcept + : _cached_size_{0}, + someoptionalfield_( + &::google::protobuf::internal::fixed_address_empty_string, + ::_pbi::ConstantInitialized()) {} + +template +PROTOBUF_CONSTEXPR OptionalRequest::OptionalRequest(::_pbi::ConstantInitialized) + : _impl_(::_pbi::ConstantInitialized()) {} +struct OptionalRequestDefaultTypeInternal { + PROTOBUF_CONSTEXPR OptionalRequestDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} + ~OptionalRequestDefaultTypeInternal() {} + union { + OptionalRequest _instance; + }; +}; + +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT + PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 OptionalRequestDefaultTypeInternal _OptionalRequest_default_instance_; + +inline constexpr ConnectivityMethod::Impl_::Impl_( + ::_pbi::ConstantInitialized) noexcept + : ip_( + &::google::protobuf::internal::fixed_address_empty_string, + ::_pbi::ConstantInitialized()), + port_{0u}, + _cached_size_{0} {} + +template +PROTOBUF_CONSTEXPR ConnectivityMethod::ConnectivityMethod(::_pbi::ConstantInitialized) + : _impl_(::_pbi::ConstantInitialized()) {} +struct ConnectivityMethodDefaultTypeInternal { + PROTOBUF_CONSTEXPR ConnectivityMethodDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} + ~ConnectivityMethodDefaultTypeInternal() {} + union { + ConnectivityMethod _instance; + }; +}; + +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT + PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 ConnectivityMethodDefaultTypeInternal _ConnectivityMethod_default_instance_; + +inline constexpr PeerDescriptor::Impl_::Impl_( + ::_pbi::ConstantInitialized) noexcept + : _cached_size_{0}, + nodeid_( + &::google::protobuf::internal::fixed_address_empty_string, + ::_pbi::ConstantInitialized()), + udp_{nullptr}, + tcp_{nullptr}, + websocket_{nullptr}, + type_{static_cast< ::NodeType >(0)}, + openinternet_{false} {} + +template +PROTOBUF_CONSTEXPR PeerDescriptor::PeerDescriptor(::_pbi::ConstantInitialized) + : _impl_(::_pbi::ConstantInitialized()) {} +struct PeerDescriptorDefaultTypeInternal { + PROTOBUF_CONSTEXPR PeerDescriptorDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} + ~PeerDescriptorDefaultTypeInternal() {} + union { + PeerDescriptor _instance; + }; +}; + +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT + PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 PeerDescriptorDefaultTypeInternal _PeerDescriptor_default_instance_; + +inline constexpr RouteMessageWrapper::Impl_::Impl_( + ::_pbi::ConstantInitialized) noexcept + : _cached_size_{0}, + requestid_( + &::google::protobuf::internal::fixed_address_empty_string, + ::_pbi::ConstantInitialized()), + message_( + &::google::protobuf::internal::fixed_address_empty_string, + ::_pbi::ConstantInitialized()), + sourcepeer_{nullptr}, + destinationpeer_{nullptr}, + previouspeer_{nullptr} {} + +template +PROTOBUF_CONSTEXPR RouteMessageWrapper::RouteMessageWrapper(::_pbi::ConstantInitialized) + : _impl_(::_pbi::ConstantInitialized()) {} +struct RouteMessageWrapperDefaultTypeInternal { + PROTOBUF_CONSTEXPR RouteMessageWrapperDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} + ~RouteMessageWrapperDefaultTypeInternal() {} + union { + RouteMessageWrapper _instance; + }; +}; + +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT + PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 RouteMessageWrapperDefaultTypeInternal _RouteMessageWrapper_default_instance_; + +inline constexpr RouteMessageAck::Impl_::Impl_( + ::_pbi::ConstantInitialized) noexcept + : _cached_size_{0}, + requestid_( + &::google::protobuf::internal::fixed_address_empty_string, + ::_pbi::ConstantInitialized()), + error_( + &::google::protobuf::internal::fixed_address_empty_string, + ::_pbi::ConstantInitialized()), + sourcepeer_{nullptr}, + destinationpeer_{nullptr} {} + +template +PROTOBUF_CONSTEXPR RouteMessageAck::RouteMessageAck(::_pbi::ConstantInitialized) + : _impl_(::_pbi::ConstantInitialized()) {} +struct RouteMessageAckDefaultTypeInternal { + PROTOBUF_CONSTEXPR RouteMessageAckDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} + ~RouteMessageAckDefaultTypeInternal() {} + union { + RouteMessageAck _instance; + }; +}; + +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT + PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 RouteMessageAckDefaultTypeInternal _RouteMessageAck_default_instance_; + +inline constexpr ClosestPeersResponse::Impl_::Impl_( + ::_pbi::ConstantInitialized) noexcept + : peers_{}, + requestid_( + &::google::protobuf::internal::fixed_address_empty_string, + ::_pbi::ConstantInitialized()), + _cached_size_{0} {} + +template +PROTOBUF_CONSTEXPR ClosestPeersResponse::ClosestPeersResponse(::_pbi::ConstantInitialized) + : _impl_(::_pbi::ConstantInitialized()) {} +struct ClosestPeersResponseDefaultTypeInternal { + PROTOBUF_CONSTEXPR ClosestPeersResponseDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} + ~ClosestPeersResponseDefaultTypeInternal() {} + union { + ClosestPeersResponse _instance; + }; +}; + +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT + PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 ClosestPeersResponseDefaultTypeInternal _ClosestPeersResponse_default_instance_; + +inline constexpr ClosestPeersRequest::Impl_::Impl_( + ::_pbi::ConstantInitialized) noexcept + : _cached_size_{0}, + requestid_( + &::google::protobuf::internal::fixed_address_empty_string, + ::_pbi::ConstantInitialized()), + peerdescriptor_{nullptr} {} + +template +PROTOBUF_CONSTEXPR ClosestPeersRequest::ClosestPeersRequest(::_pbi::ConstantInitialized) + : _impl_(::_pbi::ConstantInitialized()) {} +struct ClosestPeersRequestDefaultTypeInternal { + PROTOBUF_CONSTEXPR ClosestPeersRequestDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} + ~ClosestPeersRequestDefaultTypeInternal() {} + union { + ClosestPeersRequest _instance; + }; +}; + +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT + PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 ClosestPeersRequestDefaultTypeInternal _ClosestPeersRequest_default_instance_; +static ::_pb::Metadata file_level_metadata_TestProtos_2eproto[10]; +static const ::_pb::EnumDescriptor* file_level_enum_descriptors_TestProtos_2eproto[1]; +static constexpr const ::_pb::ServiceDescriptor** + file_level_service_descriptors_TestProtos_2eproto = nullptr; +const ::uint32_t TableStruct_TestProtos_2eproto::offsets[] PROTOBUF_SECTION_VARIABLE( + protodesc_cold) = { + PROTOBUF_FIELD_OFFSET(::RouteMessageWrapper, _impl_._has_bits_), + PROTOBUF_FIELD_OFFSET(::RouteMessageWrapper, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) + PROTOBUF_FIELD_OFFSET(::RouteMessageWrapper, _impl_.sourcepeer_), + PROTOBUF_FIELD_OFFSET(::RouteMessageWrapper, _impl_.requestid_), + PROTOBUF_FIELD_OFFSET(::RouteMessageWrapper, _impl_.destinationpeer_), + PROTOBUF_FIELD_OFFSET(::RouteMessageWrapper, _impl_.previouspeer_), + PROTOBUF_FIELD_OFFSET(::RouteMessageWrapper, _impl_.message_), + 0, + ~0u, + 1, + 2, + ~0u, + PROTOBUF_FIELD_OFFSET(::RouteMessageAck, _impl_._has_bits_), + PROTOBUF_FIELD_OFFSET(::RouteMessageAck, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) + PROTOBUF_FIELD_OFFSET(::RouteMessageAck, _impl_.sourcepeer_), + PROTOBUF_FIELD_OFFSET(::RouteMessageAck, _impl_.requestid_), + PROTOBUF_FIELD_OFFSET(::RouteMessageAck, _impl_.destinationpeer_), + PROTOBUF_FIELD_OFFSET(::RouteMessageAck, _impl_.error_), + 0, + ~0u, + 1, + ~0u, + ~0u, // no _has_bits_ + PROTOBUF_FIELD_OFFSET(::PingRequest, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) + PROTOBUF_FIELD_OFFSET(::PingRequest, _impl_.requestid_), + ~0u, // no _has_bits_ + PROTOBUF_FIELD_OFFSET(::PingResponse, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) + PROTOBUF_FIELD_OFFSET(::PingResponse, _impl_.requestid_), + PROTOBUF_FIELD_OFFSET(::ClosestPeersRequest, _impl_._has_bits_), + PROTOBUF_FIELD_OFFSET(::ClosestPeersRequest, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) + PROTOBUF_FIELD_OFFSET(::ClosestPeersRequest, _impl_.peerdescriptor_), + PROTOBUF_FIELD_OFFSET(::ClosestPeersRequest, _impl_.requestid_), + 0, + ~0u, + ~0u, // no _has_bits_ + PROTOBUF_FIELD_OFFSET(::ClosestPeersResponse, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) + PROTOBUF_FIELD_OFFSET(::ClosestPeersResponse, _impl_.peers_), + PROTOBUF_FIELD_OFFSET(::ClosestPeersResponse, _impl_.requestid_), + PROTOBUF_FIELD_OFFSET(::PeerDescriptor, _impl_._has_bits_), + PROTOBUF_FIELD_OFFSET(::PeerDescriptor, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) + PROTOBUF_FIELD_OFFSET(::PeerDescriptor, _impl_.nodeid_), + PROTOBUF_FIELD_OFFSET(::PeerDescriptor, _impl_.type_), + PROTOBUF_FIELD_OFFSET(::PeerDescriptor, _impl_.udp_), + PROTOBUF_FIELD_OFFSET(::PeerDescriptor, _impl_.tcp_), + PROTOBUF_FIELD_OFFSET(::PeerDescriptor, _impl_.websocket_), + PROTOBUF_FIELD_OFFSET(::PeerDescriptor, _impl_.openinternet_), + ~0u, + ~0u, + 0, + 1, + 2, + 3, + ~0u, // no _has_bits_ + PROTOBUF_FIELD_OFFSET(::ConnectivityMethod, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) + PROTOBUF_FIELD_OFFSET(::ConnectivityMethod, _impl_.port_), + PROTOBUF_FIELD_OFFSET(::ConnectivityMethod, _impl_.ip_), + PROTOBUF_FIELD_OFFSET(::OptionalRequest, _impl_._has_bits_), + PROTOBUF_FIELD_OFFSET(::OptionalRequest, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) + PROTOBUF_FIELD_OFFSET(::OptionalRequest, _impl_.someoptionalfield_), + 0, + PROTOBUF_FIELD_OFFSET(::OptionalResponse, _impl_._has_bits_), + PROTOBUF_FIELD_OFFSET(::OptionalResponse, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) + PROTOBUF_FIELD_OFFSET(::OptionalResponse, _impl_.someoptionalfield_), + 0, +}; + +static const ::_pbi::MigrationSchema + schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { + {0, 13, -1, sizeof(::RouteMessageWrapper)}, + {18, 30, -1, sizeof(::RouteMessageAck)}, + {34, -1, -1, sizeof(::PingRequest)}, + {43, -1, -1, sizeof(::PingResponse)}, + {52, 62, -1, sizeof(::ClosestPeersRequest)}, + {64, -1, -1, sizeof(::ClosestPeersResponse)}, + {74, 88, -1, sizeof(::PeerDescriptor)}, + {94, -1, -1, sizeof(::ConnectivityMethod)}, + {104, 113, -1, sizeof(::OptionalRequest)}, + {114, 123, -1, sizeof(::OptionalResponse)}, +}; + +static const ::_pb::Message* const file_default_instances[] = { + &::_RouteMessageWrapper_default_instance_._instance, + &::_RouteMessageAck_default_instance_._instance, + &::_PingRequest_default_instance_._instance, + &::_PingResponse_default_instance_._instance, + &::_ClosestPeersRequest_default_instance_._instance, + &::_ClosestPeersResponse_default_instance_._instance, + &::_PeerDescriptor_default_instance_._instance, + &::_ConnectivityMethod_default_instance_._instance, + &::_OptionalRequest_default_instance_._instance, + &::_OptionalResponse_default_instance_._instance, +}; +const char descriptor_table_protodef_TestProtos_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { + "\n\020TestProtos.proto\"\257\001\n\023RouteMessageWrapp" + "er\022#\n\nsourcePeer\030\001 \001(\0132\017.PeerDescriptor\022" + "\021\n\trequestId\030\002 \001(\t\022(\n\017destinationPeer\030\003 " + "\001(\0132\017.PeerDescriptor\022%\n\014previousPeer\030\004 \001" + "(\0132\017.PeerDescriptor\022\017\n\007message\030\005 \001(\014\"\202\001\n" + "\017RouteMessageAck\022#\n\nsourcePeer\030\001 \001(\0132\017.P" + "eerDescriptor\022\021\n\trequestId\030\002 \001(\t\022(\n\017dest" + "inationPeer\030\003 \001(\0132\017.PeerDescriptor\022\r\n\005er" + "ror\030\004 \001(\t\" \n\013PingRequest\022\021\n\trequestId\030\001 " + "\001(\t\"!\n\014PingResponse\022\021\n\trequestId\030\001 \001(\t\"Q" + "\n\023ClosestPeersRequest\022\'\n\016peerDescriptor\030" + "\001 \001(\0132\017.PeerDescriptor\022\021\n\trequestId\030\002 \001(" + "\t\"I\n\024ClosestPeersResponse\022\036\n\005peers\030\001 \003(\013" + "2\017.PeerDescriptor\022\021\n\trequestId\030\002 \001(\t\"\321\001\n" + "\016PeerDescriptor\022\016\n\006nodeId\030\001 \001(\014\022\027\n\004type\030" + "\002 \001(\0162\t.NodeType\022 \n\003udp\030\003 \001(\0132\023.Connecti" + "vityMethod\022 \n\003tcp\030\004 \001(\0132\023.ConnectivityMe" + "thod\022&\n\twebsocket\030\005 \001(\0132\023.ConnectivityMe" + "thod\022\031\n\014openInternet\030\006 \001(\010H\000\210\001\001B\017\n\r_open" + "Internet\".\n\022ConnectivityMethod\022\014\n\004port\030\002" + " \001(\r\022\n\n\002ip\030\003 \001(\t\"G\n\017OptionalRequest\022\036\n\021s" + "omeOptionalField\030\001 \001(\tH\000\210\001\001B\024\n\022_someOpti" + "onalField\"H\n\020OptionalResponse\022\036\n\021someOpt" + "ionalField\030\001 \001(\tH\000\210\001\001B\024\n\022_someOptionalFi" + "eld*#\n\010NodeType\022\n\n\006NODEJS\020\000\022\013\n\007BROWSER\020\001" + "2\254\001\n\rDhtRpcService\022>\n\017getClosestPeers\022\024." + "ClosestPeersRequest\032\025.ClosestPeersRespon" + "se\022#\n\004ping\022\014.PingRequest\032\r.PingResponse\022" + "6\n\014routeMessage\022\024.RouteMessageWrapper\032\020." + "RouteMessageAck2E\n\017OptionalService\0222\n\013ge" + "tOptional\022\020.OptionalRequest\032\021.OptionalRe" + "sponseB\002H\002b\006proto3" +}; +static ::absl::once_flag descriptor_table_TestProtos_2eproto_once; +const ::_pbi::DescriptorTable descriptor_table_TestProtos_2eproto = { + false, + false, + 1258, + descriptor_table_protodef_TestProtos_2eproto, + "TestProtos.proto", + &descriptor_table_TestProtos_2eproto_once, + nullptr, + 0, + 10, + schemas, + file_default_instances, + TableStruct_TestProtos_2eproto::offsets, + file_level_metadata_TestProtos_2eproto, + file_level_enum_descriptors_TestProtos_2eproto, + file_level_service_descriptors_TestProtos_2eproto, +}; + +// This function exists to be marked as weak. +// It can significantly speed up compilation by breaking up LLVM's SCC +// in the .pb.cc translation units. Large translation units see a +// reduction of more than 35% of walltime for optimized builds. Without +// the weak attribute all the messages in the file, including all the +// vtables and everything they use become part of the same SCC through +// a cycle like: +// GetMetadata -> descriptor table -> default instances -> +// vtables -> GetMetadata +// By adding a weak function here we break the connection from the +// individual vtables back into the descriptor table. +PROTOBUF_ATTRIBUTE_WEAK const ::_pbi::DescriptorTable* descriptor_table_TestProtos_2eproto_getter() { + return &descriptor_table_TestProtos_2eproto; +} +// Force running AddDescriptors() at dynamic initialization time. +PROTOBUF_ATTRIBUTE_INIT_PRIORITY2 +static ::_pbi::AddDescriptorsRunner dynamic_init_dummy_TestProtos_2eproto(&descriptor_table_TestProtos_2eproto); +const ::google::protobuf::EnumDescriptor* NodeType_descriptor() { + ::google::protobuf::internal::AssignDescriptors(&descriptor_table_TestProtos_2eproto); + return file_level_enum_descriptors_TestProtos_2eproto[0]; +} +PROTOBUF_CONSTINIT const uint32_t NodeType_internal_data_[] = { + 131072u, 0u, }; +bool NodeType_IsValid(int value) { + return 0 <= value && value <= 1; +} +// =================================================================== + +class RouteMessageWrapper::_Internal { + public: + using HasBits = decltype(std::declval()._impl_._has_bits_); + static constexpr ::int32_t kHasBitsOffset = + 8 * PROTOBUF_FIELD_OFFSET(RouteMessageWrapper, _impl_._has_bits_); + static const ::PeerDescriptor& sourcepeer(const RouteMessageWrapper* msg); + static void set_has_sourcepeer(HasBits* has_bits) { + (*has_bits)[0] |= 1u; + } + static const ::PeerDescriptor& destinationpeer(const RouteMessageWrapper* msg); + static void set_has_destinationpeer(HasBits* has_bits) { + (*has_bits)[0] |= 2u; + } + static const ::PeerDescriptor& previouspeer(const RouteMessageWrapper* msg); + static void set_has_previouspeer(HasBits* has_bits) { + (*has_bits)[0] |= 4u; + } +}; + +const ::PeerDescriptor& RouteMessageWrapper::_Internal::sourcepeer(const RouteMessageWrapper* msg) { + return *msg->_impl_.sourcepeer_; +} +const ::PeerDescriptor& RouteMessageWrapper::_Internal::destinationpeer(const RouteMessageWrapper* msg) { + return *msg->_impl_.destinationpeer_; +} +const ::PeerDescriptor& RouteMessageWrapper::_Internal::previouspeer(const RouteMessageWrapper* msg) { + return *msg->_impl_.previouspeer_; +} +RouteMessageWrapper::RouteMessageWrapper(::google::protobuf::Arena* arena) + : ::google::protobuf::Message(arena) { + SharedCtor(arena); + // @@protoc_insertion_point(arena_constructor:RouteMessageWrapper) +} +inline PROTOBUF_NDEBUG_INLINE RouteMessageWrapper::Impl_::Impl_( + ::google::protobuf::internal::InternalVisibility visibility, ::google::protobuf::Arena* arena, + const Impl_& from) + : _has_bits_{from._has_bits_}, + _cached_size_{0}, + requestid_(arena, from.requestid_), + message_(arena, from.message_) {} + +RouteMessageWrapper::RouteMessageWrapper( + ::google::protobuf::Arena* arena, + const RouteMessageWrapper& from) + : ::google::protobuf::Message(arena) { + RouteMessageWrapper* const _this = this; + (void)_this; + _internal_metadata_.MergeFrom<::google::protobuf::UnknownFieldSet>( + from._internal_metadata_); + new (&_impl_) Impl_(internal_visibility(), arena, from._impl_); + ::uint32_t cached_has_bits = _impl_._has_bits_[0]; + _impl_.sourcepeer_ = (cached_has_bits & 0x00000001u) + ? CreateMaybeMessage<::PeerDescriptor>(arena, *from._impl_.sourcepeer_) + : nullptr; + _impl_.destinationpeer_ = (cached_has_bits & 0x00000002u) + ? CreateMaybeMessage<::PeerDescriptor>(arena, *from._impl_.destinationpeer_) + : nullptr; + _impl_.previouspeer_ = (cached_has_bits & 0x00000004u) + ? CreateMaybeMessage<::PeerDescriptor>(arena, *from._impl_.previouspeer_) + : nullptr; + + // @@protoc_insertion_point(copy_constructor:RouteMessageWrapper) +} +inline PROTOBUF_NDEBUG_INLINE RouteMessageWrapper::Impl_::Impl_( + ::google::protobuf::internal::InternalVisibility visibility, + ::google::protobuf::Arena* arena) + : _cached_size_{0}, + requestid_(arena), + message_(arena) {} + +inline void RouteMessageWrapper::SharedCtor(::_pb::Arena* arena) { + new (&_impl_) Impl_(internal_visibility(), arena); + ::memset(reinterpret_cast(&_impl_) + + offsetof(Impl_, sourcepeer_), + 0, + offsetof(Impl_, previouspeer_) - + offsetof(Impl_, sourcepeer_) + + sizeof(Impl_::previouspeer_)); +} +RouteMessageWrapper::~RouteMessageWrapper() { + // @@protoc_insertion_point(destructor:RouteMessageWrapper) + _internal_metadata_.Delete<::google::protobuf::UnknownFieldSet>(); + SharedDtor(); +} +inline void RouteMessageWrapper::SharedDtor() { + ABSL_DCHECK(GetArena() == nullptr); + _impl_.requestid_.Destroy(); + _impl_.message_.Destroy(); + delete _impl_.sourcepeer_; + delete _impl_.destinationpeer_; + delete _impl_.previouspeer_; + _impl_.~Impl_(); +} + +::_pbi::CachedSize* RouteMessageWrapper::AccessCachedSize() const { + return &_impl_._cached_size_; +} +void RouteMessageWrapper::InternalSwap(RouteMessageWrapper* PROTOBUF_RESTRICT other) { + using std::swap; + GetReflection()->Swap(this, other);} + +::google::protobuf::Metadata RouteMessageWrapper::GetMetadata() const { + return ::_pbi::AssignDescriptors( + &descriptor_table_TestProtos_2eproto_getter, &descriptor_table_TestProtos_2eproto_once, + file_level_metadata_TestProtos_2eproto[0]); +} +// =================================================================== + +class RouteMessageAck::_Internal { + public: + using HasBits = decltype(std::declval()._impl_._has_bits_); + static constexpr ::int32_t kHasBitsOffset = + 8 * PROTOBUF_FIELD_OFFSET(RouteMessageAck, _impl_._has_bits_); + static const ::PeerDescriptor& sourcepeer(const RouteMessageAck* msg); + static void set_has_sourcepeer(HasBits* has_bits) { + (*has_bits)[0] |= 1u; + } + static const ::PeerDescriptor& destinationpeer(const RouteMessageAck* msg); + static void set_has_destinationpeer(HasBits* has_bits) { + (*has_bits)[0] |= 2u; + } +}; + +const ::PeerDescriptor& RouteMessageAck::_Internal::sourcepeer(const RouteMessageAck* msg) { + return *msg->_impl_.sourcepeer_; +} +const ::PeerDescriptor& RouteMessageAck::_Internal::destinationpeer(const RouteMessageAck* msg) { + return *msg->_impl_.destinationpeer_; +} +RouteMessageAck::RouteMessageAck(::google::protobuf::Arena* arena) + : ::google::protobuf::Message(arena) { + SharedCtor(arena); + // @@protoc_insertion_point(arena_constructor:RouteMessageAck) +} +inline PROTOBUF_NDEBUG_INLINE RouteMessageAck::Impl_::Impl_( + ::google::protobuf::internal::InternalVisibility visibility, ::google::protobuf::Arena* arena, + const Impl_& from) + : _has_bits_{from._has_bits_}, + _cached_size_{0}, + requestid_(arena, from.requestid_), + error_(arena, from.error_) {} + +RouteMessageAck::RouteMessageAck( + ::google::protobuf::Arena* arena, + const RouteMessageAck& from) + : ::google::protobuf::Message(arena) { + RouteMessageAck* const _this = this; + (void)_this; + _internal_metadata_.MergeFrom<::google::protobuf::UnknownFieldSet>( + from._internal_metadata_); + new (&_impl_) Impl_(internal_visibility(), arena, from._impl_); + ::uint32_t cached_has_bits = _impl_._has_bits_[0]; + _impl_.sourcepeer_ = (cached_has_bits & 0x00000001u) + ? CreateMaybeMessage<::PeerDescriptor>(arena, *from._impl_.sourcepeer_) + : nullptr; + _impl_.destinationpeer_ = (cached_has_bits & 0x00000002u) + ? CreateMaybeMessage<::PeerDescriptor>(arena, *from._impl_.destinationpeer_) + : nullptr; + + // @@protoc_insertion_point(copy_constructor:RouteMessageAck) +} +inline PROTOBUF_NDEBUG_INLINE RouteMessageAck::Impl_::Impl_( + ::google::protobuf::internal::InternalVisibility visibility, + ::google::protobuf::Arena* arena) + : _cached_size_{0}, + requestid_(arena), + error_(arena) {} + +inline void RouteMessageAck::SharedCtor(::_pb::Arena* arena) { + new (&_impl_) Impl_(internal_visibility(), arena); + ::memset(reinterpret_cast(&_impl_) + + offsetof(Impl_, sourcepeer_), + 0, + offsetof(Impl_, destinationpeer_) - + offsetof(Impl_, sourcepeer_) + + sizeof(Impl_::destinationpeer_)); +} +RouteMessageAck::~RouteMessageAck() { + // @@protoc_insertion_point(destructor:RouteMessageAck) + _internal_metadata_.Delete<::google::protobuf::UnknownFieldSet>(); + SharedDtor(); +} +inline void RouteMessageAck::SharedDtor() { + ABSL_DCHECK(GetArena() == nullptr); + _impl_.requestid_.Destroy(); + _impl_.error_.Destroy(); + delete _impl_.sourcepeer_; + delete _impl_.destinationpeer_; + _impl_.~Impl_(); +} + +::_pbi::CachedSize* RouteMessageAck::AccessCachedSize() const { + return &_impl_._cached_size_; +} +void RouteMessageAck::InternalSwap(RouteMessageAck* PROTOBUF_RESTRICT other) { + using std::swap; + GetReflection()->Swap(this, other);} + +::google::protobuf::Metadata RouteMessageAck::GetMetadata() const { + return ::_pbi::AssignDescriptors( + &descriptor_table_TestProtos_2eproto_getter, &descriptor_table_TestProtos_2eproto_once, + file_level_metadata_TestProtos_2eproto[1]); +} +// =================================================================== + +class PingRequest::_Internal { + public: +}; + +PingRequest::PingRequest(::google::protobuf::Arena* arena) + : ::google::protobuf::Message(arena) { + SharedCtor(arena); + // @@protoc_insertion_point(arena_constructor:PingRequest) +} +inline PROTOBUF_NDEBUG_INLINE PingRequest::Impl_::Impl_( + ::google::protobuf::internal::InternalVisibility visibility, ::google::protobuf::Arena* arena, + const Impl_& from) + : requestid_(arena, from.requestid_), + _cached_size_{0} {} + +PingRequest::PingRequest( + ::google::protobuf::Arena* arena, + const PingRequest& from) + : ::google::protobuf::Message(arena) { + PingRequest* const _this = this; + (void)_this; + _internal_metadata_.MergeFrom<::google::protobuf::UnknownFieldSet>( + from._internal_metadata_); + new (&_impl_) Impl_(internal_visibility(), arena, from._impl_); + + // @@protoc_insertion_point(copy_constructor:PingRequest) +} +inline PROTOBUF_NDEBUG_INLINE PingRequest::Impl_::Impl_( + ::google::protobuf::internal::InternalVisibility visibility, + ::google::protobuf::Arena* arena) + : requestid_(arena), + _cached_size_{0} {} + +inline void PingRequest::SharedCtor(::_pb::Arena* arena) { + new (&_impl_) Impl_(internal_visibility(), arena); +} +PingRequest::~PingRequest() { + // @@protoc_insertion_point(destructor:PingRequest) + _internal_metadata_.Delete<::google::protobuf::UnknownFieldSet>(); + SharedDtor(); +} +inline void PingRequest::SharedDtor() { + ABSL_DCHECK(GetArena() == nullptr); + _impl_.requestid_.Destroy(); + _impl_.~Impl_(); +} + +::_pbi::CachedSize* PingRequest::AccessCachedSize() const { + return &_impl_._cached_size_; +} +void PingRequest::InternalSwap(PingRequest* PROTOBUF_RESTRICT other) { + using std::swap; + GetReflection()->Swap(this, other);} + +::google::protobuf::Metadata PingRequest::GetMetadata() const { + return ::_pbi::AssignDescriptors( + &descriptor_table_TestProtos_2eproto_getter, &descriptor_table_TestProtos_2eproto_once, + file_level_metadata_TestProtos_2eproto[2]); +} +// =================================================================== + +class PingResponse::_Internal { + public: +}; + +PingResponse::PingResponse(::google::protobuf::Arena* arena) + : ::google::protobuf::Message(arena) { + SharedCtor(arena); + // @@protoc_insertion_point(arena_constructor:PingResponse) +} +inline PROTOBUF_NDEBUG_INLINE PingResponse::Impl_::Impl_( + ::google::protobuf::internal::InternalVisibility visibility, ::google::protobuf::Arena* arena, + const Impl_& from) + : requestid_(arena, from.requestid_), + _cached_size_{0} {} + +PingResponse::PingResponse( + ::google::protobuf::Arena* arena, + const PingResponse& from) + : ::google::protobuf::Message(arena) { + PingResponse* const _this = this; + (void)_this; + _internal_metadata_.MergeFrom<::google::protobuf::UnknownFieldSet>( + from._internal_metadata_); + new (&_impl_) Impl_(internal_visibility(), arena, from._impl_); + + // @@protoc_insertion_point(copy_constructor:PingResponse) +} +inline PROTOBUF_NDEBUG_INLINE PingResponse::Impl_::Impl_( + ::google::protobuf::internal::InternalVisibility visibility, + ::google::protobuf::Arena* arena) + : requestid_(arena), + _cached_size_{0} {} + +inline void PingResponse::SharedCtor(::_pb::Arena* arena) { + new (&_impl_) Impl_(internal_visibility(), arena); +} +PingResponse::~PingResponse() { + // @@protoc_insertion_point(destructor:PingResponse) + _internal_metadata_.Delete<::google::protobuf::UnknownFieldSet>(); + SharedDtor(); +} +inline void PingResponse::SharedDtor() { + ABSL_DCHECK(GetArena() == nullptr); + _impl_.requestid_.Destroy(); + _impl_.~Impl_(); +} + +::_pbi::CachedSize* PingResponse::AccessCachedSize() const { + return &_impl_._cached_size_; +} +void PingResponse::InternalSwap(PingResponse* PROTOBUF_RESTRICT other) { + using std::swap; + GetReflection()->Swap(this, other);} + +::google::protobuf::Metadata PingResponse::GetMetadata() const { + return ::_pbi::AssignDescriptors( + &descriptor_table_TestProtos_2eproto_getter, &descriptor_table_TestProtos_2eproto_once, + file_level_metadata_TestProtos_2eproto[3]); +} +// =================================================================== + +class ClosestPeersRequest::_Internal { + public: + using HasBits = decltype(std::declval()._impl_._has_bits_); + static constexpr ::int32_t kHasBitsOffset = + 8 * PROTOBUF_FIELD_OFFSET(ClosestPeersRequest, _impl_._has_bits_); + static const ::PeerDescriptor& peerdescriptor(const ClosestPeersRequest* msg); + static void set_has_peerdescriptor(HasBits* has_bits) { + (*has_bits)[0] |= 1u; + } +}; + +const ::PeerDescriptor& ClosestPeersRequest::_Internal::peerdescriptor(const ClosestPeersRequest* msg) { + return *msg->_impl_.peerdescriptor_; +} +ClosestPeersRequest::ClosestPeersRequest(::google::protobuf::Arena* arena) + : ::google::protobuf::Message(arena) { + SharedCtor(arena); + // @@protoc_insertion_point(arena_constructor:ClosestPeersRequest) +} +inline PROTOBUF_NDEBUG_INLINE ClosestPeersRequest::Impl_::Impl_( + ::google::protobuf::internal::InternalVisibility visibility, ::google::protobuf::Arena* arena, + const Impl_& from) + : _has_bits_{from._has_bits_}, + _cached_size_{0}, + requestid_(arena, from.requestid_) {} + +ClosestPeersRequest::ClosestPeersRequest( + ::google::protobuf::Arena* arena, + const ClosestPeersRequest& from) + : ::google::protobuf::Message(arena) { + ClosestPeersRequest* const _this = this; + (void)_this; + _internal_metadata_.MergeFrom<::google::protobuf::UnknownFieldSet>( + from._internal_metadata_); + new (&_impl_) Impl_(internal_visibility(), arena, from._impl_); + ::uint32_t cached_has_bits = _impl_._has_bits_[0]; + _impl_.peerdescriptor_ = (cached_has_bits & 0x00000001u) + ? CreateMaybeMessage<::PeerDescriptor>(arena, *from._impl_.peerdescriptor_) + : nullptr; + + // @@protoc_insertion_point(copy_constructor:ClosestPeersRequest) +} +inline PROTOBUF_NDEBUG_INLINE ClosestPeersRequest::Impl_::Impl_( + ::google::protobuf::internal::InternalVisibility visibility, + ::google::protobuf::Arena* arena) + : _cached_size_{0}, + requestid_(arena) {} + +inline void ClosestPeersRequest::SharedCtor(::_pb::Arena* arena) { + new (&_impl_) Impl_(internal_visibility(), arena); + _impl_.peerdescriptor_ = {}; +} +ClosestPeersRequest::~ClosestPeersRequest() { + // @@protoc_insertion_point(destructor:ClosestPeersRequest) + _internal_metadata_.Delete<::google::protobuf::UnknownFieldSet>(); + SharedDtor(); +} +inline void ClosestPeersRequest::SharedDtor() { + ABSL_DCHECK(GetArena() == nullptr); + _impl_.requestid_.Destroy(); + delete _impl_.peerdescriptor_; + _impl_.~Impl_(); +} + +::_pbi::CachedSize* ClosestPeersRequest::AccessCachedSize() const { + return &_impl_._cached_size_; +} +void ClosestPeersRequest::InternalSwap(ClosestPeersRequest* PROTOBUF_RESTRICT other) { + using std::swap; + GetReflection()->Swap(this, other);} + +::google::protobuf::Metadata ClosestPeersRequest::GetMetadata() const { + return ::_pbi::AssignDescriptors( + &descriptor_table_TestProtos_2eproto_getter, &descriptor_table_TestProtos_2eproto_once, + file_level_metadata_TestProtos_2eproto[4]); +} +// =================================================================== + +class ClosestPeersResponse::_Internal { + public: +}; + +ClosestPeersResponse::ClosestPeersResponse(::google::protobuf::Arena* arena) + : ::google::protobuf::Message(arena) { + SharedCtor(arena); + // @@protoc_insertion_point(arena_constructor:ClosestPeersResponse) +} +inline PROTOBUF_NDEBUG_INLINE ClosestPeersResponse::Impl_::Impl_( + ::google::protobuf::internal::InternalVisibility visibility, ::google::protobuf::Arena* arena, + const Impl_& from) + : peers_{visibility, arena, from.peers_}, + requestid_(arena, from.requestid_), + _cached_size_{0} {} + +ClosestPeersResponse::ClosestPeersResponse( + ::google::protobuf::Arena* arena, + const ClosestPeersResponse& from) + : ::google::protobuf::Message(arena) { + ClosestPeersResponse* const _this = this; + (void)_this; + _internal_metadata_.MergeFrom<::google::protobuf::UnknownFieldSet>( + from._internal_metadata_); + new (&_impl_) Impl_(internal_visibility(), arena, from._impl_); + + // @@protoc_insertion_point(copy_constructor:ClosestPeersResponse) +} +inline PROTOBUF_NDEBUG_INLINE ClosestPeersResponse::Impl_::Impl_( + ::google::protobuf::internal::InternalVisibility visibility, + ::google::protobuf::Arena* arena) + : peers_{visibility, arena}, + requestid_(arena), + _cached_size_{0} {} + +inline void ClosestPeersResponse::SharedCtor(::_pb::Arena* arena) { + new (&_impl_) Impl_(internal_visibility(), arena); +} +ClosestPeersResponse::~ClosestPeersResponse() { + // @@protoc_insertion_point(destructor:ClosestPeersResponse) + _internal_metadata_.Delete<::google::protobuf::UnknownFieldSet>(); + SharedDtor(); +} +inline void ClosestPeersResponse::SharedDtor() { + ABSL_DCHECK(GetArena() == nullptr); + _impl_.requestid_.Destroy(); + _impl_.~Impl_(); +} + +::_pbi::CachedSize* ClosestPeersResponse::AccessCachedSize() const { + return &_impl_._cached_size_; +} +void ClosestPeersResponse::InternalSwap(ClosestPeersResponse* PROTOBUF_RESTRICT other) { + using std::swap; + GetReflection()->Swap(this, other);} + +::google::protobuf::Metadata ClosestPeersResponse::GetMetadata() const { + return ::_pbi::AssignDescriptors( + &descriptor_table_TestProtos_2eproto_getter, &descriptor_table_TestProtos_2eproto_once, + file_level_metadata_TestProtos_2eproto[5]); +} +// =================================================================== + +class PeerDescriptor::_Internal { + public: + using HasBits = decltype(std::declval()._impl_._has_bits_); + static constexpr ::int32_t kHasBitsOffset = + 8 * PROTOBUF_FIELD_OFFSET(PeerDescriptor, _impl_._has_bits_); + static const ::ConnectivityMethod& udp(const PeerDescriptor* msg); + static void set_has_udp(HasBits* has_bits) { + (*has_bits)[0] |= 1u; + } + static const ::ConnectivityMethod& tcp(const PeerDescriptor* msg); + static void set_has_tcp(HasBits* has_bits) { + (*has_bits)[0] |= 2u; + } + static const ::ConnectivityMethod& websocket(const PeerDescriptor* msg); + static void set_has_websocket(HasBits* has_bits) { + (*has_bits)[0] |= 4u; + } + static void set_has_openinternet(HasBits* has_bits) { + (*has_bits)[0] |= 8u; + } +}; + +const ::ConnectivityMethod& PeerDescriptor::_Internal::udp(const PeerDescriptor* msg) { + return *msg->_impl_.udp_; +} +const ::ConnectivityMethod& PeerDescriptor::_Internal::tcp(const PeerDescriptor* msg) { + return *msg->_impl_.tcp_; +} +const ::ConnectivityMethod& PeerDescriptor::_Internal::websocket(const PeerDescriptor* msg) { + return *msg->_impl_.websocket_; +} +PeerDescriptor::PeerDescriptor(::google::protobuf::Arena* arena) + : ::google::protobuf::Message(arena) { + SharedCtor(arena); + // @@protoc_insertion_point(arena_constructor:PeerDescriptor) +} +inline PROTOBUF_NDEBUG_INLINE PeerDescriptor::Impl_::Impl_( + ::google::protobuf::internal::InternalVisibility visibility, ::google::protobuf::Arena* arena, + const Impl_& from) + : _has_bits_{from._has_bits_}, + _cached_size_{0}, + nodeid_(arena, from.nodeid_) {} + +PeerDescriptor::PeerDescriptor( + ::google::protobuf::Arena* arena, + const PeerDescriptor& from) + : ::google::protobuf::Message(arena) { + PeerDescriptor* const _this = this; + (void)_this; + _internal_metadata_.MergeFrom<::google::protobuf::UnknownFieldSet>( + from._internal_metadata_); + new (&_impl_) Impl_(internal_visibility(), arena, from._impl_); + ::uint32_t cached_has_bits = _impl_._has_bits_[0]; + _impl_.udp_ = (cached_has_bits & 0x00000001u) + ? CreateMaybeMessage<::ConnectivityMethod>(arena, *from._impl_.udp_) + : nullptr; + _impl_.tcp_ = (cached_has_bits & 0x00000002u) + ? CreateMaybeMessage<::ConnectivityMethod>(arena, *from._impl_.tcp_) + : nullptr; + _impl_.websocket_ = (cached_has_bits & 0x00000004u) + ? CreateMaybeMessage<::ConnectivityMethod>(arena, *from._impl_.websocket_) + : nullptr; + ::memcpy(reinterpret_cast(&_impl_) + + offsetof(Impl_, type_), + reinterpret_cast(&from._impl_) + + offsetof(Impl_, type_), + offsetof(Impl_, openinternet_) - + offsetof(Impl_, type_) + + sizeof(Impl_::openinternet_)); + + // @@protoc_insertion_point(copy_constructor:PeerDescriptor) +} +inline PROTOBUF_NDEBUG_INLINE PeerDescriptor::Impl_::Impl_( + ::google::protobuf::internal::InternalVisibility visibility, + ::google::protobuf::Arena* arena) + : _cached_size_{0}, + nodeid_(arena) {} + +inline void PeerDescriptor::SharedCtor(::_pb::Arena* arena) { + new (&_impl_) Impl_(internal_visibility(), arena); + ::memset(reinterpret_cast(&_impl_) + + offsetof(Impl_, udp_), + 0, + offsetof(Impl_, openinternet_) - + offsetof(Impl_, udp_) + + sizeof(Impl_::openinternet_)); +} +PeerDescriptor::~PeerDescriptor() { + // @@protoc_insertion_point(destructor:PeerDescriptor) + _internal_metadata_.Delete<::google::protobuf::UnknownFieldSet>(); + SharedDtor(); +} +inline void PeerDescriptor::SharedDtor() { + ABSL_DCHECK(GetArena() == nullptr); + _impl_.nodeid_.Destroy(); + delete _impl_.udp_; + delete _impl_.tcp_; + delete _impl_.websocket_; + _impl_.~Impl_(); +} + +::_pbi::CachedSize* PeerDescriptor::AccessCachedSize() const { + return &_impl_._cached_size_; +} +void PeerDescriptor::InternalSwap(PeerDescriptor* PROTOBUF_RESTRICT other) { + using std::swap; + GetReflection()->Swap(this, other);} + +::google::protobuf::Metadata PeerDescriptor::GetMetadata() const { + return ::_pbi::AssignDescriptors( + &descriptor_table_TestProtos_2eproto_getter, &descriptor_table_TestProtos_2eproto_once, + file_level_metadata_TestProtos_2eproto[6]); +} +// =================================================================== + +class ConnectivityMethod::_Internal { + public: +}; + +ConnectivityMethod::ConnectivityMethod(::google::protobuf::Arena* arena) + : ::google::protobuf::Message(arena) { + SharedCtor(arena); + // @@protoc_insertion_point(arena_constructor:ConnectivityMethod) +} +inline PROTOBUF_NDEBUG_INLINE ConnectivityMethod::Impl_::Impl_( + ::google::protobuf::internal::InternalVisibility visibility, ::google::protobuf::Arena* arena, + const Impl_& from) + : ip_(arena, from.ip_), + _cached_size_{0} {} + +ConnectivityMethod::ConnectivityMethod( + ::google::protobuf::Arena* arena, + const ConnectivityMethod& from) + : ::google::protobuf::Message(arena) { + ConnectivityMethod* const _this = this; + (void)_this; + _internal_metadata_.MergeFrom<::google::protobuf::UnknownFieldSet>( + from._internal_metadata_); + new (&_impl_) Impl_(internal_visibility(), arena, from._impl_); + _impl_.port_ = from._impl_.port_; + + // @@protoc_insertion_point(copy_constructor:ConnectivityMethod) +} +inline PROTOBUF_NDEBUG_INLINE ConnectivityMethod::Impl_::Impl_( + ::google::protobuf::internal::InternalVisibility visibility, + ::google::protobuf::Arena* arena) + : ip_(arena), + _cached_size_{0} {} + +inline void ConnectivityMethod::SharedCtor(::_pb::Arena* arena) { + new (&_impl_) Impl_(internal_visibility(), arena); + _impl_.port_ = {}; +} +ConnectivityMethod::~ConnectivityMethod() { + // @@protoc_insertion_point(destructor:ConnectivityMethod) + _internal_metadata_.Delete<::google::protobuf::UnknownFieldSet>(); + SharedDtor(); +} +inline void ConnectivityMethod::SharedDtor() { + ABSL_DCHECK(GetArena() == nullptr); + _impl_.ip_.Destroy(); + _impl_.~Impl_(); +} + +::_pbi::CachedSize* ConnectivityMethod::AccessCachedSize() const { + return &_impl_._cached_size_; +} +void ConnectivityMethod::InternalSwap(ConnectivityMethod* PROTOBUF_RESTRICT other) { + using std::swap; + GetReflection()->Swap(this, other);} + +::google::protobuf::Metadata ConnectivityMethod::GetMetadata() const { + return ::_pbi::AssignDescriptors( + &descriptor_table_TestProtos_2eproto_getter, &descriptor_table_TestProtos_2eproto_once, + file_level_metadata_TestProtos_2eproto[7]); +} +// =================================================================== + +class OptionalRequest::_Internal { + public: + using HasBits = decltype(std::declval()._impl_._has_bits_); + static constexpr ::int32_t kHasBitsOffset = + 8 * PROTOBUF_FIELD_OFFSET(OptionalRequest, _impl_._has_bits_); + static void set_has_someoptionalfield(HasBits* has_bits) { + (*has_bits)[0] |= 1u; + } +}; + +OptionalRequest::OptionalRequest(::google::protobuf::Arena* arena) + : ::google::protobuf::Message(arena) { + SharedCtor(arena); + // @@protoc_insertion_point(arena_constructor:OptionalRequest) +} +inline PROTOBUF_NDEBUG_INLINE OptionalRequest::Impl_::Impl_( + ::google::protobuf::internal::InternalVisibility visibility, ::google::protobuf::Arena* arena, + const Impl_& from) + : _has_bits_{from._has_bits_}, + _cached_size_{0}, + someoptionalfield_(arena, from.someoptionalfield_) {} + +OptionalRequest::OptionalRequest( + ::google::protobuf::Arena* arena, + const OptionalRequest& from) + : ::google::protobuf::Message(arena) { + OptionalRequest* const _this = this; + (void)_this; + _internal_metadata_.MergeFrom<::google::protobuf::UnknownFieldSet>( + from._internal_metadata_); + new (&_impl_) Impl_(internal_visibility(), arena, from._impl_); + + // @@protoc_insertion_point(copy_constructor:OptionalRequest) +} +inline PROTOBUF_NDEBUG_INLINE OptionalRequest::Impl_::Impl_( + ::google::protobuf::internal::InternalVisibility visibility, + ::google::protobuf::Arena* arena) + : _cached_size_{0}, + someoptionalfield_(arena) {} + +inline void OptionalRequest::SharedCtor(::_pb::Arena* arena) { + new (&_impl_) Impl_(internal_visibility(), arena); +} +OptionalRequest::~OptionalRequest() { + // @@protoc_insertion_point(destructor:OptionalRequest) + _internal_metadata_.Delete<::google::protobuf::UnknownFieldSet>(); + SharedDtor(); +} +inline void OptionalRequest::SharedDtor() { + ABSL_DCHECK(GetArena() == nullptr); + _impl_.someoptionalfield_.Destroy(); + _impl_.~Impl_(); +} + +::_pbi::CachedSize* OptionalRequest::AccessCachedSize() const { + return &_impl_._cached_size_; +} +void OptionalRequest::InternalSwap(OptionalRequest* PROTOBUF_RESTRICT other) { + using std::swap; + GetReflection()->Swap(this, other);} + +::google::protobuf::Metadata OptionalRequest::GetMetadata() const { + return ::_pbi::AssignDescriptors( + &descriptor_table_TestProtos_2eproto_getter, &descriptor_table_TestProtos_2eproto_once, + file_level_metadata_TestProtos_2eproto[8]); +} +// =================================================================== + +class OptionalResponse::_Internal { + public: + using HasBits = decltype(std::declval()._impl_._has_bits_); + static constexpr ::int32_t kHasBitsOffset = + 8 * PROTOBUF_FIELD_OFFSET(OptionalResponse, _impl_._has_bits_); + static void set_has_someoptionalfield(HasBits* has_bits) { + (*has_bits)[0] |= 1u; + } +}; + +OptionalResponse::OptionalResponse(::google::protobuf::Arena* arena) + : ::google::protobuf::Message(arena) { + SharedCtor(arena); + // @@protoc_insertion_point(arena_constructor:OptionalResponse) +} +inline PROTOBUF_NDEBUG_INLINE OptionalResponse::Impl_::Impl_( + ::google::protobuf::internal::InternalVisibility visibility, ::google::protobuf::Arena* arena, + const Impl_& from) + : _has_bits_{from._has_bits_}, + _cached_size_{0}, + someoptionalfield_(arena, from.someoptionalfield_) {} + +OptionalResponse::OptionalResponse( + ::google::protobuf::Arena* arena, + const OptionalResponse& from) + : ::google::protobuf::Message(arena) { + OptionalResponse* const _this = this; + (void)_this; + _internal_metadata_.MergeFrom<::google::protobuf::UnknownFieldSet>( + from._internal_metadata_); + new (&_impl_) Impl_(internal_visibility(), arena, from._impl_); + + // @@protoc_insertion_point(copy_constructor:OptionalResponse) +} +inline PROTOBUF_NDEBUG_INLINE OptionalResponse::Impl_::Impl_( + ::google::protobuf::internal::InternalVisibility visibility, + ::google::protobuf::Arena* arena) + : _cached_size_{0}, + someoptionalfield_(arena) {} + +inline void OptionalResponse::SharedCtor(::_pb::Arena* arena) { + new (&_impl_) Impl_(internal_visibility(), arena); +} +OptionalResponse::~OptionalResponse() { + // @@protoc_insertion_point(destructor:OptionalResponse) + _internal_metadata_.Delete<::google::protobuf::UnknownFieldSet>(); + SharedDtor(); +} +inline void OptionalResponse::SharedDtor() { + ABSL_DCHECK(GetArena() == nullptr); + _impl_.someoptionalfield_.Destroy(); + _impl_.~Impl_(); +} + +::_pbi::CachedSize* OptionalResponse::AccessCachedSize() const { + return &_impl_._cached_size_; +} +void OptionalResponse::InternalSwap(OptionalResponse* PROTOBUF_RESTRICT other) { + using std::swap; + GetReflection()->Swap(this, other);} + +::google::protobuf::Metadata OptionalResponse::GetMetadata() const { + return ::_pbi::AssignDescriptors( + &descriptor_table_TestProtos_2eproto_getter, &descriptor_table_TestProtos_2eproto_once, + file_level_metadata_TestProtos_2eproto[9]); +} +// @@protoc_insertion_point(namespace_scope) +namespace google { +namespace protobuf { +} // namespace protobuf +} // namespace google +// @@protoc_insertion_point(global_scope) +#include "google/protobuf/port_undef.inc" diff --git a/packages/streamr-proto-rpc/test/proto/TestProtos.pb.h b/packages/streamr-proto-rpc/test/proto/TestProtos.pb.h new file mode 100644 index 0000000..d63b004 --- /dev/null +++ b/packages/streamr-proto-rpc/test/proto/TestProtos.pb.h @@ -0,0 +1,3691 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: TestProtos.proto +// Protobuf C++ Version: 4.25.1 + +#ifndef GOOGLE_PROTOBUF_INCLUDED_TestProtos_2eproto_2epb_2eh +#define GOOGLE_PROTOBUF_INCLUDED_TestProtos_2eproto_2epb_2eh + +#include +#include +#include +#include + +#include "google/protobuf/port_def.inc" +#if PROTOBUF_VERSION < 4025000 +#error "This file was generated by a newer version of protoc which is" +#error "incompatible with your Protocol Buffer headers. Please update" +#error "your headers." +#endif // PROTOBUF_VERSION + +#if 4025001 < PROTOBUF_MIN_PROTOC_VERSION +#error "This file was generated by an older version of protoc which is" +#error "incompatible with your Protocol Buffer headers. Please" +#error "regenerate this file with a newer version of protoc." +#endif // PROTOBUF_MIN_PROTOC_VERSION +#include "google/protobuf/port_undef.inc" +#include "google/protobuf/io/coded_stream.h" +#include "google/protobuf/arena.h" +#include "google/protobuf/arenastring.h" +#include "google/protobuf/generated_message_util.h" +#include "google/protobuf/metadata_lite.h" +#include "google/protobuf/generated_message_reflection.h" +#include "google/protobuf/message.h" +#include "google/protobuf/repeated_field.h" // IWYU pragma: export +#include "google/protobuf/extension_set.h" // IWYU pragma: export +#include "google/protobuf/generated_enum_reflection.h" +#include "google/protobuf/unknown_field_set.h" +// @@protoc_insertion_point(includes) + +// Must be included last. +#include "google/protobuf/port_def.inc" + +#define PROTOBUF_INTERNAL_EXPORT_TestProtos_2eproto + +namespace google { +namespace protobuf { +namespace internal { +class AnyMetadata; +} // namespace internal +} // namespace protobuf +} // namespace google + +// Internal implementation detail -- do not use these members. +struct TableStruct_TestProtos_2eproto { + static const ::uint32_t offsets[]; +}; +extern const ::google::protobuf::internal::DescriptorTable + descriptor_table_TestProtos_2eproto; +class ClosestPeersRequest; +struct ClosestPeersRequestDefaultTypeInternal; +extern ClosestPeersRequestDefaultTypeInternal _ClosestPeersRequest_default_instance_; +class ClosestPeersResponse; +struct ClosestPeersResponseDefaultTypeInternal; +extern ClosestPeersResponseDefaultTypeInternal _ClosestPeersResponse_default_instance_; +class ConnectivityMethod; +struct ConnectivityMethodDefaultTypeInternal; +extern ConnectivityMethodDefaultTypeInternal _ConnectivityMethod_default_instance_; +class OptionalRequest; +struct OptionalRequestDefaultTypeInternal; +extern OptionalRequestDefaultTypeInternal _OptionalRequest_default_instance_; +class OptionalResponse; +struct OptionalResponseDefaultTypeInternal; +extern OptionalResponseDefaultTypeInternal _OptionalResponse_default_instance_; +class PeerDescriptor; +struct PeerDescriptorDefaultTypeInternal; +extern PeerDescriptorDefaultTypeInternal _PeerDescriptor_default_instance_; +class PingRequest; +struct PingRequestDefaultTypeInternal; +extern PingRequestDefaultTypeInternal _PingRequest_default_instance_; +class PingResponse; +struct PingResponseDefaultTypeInternal; +extern PingResponseDefaultTypeInternal _PingResponse_default_instance_; +class RouteMessageAck; +struct RouteMessageAckDefaultTypeInternal; +extern RouteMessageAckDefaultTypeInternal _RouteMessageAck_default_instance_; +class RouteMessageWrapper; +struct RouteMessageWrapperDefaultTypeInternal; +extern RouteMessageWrapperDefaultTypeInternal _RouteMessageWrapper_default_instance_; +namespace google { +namespace protobuf { +} // namespace protobuf +} // namespace google + +enum NodeType : int { + NODEJS = 0, + BROWSER = 1, + NodeType_INT_MIN_SENTINEL_DO_NOT_USE_ = + std::numeric_limits<::int32_t>::min(), + NodeType_INT_MAX_SENTINEL_DO_NOT_USE_ = + std::numeric_limits<::int32_t>::max(), +}; + +bool NodeType_IsValid(int value); +extern const uint32_t NodeType_internal_data_[]; +constexpr NodeType NodeType_MIN = static_cast(0); +constexpr NodeType NodeType_MAX = static_cast(1); +constexpr int NodeType_ARRAYSIZE = 1 + 1; +const ::google::protobuf::EnumDescriptor* +NodeType_descriptor(); +template +const std::string& NodeType_Name(T value) { + static_assert(std::is_same::value || + std::is_integral::value, + "Incorrect type passed to NodeType_Name()."); + return NodeType_Name(static_cast(value)); +} +template <> +inline const std::string& NodeType_Name(NodeType value) { + return ::google::protobuf::internal::NameOfDenseEnum( + static_cast(value)); +} +inline bool NodeType_Parse(absl::string_view name, NodeType* value) { + return ::google::protobuf::internal::ParseNamedEnum( + NodeType_descriptor(), name, value); +} + +// =================================================================== + + +// ------------------------------------------------------------------- + +class PingResponse final : + public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:PingResponse) */ { + public: + inline PingResponse() : PingResponse(nullptr) {} + ~PingResponse() override; + template + explicit PROTOBUF_CONSTEXPR PingResponse(::google::protobuf::internal::ConstantInitialized); + + inline PingResponse(const PingResponse& from) + : PingResponse(nullptr, from) {} + PingResponse(PingResponse&& from) noexcept + : PingResponse() { + *this = ::std::move(from); + } + + inline PingResponse& operator=(const PingResponse& from) { + CopyFrom(from); + return *this; + } + inline PingResponse& operator=(PingResponse&& from) noexcept { + if (this == &from) return *this; + if (GetArena() == from.GetArena() + #ifdef PROTOBUF_FORCE_COPY_IN_MOVE + && GetArena() != nullptr + #endif // !PROTOBUF_FORCE_COPY_IN_MOVE + ) { + InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + + inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const + ABSL_ATTRIBUTE_LIFETIME_BOUND { + return _internal_metadata_.unknown_fields<::google::protobuf::UnknownFieldSet>(::google::protobuf::UnknownFieldSet::default_instance); + } + inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() + ABSL_ATTRIBUTE_LIFETIME_BOUND { + return _internal_metadata_.mutable_unknown_fields<::google::protobuf::UnknownFieldSet>(); + } + + static const ::google::protobuf::Descriptor* descriptor() { + return GetDescriptor(); + } + static const ::google::protobuf::Descriptor* GetDescriptor() { + return default_instance().GetMetadata().descriptor; + } + static const ::google::protobuf::Reflection* GetReflection() { + return default_instance().GetMetadata().reflection; + } + static const PingResponse& default_instance() { + return *internal_default_instance(); + } + static inline const PingResponse* internal_default_instance() { + return reinterpret_cast( + &_PingResponse_default_instance_); + } + static constexpr int kIndexInFileMessages = + 3; + + friend void swap(PingResponse& a, PingResponse& b) { + a.Swap(&b); + } + inline void Swap(PingResponse* other) { + if (other == this) return; + #ifdef PROTOBUF_FORCE_COPY_IN_SWAP + if (GetArena() != nullptr && + GetArena() == other->GetArena()) { + #else // PROTOBUF_FORCE_COPY_IN_SWAP + if (GetArena() == other->GetArena()) { + #endif // !PROTOBUF_FORCE_COPY_IN_SWAP + InternalSwap(other); + } else { + ::google::protobuf::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(PingResponse* other) { + if (other == this) return; + ABSL_DCHECK(GetArena() == other->GetArena()); + InternalSwap(other); + } + + // implements Message ---------------------------------------------- + + PingResponse* New(::google::protobuf::Arena* arena = nullptr) const final { + return CreateMaybeMessage(arena); + } + int GetCachedSize() const { return _impl_._cached_size_.Get(); } + + private: + ::google::protobuf::internal::CachedSize* AccessCachedSize() const final; + void SharedCtor(::google::protobuf::Arena* arena); + void SharedDtor(); + void InternalSwap(PingResponse* other); + + private: + friend class ::google::protobuf::internal::AnyMetadata; + static ::absl::string_view FullMessageName() { + return "PingResponse"; + } + protected: + explicit PingResponse(::google::protobuf::Arena* arena); + PingResponse(::google::protobuf::Arena* arena, const PingResponse& from); + public: + + ::google::protobuf::Metadata GetMetadata() const final; + + // nested types ---------------------------------------------------- + + // accessors ------------------------------------------------------- + + enum : int { + kRequestIdFieldNumber = 1, + }; + // string requestId = 1; + void clear_requestid() ; + const std::string& requestid() const; + template + void set_requestid(Arg_&& arg, Args_... args); + std::string* mutable_requestid(); + PROTOBUF_NODISCARD std::string* release_requestid(); + void set_allocated_requestid(std::string* value); + + private: + const std::string& _internal_requestid() const; + inline PROTOBUF_ALWAYS_INLINE void _internal_set_requestid( + const std::string& value); + std::string* _internal_mutable_requestid(); + + public: + // @@protoc_insertion_point(class_scope:PingResponse) + private: + class _Internal; + + friend class ::google::protobuf::MessageLite; + friend class ::google::protobuf::Arena; + template + friend class ::google::protobuf::Arena::InternalHelper; + using InternalArenaConstructable_ = void; + using DestructorSkippable_ = void; + struct Impl_ { + + inline explicit constexpr Impl_( + ::google::protobuf::internal::ConstantInitialized) noexcept; + inline explicit Impl_(::google::protobuf::internal::InternalVisibility visibility, + ::google::protobuf::Arena* arena); + inline explicit Impl_(::google::protobuf::internal::InternalVisibility visibility, + ::google::protobuf::Arena* arena, const Impl_& from); + ::google::protobuf::internal::ArenaStringPtr requestid_; + mutable ::google::protobuf::internal::CachedSize _cached_size_; + PROTOBUF_TSAN_DECLARE_MEMBER + }; + union { Impl_ _impl_; }; + friend struct ::TableStruct_TestProtos_2eproto; +};// ------------------------------------------------------------------- + +class PingRequest final : + public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:PingRequest) */ { + public: + inline PingRequest() : PingRequest(nullptr) {} + ~PingRequest() override; + template + explicit PROTOBUF_CONSTEXPR PingRequest(::google::protobuf::internal::ConstantInitialized); + + inline PingRequest(const PingRequest& from) + : PingRequest(nullptr, from) {} + PingRequest(PingRequest&& from) noexcept + : PingRequest() { + *this = ::std::move(from); + } + + inline PingRequest& operator=(const PingRequest& from) { + CopyFrom(from); + return *this; + } + inline PingRequest& operator=(PingRequest&& from) noexcept { + if (this == &from) return *this; + if (GetArena() == from.GetArena() + #ifdef PROTOBUF_FORCE_COPY_IN_MOVE + && GetArena() != nullptr + #endif // !PROTOBUF_FORCE_COPY_IN_MOVE + ) { + InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + + inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const + ABSL_ATTRIBUTE_LIFETIME_BOUND { + return _internal_metadata_.unknown_fields<::google::protobuf::UnknownFieldSet>(::google::protobuf::UnknownFieldSet::default_instance); + } + inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() + ABSL_ATTRIBUTE_LIFETIME_BOUND { + return _internal_metadata_.mutable_unknown_fields<::google::protobuf::UnknownFieldSet>(); + } + + static const ::google::protobuf::Descriptor* descriptor() { + return GetDescriptor(); + } + static const ::google::protobuf::Descriptor* GetDescriptor() { + return default_instance().GetMetadata().descriptor; + } + static const ::google::protobuf::Reflection* GetReflection() { + return default_instance().GetMetadata().reflection; + } + static const PingRequest& default_instance() { + return *internal_default_instance(); + } + static inline const PingRequest* internal_default_instance() { + return reinterpret_cast( + &_PingRequest_default_instance_); + } + static constexpr int kIndexInFileMessages = + 2; + + friend void swap(PingRequest& a, PingRequest& b) { + a.Swap(&b); + } + inline void Swap(PingRequest* other) { + if (other == this) return; + #ifdef PROTOBUF_FORCE_COPY_IN_SWAP + if (GetArena() != nullptr && + GetArena() == other->GetArena()) { + #else // PROTOBUF_FORCE_COPY_IN_SWAP + if (GetArena() == other->GetArena()) { + #endif // !PROTOBUF_FORCE_COPY_IN_SWAP + InternalSwap(other); + } else { + ::google::protobuf::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(PingRequest* other) { + if (other == this) return; + ABSL_DCHECK(GetArena() == other->GetArena()); + InternalSwap(other); + } + + // implements Message ---------------------------------------------- + + PingRequest* New(::google::protobuf::Arena* arena = nullptr) const final { + return CreateMaybeMessage(arena); + } + int GetCachedSize() const { return _impl_._cached_size_.Get(); } + + private: + ::google::protobuf::internal::CachedSize* AccessCachedSize() const final; + void SharedCtor(::google::protobuf::Arena* arena); + void SharedDtor(); + void InternalSwap(PingRequest* other); + + private: + friend class ::google::protobuf::internal::AnyMetadata; + static ::absl::string_view FullMessageName() { + return "PingRequest"; + } + protected: + explicit PingRequest(::google::protobuf::Arena* arena); + PingRequest(::google::protobuf::Arena* arena, const PingRequest& from); + public: + + ::google::protobuf::Metadata GetMetadata() const final; + + // nested types ---------------------------------------------------- + + // accessors ------------------------------------------------------- + + enum : int { + kRequestIdFieldNumber = 1, + }; + // string requestId = 1; + void clear_requestid() ; + const std::string& requestid() const; + template + void set_requestid(Arg_&& arg, Args_... args); + std::string* mutable_requestid(); + PROTOBUF_NODISCARD std::string* release_requestid(); + void set_allocated_requestid(std::string* value); + + private: + const std::string& _internal_requestid() const; + inline PROTOBUF_ALWAYS_INLINE void _internal_set_requestid( + const std::string& value); + std::string* _internal_mutable_requestid(); + + public: + // @@protoc_insertion_point(class_scope:PingRequest) + private: + class _Internal; + + friend class ::google::protobuf::MessageLite; + friend class ::google::protobuf::Arena; + template + friend class ::google::protobuf::Arena::InternalHelper; + using InternalArenaConstructable_ = void; + using DestructorSkippable_ = void; + struct Impl_ { + + inline explicit constexpr Impl_( + ::google::protobuf::internal::ConstantInitialized) noexcept; + inline explicit Impl_(::google::protobuf::internal::InternalVisibility visibility, + ::google::protobuf::Arena* arena); + inline explicit Impl_(::google::protobuf::internal::InternalVisibility visibility, + ::google::protobuf::Arena* arena, const Impl_& from); + ::google::protobuf::internal::ArenaStringPtr requestid_; + mutable ::google::protobuf::internal::CachedSize _cached_size_; + PROTOBUF_TSAN_DECLARE_MEMBER + }; + union { Impl_ _impl_; }; + friend struct ::TableStruct_TestProtos_2eproto; +};// ------------------------------------------------------------------- + +class OptionalResponse final : + public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:OptionalResponse) */ { + public: + inline OptionalResponse() : OptionalResponse(nullptr) {} + ~OptionalResponse() override; + template + explicit PROTOBUF_CONSTEXPR OptionalResponse(::google::protobuf::internal::ConstantInitialized); + + inline OptionalResponse(const OptionalResponse& from) + : OptionalResponse(nullptr, from) {} + OptionalResponse(OptionalResponse&& from) noexcept + : OptionalResponse() { + *this = ::std::move(from); + } + + inline OptionalResponse& operator=(const OptionalResponse& from) { + CopyFrom(from); + return *this; + } + inline OptionalResponse& operator=(OptionalResponse&& from) noexcept { + if (this == &from) return *this; + if (GetArena() == from.GetArena() + #ifdef PROTOBUF_FORCE_COPY_IN_MOVE + && GetArena() != nullptr + #endif // !PROTOBUF_FORCE_COPY_IN_MOVE + ) { + InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + + inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const + ABSL_ATTRIBUTE_LIFETIME_BOUND { + return _internal_metadata_.unknown_fields<::google::protobuf::UnknownFieldSet>(::google::protobuf::UnknownFieldSet::default_instance); + } + inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() + ABSL_ATTRIBUTE_LIFETIME_BOUND { + return _internal_metadata_.mutable_unknown_fields<::google::protobuf::UnknownFieldSet>(); + } + + static const ::google::protobuf::Descriptor* descriptor() { + return GetDescriptor(); + } + static const ::google::protobuf::Descriptor* GetDescriptor() { + return default_instance().GetMetadata().descriptor; + } + static const ::google::protobuf::Reflection* GetReflection() { + return default_instance().GetMetadata().reflection; + } + static const OptionalResponse& default_instance() { + return *internal_default_instance(); + } + static inline const OptionalResponse* internal_default_instance() { + return reinterpret_cast( + &_OptionalResponse_default_instance_); + } + static constexpr int kIndexInFileMessages = + 9; + + friend void swap(OptionalResponse& a, OptionalResponse& b) { + a.Swap(&b); + } + inline void Swap(OptionalResponse* other) { + if (other == this) return; + #ifdef PROTOBUF_FORCE_COPY_IN_SWAP + if (GetArena() != nullptr && + GetArena() == other->GetArena()) { + #else // PROTOBUF_FORCE_COPY_IN_SWAP + if (GetArena() == other->GetArena()) { + #endif // !PROTOBUF_FORCE_COPY_IN_SWAP + InternalSwap(other); + } else { + ::google::protobuf::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(OptionalResponse* other) { + if (other == this) return; + ABSL_DCHECK(GetArena() == other->GetArena()); + InternalSwap(other); + } + + // implements Message ---------------------------------------------- + + OptionalResponse* New(::google::protobuf::Arena* arena = nullptr) const final { + return CreateMaybeMessage(arena); + } + int GetCachedSize() const { return _impl_._cached_size_.Get(); } + + private: + ::google::protobuf::internal::CachedSize* AccessCachedSize() const final; + void SharedCtor(::google::protobuf::Arena* arena); + void SharedDtor(); + void InternalSwap(OptionalResponse* other); + + private: + friend class ::google::protobuf::internal::AnyMetadata; + static ::absl::string_view FullMessageName() { + return "OptionalResponse"; + } + protected: + explicit OptionalResponse(::google::protobuf::Arena* arena); + OptionalResponse(::google::protobuf::Arena* arena, const OptionalResponse& from); + public: + + ::google::protobuf::Metadata GetMetadata() const final; + + // nested types ---------------------------------------------------- + + // accessors ------------------------------------------------------- + + enum : int { + kSomeOptionalFieldFieldNumber = 1, + }; + // optional string someOptionalField = 1; + bool has_someoptionalfield() const; + void clear_someoptionalfield() ; + const std::string& someoptionalfield() const; + template + void set_someoptionalfield(Arg_&& arg, Args_... args); + std::string* mutable_someoptionalfield(); + PROTOBUF_NODISCARD std::string* release_someoptionalfield(); + void set_allocated_someoptionalfield(std::string* value); + + private: + const std::string& _internal_someoptionalfield() const; + inline PROTOBUF_ALWAYS_INLINE void _internal_set_someoptionalfield( + const std::string& value); + std::string* _internal_mutable_someoptionalfield(); + + public: + // @@protoc_insertion_point(class_scope:OptionalResponse) + private: + class _Internal; + + friend class ::google::protobuf::MessageLite; + friend class ::google::protobuf::Arena; + template + friend class ::google::protobuf::Arena::InternalHelper; + using InternalArenaConstructable_ = void; + using DestructorSkippable_ = void; + struct Impl_ { + + inline explicit constexpr Impl_( + ::google::protobuf::internal::ConstantInitialized) noexcept; + inline explicit Impl_(::google::protobuf::internal::InternalVisibility visibility, + ::google::protobuf::Arena* arena); + inline explicit Impl_(::google::protobuf::internal::InternalVisibility visibility, + ::google::protobuf::Arena* arena, const Impl_& from); + ::google::protobuf::internal::HasBits<1> _has_bits_; + mutable ::google::protobuf::internal::CachedSize _cached_size_; + ::google::protobuf::internal::ArenaStringPtr someoptionalfield_; + PROTOBUF_TSAN_DECLARE_MEMBER + }; + union { Impl_ _impl_; }; + friend struct ::TableStruct_TestProtos_2eproto; +};// ------------------------------------------------------------------- + +class OptionalRequest final : + public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:OptionalRequest) */ { + public: + inline OptionalRequest() : OptionalRequest(nullptr) {} + ~OptionalRequest() override; + template + explicit PROTOBUF_CONSTEXPR OptionalRequest(::google::protobuf::internal::ConstantInitialized); + + inline OptionalRequest(const OptionalRequest& from) + : OptionalRequest(nullptr, from) {} + OptionalRequest(OptionalRequest&& from) noexcept + : OptionalRequest() { + *this = ::std::move(from); + } + + inline OptionalRequest& operator=(const OptionalRequest& from) { + CopyFrom(from); + return *this; + } + inline OptionalRequest& operator=(OptionalRequest&& from) noexcept { + if (this == &from) return *this; + if (GetArena() == from.GetArena() + #ifdef PROTOBUF_FORCE_COPY_IN_MOVE + && GetArena() != nullptr + #endif // !PROTOBUF_FORCE_COPY_IN_MOVE + ) { + InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + + inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const + ABSL_ATTRIBUTE_LIFETIME_BOUND { + return _internal_metadata_.unknown_fields<::google::protobuf::UnknownFieldSet>(::google::protobuf::UnknownFieldSet::default_instance); + } + inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() + ABSL_ATTRIBUTE_LIFETIME_BOUND { + return _internal_metadata_.mutable_unknown_fields<::google::protobuf::UnknownFieldSet>(); + } + + static const ::google::protobuf::Descriptor* descriptor() { + return GetDescriptor(); + } + static const ::google::protobuf::Descriptor* GetDescriptor() { + return default_instance().GetMetadata().descriptor; + } + static const ::google::protobuf::Reflection* GetReflection() { + return default_instance().GetMetadata().reflection; + } + static const OptionalRequest& default_instance() { + return *internal_default_instance(); + } + static inline const OptionalRequest* internal_default_instance() { + return reinterpret_cast( + &_OptionalRequest_default_instance_); + } + static constexpr int kIndexInFileMessages = + 8; + + friend void swap(OptionalRequest& a, OptionalRequest& b) { + a.Swap(&b); + } + inline void Swap(OptionalRequest* other) { + if (other == this) return; + #ifdef PROTOBUF_FORCE_COPY_IN_SWAP + if (GetArena() != nullptr && + GetArena() == other->GetArena()) { + #else // PROTOBUF_FORCE_COPY_IN_SWAP + if (GetArena() == other->GetArena()) { + #endif // !PROTOBUF_FORCE_COPY_IN_SWAP + InternalSwap(other); + } else { + ::google::protobuf::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(OptionalRequest* other) { + if (other == this) return; + ABSL_DCHECK(GetArena() == other->GetArena()); + InternalSwap(other); + } + + // implements Message ---------------------------------------------- + + OptionalRequest* New(::google::protobuf::Arena* arena = nullptr) const final { + return CreateMaybeMessage(arena); + } + int GetCachedSize() const { return _impl_._cached_size_.Get(); } + + private: + ::google::protobuf::internal::CachedSize* AccessCachedSize() const final; + void SharedCtor(::google::protobuf::Arena* arena); + void SharedDtor(); + void InternalSwap(OptionalRequest* other); + + private: + friend class ::google::protobuf::internal::AnyMetadata; + static ::absl::string_view FullMessageName() { + return "OptionalRequest"; + } + protected: + explicit OptionalRequest(::google::protobuf::Arena* arena); + OptionalRequest(::google::protobuf::Arena* arena, const OptionalRequest& from); + public: + + ::google::protobuf::Metadata GetMetadata() const final; + + // nested types ---------------------------------------------------- + + // accessors ------------------------------------------------------- + + enum : int { + kSomeOptionalFieldFieldNumber = 1, + }; + // optional string someOptionalField = 1; + bool has_someoptionalfield() const; + void clear_someoptionalfield() ; + const std::string& someoptionalfield() const; + template + void set_someoptionalfield(Arg_&& arg, Args_... args); + std::string* mutable_someoptionalfield(); + PROTOBUF_NODISCARD std::string* release_someoptionalfield(); + void set_allocated_someoptionalfield(std::string* value); + + private: + const std::string& _internal_someoptionalfield() const; + inline PROTOBUF_ALWAYS_INLINE void _internal_set_someoptionalfield( + const std::string& value); + std::string* _internal_mutable_someoptionalfield(); + + public: + // @@protoc_insertion_point(class_scope:OptionalRequest) + private: + class _Internal; + + friend class ::google::protobuf::MessageLite; + friend class ::google::protobuf::Arena; + template + friend class ::google::protobuf::Arena::InternalHelper; + using InternalArenaConstructable_ = void; + using DestructorSkippable_ = void; + struct Impl_ { + + inline explicit constexpr Impl_( + ::google::protobuf::internal::ConstantInitialized) noexcept; + inline explicit Impl_(::google::protobuf::internal::InternalVisibility visibility, + ::google::protobuf::Arena* arena); + inline explicit Impl_(::google::protobuf::internal::InternalVisibility visibility, + ::google::protobuf::Arena* arena, const Impl_& from); + ::google::protobuf::internal::HasBits<1> _has_bits_; + mutable ::google::protobuf::internal::CachedSize _cached_size_; + ::google::protobuf::internal::ArenaStringPtr someoptionalfield_; + PROTOBUF_TSAN_DECLARE_MEMBER + }; + union { Impl_ _impl_; }; + friend struct ::TableStruct_TestProtos_2eproto; +};// ------------------------------------------------------------------- + +class ConnectivityMethod final : + public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:ConnectivityMethod) */ { + public: + inline ConnectivityMethod() : ConnectivityMethod(nullptr) {} + ~ConnectivityMethod() override; + template + explicit PROTOBUF_CONSTEXPR ConnectivityMethod(::google::protobuf::internal::ConstantInitialized); + + inline ConnectivityMethod(const ConnectivityMethod& from) + : ConnectivityMethod(nullptr, from) {} + ConnectivityMethod(ConnectivityMethod&& from) noexcept + : ConnectivityMethod() { + *this = ::std::move(from); + } + + inline ConnectivityMethod& operator=(const ConnectivityMethod& from) { + CopyFrom(from); + return *this; + } + inline ConnectivityMethod& operator=(ConnectivityMethod&& from) noexcept { + if (this == &from) return *this; + if (GetArena() == from.GetArena() + #ifdef PROTOBUF_FORCE_COPY_IN_MOVE + && GetArena() != nullptr + #endif // !PROTOBUF_FORCE_COPY_IN_MOVE + ) { + InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + + inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const + ABSL_ATTRIBUTE_LIFETIME_BOUND { + return _internal_metadata_.unknown_fields<::google::protobuf::UnknownFieldSet>(::google::protobuf::UnknownFieldSet::default_instance); + } + inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() + ABSL_ATTRIBUTE_LIFETIME_BOUND { + return _internal_metadata_.mutable_unknown_fields<::google::protobuf::UnknownFieldSet>(); + } + + static const ::google::protobuf::Descriptor* descriptor() { + return GetDescriptor(); + } + static const ::google::protobuf::Descriptor* GetDescriptor() { + return default_instance().GetMetadata().descriptor; + } + static const ::google::protobuf::Reflection* GetReflection() { + return default_instance().GetMetadata().reflection; + } + static const ConnectivityMethod& default_instance() { + return *internal_default_instance(); + } + static inline const ConnectivityMethod* internal_default_instance() { + return reinterpret_cast( + &_ConnectivityMethod_default_instance_); + } + static constexpr int kIndexInFileMessages = + 7; + + friend void swap(ConnectivityMethod& a, ConnectivityMethod& b) { + a.Swap(&b); + } + inline void Swap(ConnectivityMethod* other) { + if (other == this) return; + #ifdef PROTOBUF_FORCE_COPY_IN_SWAP + if (GetArena() != nullptr && + GetArena() == other->GetArena()) { + #else // PROTOBUF_FORCE_COPY_IN_SWAP + if (GetArena() == other->GetArena()) { + #endif // !PROTOBUF_FORCE_COPY_IN_SWAP + InternalSwap(other); + } else { + ::google::protobuf::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(ConnectivityMethod* other) { + if (other == this) return; + ABSL_DCHECK(GetArena() == other->GetArena()); + InternalSwap(other); + } + + // implements Message ---------------------------------------------- + + ConnectivityMethod* New(::google::protobuf::Arena* arena = nullptr) const final { + return CreateMaybeMessage(arena); + } + int GetCachedSize() const { return _impl_._cached_size_.Get(); } + + private: + ::google::protobuf::internal::CachedSize* AccessCachedSize() const final; + void SharedCtor(::google::protobuf::Arena* arena); + void SharedDtor(); + void InternalSwap(ConnectivityMethod* other); + + private: + friend class ::google::protobuf::internal::AnyMetadata; + static ::absl::string_view FullMessageName() { + return "ConnectivityMethod"; + } + protected: + explicit ConnectivityMethod(::google::protobuf::Arena* arena); + ConnectivityMethod(::google::protobuf::Arena* arena, const ConnectivityMethod& from); + public: + + ::google::protobuf::Metadata GetMetadata() const final; + + // nested types ---------------------------------------------------- + + // accessors ------------------------------------------------------- + + enum : int { + kIpFieldNumber = 3, + kPortFieldNumber = 2, + }; + // string ip = 3; + void clear_ip() ; + const std::string& ip() const; + template + void set_ip(Arg_&& arg, Args_... args); + std::string* mutable_ip(); + PROTOBUF_NODISCARD std::string* release_ip(); + void set_allocated_ip(std::string* value); + + private: + const std::string& _internal_ip() const; + inline PROTOBUF_ALWAYS_INLINE void _internal_set_ip( + const std::string& value); + std::string* _internal_mutable_ip(); + + public: + // uint32 port = 2; + void clear_port() ; + ::uint32_t port() const; + void set_port(::uint32_t value); + + private: + ::uint32_t _internal_port() const; + void _internal_set_port(::uint32_t value); + + public: + // @@protoc_insertion_point(class_scope:ConnectivityMethod) + private: + class _Internal; + + friend class ::google::protobuf::MessageLite; + friend class ::google::protobuf::Arena; + template + friend class ::google::protobuf::Arena::InternalHelper; + using InternalArenaConstructable_ = void; + using DestructorSkippable_ = void; + struct Impl_ { + + inline explicit constexpr Impl_( + ::google::protobuf::internal::ConstantInitialized) noexcept; + inline explicit Impl_(::google::protobuf::internal::InternalVisibility visibility, + ::google::protobuf::Arena* arena); + inline explicit Impl_(::google::protobuf::internal::InternalVisibility visibility, + ::google::protobuf::Arena* arena, const Impl_& from); + ::google::protobuf::internal::ArenaStringPtr ip_; + ::uint32_t port_; + mutable ::google::protobuf::internal::CachedSize _cached_size_; + PROTOBUF_TSAN_DECLARE_MEMBER + }; + union { Impl_ _impl_; }; + friend struct ::TableStruct_TestProtos_2eproto; +};// ------------------------------------------------------------------- + +class PeerDescriptor final : + public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:PeerDescriptor) */ { + public: + inline PeerDescriptor() : PeerDescriptor(nullptr) {} + ~PeerDescriptor() override; + template + explicit PROTOBUF_CONSTEXPR PeerDescriptor(::google::protobuf::internal::ConstantInitialized); + + inline PeerDescriptor(const PeerDescriptor& from) + : PeerDescriptor(nullptr, from) {} + PeerDescriptor(PeerDescriptor&& from) noexcept + : PeerDescriptor() { + *this = ::std::move(from); + } + + inline PeerDescriptor& operator=(const PeerDescriptor& from) { + CopyFrom(from); + return *this; + } + inline PeerDescriptor& operator=(PeerDescriptor&& from) noexcept { + if (this == &from) return *this; + if (GetArena() == from.GetArena() + #ifdef PROTOBUF_FORCE_COPY_IN_MOVE + && GetArena() != nullptr + #endif // !PROTOBUF_FORCE_COPY_IN_MOVE + ) { + InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + + inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const + ABSL_ATTRIBUTE_LIFETIME_BOUND { + return _internal_metadata_.unknown_fields<::google::protobuf::UnknownFieldSet>(::google::protobuf::UnknownFieldSet::default_instance); + } + inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() + ABSL_ATTRIBUTE_LIFETIME_BOUND { + return _internal_metadata_.mutable_unknown_fields<::google::protobuf::UnknownFieldSet>(); + } + + static const ::google::protobuf::Descriptor* descriptor() { + return GetDescriptor(); + } + static const ::google::protobuf::Descriptor* GetDescriptor() { + return default_instance().GetMetadata().descriptor; + } + static const ::google::protobuf::Reflection* GetReflection() { + return default_instance().GetMetadata().reflection; + } + static const PeerDescriptor& default_instance() { + return *internal_default_instance(); + } + static inline const PeerDescriptor* internal_default_instance() { + return reinterpret_cast( + &_PeerDescriptor_default_instance_); + } + static constexpr int kIndexInFileMessages = + 6; + + friend void swap(PeerDescriptor& a, PeerDescriptor& b) { + a.Swap(&b); + } + inline void Swap(PeerDescriptor* other) { + if (other == this) return; + #ifdef PROTOBUF_FORCE_COPY_IN_SWAP + if (GetArena() != nullptr && + GetArena() == other->GetArena()) { + #else // PROTOBUF_FORCE_COPY_IN_SWAP + if (GetArena() == other->GetArena()) { + #endif // !PROTOBUF_FORCE_COPY_IN_SWAP + InternalSwap(other); + } else { + ::google::protobuf::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(PeerDescriptor* other) { + if (other == this) return; + ABSL_DCHECK(GetArena() == other->GetArena()); + InternalSwap(other); + } + + // implements Message ---------------------------------------------- + + PeerDescriptor* New(::google::protobuf::Arena* arena = nullptr) const final { + return CreateMaybeMessage(arena); + } + int GetCachedSize() const { return _impl_._cached_size_.Get(); } + + private: + ::google::protobuf::internal::CachedSize* AccessCachedSize() const final; + void SharedCtor(::google::protobuf::Arena* arena); + void SharedDtor(); + void InternalSwap(PeerDescriptor* other); + + private: + friend class ::google::protobuf::internal::AnyMetadata; + static ::absl::string_view FullMessageName() { + return "PeerDescriptor"; + } + protected: + explicit PeerDescriptor(::google::protobuf::Arena* arena); + PeerDescriptor(::google::protobuf::Arena* arena, const PeerDescriptor& from); + public: + + ::google::protobuf::Metadata GetMetadata() const final; + + // nested types ---------------------------------------------------- + + // accessors ------------------------------------------------------- + + enum : int { + kNodeIdFieldNumber = 1, + kUdpFieldNumber = 3, + kTcpFieldNumber = 4, + kWebsocketFieldNumber = 5, + kTypeFieldNumber = 2, + kOpenInternetFieldNumber = 6, + }; + // bytes nodeId = 1; + void clear_nodeid() ; + const std::string& nodeid() const; + template + void set_nodeid(Arg_&& arg, Args_... args); + std::string* mutable_nodeid(); + PROTOBUF_NODISCARD std::string* release_nodeid(); + void set_allocated_nodeid(std::string* value); + + private: + const std::string& _internal_nodeid() const; + inline PROTOBUF_ALWAYS_INLINE void _internal_set_nodeid( + const std::string& value); + std::string* _internal_mutable_nodeid(); + + public: + // .ConnectivityMethod udp = 3; + bool has_udp() const; + void clear_udp() ; + const ::ConnectivityMethod& udp() const; + PROTOBUF_NODISCARD ::ConnectivityMethod* release_udp(); + ::ConnectivityMethod* mutable_udp(); + void set_allocated_udp(::ConnectivityMethod* value); + void unsafe_arena_set_allocated_udp(::ConnectivityMethod* value); + ::ConnectivityMethod* unsafe_arena_release_udp(); + + private: + const ::ConnectivityMethod& _internal_udp() const; + ::ConnectivityMethod* _internal_mutable_udp(); + + public: + // .ConnectivityMethod tcp = 4; + bool has_tcp() const; + void clear_tcp() ; + const ::ConnectivityMethod& tcp() const; + PROTOBUF_NODISCARD ::ConnectivityMethod* release_tcp(); + ::ConnectivityMethod* mutable_tcp(); + void set_allocated_tcp(::ConnectivityMethod* value); + void unsafe_arena_set_allocated_tcp(::ConnectivityMethod* value); + ::ConnectivityMethod* unsafe_arena_release_tcp(); + + private: + const ::ConnectivityMethod& _internal_tcp() const; + ::ConnectivityMethod* _internal_mutable_tcp(); + + public: + // .ConnectivityMethod websocket = 5; + bool has_websocket() const; + void clear_websocket() ; + const ::ConnectivityMethod& websocket() const; + PROTOBUF_NODISCARD ::ConnectivityMethod* release_websocket(); + ::ConnectivityMethod* mutable_websocket(); + void set_allocated_websocket(::ConnectivityMethod* value); + void unsafe_arena_set_allocated_websocket(::ConnectivityMethod* value); + ::ConnectivityMethod* unsafe_arena_release_websocket(); + + private: + const ::ConnectivityMethod& _internal_websocket() const; + ::ConnectivityMethod* _internal_mutable_websocket(); + + public: + // .NodeType type = 2; + void clear_type() ; + ::NodeType type() const; + void set_type(::NodeType value); + + private: + ::NodeType _internal_type() const; + void _internal_set_type(::NodeType value); + + public: + // optional bool openInternet = 6; + bool has_openinternet() const; + void clear_openinternet() ; + bool openinternet() const; + void set_openinternet(bool value); + + private: + bool _internal_openinternet() const; + void _internal_set_openinternet(bool value); + + public: + // @@protoc_insertion_point(class_scope:PeerDescriptor) + private: + class _Internal; + + friend class ::google::protobuf::MessageLite; + friend class ::google::protobuf::Arena; + template + friend class ::google::protobuf::Arena::InternalHelper; + using InternalArenaConstructable_ = void; + using DestructorSkippable_ = void; + struct Impl_ { + + inline explicit constexpr Impl_( + ::google::protobuf::internal::ConstantInitialized) noexcept; + inline explicit Impl_(::google::protobuf::internal::InternalVisibility visibility, + ::google::protobuf::Arena* arena); + inline explicit Impl_(::google::protobuf::internal::InternalVisibility visibility, + ::google::protobuf::Arena* arena, const Impl_& from); + ::google::protobuf::internal::HasBits<1> _has_bits_; + mutable ::google::protobuf::internal::CachedSize _cached_size_; + ::google::protobuf::internal::ArenaStringPtr nodeid_; + ::ConnectivityMethod* udp_; + ::ConnectivityMethod* tcp_; + ::ConnectivityMethod* websocket_; + int type_; + bool openinternet_; + PROTOBUF_TSAN_DECLARE_MEMBER + }; + union { Impl_ _impl_; }; + friend struct ::TableStruct_TestProtos_2eproto; +};// ------------------------------------------------------------------- + +class RouteMessageWrapper final : + public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:RouteMessageWrapper) */ { + public: + inline RouteMessageWrapper() : RouteMessageWrapper(nullptr) {} + ~RouteMessageWrapper() override; + template + explicit PROTOBUF_CONSTEXPR RouteMessageWrapper(::google::protobuf::internal::ConstantInitialized); + + inline RouteMessageWrapper(const RouteMessageWrapper& from) + : RouteMessageWrapper(nullptr, from) {} + RouteMessageWrapper(RouteMessageWrapper&& from) noexcept + : RouteMessageWrapper() { + *this = ::std::move(from); + } + + inline RouteMessageWrapper& operator=(const RouteMessageWrapper& from) { + CopyFrom(from); + return *this; + } + inline RouteMessageWrapper& operator=(RouteMessageWrapper&& from) noexcept { + if (this == &from) return *this; + if (GetArena() == from.GetArena() + #ifdef PROTOBUF_FORCE_COPY_IN_MOVE + && GetArena() != nullptr + #endif // !PROTOBUF_FORCE_COPY_IN_MOVE + ) { + InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + + inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const + ABSL_ATTRIBUTE_LIFETIME_BOUND { + return _internal_metadata_.unknown_fields<::google::protobuf::UnknownFieldSet>(::google::protobuf::UnknownFieldSet::default_instance); + } + inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() + ABSL_ATTRIBUTE_LIFETIME_BOUND { + return _internal_metadata_.mutable_unknown_fields<::google::protobuf::UnknownFieldSet>(); + } + + static const ::google::protobuf::Descriptor* descriptor() { + return GetDescriptor(); + } + static const ::google::protobuf::Descriptor* GetDescriptor() { + return default_instance().GetMetadata().descriptor; + } + static const ::google::protobuf::Reflection* GetReflection() { + return default_instance().GetMetadata().reflection; + } + static const RouteMessageWrapper& default_instance() { + return *internal_default_instance(); + } + static inline const RouteMessageWrapper* internal_default_instance() { + return reinterpret_cast( + &_RouteMessageWrapper_default_instance_); + } + static constexpr int kIndexInFileMessages = + 0; + + friend void swap(RouteMessageWrapper& a, RouteMessageWrapper& b) { + a.Swap(&b); + } + inline void Swap(RouteMessageWrapper* other) { + if (other == this) return; + #ifdef PROTOBUF_FORCE_COPY_IN_SWAP + if (GetArena() != nullptr && + GetArena() == other->GetArena()) { + #else // PROTOBUF_FORCE_COPY_IN_SWAP + if (GetArena() == other->GetArena()) { + #endif // !PROTOBUF_FORCE_COPY_IN_SWAP + InternalSwap(other); + } else { + ::google::protobuf::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(RouteMessageWrapper* other) { + if (other == this) return; + ABSL_DCHECK(GetArena() == other->GetArena()); + InternalSwap(other); + } + + // implements Message ---------------------------------------------- + + RouteMessageWrapper* New(::google::protobuf::Arena* arena = nullptr) const final { + return CreateMaybeMessage(arena); + } + int GetCachedSize() const { return _impl_._cached_size_.Get(); } + + private: + ::google::protobuf::internal::CachedSize* AccessCachedSize() const final; + void SharedCtor(::google::protobuf::Arena* arena); + void SharedDtor(); + void InternalSwap(RouteMessageWrapper* other); + + private: + friend class ::google::protobuf::internal::AnyMetadata; + static ::absl::string_view FullMessageName() { + return "RouteMessageWrapper"; + } + protected: + explicit RouteMessageWrapper(::google::protobuf::Arena* arena); + RouteMessageWrapper(::google::protobuf::Arena* arena, const RouteMessageWrapper& from); + public: + + ::google::protobuf::Metadata GetMetadata() const final; + + // nested types ---------------------------------------------------- + + // accessors ------------------------------------------------------- + + enum : int { + kRequestIdFieldNumber = 2, + kMessageFieldNumber = 5, + kSourcePeerFieldNumber = 1, + kDestinationPeerFieldNumber = 3, + kPreviousPeerFieldNumber = 4, + }; + // string requestId = 2; + void clear_requestid() ; + const std::string& requestid() const; + template + void set_requestid(Arg_&& arg, Args_... args); + std::string* mutable_requestid(); + PROTOBUF_NODISCARD std::string* release_requestid(); + void set_allocated_requestid(std::string* value); + + private: + const std::string& _internal_requestid() const; + inline PROTOBUF_ALWAYS_INLINE void _internal_set_requestid( + const std::string& value); + std::string* _internal_mutable_requestid(); + + public: + // bytes message = 5; + void clear_message() ; + const std::string& message() const; + template + void set_message(Arg_&& arg, Args_... args); + std::string* mutable_message(); + PROTOBUF_NODISCARD std::string* release_message(); + void set_allocated_message(std::string* value); + + private: + const std::string& _internal_message() const; + inline PROTOBUF_ALWAYS_INLINE void _internal_set_message( + const std::string& value); + std::string* _internal_mutable_message(); + + public: + // .PeerDescriptor sourcePeer = 1; + bool has_sourcepeer() const; + void clear_sourcepeer() ; + const ::PeerDescriptor& sourcepeer() const; + PROTOBUF_NODISCARD ::PeerDescriptor* release_sourcepeer(); + ::PeerDescriptor* mutable_sourcepeer(); + void set_allocated_sourcepeer(::PeerDescriptor* value); + void unsafe_arena_set_allocated_sourcepeer(::PeerDescriptor* value); + ::PeerDescriptor* unsafe_arena_release_sourcepeer(); + + private: + const ::PeerDescriptor& _internal_sourcepeer() const; + ::PeerDescriptor* _internal_mutable_sourcepeer(); + + public: + // .PeerDescriptor destinationPeer = 3; + bool has_destinationpeer() const; + void clear_destinationpeer() ; + const ::PeerDescriptor& destinationpeer() const; + PROTOBUF_NODISCARD ::PeerDescriptor* release_destinationpeer(); + ::PeerDescriptor* mutable_destinationpeer(); + void set_allocated_destinationpeer(::PeerDescriptor* value); + void unsafe_arena_set_allocated_destinationpeer(::PeerDescriptor* value); + ::PeerDescriptor* unsafe_arena_release_destinationpeer(); + + private: + const ::PeerDescriptor& _internal_destinationpeer() const; + ::PeerDescriptor* _internal_mutable_destinationpeer(); + + public: + // .PeerDescriptor previousPeer = 4; + bool has_previouspeer() const; + void clear_previouspeer() ; + const ::PeerDescriptor& previouspeer() const; + PROTOBUF_NODISCARD ::PeerDescriptor* release_previouspeer(); + ::PeerDescriptor* mutable_previouspeer(); + void set_allocated_previouspeer(::PeerDescriptor* value); + void unsafe_arena_set_allocated_previouspeer(::PeerDescriptor* value); + ::PeerDescriptor* unsafe_arena_release_previouspeer(); + + private: + const ::PeerDescriptor& _internal_previouspeer() const; + ::PeerDescriptor* _internal_mutable_previouspeer(); + + public: + // @@protoc_insertion_point(class_scope:RouteMessageWrapper) + private: + class _Internal; + + friend class ::google::protobuf::MessageLite; + friend class ::google::protobuf::Arena; + template + friend class ::google::protobuf::Arena::InternalHelper; + using InternalArenaConstructable_ = void; + using DestructorSkippable_ = void; + struct Impl_ { + + inline explicit constexpr Impl_( + ::google::protobuf::internal::ConstantInitialized) noexcept; + inline explicit Impl_(::google::protobuf::internal::InternalVisibility visibility, + ::google::protobuf::Arena* arena); + inline explicit Impl_(::google::protobuf::internal::InternalVisibility visibility, + ::google::protobuf::Arena* arena, const Impl_& from); + ::google::protobuf::internal::HasBits<1> _has_bits_; + mutable ::google::protobuf::internal::CachedSize _cached_size_; + ::google::protobuf::internal::ArenaStringPtr requestid_; + ::google::protobuf::internal::ArenaStringPtr message_; + ::PeerDescriptor* sourcepeer_; + ::PeerDescriptor* destinationpeer_; + ::PeerDescriptor* previouspeer_; + PROTOBUF_TSAN_DECLARE_MEMBER + }; + union { Impl_ _impl_; }; + friend struct ::TableStruct_TestProtos_2eproto; +};// ------------------------------------------------------------------- + +class RouteMessageAck final : + public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:RouteMessageAck) */ { + public: + inline RouteMessageAck() : RouteMessageAck(nullptr) {} + ~RouteMessageAck() override; + template + explicit PROTOBUF_CONSTEXPR RouteMessageAck(::google::protobuf::internal::ConstantInitialized); + + inline RouteMessageAck(const RouteMessageAck& from) + : RouteMessageAck(nullptr, from) {} + RouteMessageAck(RouteMessageAck&& from) noexcept + : RouteMessageAck() { + *this = ::std::move(from); + } + + inline RouteMessageAck& operator=(const RouteMessageAck& from) { + CopyFrom(from); + return *this; + } + inline RouteMessageAck& operator=(RouteMessageAck&& from) noexcept { + if (this == &from) return *this; + if (GetArena() == from.GetArena() + #ifdef PROTOBUF_FORCE_COPY_IN_MOVE + && GetArena() != nullptr + #endif // !PROTOBUF_FORCE_COPY_IN_MOVE + ) { + InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + + inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const + ABSL_ATTRIBUTE_LIFETIME_BOUND { + return _internal_metadata_.unknown_fields<::google::protobuf::UnknownFieldSet>(::google::protobuf::UnknownFieldSet::default_instance); + } + inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() + ABSL_ATTRIBUTE_LIFETIME_BOUND { + return _internal_metadata_.mutable_unknown_fields<::google::protobuf::UnknownFieldSet>(); + } + + static const ::google::protobuf::Descriptor* descriptor() { + return GetDescriptor(); + } + static const ::google::protobuf::Descriptor* GetDescriptor() { + return default_instance().GetMetadata().descriptor; + } + static const ::google::protobuf::Reflection* GetReflection() { + return default_instance().GetMetadata().reflection; + } + static const RouteMessageAck& default_instance() { + return *internal_default_instance(); + } + static inline const RouteMessageAck* internal_default_instance() { + return reinterpret_cast( + &_RouteMessageAck_default_instance_); + } + static constexpr int kIndexInFileMessages = + 1; + + friend void swap(RouteMessageAck& a, RouteMessageAck& b) { + a.Swap(&b); + } + inline void Swap(RouteMessageAck* other) { + if (other == this) return; + #ifdef PROTOBUF_FORCE_COPY_IN_SWAP + if (GetArena() != nullptr && + GetArena() == other->GetArena()) { + #else // PROTOBUF_FORCE_COPY_IN_SWAP + if (GetArena() == other->GetArena()) { + #endif // !PROTOBUF_FORCE_COPY_IN_SWAP + InternalSwap(other); + } else { + ::google::protobuf::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(RouteMessageAck* other) { + if (other == this) return; + ABSL_DCHECK(GetArena() == other->GetArena()); + InternalSwap(other); + } + + // implements Message ---------------------------------------------- + + RouteMessageAck* New(::google::protobuf::Arena* arena = nullptr) const final { + return CreateMaybeMessage(arena); + } + int GetCachedSize() const { return _impl_._cached_size_.Get(); } + + private: + ::google::protobuf::internal::CachedSize* AccessCachedSize() const final; + void SharedCtor(::google::protobuf::Arena* arena); + void SharedDtor(); + void InternalSwap(RouteMessageAck* other); + + private: + friend class ::google::protobuf::internal::AnyMetadata; + static ::absl::string_view FullMessageName() { + return "RouteMessageAck"; + } + protected: + explicit RouteMessageAck(::google::protobuf::Arena* arena); + RouteMessageAck(::google::protobuf::Arena* arena, const RouteMessageAck& from); + public: + + ::google::protobuf::Metadata GetMetadata() const final; + + // nested types ---------------------------------------------------- + + // accessors ------------------------------------------------------- + + enum : int { + kRequestIdFieldNumber = 2, + kErrorFieldNumber = 4, + kSourcePeerFieldNumber = 1, + kDestinationPeerFieldNumber = 3, + }; + // string requestId = 2; + void clear_requestid() ; + const std::string& requestid() const; + template + void set_requestid(Arg_&& arg, Args_... args); + std::string* mutable_requestid(); + PROTOBUF_NODISCARD std::string* release_requestid(); + void set_allocated_requestid(std::string* value); + + private: + const std::string& _internal_requestid() const; + inline PROTOBUF_ALWAYS_INLINE void _internal_set_requestid( + const std::string& value); + std::string* _internal_mutable_requestid(); + + public: + // string error = 4; + void clear_error() ; + const std::string& error() const; + template + void set_error(Arg_&& arg, Args_... args); + std::string* mutable_error(); + PROTOBUF_NODISCARD std::string* release_error(); + void set_allocated_error(std::string* value); + + private: + const std::string& _internal_error() const; + inline PROTOBUF_ALWAYS_INLINE void _internal_set_error( + const std::string& value); + std::string* _internal_mutable_error(); + + public: + // .PeerDescriptor sourcePeer = 1; + bool has_sourcepeer() const; + void clear_sourcepeer() ; + const ::PeerDescriptor& sourcepeer() const; + PROTOBUF_NODISCARD ::PeerDescriptor* release_sourcepeer(); + ::PeerDescriptor* mutable_sourcepeer(); + void set_allocated_sourcepeer(::PeerDescriptor* value); + void unsafe_arena_set_allocated_sourcepeer(::PeerDescriptor* value); + ::PeerDescriptor* unsafe_arena_release_sourcepeer(); + + private: + const ::PeerDescriptor& _internal_sourcepeer() const; + ::PeerDescriptor* _internal_mutable_sourcepeer(); + + public: + // .PeerDescriptor destinationPeer = 3; + bool has_destinationpeer() const; + void clear_destinationpeer() ; + const ::PeerDescriptor& destinationpeer() const; + PROTOBUF_NODISCARD ::PeerDescriptor* release_destinationpeer(); + ::PeerDescriptor* mutable_destinationpeer(); + void set_allocated_destinationpeer(::PeerDescriptor* value); + void unsafe_arena_set_allocated_destinationpeer(::PeerDescriptor* value); + ::PeerDescriptor* unsafe_arena_release_destinationpeer(); + + private: + const ::PeerDescriptor& _internal_destinationpeer() const; + ::PeerDescriptor* _internal_mutable_destinationpeer(); + + public: + // @@protoc_insertion_point(class_scope:RouteMessageAck) + private: + class _Internal; + + friend class ::google::protobuf::MessageLite; + friend class ::google::protobuf::Arena; + template + friend class ::google::protobuf::Arena::InternalHelper; + using InternalArenaConstructable_ = void; + using DestructorSkippable_ = void; + struct Impl_ { + + inline explicit constexpr Impl_( + ::google::protobuf::internal::ConstantInitialized) noexcept; + inline explicit Impl_(::google::protobuf::internal::InternalVisibility visibility, + ::google::protobuf::Arena* arena); + inline explicit Impl_(::google::protobuf::internal::InternalVisibility visibility, + ::google::protobuf::Arena* arena, const Impl_& from); + ::google::protobuf::internal::HasBits<1> _has_bits_; + mutable ::google::protobuf::internal::CachedSize _cached_size_; + ::google::protobuf::internal::ArenaStringPtr requestid_; + ::google::protobuf::internal::ArenaStringPtr error_; + ::PeerDescriptor* sourcepeer_; + ::PeerDescriptor* destinationpeer_; + PROTOBUF_TSAN_DECLARE_MEMBER + }; + union { Impl_ _impl_; }; + friend struct ::TableStruct_TestProtos_2eproto; +};// ------------------------------------------------------------------- + +class ClosestPeersResponse final : + public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:ClosestPeersResponse) */ { + public: + inline ClosestPeersResponse() : ClosestPeersResponse(nullptr) {} + ~ClosestPeersResponse() override; + template + explicit PROTOBUF_CONSTEXPR ClosestPeersResponse(::google::protobuf::internal::ConstantInitialized); + + inline ClosestPeersResponse(const ClosestPeersResponse& from) + : ClosestPeersResponse(nullptr, from) {} + ClosestPeersResponse(ClosestPeersResponse&& from) noexcept + : ClosestPeersResponse() { + *this = ::std::move(from); + } + + inline ClosestPeersResponse& operator=(const ClosestPeersResponse& from) { + CopyFrom(from); + return *this; + } + inline ClosestPeersResponse& operator=(ClosestPeersResponse&& from) noexcept { + if (this == &from) return *this; + if (GetArena() == from.GetArena() + #ifdef PROTOBUF_FORCE_COPY_IN_MOVE + && GetArena() != nullptr + #endif // !PROTOBUF_FORCE_COPY_IN_MOVE + ) { + InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + + inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const + ABSL_ATTRIBUTE_LIFETIME_BOUND { + return _internal_metadata_.unknown_fields<::google::protobuf::UnknownFieldSet>(::google::protobuf::UnknownFieldSet::default_instance); + } + inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() + ABSL_ATTRIBUTE_LIFETIME_BOUND { + return _internal_metadata_.mutable_unknown_fields<::google::protobuf::UnknownFieldSet>(); + } + + static const ::google::protobuf::Descriptor* descriptor() { + return GetDescriptor(); + } + static const ::google::protobuf::Descriptor* GetDescriptor() { + return default_instance().GetMetadata().descriptor; + } + static const ::google::protobuf::Reflection* GetReflection() { + return default_instance().GetMetadata().reflection; + } + static const ClosestPeersResponse& default_instance() { + return *internal_default_instance(); + } + static inline const ClosestPeersResponse* internal_default_instance() { + return reinterpret_cast( + &_ClosestPeersResponse_default_instance_); + } + static constexpr int kIndexInFileMessages = + 5; + + friend void swap(ClosestPeersResponse& a, ClosestPeersResponse& b) { + a.Swap(&b); + } + inline void Swap(ClosestPeersResponse* other) { + if (other == this) return; + #ifdef PROTOBUF_FORCE_COPY_IN_SWAP + if (GetArena() != nullptr && + GetArena() == other->GetArena()) { + #else // PROTOBUF_FORCE_COPY_IN_SWAP + if (GetArena() == other->GetArena()) { + #endif // !PROTOBUF_FORCE_COPY_IN_SWAP + InternalSwap(other); + } else { + ::google::protobuf::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(ClosestPeersResponse* other) { + if (other == this) return; + ABSL_DCHECK(GetArena() == other->GetArena()); + InternalSwap(other); + } + + // implements Message ---------------------------------------------- + + ClosestPeersResponse* New(::google::protobuf::Arena* arena = nullptr) const final { + return CreateMaybeMessage(arena); + } + int GetCachedSize() const { return _impl_._cached_size_.Get(); } + + private: + ::google::protobuf::internal::CachedSize* AccessCachedSize() const final; + void SharedCtor(::google::protobuf::Arena* arena); + void SharedDtor(); + void InternalSwap(ClosestPeersResponse* other); + + private: + friend class ::google::protobuf::internal::AnyMetadata; + static ::absl::string_view FullMessageName() { + return "ClosestPeersResponse"; + } + protected: + explicit ClosestPeersResponse(::google::protobuf::Arena* arena); + ClosestPeersResponse(::google::protobuf::Arena* arena, const ClosestPeersResponse& from); + public: + + ::google::protobuf::Metadata GetMetadata() const final; + + // nested types ---------------------------------------------------- + + // accessors ------------------------------------------------------- + + enum : int { + kPeersFieldNumber = 1, + kRequestIdFieldNumber = 2, + }; + // repeated .PeerDescriptor peers = 1; + int peers_size() const; + private: + int _internal_peers_size() const; + + public: + void clear_peers() ; + ::PeerDescriptor* mutable_peers(int index); + ::google::protobuf::RepeatedPtrField< ::PeerDescriptor >* + mutable_peers(); + private: + const ::google::protobuf::RepeatedPtrField<::PeerDescriptor>& _internal_peers() const; + ::google::protobuf::RepeatedPtrField<::PeerDescriptor>* _internal_mutable_peers(); + public: + const ::PeerDescriptor& peers(int index) const; + ::PeerDescriptor* add_peers(); + const ::google::protobuf::RepeatedPtrField< ::PeerDescriptor >& + peers() const; + // string requestId = 2; + void clear_requestid() ; + const std::string& requestid() const; + template + void set_requestid(Arg_&& arg, Args_... args); + std::string* mutable_requestid(); + PROTOBUF_NODISCARD std::string* release_requestid(); + void set_allocated_requestid(std::string* value); + + private: + const std::string& _internal_requestid() const; + inline PROTOBUF_ALWAYS_INLINE void _internal_set_requestid( + const std::string& value); + std::string* _internal_mutable_requestid(); + + public: + // @@protoc_insertion_point(class_scope:ClosestPeersResponse) + private: + class _Internal; + + friend class ::google::protobuf::MessageLite; + friend class ::google::protobuf::Arena; + template + friend class ::google::protobuf::Arena::InternalHelper; + using InternalArenaConstructable_ = void; + using DestructorSkippable_ = void; + struct Impl_ { + + inline explicit constexpr Impl_( + ::google::protobuf::internal::ConstantInitialized) noexcept; + inline explicit Impl_(::google::protobuf::internal::InternalVisibility visibility, + ::google::protobuf::Arena* arena); + inline explicit Impl_(::google::protobuf::internal::InternalVisibility visibility, + ::google::protobuf::Arena* arena, const Impl_& from); + ::google::protobuf::RepeatedPtrField< ::PeerDescriptor > peers_; + ::google::protobuf::internal::ArenaStringPtr requestid_; + mutable ::google::protobuf::internal::CachedSize _cached_size_; + PROTOBUF_TSAN_DECLARE_MEMBER + }; + union { Impl_ _impl_; }; + friend struct ::TableStruct_TestProtos_2eproto; +};// ------------------------------------------------------------------- + +class ClosestPeersRequest final : + public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:ClosestPeersRequest) */ { + public: + inline ClosestPeersRequest() : ClosestPeersRequest(nullptr) {} + ~ClosestPeersRequest() override; + template + explicit PROTOBUF_CONSTEXPR ClosestPeersRequest(::google::protobuf::internal::ConstantInitialized); + + inline ClosestPeersRequest(const ClosestPeersRequest& from) + : ClosestPeersRequest(nullptr, from) {} + ClosestPeersRequest(ClosestPeersRequest&& from) noexcept + : ClosestPeersRequest() { + *this = ::std::move(from); + } + + inline ClosestPeersRequest& operator=(const ClosestPeersRequest& from) { + CopyFrom(from); + return *this; + } + inline ClosestPeersRequest& operator=(ClosestPeersRequest&& from) noexcept { + if (this == &from) return *this; + if (GetArena() == from.GetArena() + #ifdef PROTOBUF_FORCE_COPY_IN_MOVE + && GetArena() != nullptr + #endif // !PROTOBUF_FORCE_COPY_IN_MOVE + ) { + InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + + inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const + ABSL_ATTRIBUTE_LIFETIME_BOUND { + return _internal_metadata_.unknown_fields<::google::protobuf::UnknownFieldSet>(::google::protobuf::UnknownFieldSet::default_instance); + } + inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() + ABSL_ATTRIBUTE_LIFETIME_BOUND { + return _internal_metadata_.mutable_unknown_fields<::google::protobuf::UnknownFieldSet>(); + } + + static const ::google::protobuf::Descriptor* descriptor() { + return GetDescriptor(); + } + static const ::google::protobuf::Descriptor* GetDescriptor() { + return default_instance().GetMetadata().descriptor; + } + static const ::google::protobuf::Reflection* GetReflection() { + return default_instance().GetMetadata().reflection; + } + static const ClosestPeersRequest& default_instance() { + return *internal_default_instance(); + } + static inline const ClosestPeersRequest* internal_default_instance() { + return reinterpret_cast( + &_ClosestPeersRequest_default_instance_); + } + static constexpr int kIndexInFileMessages = + 4; + + friend void swap(ClosestPeersRequest& a, ClosestPeersRequest& b) { + a.Swap(&b); + } + inline void Swap(ClosestPeersRequest* other) { + if (other == this) return; + #ifdef PROTOBUF_FORCE_COPY_IN_SWAP + if (GetArena() != nullptr && + GetArena() == other->GetArena()) { + #else // PROTOBUF_FORCE_COPY_IN_SWAP + if (GetArena() == other->GetArena()) { + #endif // !PROTOBUF_FORCE_COPY_IN_SWAP + InternalSwap(other); + } else { + ::google::protobuf::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(ClosestPeersRequest* other) { + if (other == this) return; + ABSL_DCHECK(GetArena() == other->GetArena()); + InternalSwap(other); + } + + // implements Message ---------------------------------------------- + + ClosestPeersRequest* New(::google::protobuf::Arena* arena = nullptr) const final { + return CreateMaybeMessage(arena); + } + int GetCachedSize() const { return _impl_._cached_size_.Get(); } + + private: + ::google::protobuf::internal::CachedSize* AccessCachedSize() const final; + void SharedCtor(::google::protobuf::Arena* arena); + void SharedDtor(); + void InternalSwap(ClosestPeersRequest* other); + + private: + friend class ::google::protobuf::internal::AnyMetadata; + static ::absl::string_view FullMessageName() { + return "ClosestPeersRequest"; + } + protected: + explicit ClosestPeersRequest(::google::protobuf::Arena* arena); + ClosestPeersRequest(::google::protobuf::Arena* arena, const ClosestPeersRequest& from); + public: + + ::google::protobuf::Metadata GetMetadata() const final; + + // nested types ---------------------------------------------------- + + // accessors ------------------------------------------------------- + + enum : int { + kRequestIdFieldNumber = 2, + kPeerDescriptorFieldNumber = 1, + }; + // string requestId = 2; + void clear_requestid() ; + const std::string& requestid() const; + template + void set_requestid(Arg_&& arg, Args_... args); + std::string* mutable_requestid(); + PROTOBUF_NODISCARD std::string* release_requestid(); + void set_allocated_requestid(std::string* value); + + private: + const std::string& _internal_requestid() const; + inline PROTOBUF_ALWAYS_INLINE void _internal_set_requestid( + const std::string& value); + std::string* _internal_mutable_requestid(); + + public: + // .PeerDescriptor peerDescriptor = 1; + bool has_peerdescriptor() const; + void clear_peerdescriptor() ; + const ::PeerDescriptor& peerdescriptor() const; + PROTOBUF_NODISCARD ::PeerDescriptor* release_peerdescriptor(); + ::PeerDescriptor* mutable_peerdescriptor(); + void set_allocated_peerdescriptor(::PeerDescriptor* value); + void unsafe_arena_set_allocated_peerdescriptor(::PeerDescriptor* value); + ::PeerDescriptor* unsafe_arena_release_peerdescriptor(); + + private: + const ::PeerDescriptor& _internal_peerdescriptor() const; + ::PeerDescriptor* _internal_mutable_peerdescriptor(); + + public: + // @@protoc_insertion_point(class_scope:ClosestPeersRequest) + private: + class _Internal; + + friend class ::google::protobuf::MessageLite; + friend class ::google::protobuf::Arena; + template + friend class ::google::protobuf::Arena::InternalHelper; + using InternalArenaConstructable_ = void; + using DestructorSkippable_ = void; + struct Impl_ { + + inline explicit constexpr Impl_( + ::google::protobuf::internal::ConstantInitialized) noexcept; + inline explicit Impl_(::google::protobuf::internal::InternalVisibility visibility, + ::google::protobuf::Arena* arena); + inline explicit Impl_(::google::protobuf::internal::InternalVisibility visibility, + ::google::protobuf::Arena* arena, const Impl_& from); + ::google::protobuf::internal::HasBits<1> _has_bits_; + mutable ::google::protobuf::internal::CachedSize _cached_size_; + ::google::protobuf::internal::ArenaStringPtr requestid_; + ::PeerDescriptor* peerdescriptor_; + PROTOBUF_TSAN_DECLARE_MEMBER + }; + union { Impl_ _impl_; }; + friend struct ::TableStruct_TestProtos_2eproto; +}; + +// =================================================================== + + + + +// =================================================================== + + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wstrict-aliasing" +#endif // __GNUC__ +// ------------------------------------------------------------------- + +// RouteMessageWrapper + +// .PeerDescriptor sourcePeer = 1; +inline bool RouteMessageWrapper::has_sourcepeer() const { + bool value = (_impl_._has_bits_[0] & 0x00000001u) != 0; + PROTOBUF_ASSUME(!value || _impl_.sourcepeer_ != nullptr); + return value; +} +inline void RouteMessageWrapper::clear_sourcepeer() { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + if (_impl_.sourcepeer_ != nullptr) _impl_.sourcepeer_->Clear(); + _impl_._has_bits_[0] &= ~0x00000001u; +} +inline const ::PeerDescriptor& RouteMessageWrapper::_internal_sourcepeer() const { + PROTOBUF_TSAN_READ(&_impl_._tsan_detect_race); + const ::PeerDescriptor* p = _impl_.sourcepeer_; + return p != nullptr ? *p : reinterpret_cast(::_PeerDescriptor_default_instance_); +} +inline const ::PeerDescriptor& RouteMessageWrapper::sourcepeer() const ABSL_ATTRIBUTE_LIFETIME_BOUND { + // @@protoc_insertion_point(field_get:RouteMessageWrapper.sourcePeer) + return _internal_sourcepeer(); +} +inline void RouteMessageWrapper::unsafe_arena_set_allocated_sourcepeer(::PeerDescriptor* value) { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + if (GetArena() == nullptr) { + delete reinterpret_cast<::google::protobuf::MessageLite*>(_impl_.sourcepeer_); + } + _impl_.sourcepeer_ = reinterpret_cast<::PeerDescriptor*>(value); + if (value != nullptr) { + _impl_._has_bits_[0] |= 0x00000001u; + } else { + _impl_._has_bits_[0] &= ~0x00000001u; + } + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:RouteMessageWrapper.sourcePeer) +} +inline ::PeerDescriptor* RouteMessageWrapper::release_sourcepeer() { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + + _impl_._has_bits_[0] &= ~0x00000001u; + ::PeerDescriptor* released = _impl_.sourcepeer_; + _impl_.sourcepeer_ = nullptr; +#ifdef PROTOBUF_FORCE_COPY_IN_RELEASE + auto* old = reinterpret_cast<::google::protobuf::MessageLite*>(released); + released = ::google::protobuf::internal::DuplicateIfNonNull(released); + if (GetArena() == nullptr) { + delete old; + } +#else // PROTOBUF_FORCE_COPY_IN_RELEASE + if (GetArena() != nullptr) { + released = ::google::protobuf::internal::DuplicateIfNonNull(released); + } +#endif // !PROTOBUF_FORCE_COPY_IN_RELEASE + return released; +} +inline ::PeerDescriptor* RouteMessageWrapper::unsafe_arena_release_sourcepeer() { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + // @@protoc_insertion_point(field_release:RouteMessageWrapper.sourcePeer) + + _impl_._has_bits_[0] &= ~0x00000001u; + ::PeerDescriptor* temp = _impl_.sourcepeer_; + _impl_.sourcepeer_ = nullptr; + return temp; +} +inline ::PeerDescriptor* RouteMessageWrapper::_internal_mutable_sourcepeer() { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + _impl_._has_bits_[0] |= 0x00000001u; + if (_impl_.sourcepeer_ == nullptr) { + auto* p = CreateMaybeMessage<::PeerDescriptor>(GetArena()); + _impl_.sourcepeer_ = reinterpret_cast<::PeerDescriptor*>(p); + } + return _impl_.sourcepeer_; +} +inline ::PeerDescriptor* RouteMessageWrapper::mutable_sourcepeer() ABSL_ATTRIBUTE_LIFETIME_BOUND { + ::PeerDescriptor* _msg = _internal_mutable_sourcepeer(); + // @@protoc_insertion_point(field_mutable:RouteMessageWrapper.sourcePeer) + return _msg; +} +inline void RouteMessageWrapper::set_allocated_sourcepeer(::PeerDescriptor* value) { + ::google::protobuf::Arena* message_arena = GetArena(); + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + if (message_arena == nullptr) { + delete reinterpret_cast<::PeerDescriptor*>(_impl_.sourcepeer_); + } + + if (value != nullptr) { + ::google::protobuf::Arena* submessage_arena = reinterpret_cast<::PeerDescriptor*>(value)->GetArena(); + if (message_arena != submessage_arena) { + value = ::google::protobuf::internal::GetOwnedMessage(message_arena, value, submessage_arena); + } + _impl_._has_bits_[0] |= 0x00000001u; + } else { + _impl_._has_bits_[0] &= ~0x00000001u; + } + + _impl_.sourcepeer_ = reinterpret_cast<::PeerDescriptor*>(value); + // @@protoc_insertion_point(field_set_allocated:RouteMessageWrapper.sourcePeer) +} + +// string requestId = 2; +inline void RouteMessageWrapper::clear_requestid() { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + _impl_.requestid_.ClearToEmpty(); +} +inline const std::string& RouteMessageWrapper::requestid() const + ABSL_ATTRIBUTE_LIFETIME_BOUND { + // @@protoc_insertion_point(field_get:RouteMessageWrapper.requestId) + return _internal_requestid(); +} +template +inline PROTOBUF_ALWAYS_INLINE void RouteMessageWrapper::set_requestid(Arg_&& arg, + Args_... args) { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + ; + _impl_.requestid_.Set(static_cast(arg), args..., GetArena()); + // @@protoc_insertion_point(field_set:RouteMessageWrapper.requestId) +} +inline std::string* RouteMessageWrapper::mutable_requestid() ABSL_ATTRIBUTE_LIFETIME_BOUND { + std::string* _s = _internal_mutable_requestid(); + // @@protoc_insertion_point(field_mutable:RouteMessageWrapper.requestId) + return _s; +} +inline const std::string& RouteMessageWrapper::_internal_requestid() const { + PROTOBUF_TSAN_READ(&_impl_._tsan_detect_race); + return _impl_.requestid_.Get(); +} +inline void RouteMessageWrapper::_internal_set_requestid(const std::string& value) { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + ; + _impl_.requestid_.Set(value, GetArena()); +} +inline std::string* RouteMessageWrapper::_internal_mutable_requestid() { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + ; + return _impl_.requestid_.Mutable( GetArena()); +} +inline std::string* RouteMessageWrapper::release_requestid() { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + // @@protoc_insertion_point(field_release:RouteMessageWrapper.requestId) + return _impl_.requestid_.Release(); +} +inline void RouteMessageWrapper::set_allocated_requestid(std::string* value) { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + _impl_.requestid_.SetAllocated(value, GetArena()); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (_impl_.requestid_.IsDefault()) { + _impl_.requestid_.Set("", GetArena()); + } + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + // @@protoc_insertion_point(field_set_allocated:RouteMessageWrapper.requestId) +} + +// .PeerDescriptor destinationPeer = 3; +inline bool RouteMessageWrapper::has_destinationpeer() const { + bool value = (_impl_._has_bits_[0] & 0x00000002u) != 0; + PROTOBUF_ASSUME(!value || _impl_.destinationpeer_ != nullptr); + return value; +} +inline void RouteMessageWrapper::clear_destinationpeer() { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + if (_impl_.destinationpeer_ != nullptr) _impl_.destinationpeer_->Clear(); + _impl_._has_bits_[0] &= ~0x00000002u; +} +inline const ::PeerDescriptor& RouteMessageWrapper::_internal_destinationpeer() const { + PROTOBUF_TSAN_READ(&_impl_._tsan_detect_race); + const ::PeerDescriptor* p = _impl_.destinationpeer_; + return p != nullptr ? *p : reinterpret_cast(::_PeerDescriptor_default_instance_); +} +inline const ::PeerDescriptor& RouteMessageWrapper::destinationpeer() const ABSL_ATTRIBUTE_LIFETIME_BOUND { + // @@protoc_insertion_point(field_get:RouteMessageWrapper.destinationPeer) + return _internal_destinationpeer(); +} +inline void RouteMessageWrapper::unsafe_arena_set_allocated_destinationpeer(::PeerDescriptor* value) { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + if (GetArena() == nullptr) { + delete reinterpret_cast<::google::protobuf::MessageLite*>(_impl_.destinationpeer_); + } + _impl_.destinationpeer_ = reinterpret_cast<::PeerDescriptor*>(value); + if (value != nullptr) { + _impl_._has_bits_[0] |= 0x00000002u; + } else { + _impl_._has_bits_[0] &= ~0x00000002u; + } + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:RouteMessageWrapper.destinationPeer) +} +inline ::PeerDescriptor* RouteMessageWrapper::release_destinationpeer() { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + + _impl_._has_bits_[0] &= ~0x00000002u; + ::PeerDescriptor* released = _impl_.destinationpeer_; + _impl_.destinationpeer_ = nullptr; +#ifdef PROTOBUF_FORCE_COPY_IN_RELEASE + auto* old = reinterpret_cast<::google::protobuf::MessageLite*>(released); + released = ::google::protobuf::internal::DuplicateIfNonNull(released); + if (GetArena() == nullptr) { + delete old; + } +#else // PROTOBUF_FORCE_COPY_IN_RELEASE + if (GetArena() != nullptr) { + released = ::google::protobuf::internal::DuplicateIfNonNull(released); + } +#endif // !PROTOBUF_FORCE_COPY_IN_RELEASE + return released; +} +inline ::PeerDescriptor* RouteMessageWrapper::unsafe_arena_release_destinationpeer() { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + // @@protoc_insertion_point(field_release:RouteMessageWrapper.destinationPeer) + + _impl_._has_bits_[0] &= ~0x00000002u; + ::PeerDescriptor* temp = _impl_.destinationpeer_; + _impl_.destinationpeer_ = nullptr; + return temp; +} +inline ::PeerDescriptor* RouteMessageWrapper::_internal_mutable_destinationpeer() { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + _impl_._has_bits_[0] |= 0x00000002u; + if (_impl_.destinationpeer_ == nullptr) { + auto* p = CreateMaybeMessage<::PeerDescriptor>(GetArena()); + _impl_.destinationpeer_ = reinterpret_cast<::PeerDescriptor*>(p); + } + return _impl_.destinationpeer_; +} +inline ::PeerDescriptor* RouteMessageWrapper::mutable_destinationpeer() ABSL_ATTRIBUTE_LIFETIME_BOUND { + ::PeerDescriptor* _msg = _internal_mutable_destinationpeer(); + // @@protoc_insertion_point(field_mutable:RouteMessageWrapper.destinationPeer) + return _msg; +} +inline void RouteMessageWrapper::set_allocated_destinationpeer(::PeerDescriptor* value) { + ::google::protobuf::Arena* message_arena = GetArena(); + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + if (message_arena == nullptr) { + delete reinterpret_cast<::PeerDescriptor*>(_impl_.destinationpeer_); + } + + if (value != nullptr) { + ::google::protobuf::Arena* submessage_arena = reinterpret_cast<::PeerDescriptor*>(value)->GetArena(); + if (message_arena != submessage_arena) { + value = ::google::protobuf::internal::GetOwnedMessage(message_arena, value, submessage_arena); + } + _impl_._has_bits_[0] |= 0x00000002u; + } else { + _impl_._has_bits_[0] &= ~0x00000002u; + } + + _impl_.destinationpeer_ = reinterpret_cast<::PeerDescriptor*>(value); + // @@protoc_insertion_point(field_set_allocated:RouteMessageWrapper.destinationPeer) +} + +// .PeerDescriptor previousPeer = 4; +inline bool RouteMessageWrapper::has_previouspeer() const { + bool value = (_impl_._has_bits_[0] & 0x00000004u) != 0; + PROTOBUF_ASSUME(!value || _impl_.previouspeer_ != nullptr); + return value; +} +inline void RouteMessageWrapper::clear_previouspeer() { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + if (_impl_.previouspeer_ != nullptr) _impl_.previouspeer_->Clear(); + _impl_._has_bits_[0] &= ~0x00000004u; +} +inline const ::PeerDescriptor& RouteMessageWrapper::_internal_previouspeer() const { + PROTOBUF_TSAN_READ(&_impl_._tsan_detect_race); + const ::PeerDescriptor* p = _impl_.previouspeer_; + return p != nullptr ? *p : reinterpret_cast(::_PeerDescriptor_default_instance_); +} +inline const ::PeerDescriptor& RouteMessageWrapper::previouspeer() const ABSL_ATTRIBUTE_LIFETIME_BOUND { + // @@protoc_insertion_point(field_get:RouteMessageWrapper.previousPeer) + return _internal_previouspeer(); +} +inline void RouteMessageWrapper::unsafe_arena_set_allocated_previouspeer(::PeerDescriptor* value) { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + if (GetArena() == nullptr) { + delete reinterpret_cast<::google::protobuf::MessageLite*>(_impl_.previouspeer_); + } + _impl_.previouspeer_ = reinterpret_cast<::PeerDescriptor*>(value); + if (value != nullptr) { + _impl_._has_bits_[0] |= 0x00000004u; + } else { + _impl_._has_bits_[0] &= ~0x00000004u; + } + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:RouteMessageWrapper.previousPeer) +} +inline ::PeerDescriptor* RouteMessageWrapper::release_previouspeer() { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + + _impl_._has_bits_[0] &= ~0x00000004u; + ::PeerDescriptor* released = _impl_.previouspeer_; + _impl_.previouspeer_ = nullptr; +#ifdef PROTOBUF_FORCE_COPY_IN_RELEASE + auto* old = reinterpret_cast<::google::protobuf::MessageLite*>(released); + released = ::google::protobuf::internal::DuplicateIfNonNull(released); + if (GetArena() == nullptr) { + delete old; + } +#else // PROTOBUF_FORCE_COPY_IN_RELEASE + if (GetArena() != nullptr) { + released = ::google::protobuf::internal::DuplicateIfNonNull(released); + } +#endif // !PROTOBUF_FORCE_COPY_IN_RELEASE + return released; +} +inline ::PeerDescriptor* RouteMessageWrapper::unsafe_arena_release_previouspeer() { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + // @@protoc_insertion_point(field_release:RouteMessageWrapper.previousPeer) + + _impl_._has_bits_[0] &= ~0x00000004u; + ::PeerDescriptor* temp = _impl_.previouspeer_; + _impl_.previouspeer_ = nullptr; + return temp; +} +inline ::PeerDescriptor* RouteMessageWrapper::_internal_mutable_previouspeer() { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + _impl_._has_bits_[0] |= 0x00000004u; + if (_impl_.previouspeer_ == nullptr) { + auto* p = CreateMaybeMessage<::PeerDescriptor>(GetArena()); + _impl_.previouspeer_ = reinterpret_cast<::PeerDescriptor*>(p); + } + return _impl_.previouspeer_; +} +inline ::PeerDescriptor* RouteMessageWrapper::mutable_previouspeer() ABSL_ATTRIBUTE_LIFETIME_BOUND { + ::PeerDescriptor* _msg = _internal_mutable_previouspeer(); + // @@protoc_insertion_point(field_mutable:RouteMessageWrapper.previousPeer) + return _msg; +} +inline void RouteMessageWrapper::set_allocated_previouspeer(::PeerDescriptor* value) { + ::google::protobuf::Arena* message_arena = GetArena(); + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + if (message_arena == nullptr) { + delete reinterpret_cast<::PeerDescriptor*>(_impl_.previouspeer_); + } + + if (value != nullptr) { + ::google::protobuf::Arena* submessage_arena = reinterpret_cast<::PeerDescriptor*>(value)->GetArena(); + if (message_arena != submessage_arena) { + value = ::google::protobuf::internal::GetOwnedMessage(message_arena, value, submessage_arena); + } + _impl_._has_bits_[0] |= 0x00000004u; + } else { + _impl_._has_bits_[0] &= ~0x00000004u; + } + + _impl_.previouspeer_ = reinterpret_cast<::PeerDescriptor*>(value); + // @@protoc_insertion_point(field_set_allocated:RouteMessageWrapper.previousPeer) +} + +// bytes message = 5; +inline void RouteMessageWrapper::clear_message() { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + _impl_.message_.ClearToEmpty(); +} +inline const std::string& RouteMessageWrapper::message() const + ABSL_ATTRIBUTE_LIFETIME_BOUND { + // @@protoc_insertion_point(field_get:RouteMessageWrapper.message) + return _internal_message(); +} +template +inline PROTOBUF_ALWAYS_INLINE void RouteMessageWrapper::set_message(Arg_&& arg, + Args_... args) { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + ; + _impl_.message_.SetBytes(static_cast(arg), args..., GetArena()); + // @@protoc_insertion_point(field_set:RouteMessageWrapper.message) +} +inline std::string* RouteMessageWrapper::mutable_message() ABSL_ATTRIBUTE_LIFETIME_BOUND { + std::string* _s = _internal_mutable_message(); + // @@protoc_insertion_point(field_mutable:RouteMessageWrapper.message) + return _s; +} +inline const std::string& RouteMessageWrapper::_internal_message() const { + PROTOBUF_TSAN_READ(&_impl_._tsan_detect_race); + return _impl_.message_.Get(); +} +inline void RouteMessageWrapper::_internal_set_message(const std::string& value) { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + ; + _impl_.message_.Set(value, GetArena()); +} +inline std::string* RouteMessageWrapper::_internal_mutable_message() { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + ; + return _impl_.message_.Mutable( GetArena()); +} +inline std::string* RouteMessageWrapper::release_message() { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + // @@protoc_insertion_point(field_release:RouteMessageWrapper.message) + return _impl_.message_.Release(); +} +inline void RouteMessageWrapper::set_allocated_message(std::string* value) { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + _impl_.message_.SetAllocated(value, GetArena()); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (_impl_.message_.IsDefault()) { + _impl_.message_.Set("", GetArena()); + } + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + // @@protoc_insertion_point(field_set_allocated:RouteMessageWrapper.message) +} + +// ------------------------------------------------------------------- + +// RouteMessageAck + +// .PeerDescriptor sourcePeer = 1; +inline bool RouteMessageAck::has_sourcepeer() const { + bool value = (_impl_._has_bits_[0] & 0x00000001u) != 0; + PROTOBUF_ASSUME(!value || _impl_.sourcepeer_ != nullptr); + return value; +} +inline void RouteMessageAck::clear_sourcepeer() { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + if (_impl_.sourcepeer_ != nullptr) _impl_.sourcepeer_->Clear(); + _impl_._has_bits_[0] &= ~0x00000001u; +} +inline const ::PeerDescriptor& RouteMessageAck::_internal_sourcepeer() const { + PROTOBUF_TSAN_READ(&_impl_._tsan_detect_race); + const ::PeerDescriptor* p = _impl_.sourcepeer_; + return p != nullptr ? *p : reinterpret_cast(::_PeerDescriptor_default_instance_); +} +inline const ::PeerDescriptor& RouteMessageAck::sourcepeer() const ABSL_ATTRIBUTE_LIFETIME_BOUND { + // @@protoc_insertion_point(field_get:RouteMessageAck.sourcePeer) + return _internal_sourcepeer(); +} +inline void RouteMessageAck::unsafe_arena_set_allocated_sourcepeer(::PeerDescriptor* value) { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + if (GetArena() == nullptr) { + delete reinterpret_cast<::google::protobuf::MessageLite*>(_impl_.sourcepeer_); + } + _impl_.sourcepeer_ = reinterpret_cast<::PeerDescriptor*>(value); + if (value != nullptr) { + _impl_._has_bits_[0] |= 0x00000001u; + } else { + _impl_._has_bits_[0] &= ~0x00000001u; + } + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:RouteMessageAck.sourcePeer) +} +inline ::PeerDescriptor* RouteMessageAck::release_sourcepeer() { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + + _impl_._has_bits_[0] &= ~0x00000001u; + ::PeerDescriptor* released = _impl_.sourcepeer_; + _impl_.sourcepeer_ = nullptr; +#ifdef PROTOBUF_FORCE_COPY_IN_RELEASE + auto* old = reinterpret_cast<::google::protobuf::MessageLite*>(released); + released = ::google::protobuf::internal::DuplicateIfNonNull(released); + if (GetArena() == nullptr) { + delete old; + } +#else // PROTOBUF_FORCE_COPY_IN_RELEASE + if (GetArena() != nullptr) { + released = ::google::protobuf::internal::DuplicateIfNonNull(released); + } +#endif // !PROTOBUF_FORCE_COPY_IN_RELEASE + return released; +} +inline ::PeerDescriptor* RouteMessageAck::unsafe_arena_release_sourcepeer() { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + // @@protoc_insertion_point(field_release:RouteMessageAck.sourcePeer) + + _impl_._has_bits_[0] &= ~0x00000001u; + ::PeerDescriptor* temp = _impl_.sourcepeer_; + _impl_.sourcepeer_ = nullptr; + return temp; +} +inline ::PeerDescriptor* RouteMessageAck::_internal_mutable_sourcepeer() { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + _impl_._has_bits_[0] |= 0x00000001u; + if (_impl_.sourcepeer_ == nullptr) { + auto* p = CreateMaybeMessage<::PeerDescriptor>(GetArena()); + _impl_.sourcepeer_ = reinterpret_cast<::PeerDescriptor*>(p); + } + return _impl_.sourcepeer_; +} +inline ::PeerDescriptor* RouteMessageAck::mutable_sourcepeer() ABSL_ATTRIBUTE_LIFETIME_BOUND { + ::PeerDescriptor* _msg = _internal_mutable_sourcepeer(); + // @@protoc_insertion_point(field_mutable:RouteMessageAck.sourcePeer) + return _msg; +} +inline void RouteMessageAck::set_allocated_sourcepeer(::PeerDescriptor* value) { + ::google::protobuf::Arena* message_arena = GetArena(); + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + if (message_arena == nullptr) { + delete reinterpret_cast<::PeerDescriptor*>(_impl_.sourcepeer_); + } + + if (value != nullptr) { + ::google::protobuf::Arena* submessage_arena = reinterpret_cast<::PeerDescriptor*>(value)->GetArena(); + if (message_arena != submessage_arena) { + value = ::google::protobuf::internal::GetOwnedMessage(message_arena, value, submessage_arena); + } + _impl_._has_bits_[0] |= 0x00000001u; + } else { + _impl_._has_bits_[0] &= ~0x00000001u; + } + + _impl_.sourcepeer_ = reinterpret_cast<::PeerDescriptor*>(value); + // @@protoc_insertion_point(field_set_allocated:RouteMessageAck.sourcePeer) +} + +// string requestId = 2; +inline void RouteMessageAck::clear_requestid() { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + _impl_.requestid_.ClearToEmpty(); +} +inline const std::string& RouteMessageAck::requestid() const + ABSL_ATTRIBUTE_LIFETIME_BOUND { + // @@protoc_insertion_point(field_get:RouteMessageAck.requestId) + return _internal_requestid(); +} +template +inline PROTOBUF_ALWAYS_INLINE void RouteMessageAck::set_requestid(Arg_&& arg, + Args_... args) { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + ; + _impl_.requestid_.Set(static_cast(arg), args..., GetArena()); + // @@protoc_insertion_point(field_set:RouteMessageAck.requestId) +} +inline std::string* RouteMessageAck::mutable_requestid() ABSL_ATTRIBUTE_LIFETIME_BOUND { + std::string* _s = _internal_mutable_requestid(); + // @@protoc_insertion_point(field_mutable:RouteMessageAck.requestId) + return _s; +} +inline const std::string& RouteMessageAck::_internal_requestid() const { + PROTOBUF_TSAN_READ(&_impl_._tsan_detect_race); + return _impl_.requestid_.Get(); +} +inline void RouteMessageAck::_internal_set_requestid(const std::string& value) { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + ; + _impl_.requestid_.Set(value, GetArena()); +} +inline std::string* RouteMessageAck::_internal_mutable_requestid() { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + ; + return _impl_.requestid_.Mutable( GetArena()); +} +inline std::string* RouteMessageAck::release_requestid() { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + // @@protoc_insertion_point(field_release:RouteMessageAck.requestId) + return _impl_.requestid_.Release(); +} +inline void RouteMessageAck::set_allocated_requestid(std::string* value) { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + _impl_.requestid_.SetAllocated(value, GetArena()); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (_impl_.requestid_.IsDefault()) { + _impl_.requestid_.Set("", GetArena()); + } + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + // @@protoc_insertion_point(field_set_allocated:RouteMessageAck.requestId) +} + +// .PeerDescriptor destinationPeer = 3; +inline bool RouteMessageAck::has_destinationpeer() const { + bool value = (_impl_._has_bits_[0] & 0x00000002u) != 0; + PROTOBUF_ASSUME(!value || _impl_.destinationpeer_ != nullptr); + return value; +} +inline void RouteMessageAck::clear_destinationpeer() { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + if (_impl_.destinationpeer_ != nullptr) _impl_.destinationpeer_->Clear(); + _impl_._has_bits_[0] &= ~0x00000002u; +} +inline const ::PeerDescriptor& RouteMessageAck::_internal_destinationpeer() const { + PROTOBUF_TSAN_READ(&_impl_._tsan_detect_race); + const ::PeerDescriptor* p = _impl_.destinationpeer_; + return p != nullptr ? *p : reinterpret_cast(::_PeerDescriptor_default_instance_); +} +inline const ::PeerDescriptor& RouteMessageAck::destinationpeer() const ABSL_ATTRIBUTE_LIFETIME_BOUND { + // @@protoc_insertion_point(field_get:RouteMessageAck.destinationPeer) + return _internal_destinationpeer(); +} +inline void RouteMessageAck::unsafe_arena_set_allocated_destinationpeer(::PeerDescriptor* value) { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + if (GetArena() == nullptr) { + delete reinterpret_cast<::google::protobuf::MessageLite*>(_impl_.destinationpeer_); + } + _impl_.destinationpeer_ = reinterpret_cast<::PeerDescriptor*>(value); + if (value != nullptr) { + _impl_._has_bits_[0] |= 0x00000002u; + } else { + _impl_._has_bits_[0] &= ~0x00000002u; + } + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:RouteMessageAck.destinationPeer) +} +inline ::PeerDescriptor* RouteMessageAck::release_destinationpeer() { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + + _impl_._has_bits_[0] &= ~0x00000002u; + ::PeerDescriptor* released = _impl_.destinationpeer_; + _impl_.destinationpeer_ = nullptr; +#ifdef PROTOBUF_FORCE_COPY_IN_RELEASE + auto* old = reinterpret_cast<::google::protobuf::MessageLite*>(released); + released = ::google::protobuf::internal::DuplicateIfNonNull(released); + if (GetArena() == nullptr) { + delete old; + } +#else // PROTOBUF_FORCE_COPY_IN_RELEASE + if (GetArena() != nullptr) { + released = ::google::protobuf::internal::DuplicateIfNonNull(released); + } +#endif // !PROTOBUF_FORCE_COPY_IN_RELEASE + return released; +} +inline ::PeerDescriptor* RouteMessageAck::unsafe_arena_release_destinationpeer() { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + // @@protoc_insertion_point(field_release:RouteMessageAck.destinationPeer) + + _impl_._has_bits_[0] &= ~0x00000002u; + ::PeerDescriptor* temp = _impl_.destinationpeer_; + _impl_.destinationpeer_ = nullptr; + return temp; +} +inline ::PeerDescriptor* RouteMessageAck::_internal_mutable_destinationpeer() { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + _impl_._has_bits_[0] |= 0x00000002u; + if (_impl_.destinationpeer_ == nullptr) { + auto* p = CreateMaybeMessage<::PeerDescriptor>(GetArena()); + _impl_.destinationpeer_ = reinterpret_cast<::PeerDescriptor*>(p); + } + return _impl_.destinationpeer_; +} +inline ::PeerDescriptor* RouteMessageAck::mutable_destinationpeer() ABSL_ATTRIBUTE_LIFETIME_BOUND { + ::PeerDescriptor* _msg = _internal_mutable_destinationpeer(); + // @@protoc_insertion_point(field_mutable:RouteMessageAck.destinationPeer) + return _msg; +} +inline void RouteMessageAck::set_allocated_destinationpeer(::PeerDescriptor* value) { + ::google::protobuf::Arena* message_arena = GetArena(); + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + if (message_arena == nullptr) { + delete reinterpret_cast<::PeerDescriptor*>(_impl_.destinationpeer_); + } + + if (value != nullptr) { + ::google::protobuf::Arena* submessage_arena = reinterpret_cast<::PeerDescriptor*>(value)->GetArena(); + if (message_arena != submessage_arena) { + value = ::google::protobuf::internal::GetOwnedMessage(message_arena, value, submessage_arena); + } + _impl_._has_bits_[0] |= 0x00000002u; + } else { + _impl_._has_bits_[0] &= ~0x00000002u; + } + + _impl_.destinationpeer_ = reinterpret_cast<::PeerDescriptor*>(value); + // @@protoc_insertion_point(field_set_allocated:RouteMessageAck.destinationPeer) +} + +// string error = 4; +inline void RouteMessageAck::clear_error() { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + _impl_.error_.ClearToEmpty(); +} +inline const std::string& RouteMessageAck::error() const + ABSL_ATTRIBUTE_LIFETIME_BOUND { + // @@protoc_insertion_point(field_get:RouteMessageAck.error) + return _internal_error(); +} +template +inline PROTOBUF_ALWAYS_INLINE void RouteMessageAck::set_error(Arg_&& arg, + Args_... args) { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + ; + _impl_.error_.Set(static_cast(arg), args..., GetArena()); + // @@protoc_insertion_point(field_set:RouteMessageAck.error) +} +inline std::string* RouteMessageAck::mutable_error() ABSL_ATTRIBUTE_LIFETIME_BOUND { + std::string* _s = _internal_mutable_error(); + // @@protoc_insertion_point(field_mutable:RouteMessageAck.error) + return _s; +} +inline const std::string& RouteMessageAck::_internal_error() const { + PROTOBUF_TSAN_READ(&_impl_._tsan_detect_race); + return _impl_.error_.Get(); +} +inline void RouteMessageAck::_internal_set_error(const std::string& value) { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + ; + _impl_.error_.Set(value, GetArena()); +} +inline std::string* RouteMessageAck::_internal_mutable_error() { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + ; + return _impl_.error_.Mutable( GetArena()); +} +inline std::string* RouteMessageAck::release_error() { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + // @@protoc_insertion_point(field_release:RouteMessageAck.error) + return _impl_.error_.Release(); +} +inline void RouteMessageAck::set_allocated_error(std::string* value) { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + _impl_.error_.SetAllocated(value, GetArena()); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (_impl_.error_.IsDefault()) { + _impl_.error_.Set("", GetArena()); + } + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + // @@protoc_insertion_point(field_set_allocated:RouteMessageAck.error) +} + +// ------------------------------------------------------------------- + +// PingRequest + +// string requestId = 1; +inline void PingRequest::clear_requestid() { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + _impl_.requestid_.ClearToEmpty(); +} +inline const std::string& PingRequest::requestid() const + ABSL_ATTRIBUTE_LIFETIME_BOUND { + // @@protoc_insertion_point(field_get:PingRequest.requestId) + return _internal_requestid(); +} +template +inline PROTOBUF_ALWAYS_INLINE void PingRequest::set_requestid(Arg_&& arg, + Args_... args) { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + ; + _impl_.requestid_.Set(static_cast(arg), args..., GetArena()); + // @@protoc_insertion_point(field_set:PingRequest.requestId) +} +inline std::string* PingRequest::mutable_requestid() ABSL_ATTRIBUTE_LIFETIME_BOUND { + std::string* _s = _internal_mutable_requestid(); + // @@protoc_insertion_point(field_mutable:PingRequest.requestId) + return _s; +} +inline const std::string& PingRequest::_internal_requestid() const { + PROTOBUF_TSAN_READ(&_impl_._tsan_detect_race); + return _impl_.requestid_.Get(); +} +inline void PingRequest::_internal_set_requestid(const std::string& value) { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + ; + _impl_.requestid_.Set(value, GetArena()); +} +inline std::string* PingRequest::_internal_mutable_requestid() { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + ; + return _impl_.requestid_.Mutable( GetArena()); +} +inline std::string* PingRequest::release_requestid() { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + // @@protoc_insertion_point(field_release:PingRequest.requestId) + return _impl_.requestid_.Release(); +} +inline void PingRequest::set_allocated_requestid(std::string* value) { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + _impl_.requestid_.SetAllocated(value, GetArena()); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (_impl_.requestid_.IsDefault()) { + _impl_.requestid_.Set("", GetArena()); + } + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + // @@protoc_insertion_point(field_set_allocated:PingRequest.requestId) +} + +// ------------------------------------------------------------------- + +// PingResponse + +// string requestId = 1; +inline void PingResponse::clear_requestid() { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + _impl_.requestid_.ClearToEmpty(); +} +inline const std::string& PingResponse::requestid() const + ABSL_ATTRIBUTE_LIFETIME_BOUND { + // @@protoc_insertion_point(field_get:PingResponse.requestId) + return _internal_requestid(); +} +template +inline PROTOBUF_ALWAYS_INLINE void PingResponse::set_requestid(Arg_&& arg, + Args_... args) { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + ; + _impl_.requestid_.Set(static_cast(arg), args..., GetArena()); + // @@protoc_insertion_point(field_set:PingResponse.requestId) +} +inline std::string* PingResponse::mutable_requestid() ABSL_ATTRIBUTE_LIFETIME_BOUND { + std::string* _s = _internal_mutable_requestid(); + // @@protoc_insertion_point(field_mutable:PingResponse.requestId) + return _s; +} +inline const std::string& PingResponse::_internal_requestid() const { + PROTOBUF_TSAN_READ(&_impl_._tsan_detect_race); + return _impl_.requestid_.Get(); +} +inline void PingResponse::_internal_set_requestid(const std::string& value) { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + ; + _impl_.requestid_.Set(value, GetArena()); +} +inline std::string* PingResponse::_internal_mutable_requestid() { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + ; + return _impl_.requestid_.Mutable( GetArena()); +} +inline std::string* PingResponse::release_requestid() { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + // @@protoc_insertion_point(field_release:PingResponse.requestId) + return _impl_.requestid_.Release(); +} +inline void PingResponse::set_allocated_requestid(std::string* value) { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + _impl_.requestid_.SetAllocated(value, GetArena()); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (_impl_.requestid_.IsDefault()) { + _impl_.requestid_.Set("", GetArena()); + } + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + // @@protoc_insertion_point(field_set_allocated:PingResponse.requestId) +} + +// ------------------------------------------------------------------- + +// ClosestPeersRequest + +// .PeerDescriptor peerDescriptor = 1; +inline bool ClosestPeersRequest::has_peerdescriptor() const { + bool value = (_impl_._has_bits_[0] & 0x00000001u) != 0; + PROTOBUF_ASSUME(!value || _impl_.peerdescriptor_ != nullptr); + return value; +} +inline void ClosestPeersRequest::clear_peerdescriptor() { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + if (_impl_.peerdescriptor_ != nullptr) _impl_.peerdescriptor_->Clear(); + _impl_._has_bits_[0] &= ~0x00000001u; +} +inline const ::PeerDescriptor& ClosestPeersRequest::_internal_peerdescriptor() const { + PROTOBUF_TSAN_READ(&_impl_._tsan_detect_race); + const ::PeerDescriptor* p = _impl_.peerdescriptor_; + return p != nullptr ? *p : reinterpret_cast(::_PeerDescriptor_default_instance_); +} +inline const ::PeerDescriptor& ClosestPeersRequest::peerdescriptor() const ABSL_ATTRIBUTE_LIFETIME_BOUND { + // @@protoc_insertion_point(field_get:ClosestPeersRequest.peerDescriptor) + return _internal_peerdescriptor(); +} +inline void ClosestPeersRequest::unsafe_arena_set_allocated_peerdescriptor(::PeerDescriptor* value) { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + if (GetArena() == nullptr) { + delete reinterpret_cast<::google::protobuf::MessageLite*>(_impl_.peerdescriptor_); + } + _impl_.peerdescriptor_ = reinterpret_cast<::PeerDescriptor*>(value); + if (value != nullptr) { + _impl_._has_bits_[0] |= 0x00000001u; + } else { + _impl_._has_bits_[0] &= ~0x00000001u; + } + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:ClosestPeersRequest.peerDescriptor) +} +inline ::PeerDescriptor* ClosestPeersRequest::release_peerdescriptor() { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + + _impl_._has_bits_[0] &= ~0x00000001u; + ::PeerDescriptor* released = _impl_.peerdescriptor_; + _impl_.peerdescriptor_ = nullptr; +#ifdef PROTOBUF_FORCE_COPY_IN_RELEASE + auto* old = reinterpret_cast<::google::protobuf::MessageLite*>(released); + released = ::google::protobuf::internal::DuplicateIfNonNull(released); + if (GetArena() == nullptr) { + delete old; + } +#else // PROTOBUF_FORCE_COPY_IN_RELEASE + if (GetArena() != nullptr) { + released = ::google::protobuf::internal::DuplicateIfNonNull(released); + } +#endif // !PROTOBUF_FORCE_COPY_IN_RELEASE + return released; +} +inline ::PeerDescriptor* ClosestPeersRequest::unsafe_arena_release_peerdescriptor() { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + // @@protoc_insertion_point(field_release:ClosestPeersRequest.peerDescriptor) + + _impl_._has_bits_[0] &= ~0x00000001u; + ::PeerDescriptor* temp = _impl_.peerdescriptor_; + _impl_.peerdescriptor_ = nullptr; + return temp; +} +inline ::PeerDescriptor* ClosestPeersRequest::_internal_mutable_peerdescriptor() { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + _impl_._has_bits_[0] |= 0x00000001u; + if (_impl_.peerdescriptor_ == nullptr) { + auto* p = CreateMaybeMessage<::PeerDescriptor>(GetArena()); + _impl_.peerdescriptor_ = reinterpret_cast<::PeerDescriptor*>(p); + } + return _impl_.peerdescriptor_; +} +inline ::PeerDescriptor* ClosestPeersRequest::mutable_peerdescriptor() ABSL_ATTRIBUTE_LIFETIME_BOUND { + ::PeerDescriptor* _msg = _internal_mutable_peerdescriptor(); + // @@protoc_insertion_point(field_mutable:ClosestPeersRequest.peerDescriptor) + return _msg; +} +inline void ClosestPeersRequest::set_allocated_peerdescriptor(::PeerDescriptor* value) { + ::google::protobuf::Arena* message_arena = GetArena(); + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + if (message_arena == nullptr) { + delete reinterpret_cast<::PeerDescriptor*>(_impl_.peerdescriptor_); + } + + if (value != nullptr) { + ::google::protobuf::Arena* submessage_arena = reinterpret_cast<::PeerDescriptor*>(value)->GetArena(); + if (message_arena != submessage_arena) { + value = ::google::protobuf::internal::GetOwnedMessage(message_arena, value, submessage_arena); + } + _impl_._has_bits_[0] |= 0x00000001u; + } else { + _impl_._has_bits_[0] &= ~0x00000001u; + } + + _impl_.peerdescriptor_ = reinterpret_cast<::PeerDescriptor*>(value); + // @@protoc_insertion_point(field_set_allocated:ClosestPeersRequest.peerDescriptor) +} + +// string requestId = 2; +inline void ClosestPeersRequest::clear_requestid() { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + _impl_.requestid_.ClearToEmpty(); +} +inline const std::string& ClosestPeersRequest::requestid() const + ABSL_ATTRIBUTE_LIFETIME_BOUND { + // @@protoc_insertion_point(field_get:ClosestPeersRequest.requestId) + return _internal_requestid(); +} +template +inline PROTOBUF_ALWAYS_INLINE void ClosestPeersRequest::set_requestid(Arg_&& arg, + Args_... args) { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + ; + _impl_.requestid_.Set(static_cast(arg), args..., GetArena()); + // @@protoc_insertion_point(field_set:ClosestPeersRequest.requestId) +} +inline std::string* ClosestPeersRequest::mutable_requestid() ABSL_ATTRIBUTE_LIFETIME_BOUND { + std::string* _s = _internal_mutable_requestid(); + // @@protoc_insertion_point(field_mutable:ClosestPeersRequest.requestId) + return _s; +} +inline const std::string& ClosestPeersRequest::_internal_requestid() const { + PROTOBUF_TSAN_READ(&_impl_._tsan_detect_race); + return _impl_.requestid_.Get(); +} +inline void ClosestPeersRequest::_internal_set_requestid(const std::string& value) { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + ; + _impl_.requestid_.Set(value, GetArena()); +} +inline std::string* ClosestPeersRequest::_internal_mutable_requestid() { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + ; + return _impl_.requestid_.Mutable( GetArena()); +} +inline std::string* ClosestPeersRequest::release_requestid() { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + // @@protoc_insertion_point(field_release:ClosestPeersRequest.requestId) + return _impl_.requestid_.Release(); +} +inline void ClosestPeersRequest::set_allocated_requestid(std::string* value) { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + _impl_.requestid_.SetAllocated(value, GetArena()); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (_impl_.requestid_.IsDefault()) { + _impl_.requestid_.Set("", GetArena()); + } + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + // @@protoc_insertion_point(field_set_allocated:ClosestPeersRequest.requestId) +} + +// ------------------------------------------------------------------- + +// ClosestPeersResponse + +// repeated .PeerDescriptor peers = 1; +inline int ClosestPeersResponse::_internal_peers_size() const { + return _internal_peers().size(); +} +inline int ClosestPeersResponse::peers_size() const { + return _internal_peers_size(); +} +inline void ClosestPeersResponse::clear_peers() { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + _impl_.peers_.Clear(); +} +inline ::PeerDescriptor* ClosestPeersResponse::mutable_peers(int index) + ABSL_ATTRIBUTE_LIFETIME_BOUND { + // @@protoc_insertion_point(field_mutable:ClosestPeersResponse.peers) + return _internal_mutable_peers()->Mutable(index); +} +inline ::google::protobuf::RepeatedPtrField<::PeerDescriptor>* ClosestPeersResponse::mutable_peers() + ABSL_ATTRIBUTE_LIFETIME_BOUND { + // @@protoc_insertion_point(field_mutable_list:ClosestPeersResponse.peers) + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + return _internal_mutable_peers(); +} +inline const ::PeerDescriptor& ClosestPeersResponse::peers(int index) const + ABSL_ATTRIBUTE_LIFETIME_BOUND { + // @@protoc_insertion_point(field_get:ClosestPeersResponse.peers) + return _internal_peers().Get(index); +} +inline ::PeerDescriptor* ClosestPeersResponse::add_peers() ABSL_ATTRIBUTE_LIFETIME_BOUND { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + ::PeerDescriptor* _add = _internal_mutable_peers()->Add(); + // @@protoc_insertion_point(field_add:ClosestPeersResponse.peers) + return _add; +} +inline const ::google::protobuf::RepeatedPtrField<::PeerDescriptor>& ClosestPeersResponse::peers() const + ABSL_ATTRIBUTE_LIFETIME_BOUND { + // @@protoc_insertion_point(field_list:ClosestPeersResponse.peers) + return _internal_peers(); +} +inline const ::google::protobuf::RepeatedPtrField<::PeerDescriptor>& +ClosestPeersResponse::_internal_peers() const { + PROTOBUF_TSAN_READ(&_impl_._tsan_detect_race); + return _impl_.peers_; +} +inline ::google::protobuf::RepeatedPtrField<::PeerDescriptor>* +ClosestPeersResponse::_internal_mutable_peers() { + PROTOBUF_TSAN_READ(&_impl_._tsan_detect_race); + return &_impl_.peers_; +} + +// string requestId = 2; +inline void ClosestPeersResponse::clear_requestid() { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + _impl_.requestid_.ClearToEmpty(); +} +inline const std::string& ClosestPeersResponse::requestid() const + ABSL_ATTRIBUTE_LIFETIME_BOUND { + // @@protoc_insertion_point(field_get:ClosestPeersResponse.requestId) + return _internal_requestid(); +} +template +inline PROTOBUF_ALWAYS_INLINE void ClosestPeersResponse::set_requestid(Arg_&& arg, + Args_... args) { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + ; + _impl_.requestid_.Set(static_cast(arg), args..., GetArena()); + // @@protoc_insertion_point(field_set:ClosestPeersResponse.requestId) +} +inline std::string* ClosestPeersResponse::mutable_requestid() ABSL_ATTRIBUTE_LIFETIME_BOUND { + std::string* _s = _internal_mutable_requestid(); + // @@protoc_insertion_point(field_mutable:ClosestPeersResponse.requestId) + return _s; +} +inline const std::string& ClosestPeersResponse::_internal_requestid() const { + PROTOBUF_TSAN_READ(&_impl_._tsan_detect_race); + return _impl_.requestid_.Get(); +} +inline void ClosestPeersResponse::_internal_set_requestid(const std::string& value) { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + ; + _impl_.requestid_.Set(value, GetArena()); +} +inline std::string* ClosestPeersResponse::_internal_mutable_requestid() { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + ; + return _impl_.requestid_.Mutable( GetArena()); +} +inline std::string* ClosestPeersResponse::release_requestid() { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + // @@protoc_insertion_point(field_release:ClosestPeersResponse.requestId) + return _impl_.requestid_.Release(); +} +inline void ClosestPeersResponse::set_allocated_requestid(std::string* value) { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + _impl_.requestid_.SetAllocated(value, GetArena()); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (_impl_.requestid_.IsDefault()) { + _impl_.requestid_.Set("", GetArena()); + } + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + // @@protoc_insertion_point(field_set_allocated:ClosestPeersResponse.requestId) +} + +// ------------------------------------------------------------------- + +// PeerDescriptor + +// bytes nodeId = 1; +inline void PeerDescriptor::clear_nodeid() { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + _impl_.nodeid_.ClearToEmpty(); +} +inline const std::string& PeerDescriptor::nodeid() const + ABSL_ATTRIBUTE_LIFETIME_BOUND { + // @@protoc_insertion_point(field_get:PeerDescriptor.nodeId) + return _internal_nodeid(); +} +template +inline PROTOBUF_ALWAYS_INLINE void PeerDescriptor::set_nodeid(Arg_&& arg, + Args_... args) { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + ; + _impl_.nodeid_.SetBytes(static_cast(arg), args..., GetArena()); + // @@protoc_insertion_point(field_set:PeerDescriptor.nodeId) +} +inline std::string* PeerDescriptor::mutable_nodeid() ABSL_ATTRIBUTE_LIFETIME_BOUND { + std::string* _s = _internal_mutable_nodeid(); + // @@protoc_insertion_point(field_mutable:PeerDescriptor.nodeId) + return _s; +} +inline const std::string& PeerDescriptor::_internal_nodeid() const { + PROTOBUF_TSAN_READ(&_impl_._tsan_detect_race); + return _impl_.nodeid_.Get(); +} +inline void PeerDescriptor::_internal_set_nodeid(const std::string& value) { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + ; + _impl_.nodeid_.Set(value, GetArena()); +} +inline std::string* PeerDescriptor::_internal_mutable_nodeid() { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + ; + return _impl_.nodeid_.Mutable( GetArena()); +} +inline std::string* PeerDescriptor::release_nodeid() { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + // @@protoc_insertion_point(field_release:PeerDescriptor.nodeId) + return _impl_.nodeid_.Release(); +} +inline void PeerDescriptor::set_allocated_nodeid(std::string* value) { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + _impl_.nodeid_.SetAllocated(value, GetArena()); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (_impl_.nodeid_.IsDefault()) { + _impl_.nodeid_.Set("", GetArena()); + } + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + // @@protoc_insertion_point(field_set_allocated:PeerDescriptor.nodeId) +} + +// .NodeType type = 2; +inline void PeerDescriptor::clear_type() { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + _impl_.type_ = 0; +} +inline ::NodeType PeerDescriptor::type() const { + // @@protoc_insertion_point(field_get:PeerDescriptor.type) + return _internal_type(); +} +inline void PeerDescriptor::set_type(::NodeType value) { + _internal_set_type(value); + // @@protoc_insertion_point(field_set:PeerDescriptor.type) +} +inline ::NodeType PeerDescriptor::_internal_type() const { + PROTOBUF_TSAN_READ(&_impl_._tsan_detect_race); + return static_cast<::NodeType>(_impl_.type_); +} +inline void PeerDescriptor::_internal_set_type(::NodeType value) { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + ; + _impl_.type_ = value; +} + +// .ConnectivityMethod udp = 3; +inline bool PeerDescriptor::has_udp() const { + bool value = (_impl_._has_bits_[0] & 0x00000001u) != 0; + PROTOBUF_ASSUME(!value || _impl_.udp_ != nullptr); + return value; +} +inline void PeerDescriptor::clear_udp() { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + if (_impl_.udp_ != nullptr) _impl_.udp_->Clear(); + _impl_._has_bits_[0] &= ~0x00000001u; +} +inline const ::ConnectivityMethod& PeerDescriptor::_internal_udp() const { + PROTOBUF_TSAN_READ(&_impl_._tsan_detect_race); + const ::ConnectivityMethod* p = _impl_.udp_; + return p != nullptr ? *p : reinterpret_cast(::_ConnectivityMethod_default_instance_); +} +inline const ::ConnectivityMethod& PeerDescriptor::udp() const ABSL_ATTRIBUTE_LIFETIME_BOUND { + // @@protoc_insertion_point(field_get:PeerDescriptor.udp) + return _internal_udp(); +} +inline void PeerDescriptor::unsafe_arena_set_allocated_udp(::ConnectivityMethod* value) { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + if (GetArena() == nullptr) { + delete reinterpret_cast<::google::protobuf::MessageLite*>(_impl_.udp_); + } + _impl_.udp_ = reinterpret_cast<::ConnectivityMethod*>(value); + if (value != nullptr) { + _impl_._has_bits_[0] |= 0x00000001u; + } else { + _impl_._has_bits_[0] &= ~0x00000001u; + } + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:PeerDescriptor.udp) +} +inline ::ConnectivityMethod* PeerDescriptor::release_udp() { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + + _impl_._has_bits_[0] &= ~0x00000001u; + ::ConnectivityMethod* released = _impl_.udp_; + _impl_.udp_ = nullptr; +#ifdef PROTOBUF_FORCE_COPY_IN_RELEASE + auto* old = reinterpret_cast<::google::protobuf::MessageLite*>(released); + released = ::google::protobuf::internal::DuplicateIfNonNull(released); + if (GetArena() == nullptr) { + delete old; + } +#else // PROTOBUF_FORCE_COPY_IN_RELEASE + if (GetArena() != nullptr) { + released = ::google::protobuf::internal::DuplicateIfNonNull(released); + } +#endif // !PROTOBUF_FORCE_COPY_IN_RELEASE + return released; +} +inline ::ConnectivityMethod* PeerDescriptor::unsafe_arena_release_udp() { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + // @@protoc_insertion_point(field_release:PeerDescriptor.udp) + + _impl_._has_bits_[0] &= ~0x00000001u; + ::ConnectivityMethod* temp = _impl_.udp_; + _impl_.udp_ = nullptr; + return temp; +} +inline ::ConnectivityMethod* PeerDescriptor::_internal_mutable_udp() { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + _impl_._has_bits_[0] |= 0x00000001u; + if (_impl_.udp_ == nullptr) { + auto* p = CreateMaybeMessage<::ConnectivityMethod>(GetArena()); + _impl_.udp_ = reinterpret_cast<::ConnectivityMethod*>(p); + } + return _impl_.udp_; +} +inline ::ConnectivityMethod* PeerDescriptor::mutable_udp() ABSL_ATTRIBUTE_LIFETIME_BOUND { + ::ConnectivityMethod* _msg = _internal_mutable_udp(); + // @@protoc_insertion_point(field_mutable:PeerDescriptor.udp) + return _msg; +} +inline void PeerDescriptor::set_allocated_udp(::ConnectivityMethod* value) { + ::google::protobuf::Arena* message_arena = GetArena(); + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + if (message_arena == nullptr) { + delete reinterpret_cast<::ConnectivityMethod*>(_impl_.udp_); + } + + if (value != nullptr) { + ::google::protobuf::Arena* submessage_arena = reinterpret_cast<::ConnectivityMethod*>(value)->GetArena(); + if (message_arena != submessage_arena) { + value = ::google::protobuf::internal::GetOwnedMessage(message_arena, value, submessage_arena); + } + _impl_._has_bits_[0] |= 0x00000001u; + } else { + _impl_._has_bits_[0] &= ~0x00000001u; + } + + _impl_.udp_ = reinterpret_cast<::ConnectivityMethod*>(value); + // @@protoc_insertion_point(field_set_allocated:PeerDescriptor.udp) +} + +// .ConnectivityMethod tcp = 4; +inline bool PeerDescriptor::has_tcp() const { + bool value = (_impl_._has_bits_[0] & 0x00000002u) != 0; + PROTOBUF_ASSUME(!value || _impl_.tcp_ != nullptr); + return value; +} +inline void PeerDescriptor::clear_tcp() { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + if (_impl_.tcp_ != nullptr) _impl_.tcp_->Clear(); + _impl_._has_bits_[0] &= ~0x00000002u; +} +inline const ::ConnectivityMethod& PeerDescriptor::_internal_tcp() const { + PROTOBUF_TSAN_READ(&_impl_._tsan_detect_race); + const ::ConnectivityMethod* p = _impl_.tcp_; + return p != nullptr ? *p : reinterpret_cast(::_ConnectivityMethod_default_instance_); +} +inline const ::ConnectivityMethod& PeerDescriptor::tcp() const ABSL_ATTRIBUTE_LIFETIME_BOUND { + // @@protoc_insertion_point(field_get:PeerDescriptor.tcp) + return _internal_tcp(); +} +inline void PeerDescriptor::unsafe_arena_set_allocated_tcp(::ConnectivityMethod* value) { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + if (GetArena() == nullptr) { + delete reinterpret_cast<::google::protobuf::MessageLite*>(_impl_.tcp_); + } + _impl_.tcp_ = reinterpret_cast<::ConnectivityMethod*>(value); + if (value != nullptr) { + _impl_._has_bits_[0] |= 0x00000002u; + } else { + _impl_._has_bits_[0] &= ~0x00000002u; + } + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:PeerDescriptor.tcp) +} +inline ::ConnectivityMethod* PeerDescriptor::release_tcp() { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + + _impl_._has_bits_[0] &= ~0x00000002u; + ::ConnectivityMethod* released = _impl_.tcp_; + _impl_.tcp_ = nullptr; +#ifdef PROTOBUF_FORCE_COPY_IN_RELEASE + auto* old = reinterpret_cast<::google::protobuf::MessageLite*>(released); + released = ::google::protobuf::internal::DuplicateIfNonNull(released); + if (GetArena() == nullptr) { + delete old; + } +#else // PROTOBUF_FORCE_COPY_IN_RELEASE + if (GetArena() != nullptr) { + released = ::google::protobuf::internal::DuplicateIfNonNull(released); + } +#endif // !PROTOBUF_FORCE_COPY_IN_RELEASE + return released; +} +inline ::ConnectivityMethod* PeerDescriptor::unsafe_arena_release_tcp() { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + // @@protoc_insertion_point(field_release:PeerDescriptor.tcp) + + _impl_._has_bits_[0] &= ~0x00000002u; + ::ConnectivityMethod* temp = _impl_.tcp_; + _impl_.tcp_ = nullptr; + return temp; +} +inline ::ConnectivityMethod* PeerDescriptor::_internal_mutable_tcp() { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + _impl_._has_bits_[0] |= 0x00000002u; + if (_impl_.tcp_ == nullptr) { + auto* p = CreateMaybeMessage<::ConnectivityMethod>(GetArena()); + _impl_.tcp_ = reinterpret_cast<::ConnectivityMethod*>(p); + } + return _impl_.tcp_; +} +inline ::ConnectivityMethod* PeerDescriptor::mutable_tcp() ABSL_ATTRIBUTE_LIFETIME_BOUND { + ::ConnectivityMethod* _msg = _internal_mutable_tcp(); + // @@protoc_insertion_point(field_mutable:PeerDescriptor.tcp) + return _msg; +} +inline void PeerDescriptor::set_allocated_tcp(::ConnectivityMethod* value) { + ::google::protobuf::Arena* message_arena = GetArena(); + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + if (message_arena == nullptr) { + delete reinterpret_cast<::ConnectivityMethod*>(_impl_.tcp_); + } + + if (value != nullptr) { + ::google::protobuf::Arena* submessage_arena = reinterpret_cast<::ConnectivityMethod*>(value)->GetArena(); + if (message_arena != submessage_arena) { + value = ::google::protobuf::internal::GetOwnedMessage(message_arena, value, submessage_arena); + } + _impl_._has_bits_[0] |= 0x00000002u; + } else { + _impl_._has_bits_[0] &= ~0x00000002u; + } + + _impl_.tcp_ = reinterpret_cast<::ConnectivityMethod*>(value); + // @@protoc_insertion_point(field_set_allocated:PeerDescriptor.tcp) +} + +// .ConnectivityMethod websocket = 5; +inline bool PeerDescriptor::has_websocket() const { + bool value = (_impl_._has_bits_[0] & 0x00000004u) != 0; + PROTOBUF_ASSUME(!value || _impl_.websocket_ != nullptr); + return value; +} +inline void PeerDescriptor::clear_websocket() { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + if (_impl_.websocket_ != nullptr) _impl_.websocket_->Clear(); + _impl_._has_bits_[0] &= ~0x00000004u; +} +inline const ::ConnectivityMethod& PeerDescriptor::_internal_websocket() const { + PROTOBUF_TSAN_READ(&_impl_._tsan_detect_race); + const ::ConnectivityMethod* p = _impl_.websocket_; + return p != nullptr ? *p : reinterpret_cast(::_ConnectivityMethod_default_instance_); +} +inline const ::ConnectivityMethod& PeerDescriptor::websocket() const ABSL_ATTRIBUTE_LIFETIME_BOUND { + // @@protoc_insertion_point(field_get:PeerDescriptor.websocket) + return _internal_websocket(); +} +inline void PeerDescriptor::unsafe_arena_set_allocated_websocket(::ConnectivityMethod* value) { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + if (GetArena() == nullptr) { + delete reinterpret_cast<::google::protobuf::MessageLite*>(_impl_.websocket_); + } + _impl_.websocket_ = reinterpret_cast<::ConnectivityMethod*>(value); + if (value != nullptr) { + _impl_._has_bits_[0] |= 0x00000004u; + } else { + _impl_._has_bits_[0] &= ~0x00000004u; + } + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:PeerDescriptor.websocket) +} +inline ::ConnectivityMethod* PeerDescriptor::release_websocket() { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + + _impl_._has_bits_[0] &= ~0x00000004u; + ::ConnectivityMethod* released = _impl_.websocket_; + _impl_.websocket_ = nullptr; +#ifdef PROTOBUF_FORCE_COPY_IN_RELEASE + auto* old = reinterpret_cast<::google::protobuf::MessageLite*>(released); + released = ::google::protobuf::internal::DuplicateIfNonNull(released); + if (GetArena() == nullptr) { + delete old; + } +#else // PROTOBUF_FORCE_COPY_IN_RELEASE + if (GetArena() != nullptr) { + released = ::google::protobuf::internal::DuplicateIfNonNull(released); + } +#endif // !PROTOBUF_FORCE_COPY_IN_RELEASE + return released; +} +inline ::ConnectivityMethod* PeerDescriptor::unsafe_arena_release_websocket() { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + // @@protoc_insertion_point(field_release:PeerDescriptor.websocket) + + _impl_._has_bits_[0] &= ~0x00000004u; + ::ConnectivityMethod* temp = _impl_.websocket_; + _impl_.websocket_ = nullptr; + return temp; +} +inline ::ConnectivityMethod* PeerDescriptor::_internal_mutable_websocket() { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + _impl_._has_bits_[0] |= 0x00000004u; + if (_impl_.websocket_ == nullptr) { + auto* p = CreateMaybeMessage<::ConnectivityMethod>(GetArena()); + _impl_.websocket_ = reinterpret_cast<::ConnectivityMethod*>(p); + } + return _impl_.websocket_; +} +inline ::ConnectivityMethod* PeerDescriptor::mutable_websocket() ABSL_ATTRIBUTE_LIFETIME_BOUND { + ::ConnectivityMethod* _msg = _internal_mutable_websocket(); + // @@protoc_insertion_point(field_mutable:PeerDescriptor.websocket) + return _msg; +} +inline void PeerDescriptor::set_allocated_websocket(::ConnectivityMethod* value) { + ::google::protobuf::Arena* message_arena = GetArena(); + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + if (message_arena == nullptr) { + delete reinterpret_cast<::ConnectivityMethod*>(_impl_.websocket_); + } + + if (value != nullptr) { + ::google::protobuf::Arena* submessage_arena = reinterpret_cast<::ConnectivityMethod*>(value)->GetArena(); + if (message_arena != submessage_arena) { + value = ::google::protobuf::internal::GetOwnedMessage(message_arena, value, submessage_arena); + } + _impl_._has_bits_[0] |= 0x00000004u; + } else { + _impl_._has_bits_[0] &= ~0x00000004u; + } + + _impl_.websocket_ = reinterpret_cast<::ConnectivityMethod*>(value); + // @@protoc_insertion_point(field_set_allocated:PeerDescriptor.websocket) +} + +// optional bool openInternet = 6; +inline bool PeerDescriptor::has_openinternet() const { + bool value = (_impl_._has_bits_[0] & 0x00000008u) != 0; + return value; +} +inline void PeerDescriptor::clear_openinternet() { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + _impl_.openinternet_ = false; + _impl_._has_bits_[0] &= ~0x00000008u; +} +inline bool PeerDescriptor::openinternet() const { + // @@protoc_insertion_point(field_get:PeerDescriptor.openInternet) + return _internal_openinternet(); +} +inline void PeerDescriptor::set_openinternet(bool value) { + _internal_set_openinternet(value); + // @@protoc_insertion_point(field_set:PeerDescriptor.openInternet) +} +inline bool PeerDescriptor::_internal_openinternet() const { + PROTOBUF_TSAN_READ(&_impl_._tsan_detect_race); + return _impl_.openinternet_; +} +inline void PeerDescriptor::_internal_set_openinternet(bool value) { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + _impl_._has_bits_[0] |= 0x00000008u; + _impl_.openinternet_ = value; +} + +// ------------------------------------------------------------------- + +// ConnectivityMethod + +// uint32 port = 2; +inline void ConnectivityMethod::clear_port() { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + _impl_.port_ = 0u; +} +inline ::uint32_t ConnectivityMethod::port() const { + // @@protoc_insertion_point(field_get:ConnectivityMethod.port) + return _internal_port(); +} +inline void ConnectivityMethod::set_port(::uint32_t value) { + _internal_set_port(value); + // @@protoc_insertion_point(field_set:ConnectivityMethod.port) +} +inline ::uint32_t ConnectivityMethod::_internal_port() const { + PROTOBUF_TSAN_READ(&_impl_._tsan_detect_race); + return _impl_.port_; +} +inline void ConnectivityMethod::_internal_set_port(::uint32_t value) { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + ; + _impl_.port_ = value; +} + +// string ip = 3; +inline void ConnectivityMethod::clear_ip() { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + _impl_.ip_.ClearToEmpty(); +} +inline const std::string& ConnectivityMethod::ip() const + ABSL_ATTRIBUTE_LIFETIME_BOUND { + // @@protoc_insertion_point(field_get:ConnectivityMethod.ip) + return _internal_ip(); +} +template +inline PROTOBUF_ALWAYS_INLINE void ConnectivityMethod::set_ip(Arg_&& arg, + Args_... args) { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + ; + _impl_.ip_.Set(static_cast(arg), args..., GetArena()); + // @@protoc_insertion_point(field_set:ConnectivityMethod.ip) +} +inline std::string* ConnectivityMethod::mutable_ip() ABSL_ATTRIBUTE_LIFETIME_BOUND { + std::string* _s = _internal_mutable_ip(); + // @@protoc_insertion_point(field_mutable:ConnectivityMethod.ip) + return _s; +} +inline const std::string& ConnectivityMethod::_internal_ip() const { + PROTOBUF_TSAN_READ(&_impl_._tsan_detect_race); + return _impl_.ip_.Get(); +} +inline void ConnectivityMethod::_internal_set_ip(const std::string& value) { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + ; + _impl_.ip_.Set(value, GetArena()); +} +inline std::string* ConnectivityMethod::_internal_mutable_ip() { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + ; + return _impl_.ip_.Mutable( GetArena()); +} +inline std::string* ConnectivityMethod::release_ip() { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + // @@protoc_insertion_point(field_release:ConnectivityMethod.ip) + return _impl_.ip_.Release(); +} +inline void ConnectivityMethod::set_allocated_ip(std::string* value) { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + _impl_.ip_.SetAllocated(value, GetArena()); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (_impl_.ip_.IsDefault()) { + _impl_.ip_.Set("", GetArena()); + } + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + // @@protoc_insertion_point(field_set_allocated:ConnectivityMethod.ip) +} + +// ------------------------------------------------------------------- + +// OptionalRequest + +// optional string someOptionalField = 1; +inline bool OptionalRequest::has_someoptionalfield() const { + bool value = (_impl_._has_bits_[0] & 0x00000001u) != 0; + return value; +} +inline void OptionalRequest::clear_someoptionalfield() { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + _impl_.someoptionalfield_.ClearToEmpty(); + _impl_._has_bits_[0] &= ~0x00000001u; +} +inline const std::string& OptionalRequest::someoptionalfield() const + ABSL_ATTRIBUTE_LIFETIME_BOUND { + // @@protoc_insertion_point(field_get:OptionalRequest.someOptionalField) + return _internal_someoptionalfield(); +} +template +inline PROTOBUF_ALWAYS_INLINE void OptionalRequest::set_someoptionalfield(Arg_&& arg, + Args_... args) { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + _impl_._has_bits_[0] |= 0x00000001u; + _impl_.someoptionalfield_.Set(static_cast(arg), args..., GetArena()); + // @@protoc_insertion_point(field_set:OptionalRequest.someOptionalField) +} +inline std::string* OptionalRequest::mutable_someoptionalfield() ABSL_ATTRIBUTE_LIFETIME_BOUND { + std::string* _s = _internal_mutable_someoptionalfield(); + // @@protoc_insertion_point(field_mutable:OptionalRequest.someOptionalField) + return _s; +} +inline const std::string& OptionalRequest::_internal_someoptionalfield() const { + PROTOBUF_TSAN_READ(&_impl_._tsan_detect_race); + return _impl_.someoptionalfield_.Get(); +} +inline void OptionalRequest::_internal_set_someoptionalfield(const std::string& value) { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + _impl_._has_bits_[0] |= 0x00000001u; + _impl_.someoptionalfield_.Set(value, GetArena()); +} +inline std::string* OptionalRequest::_internal_mutable_someoptionalfield() { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + _impl_._has_bits_[0] |= 0x00000001u; + return _impl_.someoptionalfield_.Mutable( GetArena()); +} +inline std::string* OptionalRequest::release_someoptionalfield() { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + // @@protoc_insertion_point(field_release:OptionalRequest.someOptionalField) + if ((_impl_._has_bits_[0] & 0x00000001u) == 0) { + return nullptr; + } + _impl_._has_bits_[0] &= ~0x00000001u; + auto* released = _impl_.someoptionalfield_.Release(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.someoptionalfield_.Set("", GetArena()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + return released; +} +inline void OptionalRequest::set_allocated_someoptionalfield(std::string* value) { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + if (value != nullptr) { + _impl_._has_bits_[0] |= 0x00000001u; + } else { + _impl_._has_bits_[0] &= ~0x00000001u; + } + _impl_.someoptionalfield_.SetAllocated(value, GetArena()); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (_impl_.someoptionalfield_.IsDefault()) { + _impl_.someoptionalfield_.Set("", GetArena()); + } + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + // @@protoc_insertion_point(field_set_allocated:OptionalRequest.someOptionalField) +} + +// ------------------------------------------------------------------- + +// OptionalResponse + +// optional string someOptionalField = 1; +inline bool OptionalResponse::has_someoptionalfield() const { + bool value = (_impl_._has_bits_[0] & 0x00000001u) != 0; + return value; +} +inline void OptionalResponse::clear_someoptionalfield() { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + _impl_.someoptionalfield_.ClearToEmpty(); + _impl_._has_bits_[0] &= ~0x00000001u; +} +inline const std::string& OptionalResponse::someoptionalfield() const + ABSL_ATTRIBUTE_LIFETIME_BOUND { + // @@protoc_insertion_point(field_get:OptionalResponse.someOptionalField) + return _internal_someoptionalfield(); +} +template +inline PROTOBUF_ALWAYS_INLINE void OptionalResponse::set_someoptionalfield(Arg_&& arg, + Args_... args) { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + _impl_._has_bits_[0] |= 0x00000001u; + _impl_.someoptionalfield_.Set(static_cast(arg), args..., GetArena()); + // @@protoc_insertion_point(field_set:OptionalResponse.someOptionalField) +} +inline std::string* OptionalResponse::mutable_someoptionalfield() ABSL_ATTRIBUTE_LIFETIME_BOUND { + std::string* _s = _internal_mutable_someoptionalfield(); + // @@protoc_insertion_point(field_mutable:OptionalResponse.someOptionalField) + return _s; +} +inline const std::string& OptionalResponse::_internal_someoptionalfield() const { + PROTOBUF_TSAN_READ(&_impl_._tsan_detect_race); + return _impl_.someoptionalfield_.Get(); +} +inline void OptionalResponse::_internal_set_someoptionalfield(const std::string& value) { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + _impl_._has_bits_[0] |= 0x00000001u; + _impl_.someoptionalfield_.Set(value, GetArena()); +} +inline std::string* OptionalResponse::_internal_mutable_someoptionalfield() { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + _impl_._has_bits_[0] |= 0x00000001u; + return _impl_.someoptionalfield_.Mutable( GetArena()); +} +inline std::string* OptionalResponse::release_someoptionalfield() { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + // @@protoc_insertion_point(field_release:OptionalResponse.someOptionalField) + if ((_impl_._has_bits_[0] & 0x00000001u) == 0) { + return nullptr; + } + _impl_._has_bits_[0] &= ~0x00000001u; + auto* released = _impl_.someoptionalfield_.Release(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.someoptionalfield_.Set("", GetArena()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + return released; +} +inline void OptionalResponse::set_allocated_someoptionalfield(std::string* value) { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + if (value != nullptr) { + _impl_._has_bits_[0] |= 0x00000001u; + } else { + _impl_._has_bits_[0] &= ~0x00000001u; + } + _impl_.someoptionalfield_.SetAllocated(value, GetArena()); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (_impl_.someoptionalfield_.IsDefault()) { + _impl_.someoptionalfield_.Set("", GetArena()); + } + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + // @@protoc_insertion_point(field_set_allocated:OptionalResponse.someOptionalField) +} + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif // __GNUC__ + +// @@protoc_insertion_point(namespace_scope) + + +namespace google { +namespace protobuf { + +template <> +struct is_proto_enum<::NodeType> : std::true_type {}; +template <> +inline const EnumDescriptor* GetEnumDescriptor<::NodeType>() { + return ::NodeType_descriptor(); +} + +} // namespace protobuf +} // namespace google + +// @@protoc_insertion_point(global_scope) + +#include "google/protobuf/port_undef.inc" + +#endif // GOOGLE_PROTOBUF_INCLUDED_TestProtos_2eproto_2epb_2eh diff --git a/packages/streamr-proto-rpc/test/proto/TestProtos.server.pb.h b/packages/streamr-proto-rpc/test/proto/TestProtos.server.pb.h new file mode 100644 index 0000000..2b97b40 --- /dev/null +++ b/packages/streamr-proto-rpc/test/proto/TestProtos.server.pb.h @@ -0,0 +1,26 @@ +// Generated by the protocol buffer streamr pluging. DO NOT EDIT! +// Generated from protobuf file "TestProtos.proto" + +#ifndef STREAMR_PROTORPC_TESTPROTOS_SERVER_PB_H +#define STREAMR_PROTORPC_TESTPROTOS_SERVER_PB_H + +#include "TestProtos.pb.h" // NOLINT +#include + +namespace streamr::protorpc { +class DhtRpcService { +public: + virtual ~DhtRpcService() = default; + virtual ClosestPeersResponse getClosestPeers(const ClosestPeersRequest& request, const ProtoCallContext& callContext) = 0; + virtual PingResponse ping(const PingRequest& request, const ProtoCallContext& callContext) = 0; + virtual RouteMessageAck routeMessage(const RouteMessageWrapper& request, const ProtoCallContext& callContext) = 0; +}; // class DhtRpcService +class OptionalService { +public: + virtual ~OptionalService() = default; + virtual OptionalResponse getOptional(const OptionalRequest& request, const ProtoCallContext& callContext) = 0; +}; // class OptionalService +}; // namespace streamr::protorpc + +#endif // STREAMR_PROTORPC_TESTPROTOS_SERVER_PB_H + diff --git a/packages/streamr-proto-rpc/test/proto/WakeUpRpc.client.pb.h b/packages/streamr-proto-rpc/test/proto/WakeUpRpc.client.pb.h new file mode 100644 index 0000000..716ef6c --- /dev/null +++ b/packages/streamr-proto-rpc/test/proto/WakeUpRpc.client.pb.h @@ -0,0 +1,26 @@ +// generated by the protocol buffer streamr pluging. DO NOT EDIT! +// generated from protobuf file "WakeUpRpc.proto" + +#ifndef STREAMR_PROTORPC_WAKEUPRPC_CLIENT_PB_H +#define STREAMR_PROTORPC_WAKEUPRPC_CLIENT_PB_H + +#include +#include "WakeUpRpc.pb.h" // NOLINT +#include "streamr-proto-rpc/ProtoCallContext.hpp" +#include "streamr-proto-rpc/RpcCommunicator.hpp" + + +namespace streamr::protorpc { +class WakeUpRpcServiceClient { +private: +RpcCommunicator& communicator; +public: + WakeUpRpcServiceClient(RpcCommunicator& communicator) : communicator(communicator) {} + folly::coro::Task wakeUp(const WakeUpRequest& request, const ProtoCallContext& callContext) { + return communicator.notify("wakeUp", request, callContext); + } +}; // class WakeUpRpcServiceClient +}; // namespace streamr::protorpc + +#endif // STREAMR_PROTORPC_WAKEUPRPC_CLIENT_PB_H + diff --git a/packages/streamr-proto-rpc/test/proto/WakeUpRpc.pb.cc b/packages/streamr-proto-rpc/test/proto/WakeUpRpc.pb.cc new file mode 100644 index 0000000..f338a14 --- /dev/null +++ b/packages/streamr-proto-rpc/test/proto/WakeUpRpc.pb.cc @@ -0,0 +1,182 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: WakeUpRpc.proto + +#include "WakeUpRpc.pb.h" + +#include +#include "google/protobuf/io/coded_stream.h" +#include "google/protobuf/extension_set.h" +#include "google/protobuf/wire_format_lite.h" +#include "google/protobuf/descriptor.h" +#include "google/protobuf/generated_message_reflection.h" +#include "google/protobuf/reflection_ops.h" +#include "google/protobuf/wire_format.h" +// @@protoc_insertion_point(includes) + +// Must be included last. +#include "google/protobuf/port_def.inc" +PROTOBUF_PRAGMA_INIT_SEG +namespace _pb = ::google::protobuf; +namespace _pbi = ::google::protobuf::internal; + +inline constexpr WakeUpRequest::Impl_::Impl_( + ::_pbi::ConstantInitialized) noexcept + : reason_( + &::google::protobuf::internal::fixed_address_empty_string, + ::_pbi::ConstantInitialized()), + _cached_size_{0} {} + +template +PROTOBUF_CONSTEXPR WakeUpRequest::WakeUpRequest(::_pbi::ConstantInitialized) + : _impl_(::_pbi::ConstantInitialized()) {} +struct WakeUpRequestDefaultTypeInternal { + PROTOBUF_CONSTEXPR WakeUpRequestDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} + ~WakeUpRequestDefaultTypeInternal() {} + union { + WakeUpRequest _instance; + }; +}; + +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT + PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 WakeUpRequestDefaultTypeInternal _WakeUpRequest_default_instance_; +static ::_pb::Metadata file_level_metadata_WakeUpRpc_2eproto[1]; +static constexpr const ::_pb::EnumDescriptor** + file_level_enum_descriptors_WakeUpRpc_2eproto = nullptr; +static constexpr const ::_pb::ServiceDescriptor** + file_level_service_descriptors_WakeUpRpc_2eproto = nullptr; +const ::uint32_t TableStruct_WakeUpRpc_2eproto::offsets[] PROTOBUF_SECTION_VARIABLE( + protodesc_cold) = { + ~0u, // no _has_bits_ + PROTOBUF_FIELD_OFFSET(::WakeUpRequest, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) + PROTOBUF_FIELD_OFFSET(::WakeUpRequest, _impl_.reason_), +}; + +static const ::_pbi::MigrationSchema + schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { + {0, -1, -1, sizeof(::WakeUpRequest)}, +}; + +static const ::_pb::Message* const file_default_instances[] = { + &::_WakeUpRequest_default_instance_._instance, +}; +const char descriptor_table_protodef_WakeUpRpc_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { + "\n\017WakeUpRpc.proto\032\033google/protobuf/empty" + ".proto\"\037\n\rWakeUpRequest\022\016\n\006reason\030\001 \001(\t2" + "D\n\020WakeUpRpcService\0220\n\006wakeUp\022\016.WakeUpRe" + "quest\032\026.google.protobuf.EmptyB\002H\002b\006proto" + "3" +}; +static const ::_pbi::DescriptorTable* const descriptor_table_WakeUpRpc_2eproto_deps[1] = + { + &::descriptor_table_google_2fprotobuf_2fempty_2eproto, +}; +static ::absl::once_flag descriptor_table_WakeUpRpc_2eproto_once; +const ::_pbi::DescriptorTable descriptor_table_WakeUpRpc_2eproto = { + false, + false, + 161, + descriptor_table_protodef_WakeUpRpc_2eproto, + "WakeUpRpc.proto", + &descriptor_table_WakeUpRpc_2eproto_once, + descriptor_table_WakeUpRpc_2eproto_deps, + 1, + 1, + schemas, + file_default_instances, + TableStruct_WakeUpRpc_2eproto::offsets, + file_level_metadata_WakeUpRpc_2eproto, + file_level_enum_descriptors_WakeUpRpc_2eproto, + file_level_service_descriptors_WakeUpRpc_2eproto, +}; + +// This function exists to be marked as weak. +// It can significantly speed up compilation by breaking up LLVM's SCC +// in the .pb.cc translation units. Large translation units see a +// reduction of more than 35% of walltime for optimized builds. Without +// the weak attribute all the messages in the file, including all the +// vtables and everything they use become part of the same SCC through +// a cycle like: +// GetMetadata -> descriptor table -> default instances -> +// vtables -> GetMetadata +// By adding a weak function here we break the connection from the +// individual vtables back into the descriptor table. +PROTOBUF_ATTRIBUTE_WEAK const ::_pbi::DescriptorTable* descriptor_table_WakeUpRpc_2eproto_getter() { + return &descriptor_table_WakeUpRpc_2eproto; +} +// Force running AddDescriptors() at dynamic initialization time. +PROTOBUF_ATTRIBUTE_INIT_PRIORITY2 +static ::_pbi::AddDescriptorsRunner dynamic_init_dummy_WakeUpRpc_2eproto(&descriptor_table_WakeUpRpc_2eproto); +// =================================================================== + +class WakeUpRequest::_Internal { + public: +}; + +WakeUpRequest::WakeUpRequest(::google::protobuf::Arena* arena) + : ::google::protobuf::Message(arena) { + SharedCtor(arena); + // @@protoc_insertion_point(arena_constructor:WakeUpRequest) +} +inline PROTOBUF_NDEBUG_INLINE WakeUpRequest::Impl_::Impl_( + ::google::protobuf::internal::InternalVisibility visibility, ::google::protobuf::Arena* arena, + const Impl_& from) + : reason_(arena, from.reason_), + _cached_size_{0} {} + +WakeUpRequest::WakeUpRequest( + ::google::protobuf::Arena* arena, + const WakeUpRequest& from) + : ::google::protobuf::Message(arena) { + WakeUpRequest* const _this = this; + (void)_this; + _internal_metadata_.MergeFrom<::google::protobuf::UnknownFieldSet>( + from._internal_metadata_); + new (&_impl_) Impl_(internal_visibility(), arena, from._impl_); + + // @@protoc_insertion_point(copy_constructor:WakeUpRequest) +} +inline PROTOBUF_NDEBUG_INLINE WakeUpRequest::Impl_::Impl_( + ::google::protobuf::internal::InternalVisibility visibility, + ::google::protobuf::Arena* arena) + : reason_(arena), + _cached_size_{0} {} + +inline void WakeUpRequest::SharedCtor(::_pb::Arena* arena) { + new (&_impl_) Impl_(internal_visibility(), arena); +} +WakeUpRequest::~WakeUpRequest() { + // @@protoc_insertion_point(destructor:WakeUpRequest) + _internal_metadata_.Delete<::google::protobuf::UnknownFieldSet>(); + SharedDtor(); +} +inline void WakeUpRequest::SharedDtor() { + ABSL_DCHECK(GetArena() == nullptr); + _impl_.reason_.Destroy(); + _impl_.~Impl_(); +} + +::_pbi::CachedSize* WakeUpRequest::AccessCachedSize() const { + return &_impl_._cached_size_; +} +void WakeUpRequest::InternalSwap(WakeUpRequest* PROTOBUF_RESTRICT other) { + using std::swap; + GetReflection()->Swap(this, other);} + +::google::protobuf::Metadata WakeUpRequest::GetMetadata() const { + return ::_pbi::AssignDescriptors( + &descriptor_table_WakeUpRpc_2eproto_getter, &descriptor_table_WakeUpRpc_2eproto_once, + file_level_metadata_WakeUpRpc_2eproto[0]); +} +// @@protoc_insertion_point(namespace_scope) +namespace google { +namespace protobuf { +} // namespace protobuf +} // namespace google +// @@protoc_insertion_point(global_scope) +#include "google/protobuf/port_undef.inc" diff --git a/packages/streamr-proto-rpc/test/proto/WakeUpRpc.pb.h b/packages/streamr-proto-rpc/test/proto/WakeUpRpc.pb.h new file mode 100644 index 0000000..3b818f1 --- /dev/null +++ b/packages/streamr-proto-rpc/test/proto/WakeUpRpc.pb.h @@ -0,0 +1,309 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: WakeUpRpc.proto +// Protobuf C++ Version: 4.25.1 + +#ifndef GOOGLE_PROTOBUF_INCLUDED_WakeUpRpc_2eproto_2epb_2eh +#define GOOGLE_PROTOBUF_INCLUDED_WakeUpRpc_2eproto_2epb_2eh + +#include +#include +#include +#include + +#include "google/protobuf/port_def.inc" +#if PROTOBUF_VERSION < 4025000 +#error "This file was generated by a newer version of protoc which is" +#error "incompatible with your Protocol Buffer headers. Please update" +#error "your headers." +#endif // PROTOBUF_VERSION + +#if 4025001 < PROTOBUF_MIN_PROTOC_VERSION +#error "This file was generated by an older version of protoc which is" +#error "incompatible with your Protocol Buffer headers. Please" +#error "regenerate this file with a newer version of protoc." +#endif // PROTOBUF_MIN_PROTOC_VERSION +#include "google/protobuf/port_undef.inc" +#include "google/protobuf/io/coded_stream.h" +#include "google/protobuf/arena.h" +#include "google/protobuf/arenastring.h" +#include "google/protobuf/generated_message_util.h" +#include "google/protobuf/metadata_lite.h" +#include "google/protobuf/generated_message_reflection.h" +#include "google/protobuf/message.h" +#include "google/protobuf/repeated_field.h" // IWYU pragma: export +#include "google/protobuf/extension_set.h" // IWYU pragma: export +#include "google/protobuf/unknown_field_set.h" +#include "google/protobuf/empty.pb.h" +// @@protoc_insertion_point(includes) + +// Must be included last. +#include "google/protobuf/port_def.inc" + +#define PROTOBUF_INTERNAL_EXPORT_WakeUpRpc_2eproto + +namespace google { +namespace protobuf { +namespace internal { +class AnyMetadata; +} // namespace internal +} // namespace protobuf +} // namespace google + +// Internal implementation detail -- do not use these members. +struct TableStruct_WakeUpRpc_2eproto { + static const ::uint32_t offsets[]; +}; +extern const ::google::protobuf::internal::DescriptorTable + descriptor_table_WakeUpRpc_2eproto; +class WakeUpRequest; +struct WakeUpRequestDefaultTypeInternal; +extern WakeUpRequestDefaultTypeInternal _WakeUpRequest_default_instance_; +namespace google { +namespace protobuf { +} // namespace protobuf +} // namespace google + + +// =================================================================== + + +// ------------------------------------------------------------------- + +class WakeUpRequest final : + public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:WakeUpRequest) */ { + public: + inline WakeUpRequest() : WakeUpRequest(nullptr) {} + ~WakeUpRequest() override; + template + explicit PROTOBUF_CONSTEXPR WakeUpRequest(::google::protobuf::internal::ConstantInitialized); + + inline WakeUpRequest(const WakeUpRequest& from) + : WakeUpRequest(nullptr, from) {} + WakeUpRequest(WakeUpRequest&& from) noexcept + : WakeUpRequest() { + *this = ::std::move(from); + } + + inline WakeUpRequest& operator=(const WakeUpRequest& from) { + CopyFrom(from); + return *this; + } + inline WakeUpRequest& operator=(WakeUpRequest&& from) noexcept { + if (this == &from) return *this; + if (GetArena() == from.GetArena() + #ifdef PROTOBUF_FORCE_COPY_IN_MOVE + && GetArena() != nullptr + #endif // !PROTOBUF_FORCE_COPY_IN_MOVE + ) { + InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + + inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const + ABSL_ATTRIBUTE_LIFETIME_BOUND { + return _internal_metadata_.unknown_fields<::google::protobuf::UnknownFieldSet>(::google::protobuf::UnknownFieldSet::default_instance); + } + inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() + ABSL_ATTRIBUTE_LIFETIME_BOUND { + return _internal_metadata_.mutable_unknown_fields<::google::protobuf::UnknownFieldSet>(); + } + + static const ::google::protobuf::Descriptor* descriptor() { + return GetDescriptor(); + } + static const ::google::protobuf::Descriptor* GetDescriptor() { + return default_instance().GetMetadata().descriptor; + } + static const ::google::protobuf::Reflection* GetReflection() { + return default_instance().GetMetadata().reflection; + } + static const WakeUpRequest& default_instance() { + return *internal_default_instance(); + } + static inline const WakeUpRequest* internal_default_instance() { + return reinterpret_cast( + &_WakeUpRequest_default_instance_); + } + static constexpr int kIndexInFileMessages = + 0; + + friend void swap(WakeUpRequest& a, WakeUpRequest& b) { + a.Swap(&b); + } + inline void Swap(WakeUpRequest* other) { + if (other == this) return; + #ifdef PROTOBUF_FORCE_COPY_IN_SWAP + if (GetArena() != nullptr && + GetArena() == other->GetArena()) { + #else // PROTOBUF_FORCE_COPY_IN_SWAP + if (GetArena() == other->GetArena()) { + #endif // !PROTOBUF_FORCE_COPY_IN_SWAP + InternalSwap(other); + } else { + ::google::protobuf::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(WakeUpRequest* other) { + if (other == this) return; + ABSL_DCHECK(GetArena() == other->GetArena()); + InternalSwap(other); + } + + // implements Message ---------------------------------------------- + + WakeUpRequest* New(::google::protobuf::Arena* arena = nullptr) const final { + return CreateMaybeMessage(arena); + } + int GetCachedSize() const { return _impl_._cached_size_.Get(); } + + private: + ::google::protobuf::internal::CachedSize* AccessCachedSize() const final; + void SharedCtor(::google::protobuf::Arena* arena); + void SharedDtor(); + void InternalSwap(WakeUpRequest* other); + + private: + friend class ::google::protobuf::internal::AnyMetadata; + static ::absl::string_view FullMessageName() { + return "WakeUpRequest"; + } + protected: + explicit WakeUpRequest(::google::protobuf::Arena* arena); + WakeUpRequest(::google::protobuf::Arena* arena, const WakeUpRequest& from); + public: + + ::google::protobuf::Metadata GetMetadata() const final; + + // nested types ---------------------------------------------------- + + // accessors ------------------------------------------------------- + + enum : int { + kReasonFieldNumber = 1, + }; + // string reason = 1; + void clear_reason() ; + const std::string& reason() const; + template + void set_reason(Arg_&& arg, Args_... args); + std::string* mutable_reason(); + PROTOBUF_NODISCARD std::string* release_reason(); + void set_allocated_reason(std::string* value); + + private: + const std::string& _internal_reason() const; + inline PROTOBUF_ALWAYS_INLINE void _internal_set_reason( + const std::string& value); + std::string* _internal_mutable_reason(); + + public: + // @@protoc_insertion_point(class_scope:WakeUpRequest) + private: + class _Internal; + + friend class ::google::protobuf::MessageLite; + friend class ::google::protobuf::Arena; + template + friend class ::google::protobuf::Arena::InternalHelper; + using InternalArenaConstructable_ = void; + using DestructorSkippable_ = void; + struct Impl_ { + + inline explicit constexpr Impl_( + ::google::protobuf::internal::ConstantInitialized) noexcept; + inline explicit Impl_(::google::protobuf::internal::InternalVisibility visibility, + ::google::protobuf::Arena* arena); + inline explicit Impl_(::google::protobuf::internal::InternalVisibility visibility, + ::google::protobuf::Arena* arena, const Impl_& from); + ::google::protobuf::internal::ArenaStringPtr reason_; + mutable ::google::protobuf::internal::CachedSize _cached_size_; + PROTOBUF_TSAN_DECLARE_MEMBER + }; + union { Impl_ _impl_; }; + friend struct ::TableStruct_WakeUpRpc_2eproto; +}; + +// =================================================================== + + + + +// =================================================================== + + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wstrict-aliasing" +#endif // __GNUC__ +// ------------------------------------------------------------------- + +// WakeUpRequest + +// string reason = 1; +inline void WakeUpRequest::clear_reason() { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + _impl_.reason_.ClearToEmpty(); +} +inline const std::string& WakeUpRequest::reason() const + ABSL_ATTRIBUTE_LIFETIME_BOUND { + // @@protoc_insertion_point(field_get:WakeUpRequest.reason) + return _internal_reason(); +} +template +inline PROTOBUF_ALWAYS_INLINE void WakeUpRequest::set_reason(Arg_&& arg, + Args_... args) { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + ; + _impl_.reason_.Set(static_cast(arg), args..., GetArena()); + // @@protoc_insertion_point(field_set:WakeUpRequest.reason) +} +inline std::string* WakeUpRequest::mutable_reason() ABSL_ATTRIBUTE_LIFETIME_BOUND { + std::string* _s = _internal_mutable_reason(); + // @@protoc_insertion_point(field_mutable:WakeUpRequest.reason) + return _s; +} +inline const std::string& WakeUpRequest::_internal_reason() const { + PROTOBUF_TSAN_READ(&_impl_._tsan_detect_race); + return _impl_.reason_.Get(); +} +inline void WakeUpRequest::_internal_set_reason(const std::string& value) { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + ; + _impl_.reason_.Set(value, GetArena()); +} +inline std::string* WakeUpRequest::_internal_mutable_reason() { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + ; + return _impl_.reason_.Mutable( GetArena()); +} +inline std::string* WakeUpRequest::release_reason() { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + // @@protoc_insertion_point(field_release:WakeUpRequest.reason) + return _impl_.reason_.Release(); +} +inline void WakeUpRequest::set_allocated_reason(std::string* value) { + PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race); + _impl_.reason_.SetAllocated(value, GetArena()); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (_impl_.reason_.IsDefault()) { + _impl_.reason_.Set("", GetArena()); + } + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + // @@protoc_insertion_point(field_set_allocated:WakeUpRequest.reason) +} + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif // __GNUC__ + +// @@protoc_insertion_point(namespace_scope) + + +// @@protoc_insertion_point(global_scope) + +#include "google/protobuf/port_undef.inc" + +#endif // GOOGLE_PROTOBUF_INCLUDED_WakeUpRpc_2eproto_2epb_2eh diff --git a/packages/streamr-proto-rpc/test/proto/WakeUpRpc.server.pb.h b/packages/streamr-proto-rpc/test/proto/WakeUpRpc.server.pb.h new file mode 100644 index 0000000..44dbc61 --- /dev/null +++ b/packages/streamr-proto-rpc/test/proto/WakeUpRpc.server.pb.h @@ -0,0 +1,19 @@ +// Generated by the protocol buffer streamr pluging. DO NOT EDIT! +// Generated from protobuf file "WakeUpRpc.proto" + +#ifndef STREAMR_PROTORPC_WAKEUPRPC_SERVER_PB_H +#define STREAMR_PROTORPC_WAKEUPRPC_SERVER_PB_H + +#include "WakeUpRpc.pb.h" // NOLINT +#include + +namespace streamr::protorpc { +class WakeUpRpcService { +public: + virtual ~WakeUpRpcService() = default; + virtual void wakeUp(const WakeUpRequest& request, const ProtoCallContext& callContext) = 0; +}; // class WakeUpRpcService +}; // namespace streamr::protorpc + +#endif // STREAMR_PROTORPC_WAKEUPRPC_SERVER_PB_H + diff --git a/packages/streamr-proto-rpc/test/protos/HelloRpc.proto b/packages/streamr-proto-rpc/test/protos/HelloRpc.proto new file mode 100644 index 0000000..0d9a7b1 --- /dev/null +++ b/packages/streamr-proto-rpc/test/protos/HelloRpc.proto @@ -0,0 +1,17 @@ +// This file is a copy of +// https://github.com/streamr-dev/network/blob/b267dcfb1e98fa2b882fa21a41a279f3a8658f50/packages/proto-rpc/test/protos/HelloRpc.proto + +syntax = "proto3"; +option optimize_for = CODE_SIZE; + +service HelloRpcService { + rpc sayHello (HelloRequest) returns (HelloResponse); +} + +message HelloRequest { + string myName = 1; + } + +message HelloResponse { + string greeting = 1; + } \ No newline at end of file diff --git a/packages/streamr-proto-rpc/test/protos/TestProtos.proto b/packages/streamr-proto-rpc/test/protos/TestProtos.proto new file mode 100644 index 0000000..98575b5 --- /dev/null +++ b/packages/streamr-proto-rpc/test/protos/TestProtos.proto @@ -0,0 +1,76 @@ +// This file is a copy of +// https://github.com/streamr-dev/network/blob/b267dcfb1e98fa2b882fa21a41a279f3a8658f50/packages/proto-rpc/test/protos/TestProtos.proto + +syntax = "proto3"; + +option optimize_for = CODE_SIZE; + +service DhtRpcService { + rpc getClosestPeers (ClosestPeersRequest) returns (ClosestPeersResponse); + rpc ping (PingRequest) returns (PingResponse); + rpc routeMessage (RouteMessageWrapper) returns (RouteMessageAck); +} + +message RouteMessageWrapper { + PeerDescriptor sourcePeer = 1; + string requestId = 2; + PeerDescriptor destinationPeer = 3; + PeerDescriptor previousPeer = 4; + bytes message = 5; // Expected to be of type Message +} + +message RouteMessageAck { + PeerDescriptor sourcePeer = 1; + string requestId = 2; + PeerDescriptor destinationPeer = 3; + string error = 4; +} + +message PingRequest { + string requestId = 1; + } + +message PingResponse { + string requestId = 1; + } + +message ClosestPeersRequest { + PeerDescriptor peerDescriptor = 1; + string requestId = 2; + } + +message ClosestPeersResponse { + repeated PeerDescriptor peers = 1; + string requestId = 2; + } + +message PeerDescriptor { + bytes nodeId = 1; + NodeType type = 2; + ConnectivityMethod udp = 3; + ConnectivityMethod tcp = 4; + ConnectivityMethod websocket = 5; + optional bool openInternet = 6; + } + + message ConnectivityMethod { + uint32 port = 2; + string ip = 3; + } + + service OptionalService { + rpc getOptional (OptionalRequest) returns (OptionalResponse); + } + + message OptionalRequest { + optional string someOptionalField = 1; + } + + message OptionalResponse { + optional string someOptionalField = 1; + } + + enum NodeType { + NODEJS = 0; + BROWSER = 1; + } diff --git a/packages/streamr-proto-rpc/test/protos/WakeUpRpc.proto b/packages/streamr-proto-rpc/test/protos/WakeUpRpc.proto new file mode 100644 index 0000000..195923d --- /dev/null +++ b/packages/streamr-proto-rpc/test/protos/WakeUpRpc.proto @@ -0,0 +1,15 @@ +// This file is a copy of +// https://github.com/streamr-dev/network/blob/b267dcfb1e98fa2b882fa21a41a279f3a8658f50/packages/proto-rpc/test/protos/WakeUpRpc.proto + +syntax = "proto3"; +option optimize_for = CODE_SIZE; + +import "google/protobuf/empty.proto"; + +service WakeUpRpcService { + rpc wakeUp (WakeUpRequest) returns (google.protobuf.Empty); +} + +message WakeUpRequest { + string reason = 1; + } diff --git a/packages/streamr-proto-rpc/test/unit/RpcCommunicatorTest.cpp b/packages/streamr-proto-rpc/test/unit/RpcCommunicatorTest.cpp new file mode 100644 index 0000000..04a7ff3 --- /dev/null +++ b/packages/streamr-proto-rpc/test/unit/RpcCommunicatorTest.cpp @@ -0,0 +1,468 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "HelloRpc.pb.h" +#include "streamr-proto-rpc/Errors.hpp" +#include "streamr-proto-rpc/ProtoCallContext.hpp" +#include "streamr-proto-rpc/ServerRegistry.hpp" + +namespace streamr::protorpc { + +class RpcCommunicatorTest : public ::testing::Test { +public: + RpcCommunicatorTest() + : executor(folly::CPUThreadPoolExecutor(threadPoolSize)) {} // NOLINT + + ~RpcCommunicatorTest() override { + SLogger::warn("Deleting executor of RpcCommunicatorTest"); + SLogger::warn("RpcCommunicatorTest executor deleted"); + } + +protected: + RpcCommunicator communicator1; // NOLINT + RpcCommunicator communicator2; // NOLINT + folly::CPUThreadPoolExecutor executor; // NOLINT + + void SetUp() override {} + + void setCallbacks(bool isMethod = true) { + communicator2.setOutgoingMessageCallback( + [this]( + const RpcMessage& message, + const std::string& /* requestId */, + const ProtoCallContext& /* context */) -> void { + SLogger::info("onOutgoingMessageCallback()"); + communicator1.handleIncomingMessage( + message, ProtoCallContext()); + }); + if (isMethod) { + communicator1.setOutgoingMessageCallback( + [this]( + const RpcMessage& message, + const std::string& /* requestId */, + const ProtoCallContext& /* context */) -> void { + SLogger::info("onOutgoingMessageCallback()"); + communicator2.handleIncomingMessage( + message, ProtoCallContext()); + }); + } + } +}; + +void registerTestRcpMethod(RpcCommunicator& communicator) { + communicator.registerRpcMethod( + "testFunction", + [](const HelloRequest& request, + const ProtoCallContext& /* context */) -> HelloResponse { + HelloResponse response; + SLogger::info("testFunction() request.myname():", request.myname()); + response.set_greeting("Hello, " + request.myname()); + return response; + }); +} + +template +void registerThrowingRcpMethod(RpcCommunicator& communicator) { + communicator.registerRpcMethod( + "testFunction", + [](const HelloRequest& /* request */, + const ProtoCallContext& /* context */) -> HelloResponse { + throw T("TestException"); + }); +} + +void registerThrowingTestRcpMethodUnknown(RpcCommunicator& communicator) { + const int unknownThrow = 42; + communicator.registerRpcMethod( + "testFunction", + [](const HelloRequest& /* request */, + const ProtoCallContext& /* context */) -> HelloResponse { + throw unknownThrow; // NOLINT + }); +} +/* +void setOutgoingCallback(RpcCommunicator& sender, RpcCommunicator& receiver) { + sender.setOutgoingMessageCallback( + [&receiver]( + const RpcMessage& message, + const std::string& requestId , + const ProtoCallContext& context ) -> void { + SLogger::info("onOutgoingMessageCallback()"); + receiver.handleIncomingMessage(message, ProtoCallContext()); + }); +} + +void setOutgoingCallbacks( + RpcCommunicator& communicator1, RpcCommunicator& communicator2) { + setOutgoingCallback(communicator2, communicator1); + setOutgoingCallback(communicator1, communicator2); +} +*/ +template +void setOutgoingCallbackWithException(RpcCommunicator& sender) { + sender.setOutgoingMessageCallback( + [](const RpcMessage& /* message */, + const std::string& /* requestId */, + const ProtoCallContext& /* context */) -> void { + SLogger::info("onOutgoingMessageCallback() throws"); + throw T("TestException"); + }); +} + +void setOutgoingCallbackWithThrownUnknown(RpcCommunicator& sender) { + const int unknownThrow = 42; + sender.setOutgoingMessageCallback( + [](const RpcMessage& /* message */, + const std::string& /* requestId */, + const ProtoCallContext& /* context */) -> void { + SLogger::info("onOutgoingMessageCallback() throws"); + throw unknownThrow; // NOLINT + }); +} + +auto sendHelloRequest( + RpcCommunicator& sender, folly::CPUThreadPoolExecutor* executor) { + HelloRequest request; + request.set_myname("Test"); + return folly::coro::blockingWait( + sender + .request( + "testFunction", request, ProtoCallContext()) + .scheduleOn(executor)); +} + +auto sendHelloNotification( + RpcCommunicator& sender, folly::CPUThreadPoolExecutor* executor) { + HelloRequest request; + request.set_myname("Test"); + folly::coro::blockingWait( + sender.notify("testFunction", request, ProtoCallContext()) + .scheduleOn(executor)); +} + +void verifyClientError( + const RpcClientError& ex, + const ErrorCode expectedErrorCode, + const std::string& expectedOriginalErrorInfo) { + SLogger::info("Caught RpcClientError", ex.what()); + EXPECT_EQ(ex.code, expectedErrorCode); + EXPECT_TRUE(ex.originalErrorInfo.has_value()); + EXPECT_EQ(ex.originalErrorInfo.value(), expectedOriginalErrorInfo); +} + +void registerSleepingTestRcpMethod(RpcCommunicator& communicator) { + communicator.registerRpcMethod( + "testFunction", + [](const HelloRequest& request, + const ProtoCallContext& /* context */) -> HelloResponse { + SLogger::info("TestSleepingRpcMethod sleeping 1s"); + std::this_thread::sleep_for(std::chrono::seconds(1)); // NOLINT + HelloResponse response; + response.set_greeting("Hello, " + request.myname()); + return response; + }); +} + +TEST_F(RpcCommunicatorTest, TestCanRegisterRpcMethod) { + RpcCommunicator communicator; + registerTestRcpMethod(communicator); + EXPECT_EQ(true, true); +} + +TEST_F(RpcCommunicatorTest, TestCanMakeRpcCall) { + registerTestRcpMethod(communicator1); + setCallbacks(); + auto result = sendHelloRequest(communicator2, &executor); + EXPECT_EQ("Hello, Test", result.greeting()); +} + +TEST_F(RpcCommunicatorTest, TestrequestClientThrowsRuntimeError) { + registerTestRcpMethod(communicator1); + setOutgoingCallbackWithException(communicator2); + try { + sendHelloRequest(communicator2, &executor); + EXPECT_TRUE(false); + } catch (const RpcClientError& ex) { + verifyClientError(ex, ErrorCode::RPC_CLIENT_ERROR, "TestException"); + } catch (...) { + EXPECT_TRUE(false); + } +} + +TEST_F(RpcCommunicatorTest, TestrequestClientThrowsFailedToParse) { + registerTestRcpMethod(communicator1); + setOutgoingCallbackWithException(communicator2); + try { + sendHelloRequest(communicator2, &executor); + EXPECT_TRUE(false); + } catch (const RpcClientError& ex) { + verifyClientError( + ex, + ErrorCode::RPC_CLIENT_ERROR, + "code: FAILED_TO_PARSE, message: TestException"); + } catch (...) { + EXPECT_TRUE(false); + } +} + +TEST_F(RpcCommunicatorTest, TestrequestClientThrowsUnknownError) { + registerTestRcpMethod(communicator1); + setOutgoingCallbackWithThrownUnknown(communicator2); + try { + sendHelloRequest(communicator2, &executor); + EXPECT_TRUE(false); + } catch (...) { + EXPECT_TRUE(true); + } +} + +TEST_F(RpcCommunicatorTest, TestrequestServerThrowsRuntimeError) { + registerThrowingRcpMethod(communicator1); + setCallbacks(); + try { + sendHelloRequest(communicator2, &executor); + EXPECT_TRUE(false); + } catch (const RpcServerError& ex) { + EXPECT_EQ(ex.code, ErrorCode::RPC_SERVER_ERROR); + EXPECT_TRUE( + ex.errorClassName.find("runtime_error") != std::string::npos); + EXPECT_EQ(ex.message, "TestException"); + } catch (...) { + EXPECT_TRUE(false); + } +} + +TEST_F(RpcCommunicatorTest, TestrequestServerThrowsUnknownRpcMethod) { + registerThrowingRcpMethod(communicator1); + setCallbacks(); + try { + sendHelloRequest(communicator2, &executor); + EXPECT_TRUE(false); + } catch (const UnknownRpcMethod& ex) { + EXPECT_EQ(ex.code, ErrorCode::UNKNOWN_RPC_METHOD); + } catch (...) { + EXPECT_TRUE(false); + } +} + +TEST_F(RpcCommunicatorTest, TestrequestServerThrowsRcpTimeout) { + registerThrowingRcpMethod(communicator1); + setCallbacks(); + try { + sendHelloRequest(communicator2, &executor); + EXPECT_TRUE(false); + } catch (const RpcTimeout& ex) { + EXPECT_EQ(ex.code, ErrorCode::RPC_TIMEOUT); + } catch (...) { + EXPECT_TRUE(false); + } +} + +TEST_F(RpcCommunicatorTest, TestrequestServerThrowsFailedToParse) { + registerThrowingRcpMethod(communicator1); + setCallbacks(); + try { + sendHelloRequest(communicator2, &executor); + EXPECT_TRUE(false); + } catch (const RpcServerError& ex) { + EXPECT_EQ(ex.code, ErrorCode::RPC_SERVER_ERROR); + EXPECT_EQ(ex.errorCode, "FAILED_TO_PARSE"); + EXPECT_TRUE( + ex.errorClassName.find("FailedToParse") != std::string::npos); + } catch (...) { + EXPECT_TRUE(false); + } +} + +TEST_F(RpcCommunicatorTest, TestrequestServerThrowsUnknown) { + registerThrowingTestRcpMethodUnknown(communicator1); + setCallbacks(); + try { + sendHelloRequest(communicator2, &executor); + EXPECT_TRUE(false); + } catch (...) { + EXPECT_TRUE(true); + } +} + +TEST_F(RpcCommunicatorTest, TestCannotify) { + std::string requestMsg; + communicator1.registerRpcNotification( + "testFunction", + [&requestMsg]( + const HelloRequest& request, const ProtoCallContext& /* context */) + -> void { requestMsg = request.DebugString(); }); + setCallbacks(false); + sendHelloNotification(communicator2, &executor); + EXPECT_EQ(requestMsg, "myName: \"Test\"\n"); +} + +TEST_F(RpcCommunicatorTest, TestnotifyClientThrowsRuntimeError) { + setOutgoingCallbackWithException(communicator2); + try { + sendHelloNotification(communicator2, &executor); + EXPECT_TRUE(false); + } catch (const RpcClientError& ex) { + verifyClientError(ex, ErrorCode::RPC_CLIENT_ERROR, "TestException"); + } catch (...) { + EXPECT_TRUE(false); + } +} + +TEST_F(RpcCommunicatorTest, TestnotifyClientThrowsFailedToParse) { + setOutgoingCallbackWithException(communicator2); + try { + sendHelloNotification(communicator2, &executor); + EXPECT_TRUE(false); + } catch (const RpcClientError& ex) { + verifyClientError( + ex, + ErrorCode::RPC_CLIENT_ERROR, + "code: FAILED_TO_PARSE, message: TestException"); + } catch (...) { + EXPECT_TRUE(false); + } +} + +TEST_F(RpcCommunicatorTest, TestRpcTimeoutOnClientSide) { + registerTestRcpMethod(communicator1); + + communicator2.setOutgoingMessageCallback( + [&communicator1 = this->communicator1]( + const RpcMessage& /* message */, + const std::string& /* requestId */, + const ProtoCallContext& /* context */) -> void { + SLogger::info("setOutgoingMessageCallback() sleeping 1s"); + std::this_thread::sleep_for(std::chrono::seconds(1)); // NOLINT + }); + + HelloRequest request; + request.set_myname("Test"); + + try { + folly::coro::blockingWait( + communicator2 + .request( + "testFunction", + request, + ProtoCallContext{.timeout = 50}) // NOLINT + .scheduleOn(&executor)); + // Test fails here + EXPECT_TRUE(false); + } catch (const RpcTimeout& ex) { + SLogger::info("TestRpcTimeout caught RpcTimeout", ex.what()); + } catch (const std::exception& ex) { + SLogger::info( + "TestRpcTimeoutOnClientSide caught unknown exception", ex.what()); + EXPECT_TRUE(false); + } +} + +TEST_F(RpcCommunicatorTest, TestRpcTimeoutOnServerSide) { + registerSleepingTestRcpMethod(communicator1); + + std::shared_ptr thread; + + communicator2.setOutgoingMessageCallback( + [&communicator1 = this->communicator1, &thread]( + const RpcMessage& message, + const std::string& /* requestId */, + const ProtoCallContext& context) -> void { + thread = std::make_shared( + [&communicator1, message, context]() { + SLogger::info("Starting thread for server"); + communicator1.handleIncomingMessage(message, context); + }); + }); + communicator1.setOutgoingMessageCallback( + [&communicator2 = this->communicator2]( + const RpcMessage& message, + const std::string& /* requestId */, + const ProtoCallContext& context) -> void { + communicator2.handleIncomingMessage(message, context); + }); + + HelloRequest request; + request.set_myname("Test"); + try { + auto result = folly::coro::blockingWait( + communicator2 + .request( + "testFunction", + request, + ProtoCallContext{.timeout = 50}) // NOLINT + .scheduleOn(&executor)); + EXPECT_EQ(true, false); + } catch (const RpcTimeout& ex) { + SLogger::info( + "TestRpcTimeoutOnServerSide caught RpcTimeout", ex.what()); + } catch (...) { + SLogger::info("TestRpcTimeoutOnServerSide caught unknown exception"); + EXPECT_EQ(true, false); + } + thread->join(); +} + +TEST_F(RpcCommunicatorTest, TestRpcTimeoutOnClientSideForNotification) { + std::string requestMsg; + + communicator1.registerRpcNotification( + "testFunction", + [&requestMsg]( + const HelloRequest& request, const ProtoCallContext& /* context */) + -> void { requestMsg = request.DebugString(); }); + + HelloRequest request; + request.set_myname("Test"); + + communicator2.setOutgoingMessageCallback( + [&communicator1 = this->communicator1]( + const RpcMessage& /* message */, + const std::string& /* requestId */, + const ProtoCallContext& /* context */) -> void { + std::cout << "setOutgoingMessageCallback() sleeping 1s, thread id: " + << std::this_thread::get_id() << "\n"; + std::this_thread::sleep_for(std::chrono::seconds(1)); // NOLINT + }); + try { + // auto str = std::this_thread::get_id(); + + std::cout << "Calling notify() from thread id: " + << std::this_thread::get_id() << "\n"; + folly::coro::blockingWait( + communicator2 + .notify( + "testFunction", + request, + ProtoCallContext{.timeout = 50}) // NOLINT + .scheduleOn(&executor)); + // Test fails here + EXPECT_TRUE(false); + } catch (const RpcTimeout& ex) { + std::cout + << "TestRpcTimeoutOnClientSideForNotification caught RpcTimeout in thread id: " + << std::this_thread::get_id() << "\n"; + } catch (const std::exception& ex) { + std::cout + << "TestRpcTimeoutOnClientSideForNotification caught unknown exception in thread id: " + << std::this_thread::get_id() << "\n"; + EXPECT_TRUE(false); + EXPECT_TRUE(false); + } +} + +} // namespace streamr::protorpc diff --git a/packages/streamr-proto-rpc/test/unit/ServerRegistryTest.cpp b/packages/streamr-proto-rpc/test/unit/ServerRegistryTest.cpp new file mode 100644 index 0000000..b381a9f --- /dev/null +++ b/packages/streamr-proto-rpc/test/unit/ServerRegistryTest.cpp @@ -0,0 +1,91 @@ +#include + +#include +#include "HelloRpc.pb.h" +#include "streamr-proto-rpc/ServerRegistry.hpp" + +// BEGINNOLINT + +namespace streamr::protorpc { + +class ServerRegistryTest : public ::testing::Test { +protected: + ServerRegistry registry; // NOLINT + void SetUp() override {} +}; + +RpcMessage createHelloRcpMessage( + std::optional method = "sayHello") { + HelloRequest request; + request.set_myname("testUser"); + RpcMessage requestWrapper; + auto& header = *requestWrapper.mutable_header(); + if (method.has_value()) { + header["method"] = method.value(); + } + header["request"] = "request"; + + Any* body = new Any(); + body->PackFrom(request); + requestWrapper.set_allocated_body(body); // protobuf will take ownership + + requestWrapper.set_requestid("request-id"); + return requestWrapper; +} + +TEST_F(ServerRegistryTest, TestCanHandleRequest) { + RpcMessage requestWrapper = createHelloRcpMessage(); + registry.registerRpcMethod( + "sayHello", + [](const HelloRequest& request, + const ProtoCallContext& /* callContext */) -> HelloResponse { + HelloResponse response; + response.set_greeting("hello " + request.myname()); + + return response; + }); + auto res = registry.handleRequest(requestWrapper, {}); + HelloResponse helloResponse; + auto unpacked = res.UnpackTo(&helloResponse); + EXPECT_EQ(helloResponse.greeting(), "hello testUser"); +} + +TEST_F(ServerRegistryTest, HandleUnknownRpcMethod) { + RpcMessage requestWrapper = createHelloRcpMessage("unknownMethod"); + EXPECT_THROW(registry.handleRequest(requestWrapper, {}), UnknownRpcMethod); +} + +TEST_F(ServerRegistryTest, HandleRequestWithMissingMethodHeader) { + RpcMessage requestWrapper = createHelloRcpMessage(std::nullopt); + EXPECT_THROW(registry.handleRequest(requestWrapper, {}), UnknownRpcMethod); +} + +TEST_F(ServerRegistryTest, RegisterAndHandleRpcNotification) { + RpcMessage requestWrapper = createHelloRcpMessage("testNotification"); + bool notificationCalled = false; + auto rpcNotification = [¬ificationCalled]( + const HelloRequest& /* request */, + const ProtoCallContext& /* context */) -> void { + notificationCalled = true; + }; + registry.registerRpcNotification( + "testNotification", rpcNotification); + registry.handleNotification(requestWrapper, {}); + EXPECT_TRUE(notificationCalled); +} + +TEST_F(ServerRegistryTest, HandleUnknownRpcNotification) { + RpcMessage requestWrapper = createHelloRcpMessage("unknownNotification"); + EXPECT_THROW( + registry.handleNotification(requestWrapper, {}), UnknownRpcMethod); +} + +TEST_F(ServerRegistryTest, HandleNotificationWithMissingMethodHeader) { + RpcMessage requestWrapper = createHelloRcpMessage(std::nullopt); + EXPECT_THROW( + registry.handleNotification(requestWrapper, {}), UnknownRpcMethod); +} + +} // namespace streamr::protorpc + +// ENDNOLINT \ No newline at end of file diff --git a/packages/streamr-proto-rpc/vcpkg.json b/packages/streamr-proto-rpc/vcpkg.json index efc35a6..af21050 100644 --- a/packages/streamr-proto-rpc/vcpkg.json +++ b/packages/streamr-proto-rpc/vcpkg.json @@ -2,14 +2,19 @@ "name": "streamr-proto-rpc", "version": "1.0.0", "dependencies": [ - "folly" + "gtest", + "protobuf", + "folly", + "boost-uuid", + "magic-enum" ], "features": { "monorepo": { "description": "Monorepo dependencies", "dependencies": [ - "streamr-logger" + "streamr-logger", + "streamr-eventemitter" ] } } -} \ No newline at end of file +} diff --git a/packages/streamr-utils/homebrewClang.cmake b/packages/streamr-utils/homebrewClang.cmake index 41e7cac..7fb0426 100644 --- a/packages/streamr-utils/homebrewClang.cmake +++ b/packages/streamr-utils/homebrewClang.cmake @@ -1,7 +1,7 @@ if (${APPLE}) set(HOMEBREW_PREFIX $ENV{HOMEBREW_PREFIX}) - set(LLVM_PREFIX "${HOMEBREW_PREFIX}/opt/llvm") + set(LLVM_PREFIX "${HOMEBREW_PREFIX}") set(CMAKE_C_COMPILER "${LLVM_PREFIX}/bin/clang") set(CMAKE_CXX_COMPILER "${LLVM_PREFIX}/bin/clang++") set(ENV{CC} "${CMAKE_C_COMPILER}") @@ -20,7 +20,7 @@ if (${APPLE}) set(CMAKE_FIND_FRAMEWORK LAST) set(CMAKE_FIND_APPBUNDLE LAST) - add_link_options("-L/opt/homebrew/opt/llvm/lib/c++" "-Wl,-rpath,/opt/homebrew/opt/llvm/lib/c++") + add_link_options("-L/opt/homebrew/lib/c++" "-Wl,-rpath,/opt/homebrew/lib/c++") #set(CMAKE_FIND_USE_CMAKE_SYSTEM_PATH FALSE) #set(CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH FALSE) endif() diff --git a/packages/streamr-utils/monorepoPackage.cmake b/packages/streamr-utils/monorepoPackage.cmake index 3df1f3b..58c93b9 100644 --- a/packages/streamr-utils/monorepoPackage.cmake +++ b/packages/streamr-utils/monorepoPackage.cmake @@ -1,7 +1,14 @@ +set(CMAKE_POLICY_DEFAULT_CMP0077 NEW) if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/../../MonorepoPackages.cmake) message(STATUS "In monorepo sub-package ${CMAKE_CURRENT_SOURCE_DIR}") - + + # if in monorepo, do not install vcpkg dependencies + set(VCPKG_MANIFEST_INSTALL OFF) + + # if in monorepo, use the vcpkg dependencies from the monorepo root + set(VCPKG_INSTALLED_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../build/vcpkg_installed) + # if in monorepo, use the monorepo deps from filesystem if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/vcpkg.json) file(READ ${CMAKE_CURRENT_SOURCE_DIR}/vcpkg.json VCPKG_JSON) diff --git a/vcpkg b/vcpkg index 099fb92..fe1cde6 160000 --- a/vcpkg +++ b/vcpkg @@ -1 +1 @@ -Subproject commit 099fb9250d916511782bf5215f01f2e7141beb3a +Subproject commit fe1cde61e971d53c9687cf9a46308f8f55da19fa diff --git a/vcpkg.json b/vcpkg.json index ee32a9e..125e67b 100644 --- a/vcpkg.json +++ b/vcpkg.json @@ -4,8 +4,11 @@ "dependencies": [ "boost-config", "boost-pfr", + "boost-uuid", "folly", "gtest", - "nlohmann-json" + "magic-enum", + "nlohmann-json", + "protobuf" ] }