feat(rpc): implement P2 S-RPC-01..03 Wire v1 binary codec and unary HTTP/1.1 RPC subsystem
This commit is contained in:
1 parent
691808eab6
commit
5184d1cf8c
11 files changed
+1778
-1
No files matched your search
@@ -0,0 +1,14 @@
|
||||
cmake_minimum_required(VERSION 4.0)
|
||||
project(VoidRpcOnlyConsumer LANGUAGES CXX)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 26)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||
|
||||
find_package(Void CONFIG REQUIRED COMPONENTS RPC)
|
||||
|
||||
add_executable(rpc_only_consumer main.cpp)
|
||||
target_link_libraries(rpc_only_consumer PRIVATE Void::RPC)
|
||||
|
||||
enable_testing()
|
||||
add_test(NAME rpc_only_consumer COMMAND rpc_only_consumer)
|
||||
@@ -0,0 +1,26 @@
|
||||
#include <Void/RPC/Codec.hpp>
|
||||
#include <Void/RPC/Rpc.hpp>
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstring>
|
||||
|
||||
int main()
|
||||
{
|
||||
using namespace Void::RPC;
|
||||
Server server;
|
||||
constexpr MethodId kPing{1, 1};
|
||||
auto reg = server.bind(
|
||||
MethodDescriptor{kPing, "sys", "ping", 1, true},
|
||||
[](const CallContext&, OwnedBytes body) { return Void::Result::ok(body); });
|
||||
if (!reg.has_value() || !server.start().has_value()) {
|
||||
return 1;
|
||||
}
|
||||
Client client{ClientOptions{.endpoint_base_url = server.base_url()}};
|
||||
OwnedBytes payload{std::byte{'o'}, std::byte{'k'}};
|
||||
auto resp = client.call(kPing, payload);
|
||||
server.shutdown();
|
||||
if (!resp.has_value() || resp->size() != 2 || (*resp)[0] != std::byte{'o'}) {
|
||||
return 2;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
Reference in new issue
Block a user