Skip to content

Commit 6eaae27

Browse files
committed
RPC: move kphp::forks::id_managed to the right place
1 parent 5a3297d commit 6eaae27

3 files changed

Lines changed: 12 additions & 12 deletions

File tree

runtime-light/stdlib/rpc/rpc-api.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include "runtime-light/stdlib/component/component-api.h"
2929
#include "runtime-light/stdlib/diagnostics/exception-functions.h"
3030
#include "runtime-light/stdlib/diagnostics/logs.h"
31+
#include "runtime-light/stdlib/fork/fork-functions.h"
3132
#include "runtime-light/stdlib/rpc/rpc-client-state.h"
3233
#include "runtime-light/stdlib/rpc/rpc-constants.h"
3334
#include "runtime-light/stdlib/rpc/rpc-extra-headers.h"
@@ -205,7 +206,7 @@ kphp::coro::task<array<mixed>> rpc_tl_query_result_one_impl(int64_t query_id) no
205206
}
206207

207208
kphp::log::assertion(opt_awaiter_task.has_value());
208-
auto opt_response{co_await *std::exchange(opt_awaiter_task, std::nullopt)};
209+
auto opt_response{co_await kphp::forks::id_managed(*std::exchange(opt_awaiter_task, std::nullopt))};
209210
if (!opt_response) [[unlikely]] {
210211
co_return TlRpcError::make_error(TL_ERROR_QUERY_TIMEOUT, string{"rpc response timeout"});
211212
}
@@ -258,7 +259,7 @@ kphp::coro::task<class_instance<C$VK$TL$RpcResponse>> typed_rpc_tl_query_result_
258259
}
259260

260261
kphp::log::assertion(opt_awaiter_task.has_value());
261-
auto opt_response{co_await *std::exchange(opt_awaiter_task, std::nullopt)};
262+
auto opt_response{co_await kphp::forks::id_managed(*std::exchange(opt_awaiter_task, std::nullopt))};
262263
if (!opt_response) [[unlikely]] {
263264
co_return error_factory.make_error(TL_ERROR_QUERY_TIMEOUT, string{"rpc response timeout"});
264265
}

runtime-light/stdlib/rpc/rpc-api.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -275,10 +275,10 @@ kphp::coro::task<array<array<mixed>>> f$rpc_fetch_responses_synchronously(array<
275275

276276
// === client typed ===============================================================================
277277

278-
template<std::derived_from<C$VK$TL$RpcFunction> rpc_function_t, std::same_as<KphpRpcRequest> rpc_request_t = KphpRpcRequest>
279-
kphp::coro::task<array<int64_t>> f$rpc_send_typed_query_requests(string actor, array<class_instance<rpc_function_t>> query_functions, Optional<double> timeout,
280-
bool ignore_answer, class_instance<C$KphpRpcRequestsExtraInfo> requests_extra_info,
281-
bool need_responses_extra_info) noexcept {
278+
template<std::derived_from<C$VK$TL$RpcFunction> rpc_function_type, std::same_as<KphpRpcRequest> rpc_request_type = KphpRpcRequest>
279+
kphp::coro::task<array<int64_t>>
280+
f$rpc_send_typed_query_requests(string actor, array<class_instance<rpc_function_type>> query_functions, Optional<double> timeout, bool ignore_answer,
281+
class_instance<C$KphpRpcRequestsExtraInfo> requests_extra_info, bool need_responses_extra_info) noexcept {
282282
if (ignore_answer && need_responses_extra_info) [[unlikely]] {
283283
kphp::log::warning("both $ignore_answer and $need_responses_extra_info are 'true'. Metrics won't be collected");
284284
}
@@ -290,7 +290,7 @@ kphp::coro::task<array<int64_t>> f$rpc_send_typed_query_requests(string actor, a
290290

291291
for (const auto& it : std::as_const(query_functions)) {
292292
const auto query_info{co_await kphp::forks::id_managed(kphp::rpc::detail::typed_rpc_tl_query_one_impl(
293-
{actor.c_str(), actor.size()}, rpc_request_t{it.get_value()}, opt_timeout, collect_resp_extra_info, ignore_answer))};
293+
{actor.c_str(), actor.size()}, rpc_request_type{it.get_value()}, opt_timeout, collect_resp_extra_info, ignore_answer))};
294294
query_ids.set_value(it.get_key(), query_info.id);
295295
req_extra_info_arr.set_value(it.get_key(), kphp::rpc::request_extra_info{query_info.request_size});
296296
}
@@ -301,12 +301,12 @@ kphp::coro::task<array<int64_t>> f$rpc_send_typed_query_requests(string actor, a
301301
co_return std::move(query_ids);
302302
}
303303

304-
template<std::same_as<int64_t> query_id_t = int64_t, std::same_as<RpcResponseErrorFactory> error_factory_t = RpcResponseErrorFactory>
305-
requires std::default_initializable<error_factory_t>
306-
kphp::coro::task<array<class_instance<C$VK$TL$RpcResponse>>> f$rpc_fetch_typed_responses(array<query_id_t> query_ids) noexcept {
304+
template<std::same_as<int64_t> query_id_type = int64_t, std::same_as<RpcResponseErrorFactory> error_factory_type = RpcResponseErrorFactory>
305+
requires std::default_initializable<error_factory_type>
306+
kphp::coro::task<array<class_instance<C$VK$TL$RpcResponse>>> f$rpc_fetch_typed_responses(array<query_id_type> query_ids) noexcept {
307307
array<class_instance<C$VK$TL$RpcResponse>> res{query_ids.size()};
308308
for (const auto& it : std::as_const(query_ids)) {
309-
res.set_value(it.get_key(), co_await kphp::forks::id_managed(kphp::rpc::detail::typed_rpc_tl_query_result_one_impl(it.get_value(), error_factory_t{})));
309+
res.set_value(it.get_key(), co_await kphp::forks::id_managed(kphp::rpc::detail::typed_rpc_tl_query_result_one_impl(it.get_value(), error_factory_type{})));
310310
}
311311
co_return std::move(res);
312312
}

runtime-light/stdlib/rpc/rpc-client-state.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
#include "runtime-common/core/allocator/script-allocator.h"
1313
#include "runtime-common/core/runtime-core.h"
1414
#include "runtime-common/core/std/containers.h"
15-
#include "runtime-light/coroutine/await-set.h"
1615
#include "runtime-light/coroutine/shared-task.h"
1716
#include "runtime-light/stdlib/rpc/rpc-constants.h"
1817
#include "runtime-light/stdlib/rpc/rpc-extra-info.h"

0 commit comments

Comments
 (0)