Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions common/tl-files/common.tl
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ rpcReqResultExtra#c5011709 {flags:#}
failed_subqueries:flags.4?int
compression_version:flags.5?int
stats:flags.6?%(Dictionary string)
shards_binlog_pos:flags.14?%(Dictionary long)
epoch_number:flags.27?%long view_number:flags.27?%long
= RpcReqResultExtra flags;

Expand Down
3 changes: 2 additions & 1 deletion common/tl/constants/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,10 @@ inline constexpr uint32_t response_size = 1U << 3U;
inline constexpr uint32_t failed_subqueries = 1U << 4U;
inline constexpr uint32_t compression_version = 1U << 5U;
inline constexpr uint32_t stats = 1U << 6U;
inline constexpr uint32_t shards_binlog_pos = 1U << 14U;
inline constexpr uint32_t epoch_number = 1U << 27U;
inline constexpr uint32_t view_number = 1U << 27U;
inline constexpr uint32_t ALL = 0x0800007f;
inline constexpr uint32_t ALL = 0x0800407f;
} // namespace rpc_req_result_extra_flags

} // namespace common
Expand Down
4 changes: 4 additions & 0 deletions runtime-light/stdlib/rpc/rpc-tl-error.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ bool TlRpcError::try_fetch() noexcept {
return false;
}
fetcher = tl::fetcher{req_result_header.result};
if (!magic.fetch(fetcher)) [[unlikely]] {
THROW_EXCEPTION(kphp::rpc::exception::not_enough_data_to_fetch::make());
return false;
}
}
if (!magic.expect(TL_RPC_REQ_ERROR)) {
return false;
Expand Down
11 changes: 11 additions & 0 deletions runtime-light/tl/tl-types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,9 @@ bool rpcReqResultExtra::fetch(tl::fetcher& tlf, const tl::mask& flags) noexcept
if (ok && static_cast<bool>(flags.value & STATS_FLAG)) {
ok = opt_stats.emplace().fetch(tlf);
}
if (ok && static_cast<bool>(flags.value & SHARDS_BINLOG_POS_FLAG)) {
ok = opt_shards_binlog_pos.emplace().fetch(tlf);
}
if (ok && static_cast<bool>(flags.value & EPOCH_NUMBER_FLAG)) {
kphp::log::assertion(static_cast<bool>(flags.value & VIEW_NUMBER_FLAG));
ok = opt_epoch_number.emplace().fetch(tlf) && opt_view_number.emplace().fetch(tlf);
Expand Down Expand Up @@ -278,6 +281,10 @@ void rpcReqResultExtra::store(tl::storer& tls, const tl::mask& flags) const noex
kphp::log::assertion(opt_stats.has_value());
opt_stats->store(tls);
}
if (static_cast<bool>(flags.value & SHARDS_BINLOG_POS_FLAG)) {
kphp::log::assertion(opt_shards_binlog_pos.has_value());
opt_shards_binlog_pos->store(tls);
}
if (static_cast<bool>(flags.value & EPOCH_NUMBER_FLAG)) {
kphp::log::assertion(opt_epoch_number.has_value() && static_cast<bool>(flags.value & VIEW_NUMBER_FLAG) && opt_view_number.has_value());
opt_epoch_number->store(tls), opt_view_number->store(tls);
Expand Down Expand Up @@ -314,6 +321,10 @@ size_t rpcReqResultExtra::footprint(const tl::mask& flags) const noexcept {
kphp::log::assertion(opt_stats.has_value());
footprint += opt_stats->footprint();
}
if (static_cast<bool>(flags.value & SHARDS_BINLOG_POS_FLAG)) {
kphp::log::assertion(opt_shards_binlog_pos.has_value());
footprint += opt_shards_binlog_pos->footprint();
}
if (static_cast<bool>(flags.value & EPOCH_NUMBER_FLAG)) {
kphp::log::assertion(opt_epoch_number.has_value() && static_cast<bool>(flags.value & VIEW_NUMBER_FLAG) && opt_view_number.has_value());
footprint += opt_epoch_number->footprint() + opt_view_number->footprint();
Expand Down
2 changes: 2 additions & 0 deletions runtime-light/tl/tl-types.h
Original file line number Diff line number Diff line change
Expand Up @@ -1140,6 +1140,7 @@ class rpcReqResultExtra final {
static constexpr uint32_t FAILED_SUBQUERIES_FLAG = vk::tl::common::rpc_req_result_extra_flags::failed_subqueries;
static constexpr uint32_t COMPRESSION_VERSION_FLAG = vk::tl::common::rpc_req_result_extra_flags::compression_version;
static constexpr uint32_t STATS_FLAG = vk::tl::common::rpc_req_result_extra_flags::stats;
static constexpr uint32_t SHARDS_BINLOG_POS_FLAG = vk::tl::common::rpc_req_result_extra_flags::shards_binlog_pos;
static constexpr uint32_t EPOCH_NUMBER_FLAG = vk::tl::common::rpc_req_result_extra_flags::epoch_number;
static constexpr uint32_t VIEW_NUMBER_FLAG = vk::tl::common::rpc_req_result_extra_flags::view_number;

Expand All @@ -1152,6 +1153,7 @@ class rpcReqResultExtra final {
std::optional<tl::i32> opt_failed_subqueries;
std::optional<tl::i32> opt_compression_version;
std::optional<tl::dictionary<tl::string>> opt_stats;
std::optional<tl::dictionary<tl::i64>> opt_shards_binlog_pos;
std::optional<tl::i64> opt_epoch_number;
std::optional<tl::i64> opt_view_number;

Expand Down
11 changes: 9 additions & 2 deletions runtime/tl/rpc_req_error.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,19 @@ void RpcError::fetch_and_skip_header(int flags) const noexcept {
tl_parse_int();
}
if (flags & vk::tl::common::rpc_req_result_extra_flags::stats) {
size_t n = tl_parse_int();
for (int i = 0; i < n; ++i) {
auto n{tl_parse_int()};
for (auto i{0}; i < n; ++i) {
tl_parse_string();
tl_parse_string();
}
}
if (flags & vk::tl::common::rpc_req_result_extra_flags::shards_binlog_pos) {
auto n{tl_parse_int()};
for (auto i{0}; i < n; ++i) {
tl_parse_string();
tl_parse_long();
}
}
if (flags & vk::tl::common::rpc_req_result_extra_flags::epoch_number) {
tl_parse_long();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ class rpcReqResultExtra {
/** Field mask for $stats field */
const BIT_STATS_6 = (1 << 6);

/** Field mask for $shards_binlog_pos field */
const BIT_SHARDS_BINLOG_POS_14 = (1 << 14);

/** Field mask for $epoch_number field */
const BIT_EPOCH_NUMBER_27 = (1 << 27);

Expand Down Expand Up @@ -69,6 +72,9 @@ class rpcReqResultExtra {
/** @var string[]|null */
public $stats = null;

/** @var int[]|null */
public $shards_binlog_pos = null;

/** @var int|null */
public $epoch_number = null;

Expand Down Expand Up @@ -115,6 +121,10 @@ public function calculateFlags() {
$mask |= self::BIT_STATS_6;
}

if ($this->shards_binlog_pos !== null) {
$mask |= self::BIT_SHARDS_BINLOG_POS_14;
}

if ($this->epoch_number !== null && $this->view_number !== null) {
$mask |= (self::BIT_EPOCH_NUMBER_27 | self::BIT_VIEW_NUMBER_27);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public function getTLFunctionName() {
*
* @return TL\RpcFunctionFetcher
*/
public function typedStore(){
public function typedStore() {
return null;
}

Expand All @@ -78,7 +78,7 @@ public function typedStore(){
*
* @return TL\RpcFunctionFetcher
*/
public function typedFetch(){
public function typedFetch() {
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public function getTLFunctionName() {
*
* @return TL\RpcFunctionFetcher
*/
public function typedStore(){
public function typedStore() {
return null;
}

Expand All @@ -82,7 +82,7 @@ public function typedStore(){
*
* @return TL\RpcFunctionFetcher
*/
public function typedFetch(){
public function typedFetch() {
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public function getTLFunctionName() {
*
* @return TL\RpcFunctionFetcher
*/
public function typedStore(){
public function typedStore() {
return null;
}

Expand All @@ -78,7 +78,7 @@ public function typedStore(){
*
* @return TL\RpcFunctionFetcher
*/
public function typedFetch(){
public function typedFetch() {
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public function getTLFunctionName() {
*
* @return TL\RpcFunctionFetcher
*/
public function typedStore(){
public function typedStore() {
return null;
}

Expand All @@ -78,7 +78,7 @@ public function typedStore(){
*
* @return TL\RpcFunctionFetcher
*/
public function typedFetch(){
public function typedFetch() {
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public function getTLFunctionName() {
*
* @return TL\RpcFunctionFetcher
*/
public function typedStore(){
public function typedStore() {
return null;
}

Expand All @@ -78,7 +78,7 @@ public function typedStore(){
*
* @return TL\RpcFunctionFetcher
*/
public function typedFetch(){
public function typedFetch() {
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public function getTLFunctionName() {
*
* @return TL\RpcFunctionFetcher
*/
public function typedStore(){
public function typedStore() {
return null;
}

Expand All @@ -82,7 +82,7 @@ public function typedStore(){
*
* @return TL\RpcFunctionFetcher
*/
public function typedFetch(){
public function typedFetch() {
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public function getTLFunctionName() {
*
* @return TL\RpcFunctionFetcher
*/
public function typedStore(){
public function typedStore() {
return null;
}

Expand All @@ -78,7 +78,7 @@ public function typedStore(){
*
* @return TL\RpcFunctionFetcher
*/
public function typedFetch(){
public function typedFetch() {
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public function getTLFunctionName() {
*
* @return TL\RpcFunctionFetcher
*/
public function typedStore(){
public function typedStore() {
return null;
}

Expand All @@ -78,7 +78,7 @@ public function typedStore(){
*
* @return TL\RpcFunctionFetcher
*/
public function typedFetch(){
public function typedFetch() {
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public function getTLFunctionName() {
*
* @return TL\RpcFunctionFetcher
*/
public function typedStore(){
public function typedStore() {
return null;
}

Expand All @@ -78,7 +78,7 @@ public function typedStore(){
*
* @return TL\RpcFunctionFetcher
*/
public function typedFetch(){
public function typedFetch() {
return null;
}

Expand Down
9 changes: 9 additions & 0 deletions vkext/vkext-rpc-req-error.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,15 @@ void tl::RpcReqResultExtra::tl_fetch(int flags) {
stats->emplace(std::move(key), std::move(val));
}
}
if (flags & vk::tl::common::rpc_req_result_extra_flags::shards_binlog_pos) {
size_t n = tl_parse_int();
shards_binlog_pos.emplace();
for (int i = 0; i < n; ++i) {
auto key = tl_parse_string();
auto val = tl_parse_long();
shards_binlog_pos->emplace(std::move(key), val);
}
}
if (flags & vk::tl::common::rpc_req_result_extra_flags::epoch_number) {
epoch_number = tl_parse_long();
}
Expand Down
1 change: 1 addition & 0 deletions vkext/vkext-rpc-req-error.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ struct RpcReqResultExtra {
std::optional<int> failed_subqueries;
std::optional<int> compression_version;
std::optional<std::map<std::string, std::string>> stats;
std::optional<std::map<std::string, long long>> shards_binlog_pos;
std::optional<long long> epoch_number;
std::optional<long long> view_number;

Expand Down
11 changes: 11 additions & 0 deletions vkext/vkext-rpc-tl-serialization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "common/tl/compiler/tl-tl.h"
#include "common/tl/constants/common.h"

#include "vkext/vk_zend.h"
#include "vkext/vkext-errors.h"
#include "vkext/vkext-rpc-include.h"
#include "vkext/vkext-rpc-req-error.h"
Expand Down Expand Up @@ -1331,6 +1332,16 @@ static zval *convert_rpc_extra_header_to_php_repr(const vkext_rpc::tl::RpcReqRes
}
set_field(&res, stats_field, "stats", -1); // it frees allocated zval for stats_field
}
if (header.shards_binlog_pos.has_value()) {
zval *shards_binlog_pos_field;
VK_ALLOC_INIT_ZVAL(shards_binlog_pos_field);
array_init(shards_binlog_pos_field);

for (const auto &[key, value] : header.shards_binlog_pos.value()) {
add_assoc_long(shards_binlog_pos_field, key.c_str(), value);
}
set_field(&res, shards_binlog_pos_field, "shards_binlog_pos", -1); // it frees allocated zval for shards_binlog_pos_field
}
if (header.epoch_number.has_value()) {
set_field_int(&res, header.epoch_number.value(), "epoch_number", -1);
}
Expand Down
Loading