userver: userver/storages/redis/request_data_base.hpp Source File
Loading...
Searching...
No Matches
request_data_base.hpp
1#pragma once
2
3#include <string>
4
5#include <userver/engine/impl/context_accessor.hpp>
6#include <userver/storages/redis/reply_fwd.hpp>
7#include <userver/storages/redis/reply_types.hpp>
8#include <userver/storages/redis/scan_tag.hpp>
9
10USERVER_NAMESPACE_BEGIN
11
12namespace storages::redis {
13
14// Mock note:
15// Request->
16// RequestDataBase
17//
18// RequestDataBase <- RequestDataImpl
19// RequestDataBase <- MockRequestDataBase <- UserMockRequestData
20
21template <typename ReplyType>
22class RequestDataBase {
23 public:
24 virtual ~RequestDataBase() = default;
25
26 virtual void Wait() = 0;
27
28 virtual ReplyType Get(const std::string& request_description) = 0;
29
30 virtual ReplyPtr GetRaw() = 0;
31
32 virtual engine::impl::ContextAccessor* TryGetContextAccessor() noexcept = 0;
33};
34
35template <ScanTag scan_tag>
37 public:
38 using ReplyElem = typename ScanReplyElem<scan_tag>::type;
39
40 virtual ~RequestScanDataBase() = default;
41
42 void SetRequestDescription(std::string request_description) {
43 request_description_ = std::move(request_description);
44 }
45
46 virtual ReplyElem Get() = 0;
47
48 virtual ReplyElem& Current() = 0;
49
50 virtual bool Eof() = 0;
51
52 protected:
53 // NOLINTNEXTLINE(misc-non-private-member-variables-in-classes)
54 std::string request_description_;
55};
56
57} // namespace storages::redis
58
59USERVER_NAMESPACE_END