7#include <userver/engine/future.hpp>
8#include <userver/storages/redis/request_data_base.hpp>
10USERVER_NAMESPACE_BEGIN
14[[noreturn]]
void ThrowTransactionNotStarted(std::string_view description);
16template <
typename ReplyType>
17class TransactionSubrequestDataImpl
final :
public RequestDataBase<ReplyType> {
19 TransactionSubrequestDataImpl(engine::Future<ReplyType> future)
20 : future_(std::move(future)) {}
22 void Wait()
override { ThrowIfNotReady(
"Wait() for"); }
24 ReplyType Get(
const std::string& )
override {
25 ThrowIfNotReady(
"Get()");
29 ReplyPtr GetRaw()
override {
30 throw std::logic_error(
"call TransactionSubrequestDataImpl::GetRaw()");
33 engine::impl::ContextAccessor* TryGetContextAccessor()
noexcept override {
39 void ThrowIfNotReady(std::string_view description) {
40 if (future_.wait_until(engine::Deadline::Passed()) !=
41 engine::FutureStatus::kReady) {
42 ThrowTransactionNotStarted(description);
46 engine::Future<ReplyType> future_;