[k2] rpc client API#1635
Conversation
156e9ec to
222adae
Compare
a342aa9 to
e77636c
Compare
0c1f4cc to
44d348e
Compare
| kphp::coro::io_scheduler& m_scheduler{kphp::coro::io_scheduler::get()}; | ||
| std::chrono::nanoseconds timeout{kphp::time::remaining(deadline)}; | ||
|
|
||
| co_await m_scheduler.poll(rpc_d, kphp::coro::poll_op::read, timeout); |
There was a problem hiding this comment.
Looks like it's possible for timeout to become zero or negative here. Please, read io_scheduler::poll documentation for timeout
There was a problem hiding this comment.
Yeap, handled timeout <= 0 case manually
| } | ||
| } | ||
|
|
||
| kphp::coro::task<void> wait_for_response() noexcept; |
There was a problem hiding this comment.
Let's take one more step if you started splitting declarations and definitions:
- let's have
query_handle's body only include declarations with doc comments - let's have all implementation defined out-of-class
There was a problem hiding this comment.
Done. Only constructors, destructor and assign operators have definition inside class
| } | ||
| } | ||
|
|
||
| std::expected<query_handle, int32_t> send_and_get_handle(std::string_view actor, bool collect_responses_extra_info, bool ignore_answer, |
There was a problem hiding this comment.
nit: why not just send? Do we really need to highlight that we get handle as a return value?
I don't understand why do we need this function at all. It seems like it's literally part of kphp::rpc::send_request
There was a problem hiding this comment.
- Renamed it with send
- I've moved logic about regularize_extra_headers and collect_response_extra to
kphp::rpc::send_request, and leaved here only logic about creating query. That allowed me to avoidrpc_query_handle.cppfile
| if (it_rpc_request_handle == rpc_client_instance_st.rpc_query_handles.end()) [[unlikely]] { | ||
| co_return request_id; | ||
| } | ||
| // FIXME after response fetch finished `it_rpc_request_handle` will become invalid iterator |
There was a problem hiding this comment.
WE discussed, that wait_for_response may await inside and overlife object destruction, but this is not a problem, because after wait it does not touch object fields
| k2::instant(std::addressof(now_instant)); | ||
|
|
||
| std::chrono::nanoseconds now_ns{now_instant.time_point_ns}; | ||
| std::chrono::nanoseconds deadline_ns{duration_cast<std::chrono::nanoseconds>(deadline)}; |
There was a problem hiding this comment.
- What is
duration_casthere? - It looks like you use duration as time point. Please, correct me if I'm wrong
There was a problem hiding this comment.
You'r right. Replaced deadlines types with std::chrono::steady_clock::time_point
|
|
||
| namespace kphp::rpc { | ||
|
|
||
| inline constexpr std::string_view EMPTY_QUERY_ERROR_DESCRIPTION = "fetching rpc response from empty query"; |
There was a problem hiding this comment.
Do we need this? Isn't it enough to return an error code?
There was a problem hiding this comment.
laeved only rpc error code
|
|
||
| class query_handle { | ||
| k2::descriptor m_descriptor{k2::INVALID_PLATFORM_DESCRIPTOR}; | ||
| std::chrono::steady_clock::time_point m_deadline{}; |
There was a problem hiding this comment.
nit: no need for explicit init here
…GAIN` errno if response is not ready
…e std::string_view instead of string, removed m_id from query_handle
…sponse_awaiter_tasks
…:STATIC_BUFFER_LENGTH`; added `if collect_responses_extra_info` check
df743db to
6435238
Compare
No description provided.