userver: userver/ugrpc/client/impl/async_method_invocation.hpp Source File
Loading...
Searching...
No Matches
async_method_invocation.hpp
1#pragma once
2
3#include <optional>
4
5#include <google/rpc/status.pb.h>
6#include <grpcpp/client_context.h>
7#include <grpcpp/impl/codegen/status.h>
8
9#include <userver/engine/deadline.hpp>
10
11#include <userver/ugrpc/impl/async_method_invocation.hpp>
12
13USERVER_NAMESPACE_BEGIN
14
15namespace ugrpc::client::impl {
16
17class RpcData;
18
19/// @brief Contains parsed additional data for grpc status
20/// For example parsed status string
21struct ParsedGStatus final {
22 /// @brief Processes status and builds ParsedGStatus
23 static ParsedGStatus ProcessStatus(const grpc::Status& status);
24
25 std::optional<google::rpc::Status> gstatus;
26 std::optional<std::string> gstatus_string;
27};
28
29/// AsyncMethodInvocation for Finish method that stops stats and Span timers
30/// ASAP, without waiting for a Task to wake up
31class FinishAsyncMethodInvocation final
32 : public ugrpc::impl::AsyncMethodInvocation {
33 public:
34 explicit FinishAsyncMethodInvocation(RpcData& rpc_data);
35 ~FinishAsyncMethodInvocation() override;
36
37 grpc::Status& GetStatus();
38 ParsedGStatus& GetParsedGStatus();
39
40 void Notify(bool ok) noexcept override;
41
42 private:
43 RpcData& rpc_data_;
44 grpc::Status& status_;
45 ParsedGStatus parsed_gstatus_;
46};
47
48ugrpc::impl::AsyncMethodInvocation::WaitStatus Wait(
49 ugrpc::impl::AsyncMethodInvocation& invocation,
50 grpc::ClientContext& context) noexcept;
51
52ugrpc::impl::AsyncMethodInvocation::WaitStatus WaitUntil(
53 ugrpc::impl::AsyncMethodInvocation& invocation,
54 grpc::ClientContext& context, engine::Deadline deadline) noexcept;
55
56} // namespace ugrpc::client::impl
57
58USERVER_NAMESPACE_END