Skip to content

Commit

Permalink
rename api
Browse files Browse the repository at this point in the history
  • Loading branch information
Vadim Sadokhov committed Nov 2, 2024
1 parent 32406b7 commit 67a6200
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 16 deletions.
10 changes: 5 additions & 5 deletions runtime-light/stdlib/job-worker/job-worker-api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,17 +84,17 @@ task_t<int64_t> kphp_job_worker_start_impl(string request, double timeout, bool

// ================================================================================================

task_t<Optional<int64_t>> f$k2_job_worker_start(string request, double timeout) noexcept {
task_t<Optional<int64_t>> f$job_worker_send_request(string request, double timeout) noexcept {
const auto fork_id{co_await kphp_job_worker_start_impl(std::move(request), timeout, false)};
co_return fork_id != INVALID_FORK_ID ? fork_id : false;
}

task_t<bool> f$k2_job_worker_start_no_reply(string request, double timeout) noexcept {
task_t<bool> f$job_worker_send_noreply_request(string request, double timeout) noexcept {
const auto fork_id{co_await kphp_job_worker_start_impl(std::move(request), timeout, true)};
co_return fork_id != INVALID_FORK_ID;
}

task_t<array<Optional<int64_t>>> f$k2_job_worker_start_multi(array<string> requests, double timeout) noexcept {
task_t<array<Optional<int64_t>>> f$job_worker_send_multi_request(array<string> requests, double timeout) noexcept {
array<Optional<int64_t>> fork_ids{requests.size()};
for (const auto &it : requests) {
const auto fork_id{co_await kphp_job_worker_start_impl(it.get_value(), timeout, false)};
Expand All @@ -105,7 +105,7 @@ task_t<array<Optional<int64_t>>> f$k2_job_worker_start_multi(array<string> reque

// ================================================================================================

task_t<string> f$k2_job_worker_fetch_request() noexcept {
task_t<string> f$job_worker_fetch_request() noexcept {
if (!f$is_kphp_job_workers_enabled()) {
php_warning("couldn't fetch job worker request: job workers are disabled");
co_return string{};
Expand All @@ -119,7 +119,7 @@ task_t<string> f$k2_job_worker_fetch_request() noexcept {
co_return std::exchange(jw_server_ctx.body, string{});
}

task_t<int64_t> f$k2_job_worker_store_response(string response) noexcept {
task_t<int64_t> f$job_worker_store_response(string response) noexcept {
auto &component_ctx{*get_component_context()};
auto &jw_server_ctx{JobWorkerServerComponentContext::get()};
if (!f$is_kphp_job_workers_enabled()) { // workers are enabled
Expand Down
10 changes: 5 additions & 5 deletions runtime-light/stdlib/job-worker/job-worker-api.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@

// === Client =====================================================================================

task_t<Optional<int64_t>> f$k2_job_worker_start(string request, double timeout) noexcept;
task_t<Optional<int64_t>> f$job_worker_send_request(string request, double timeout) noexcept;

task_t<bool> f$k2_job_worker_start_no_reply(string request, double timeout) noexcept;
task_t<bool> f$job_worker_send_noreply_request(string request, double timeout) noexcept;

task_t<array<Optional<int64_t>>> f$k2_job_worker_start_multi(array<string> requests, double timeout) noexcept;
task_t<array<Optional<int64_t>>> f$job_worker_send_multi_request(array<string> requests, double timeout) noexcept;

// === Server =====================================================================================

task_t<string> f$k2_job_worker_fetch_request() noexcept;
task_t<string> f$job_worker_fetch_request() noexcept;

task_t<int64_t> f$k2_job_worker_store_response(string response) noexcept;
task_t<int64_t> f$job_worker_store_response(string response) noexcept;

// === Misc =======================================================================================

Expand Down
4 changes: 2 additions & 2 deletions runtime-light/stdlib/rpc/rpc-api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ string f$fetch_string() noexcept {

// === Rpc Query ==================================================================================

task_t<array<int64_t>> f$k2_kphp_rpc_tl_query(string actor, array<mixed> tl_objects, double timeout, bool ignore_answer,
task_t<array<int64_t>> f$rpc_send_request(string actor, array<mixed> tl_objects, double timeout, bool ignore_answer,
class_instance<C$KphpRpcRequestsExtraInfo> requests_extra_info, bool need_responses_extra_info) noexcept {
if (ignore_answer && need_responses_extra_info) {
php_warning("Both $ignore_answer and $need_responses_extra_info are 'true'. Can't collect metrics for ignored answers");
Expand All @@ -380,7 +380,7 @@ task_t<array<int64_t>> f$k2_kphp_rpc_tl_query(string actor, array<mixed> tl_obje
co_return query_ids;
}

task_t<array<array<mixed>>> f$k2_kphp_rpc_tl_query_result(array<int64_t> query_ids) noexcept {
task_t<array<array<mixed>>> f$rpc_fetch_response(array<int64_t> query_ids) noexcept {
array<array<mixed>> res{query_ids.size()};
for (const auto &it : query_ids) {
res.set_value(it.get_key(), co_await rpc_impl_::rpc_tl_query_result_one_impl(it.get_value()));
Expand Down
8 changes: 4 additions & 4 deletions runtime-light/stdlib/rpc/rpc-api.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,11 @@ string f$fetch_string() noexcept;

// === Rpc Query ==================================================================================

task_t<array<int64_t>> f$k2_kphp_rpc_tl_query(string actor, array<mixed> tl_objects, double timeout = -1.0, bool ignore_answer = false,
task_t<array<int64_t>> f$rpc_send_request(string actor, array<mixed> tl_objects, double timeout = -1.0, bool ignore_answer = false,
class_instance<C$KphpRpcRequestsExtraInfo> requests_extra_info = {}, bool need_responses_extra_info = false) noexcept;

template<std::derived_from<C$VK$TL$RpcFunction> rpc_function_t, std::same_as<KphpRpcRequest> rpc_request_t = KphpRpcRequest>
task_t<array<int64_t>> f$k2_kphp_typed_rpc_tl_query(string actor, array<class_instance<rpc_function_t>> query_functions, double timeout = -1.0,
task_t<array<int64_t>> f$rpc_send_typed_query_request(string actor, array<class_instance<rpc_function_t>> query_functions, double timeout = -1.0,
bool ignore_answer = false, class_instance<C$KphpRpcRequestsExtraInfo> requests_extra_info = {},
bool need_responses_extra_info = false) noexcept {
if (ignore_answer && need_responses_extra_info) {
Expand All @@ -87,11 +87,11 @@ task_t<array<int64_t>> f$k2_kphp_typed_rpc_tl_query(string actor, array<class_in
co_return query_ids;
}

task_t<array<array<mixed>>> f$k2_kphp_rpc_tl_query_result(array<int64_t> query_ids) noexcept;
task_t<array<array<mixed>>> f$rpc_fetch_response(array<int64_t> query_ids) noexcept;

template<std::same_as<int64_t> query_id_t = int64_t, std::same_as<RpcResponseErrorFactory> error_factory_t = RpcResponseErrorFactory>
requires std::default_initializable<error_factory_t> task_t<array<class_instance<C$VK$TL$RpcResponse>>>
f$k2_kphp_typed_rpc_tl_query_result(array<query_id_t> query_ids) noexcept {
f$rpc_fetch_typed_response(array<query_id_t> query_ids) noexcept {
array<class_instance<C$VK$TL$RpcResponse>> res{query_ids.size()};
for (const auto &it : query_ids) {
res.set_value(it.get_key(), co_await rpc_impl_::typed_rpc_tl_query_result_one_impl(it.get_value(), error_factory_t{}));
Expand Down

0 comments on commit 67a6200

Please sign in to comment.