userver: /data/code/userver/libraries/grpc-proto-structs/include/userver/grpc-proto-structs/client/response_future.hpp Source File
Loading...
Searching...
No Matches
response_future.hpp
Go to the documentation of this file.
1#pragma once
2
5
6#include <userver/compiler/impl/lifetime.hpp>
10
11USERVER_NAMESPACE_BEGIN
12
13namespace grpc_proto_structs::client {
14
16template <typename Response>
17class ResponseFuture final {
18public:
19 using VanillaResponse = proto_structs::traits::CompatibleMessageType<Response>;
21
22 explicit ResponseFuture(VanillaFuture&& future)
23 : future_{std::move(future)}
24 {}
25
29 [[nodiscard]] bool IsReady() const { return future_.IsReady(); }
30
34 [[nodiscard]] engine::FutureStatus WaitUntil(engine::Deadline deadline) const noexcept {
35 return future_.WaitUntil(deadline);
36 }
37
47 Response Get() { return proto_structs::MessageToStruct<Response>(future_.Get()); }
48
50 void Cancel() { return future_.Cancel(); }
51
53 ugrpc::client::CallContext& GetContext() { return future_.GetContext(); }
54
56 const ugrpc::client::CallContext& GetContext() const { return future_.GetContext(); }
57
59 engine::AwaitableToken GetAwaitableToken() noexcept USERVER_IMPL_LIFETIME_BOUND {
60 return future_.GetAwaitableToken();
61 }
62
63private:
64 VanillaFuture future_;
65};
66
67} // namespace grpc_proto_structs::client
68
69USERVER_NAMESPACE_END