-
Notifications
You must be signed in to change notification settings - Fork 95
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
maintained RpcReqError with headers in vkext (#915)
* rename 'memcache' to 'rpc-tl' in serialization code * fetch RpcReqError with Header as `rpcResponseHeader` with error inside `$result` field * added ini parameter to enable rpc error with header fetching, turned off by default
- Loading branch information
Showing
10 changed files
with
292 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
// Compiler for PHP (aka KPHP) | ||
// Copyright (c) 2023 LLC «V Kontakte» | ||
// Distributed under the GPL v3 License, see LICENSE.notice.txt | ||
|
||
#include "vkext/vkext-rpc-req-error.h" | ||
|
||
#include "common/tl/constants/common.h" | ||
|
||
namespace vkext_rpc { | ||
void tl::NetPid::tl_fetch() { | ||
ip = tl_parse_int(); | ||
port_pid = tl_parse_int(); | ||
utime = tl_parse_int(); | ||
} | ||
|
||
void tl::RpcReqResultExtra::tl_fetch(int flags) { | ||
if (flags & vk::tl::common::rpc_req_result_extra_flags::binlog_pos) { | ||
binlog_pos = tl_parse_long(); | ||
} | ||
if (flags & vk::tl::common::rpc_req_result_extra_flags::binlog_time) { | ||
binlog_time = tl_parse_long(); | ||
} | ||
if (flags & vk::tl::common::rpc_req_result_extra_flags::engine_pid) { | ||
engine_pid.emplace().tl_fetch(); | ||
} | ||
if (flags & vk::tl::common::rpc_req_result_extra_flags::request_size) { | ||
request_size = tl_parse_int(); | ||
} | ||
if (flags & vk::tl::common::rpc_req_result_extra_flags::response_size) { | ||
response_size = tl_parse_int(); | ||
} | ||
if (flags & vk::tl::common::rpc_req_result_extra_flags::failed_subqueries) { | ||
failed_subqueries = tl_parse_int(); | ||
} | ||
if (flags & vk::tl::common::rpc_req_result_extra_flags::compression_version) { | ||
compression_version = tl_parse_int(); | ||
} | ||
if (flags & vk::tl::common::rpc_req_result_extra_flags::stats) { | ||
size_t n = tl_parse_int(); | ||
stats.emplace(); | ||
for (int i = 0; i < n; ++i) { | ||
auto key = tl_parse_string(); | ||
auto val = tl_parse_string(); | ||
stats->emplace(std::move(key), std::move(val)); | ||
} | ||
} | ||
if (flags & vk::tl::common::rpc_req_result_extra_flags::epoch_number) { | ||
epoch_number = tl_parse_long(); | ||
} | ||
if (flags & vk::tl::common::rpc_req_result_extra_flags::view_number) { | ||
view_number = tl_parse_long(); | ||
} | ||
} | ||
|
||
void tl::RpcReqError::tl_fetch() { | ||
tl_parse_long(); // unused query_id | ||
error_code = tl_parse_int(); | ||
error_msg = tl_parse_string(); | ||
} | ||
|
||
void RpcError::try_fetch() { | ||
int op = tl_parse_int(); | ||
if (op == TL_REQ_RESULT_HEADER) { | ||
flags = tl_parse_int(); | ||
header.emplace().tl_fetch(flags); | ||
op = tl_parse_int(); | ||
} | ||
if (op == TL_RPC_REQ_ERROR) { | ||
error.emplace().tl_fetch(); | ||
} | ||
} | ||
} // namespace vkext_rpc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// Compiler for PHP (aka KPHP) | ||
// Copyright (c) 2023 LLC «V Kontakte» | ||
// Distributed under the GPL v3 License, see LICENSE.notice.txt | ||
|
||
#pragma once | ||
|
||
|
||
#include <map> | ||
#include <optional> | ||
#include <string> | ||
|
||
#include "vkext/vkext-tl-parse.h" | ||
|
||
namespace vkext_rpc { | ||
namespace tl { | ||
struct NetPid { | ||
int ip{0}; | ||
int port_pid{0}; | ||
int utime{0}; | ||
|
||
void tl_fetch(); | ||
}; | ||
|
||
struct RpcReqResultExtra { | ||
std::optional<long long> binlog_pos; | ||
std::optional<long long> binlog_time; | ||
std::optional<NetPid> engine_pid; | ||
std::optional<int> request_size; | ||
std::optional<int> response_size; | ||
std::optional<int> failed_subqueries; | ||
std::optional<int> compression_version; | ||
std::optional<std::map<std::string, std::string>> stats; | ||
std::optional<long long> epoch_number; | ||
std::optional<long long> view_number; | ||
|
||
void tl_fetch(int flags); | ||
}; | ||
|
||
struct RpcReqError { | ||
int error_code{0}; | ||
std::string error_msg; | ||
|
||
void tl_fetch(); | ||
}; | ||
} // namespace tl | ||
|
||
struct RpcError { | ||
int flags{0}; | ||
std::optional<tl::RpcReqResultExtra> header; | ||
std::optional<tl::RpcReqError> error; | ||
|
||
void try_fetch(); | ||
}; | ||
} // namespace vkext_rpc |
Oops, something went wrong.