working commit

This commit is contained in:
2026-04-29 11:54:21 +02:00
parent 5e1ca61df9
commit 972096c53d
8 changed files with 149 additions and 86 deletions
+71 -41
View File
@@ -23,7 +23,8 @@ namespace _pbi = _pb::internal;
namespace control {
PROTOBUF_CONSTEXPR ReqMeta::ReqMeta(
::_pbi::ConstantInitialized): _impl_{
/*decltype(_impl_.rpcname_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}}
/*decltype(_impl_.kind_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}}
, /*decltype(_impl_.rpc_)*/false
, /*decltype(_impl_._cached_size_)*/{}} {}
struct ReqMetaDefaultTypeInternal {
PROTOBUF_CONSTEXPR ReqMetaDefaultTypeInternal()
@@ -114,7 +115,8 @@ const uint32_t TableStruct_control_2eproto::offsets[] PROTOBUF_SECTION_VARIABLE(
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
~0u, // no _inlined_string_donated_
PROTOBUF_FIELD_OFFSET(::control::ReqMeta, _impl_.rpcname_),
PROTOBUF_FIELD_OFFSET(::control::ReqMeta, _impl_.kind_),
PROTOBUF_FIELD_OFFSET(::control::ReqMeta, _impl_.rpc_),
~0u, // no _has_bits_
PROTOBUF_FIELD_OFFSET(::control::ResMeta, _internal_metadata_),
~0u, // no _extensions_
@@ -156,11 +158,11 @@ const uint32_t TableStruct_control_2eproto::offsets[] PROTOBUF_SECTION_VARIABLE(
};
static const ::_pbi::MigrationSchema schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {
{ 0, -1, -1, sizeof(::control::ReqMeta)},
{ 7, -1, -1, sizeof(::control::ResMeta)},
{ 15, -1, -1, sizeof(::control::Request)},
{ 22, -1, -1, sizeof(::control::Result)},
{ 29, -1, -1, sizeof(::control::HelloRequest)},
{ 37, -1, -1, sizeof(::control::HelloResult)},
{ 8, -1, -1, sizeof(::control::ResMeta)},
{ 16, -1, -1, sizeof(::control::Request)},
{ 23, -1, -1, sizeof(::control::Result)},
{ 30, -1, -1, sizeof(::control::HelloRequest)},
{ 38, -1, -1, sizeof(::control::HelloResult)},
};
static const ::_pb::Message* const file_default_instances[] = {
@@ -173,18 +175,19 @@ static const ::_pb::Message* const file_default_instances[] = {
};
const char descriptor_table_protodef_control_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) =
"\n\rcontrol.proto\022\007control\"\032\n\007ReqMeta\022\017\n\007r"
"pcname\030\001 \001(\t\")\n\007ResMeta\022\r\n\005error\030\001 \001(\010\022\017"
"\n\007message\030\002 \001(\t\")\n\007Request\022\036\n\004meta\030\001 \001(\013"
"2\020.control.ReqMeta\"(\n\006Result\022\036\n\004meta\030\001 \001"
"(\0132\020.control.ResMeta\"\?\n\014HelloRequest\022\036\n\004"
"meta\030\001 \001(\0132\020.control.ReqMeta\022\017\n\007message\030"
"\002 \001(\t\">\n\013HelloResult\022\036\n\004meta\030\001 \001(\0132\020.con"
"trol.ResMeta\022\017\n\007message\030\002 \001(\tb\006proto3"
"\n\rcontrol.proto\022\007control\"$\n\007ReqMeta\022\014\n\004k"
"ind\030\001 \001(\t\022\013\n\003rpc\030\002 \001(\010\")\n\007ResMeta\022\r\n\005err"
"or\030\001 \001(\010\022\017\n\007message\030\002 \001(\t\")\n\007Request\022\036\n\004"
"meta\030\001 \001(\0132\020.control.ReqMeta\"(\n\006Result\022\036"
"\n\004meta\030\001 \001(\0132\020.control.ResMeta\"\?\n\014HelloR"
"equest\022\036\n\004meta\030\001 \001(\0132\020.control.ReqMeta\022\017"
"\n\007message\030\002 \001(\t\">\n\013HelloResult\022\036\n\004meta\030\001"
" \001(\0132\020.control.ResMeta\022\017\n\007message\030\002 \001(\tb"
"\006proto3"
;
static ::_pbi::once_flag descriptor_table_control_2eproto_once;
const ::_pbi::DescriptorTable descriptor_table_control_2eproto = {
false, false, 317, descriptor_table_protodef_control_2eproto,
false, false, 327, descriptor_table_protodef_control_2eproto,
"control.proto",
&descriptor_table_control_2eproto_once, nullptr, 0, 6,
schemas, file_default_instances, TableStruct_control_2eproto::offsets,
@@ -215,18 +218,20 @@ ReqMeta::ReqMeta(const ReqMeta& from)
: ::PROTOBUF_NAMESPACE_ID::Message() {
ReqMeta* const _this = this; (void)_this;
new (&_impl_) Impl_{
decltype(_impl_.rpcname_){}
decltype(_impl_.kind_){}
, decltype(_impl_.rpc_){}
, /*decltype(_impl_._cached_size_)*/{}};
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
_impl_.rpcname_.InitDefault();
_impl_.kind_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
_impl_.rpcname_.Set("", GetArenaForAllocation());
_impl_.kind_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (!from._internal_rpcname().empty()) {
_this->_impl_.rpcname_.Set(from._internal_rpcname(),
if (!from._internal_kind().empty()) {
_this->_impl_.kind_.Set(from._internal_kind(),
_this->GetArenaForAllocation());
}
_this->_impl_.rpc_ = from._impl_.rpc_;
// @@protoc_insertion_point(copy_constructor:control.ReqMeta)
}
@@ -235,12 +240,13 @@ inline void ReqMeta::SharedCtor(
(void)arena;
(void)is_message_owned;
new (&_impl_) Impl_{
decltype(_impl_.rpcname_){}
decltype(_impl_.kind_){}
, decltype(_impl_.rpc_){false}
, /*decltype(_impl_._cached_size_)*/{}
};
_impl_.rpcname_.InitDefault();
_impl_.kind_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
_impl_.rpcname_.Set("", GetArenaForAllocation());
_impl_.kind_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
}
@@ -255,7 +261,7 @@ ReqMeta::~ReqMeta() {
inline void ReqMeta::SharedDtor() {
GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
_impl_.rpcname_.Destroy();
_impl_.kind_.Destroy();
}
void ReqMeta::SetCachedSize(int size) const {
@@ -268,7 +274,8 @@ void ReqMeta::Clear() {
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
_impl_.rpcname_.ClearToEmpty();
_impl_.kind_.ClearToEmpty();
_impl_.rpc_ = false;
_internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
@@ -278,13 +285,21 @@ const char* ReqMeta::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx)
uint32_t tag;
ptr = ::_pbi::ReadTag(ptr, &tag);
switch (tag >> 3) {
// string rpcname = 1;
// string kind = 1;
case 1:
if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 10)) {
auto str = _internal_mutable_rpcname();
auto str = _internal_mutable_kind();
ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx);
CHK_(ptr);
CHK_(::_pbi::VerifyUTF8(str, "control.ReqMeta.rpcname"));
CHK_(::_pbi::VerifyUTF8(str, "control.ReqMeta.kind"));
} else
goto handle_unusual;
continue;
// bool rpc = 2;
case 2:
if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 16)) {
_impl_.rpc_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
CHK_(ptr);
} else
goto handle_unusual;
continue;
@@ -317,14 +332,20 @@ uint8_t* ReqMeta::_InternalSerialize(
uint32_t cached_has_bits = 0;
(void) cached_has_bits;
// string rpcname = 1;
if (!this->_internal_rpcname().empty()) {
// string kind = 1;
if (!this->_internal_kind().empty()) {
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String(
this->_internal_rpcname().data(), static_cast<int>(this->_internal_rpcname().length()),
this->_internal_kind().data(), static_cast<int>(this->_internal_kind().length()),
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE,
"control.ReqMeta.rpcname");
"control.ReqMeta.kind");
target = stream->WriteStringMaybeAliased(
1, this->_internal_rpcname(), target);
1, this->_internal_kind(), target);
}
// bool rpc = 2;
if (this->_internal_rpc() != 0) {
target = stream->EnsureSpace(target);
target = ::_pbi::WireFormatLite::WriteBoolToArray(2, this->_internal_rpc(), target);
}
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
@@ -343,11 +364,16 @@ size_t ReqMeta::ByteSizeLong() const {
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
// string rpcname = 1;
if (!this->_internal_rpcname().empty()) {
// string kind = 1;
if (!this->_internal_kind().empty()) {
total_size += 1 +
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
this->_internal_rpcname());
this->_internal_kind());
}
// bool rpc = 2;
if (this->_internal_rpc() != 0) {
total_size += 1 + 1;
}
return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_);
@@ -368,8 +394,11 @@ void ReqMeta::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOB
uint32_t cached_has_bits = 0;
(void) cached_has_bits;
if (!from._internal_rpcname().empty()) {
_this->_internal_set_rpcname(from._internal_rpcname());
if (!from._internal_kind().empty()) {
_this->_internal_set_kind(from._internal_kind());
}
if (from._internal_rpc() != 0) {
_this->_internal_set_rpc(from._internal_rpc());
}
_this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
}
@@ -391,9 +420,10 @@ void ReqMeta::InternalSwap(ReqMeta* other) {
auto* rhs_arena = other->GetArenaForAllocation();
_internal_metadata_.InternalSwap(&other->_internal_metadata_);
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
&_impl_.rpcname_, lhs_arena,
&other->_impl_.rpcname_, rhs_arena
&_impl_.kind_, lhs_arena,
&other->_impl_.kind_, rhs_arena
);
swap(_impl_.rpc_, other->_impl_.rpc_);
}
::PROTOBUF_NAMESPACE_ID::Metadata ReqMeta::GetMetadata() const {
+70 -39
View File
@@ -197,20 +197,30 @@ class ReqMeta final :
// accessors -------------------------------------------------------
enum : int {
kRpcnameFieldNumber = 1,
kKindFieldNumber = 1,
kRpcFieldNumber = 2,
};
// string rpcname = 1;
void clear_rpcname();
const std::string& rpcname() const;
// string kind = 1;
void clear_kind();
const std::string& kind() const;
template <typename ArgT0 = const std::string&, typename... ArgT>
void set_rpcname(ArgT0&& arg0, ArgT... args);
std::string* mutable_rpcname();
PROTOBUF_NODISCARD std::string* release_rpcname();
void set_allocated_rpcname(std::string* rpcname);
void set_kind(ArgT0&& arg0, ArgT... args);
std::string* mutable_kind();
PROTOBUF_NODISCARD std::string* release_kind();
void set_allocated_kind(std::string* kind);
private:
const std::string& _internal_rpcname() const;
inline PROTOBUF_ALWAYS_INLINE void _internal_set_rpcname(const std::string& value);
std::string* _internal_mutable_rpcname();
const std::string& _internal_kind() const;
inline PROTOBUF_ALWAYS_INLINE void _internal_set_kind(const std::string& value);
std::string* _internal_mutable_kind();
public:
// bool rpc = 2;
void clear_rpc();
bool rpc() const;
void set_rpc(bool value);
private:
bool _internal_rpc() const;
void _internal_set_rpc(bool value);
public:
// @@protoc_insertion_point(class_scope:control.ReqMeta)
@@ -221,7 +231,8 @@ class ReqMeta final :
typedef void InternalArenaConstructable_;
typedef void DestructorSkippable_;
struct Impl_ {
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr rpcname_;
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr kind_;
bool rpc_;
mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_;
};
union { Impl_ _impl_; };
@@ -1062,54 +1073,74 @@ class HelloResult final :
#endif // __GNUC__
// ReqMeta
// string rpcname = 1;
inline void ReqMeta::clear_rpcname() {
_impl_.rpcname_.ClearToEmpty();
// string kind = 1;
inline void ReqMeta::clear_kind() {
_impl_.kind_.ClearToEmpty();
}
inline const std::string& ReqMeta::rpcname() const {
// @@protoc_insertion_point(field_get:control.ReqMeta.rpcname)
return _internal_rpcname();
inline const std::string& ReqMeta::kind() const {
// @@protoc_insertion_point(field_get:control.ReqMeta.kind)
return _internal_kind();
}
template <typename ArgT0, typename... ArgT>
inline PROTOBUF_ALWAYS_INLINE
void ReqMeta::set_rpcname(ArgT0&& arg0, ArgT... args) {
void ReqMeta::set_kind(ArgT0&& arg0, ArgT... args) {
_impl_.rpcname_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:control.ReqMeta.rpcname)
_impl_.kind_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:control.ReqMeta.kind)
}
inline std::string* ReqMeta::mutable_rpcname() {
std::string* _s = _internal_mutable_rpcname();
// @@protoc_insertion_point(field_mutable:control.ReqMeta.rpcname)
inline std::string* ReqMeta::mutable_kind() {
std::string* _s = _internal_mutable_kind();
// @@protoc_insertion_point(field_mutable:control.ReqMeta.kind)
return _s;
}
inline const std::string& ReqMeta::_internal_rpcname() const {
return _impl_.rpcname_.Get();
inline const std::string& ReqMeta::_internal_kind() const {
return _impl_.kind_.Get();
}
inline void ReqMeta::_internal_set_rpcname(const std::string& value) {
inline void ReqMeta::_internal_set_kind(const std::string& value) {
_impl_.rpcname_.Set(value, GetArenaForAllocation());
_impl_.kind_.Set(value, GetArenaForAllocation());
}
inline std::string* ReqMeta::_internal_mutable_rpcname() {
inline std::string* ReqMeta::_internal_mutable_kind() {
return _impl_.rpcname_.Mutable(GetArenaForAllocation());
return _impl_.kind_.Mutable(GetArenaForAllocation());
}
inline std::string* ReqMeta::release_rpcname() {
// @@protoc_insertion_point(field_release:control.ReqMeta.rpcname)
return _impl_.rpcname_.Release();
inline std::string* ReqMeta::release_kind() {
// @@protoc_insertion_point(field_release:control.ReqMeta.kind)
return _impl_.kind_.Release();
}
inline void ReqMeta::set_allocated_rpcname(std::string* rpcname) {
if (rpcname != nullptr) {
inline void ReqMeta::set_allocated_kind(std::string* kind) {
if (kind != nullptr) {
} else {
}
_impl_.rpcname_.SetAllocated(rpcname, GetArenaForAllocation());
_impl_.kind_.SetAllocated(kind, GetArenaForAllocation());
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (_impl_.rpcname_.IsDefault()) {
_impl_.rpcname_.Set("", GetArenaForAllocation());
if (_impl_.kind_.IsDefault()) {
_impl_.kind_.Set("", GetArenaForAllocation());
}
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:control.ReqMeta.rpcname)
// @@protoc_insertion_point(field_set_allocated:control.ReqMeta.kind)
}
// bool rpc = 2;
inline void ReqMeta::clear_rpc() {
_impl_.rpc_ = false;
}
inline bool ReqMeta::_internal_rpc() const {
return _impl_.rpc_;
}
inline bool ReqMeta::rpc() const {
// @@protoc_insertion_point(field_get:control.ReqMeta.rpc)
return _internal_rpc();
}
inline void ReqMeta::_internal_set_rpc(bool value) {
_impl_.rpc_ = value;
}
inline void ReqMeta::set_rpc(bool value) {
_internal_set_rpc(value);
// @@protoc_insertion_point(field_set:control.ReqMeta.rpc)
}
// -------------------------------------------------------------------
+2 -1
View File
@@ -5,7 +5,8 @@ package control;
//option cc_generic_services = false;
message ReqMeta {
string rpcname = 1;
string kind = 1;
bool rpc = 2;
}
message ResMeta {
+1 -1
View File
@@ -31,7 +31,7 @@ std::expected<void, std::string> RPCClient::DoTransaction(const pbMessage& pbReq
connector->Write(reqPacket);
const int headerSize = 8;
const int headerSize = rpcHeaderSize;
std::string rawResHeader;
connector->Read(rawResHeader, headerSize);
RPCHeader resHeader;
+2 -1
View File
@@ -1,7 +1,8 @@
#include <string>
const uint32_t MAGIC = 0xABBA;
constexpr uint32_t MAGIC = 0xABBA;
constexpr int rpcHeaderSize = 8;
class RPCHeader {
private:
+1 -1
View File
@@ -56,7 +56,7 @@ TestSocketHandler::~TestSocketHandler(void) {};
void TestSocketHandler::Handle(int sock) {
logger.Log(std::format("Handler {} start", sock));
const int headerSize = 8;
const int headerSize = rpcHeaderSize;
std::string inRawHeader(headerSize, '\0');
int rsize = 0;
if ((rsize = read(sock, inRawHeader.data(), inRawHeader.size())) < 0) {
+1 -1
View File
@@ -21,7 +21,7 @@ std::expected<int, std::string> TestConnector::Write(std::string reqNetPacket) {
std::stringstream ss(reqNetPacket);
// Read binary header
std::string reqRawHeader;
const int rhSize = 8;
const int rhSize = rpcHeaderSize;
reqRawHeader.resize(rhSize);
ss.read(reqRawHeader.data(), rhSize);
// Decode header
+1 -1
View File
@@ -57,7 +57,7 @@ int main(int argc, char** argv) {
// Read binary header
std::string resRawHeader;
const int rhSize = 8;
const int rhSize = rpcHeaderSize;
auto rSize = conn.Read(resRawHeader, rhSize);
RPCHeader resHeader;