9#include <userver/logging/fwd.hpp>
10#include <userver/utils/strong_typedef.hpp>
12#include <userver/storages/redis/command_control.hpp>
13#include <userver/storages/redis/impl/types.hpp>
15USERVER_NAMESPACE_BEGIN
17namespace storages::
redis {
23using Password = utils::NonLoggable<
class PasswordTag, std::string>;
25enum class ConnectionSecurity { kNone, kTLS };
28 std::string host =
"localhost";
31 bool read_only =
false;
32 ConnectionSecurity connection_security = ConnectionSecurity::kNone;
34 HostVector resolved_host{};
36 ConnectionInfo() =
default;
37 ConnectionInfo(std::string host,
int port, Password password,
38 bool read_only =
false,
39 ConnectionSecurity security = ConnectionSecurity::kNone,
40 HostVector resolved_host = {})
41 : host{std::move(host)},
43 password{std::move(password)},
45 connection_security(security),
46 resolved_host(std::move(resolved_host)) {}
52 double inprogress = 0.0;
53 double timeouts = 0.0;
63 template <
typename... Args>
64 CmdArgs(Args&&... _args) {
65 Then(std::forward<Args>(_args)...);
68 CmdArgs(
const CmdArgs& o) =
delete;
74 template <
typename... Args>
88using ScanCursor = int64_t;
90template <
typename Arg>
91typename std::enable_if<std::is_arithmetic<Arg>::value,
void>::type PutArg(
92 CmdArgs::CmdArgsArray& args_,
const Arg& arg) {
93 args_.emplace_back(std::to_string(arg));
96void PutArg(CmdArgs::CmdArgsArray& args_,
const char* arg);
98void PutArg(CmdArgs::CmdArgsArray& args_,
const std::string& arg);
100void PutArg(CmdArgs::CmdArgsArray& args_, std::string&& arg);
102void PutArg(CmdArgs::CmdArgsArray& args_,
const std::vector<std::string>& arg);
104void PutArg(CmdArgs::CmdArgsArray& args_,
105 const std::vector<std::pair<std::string, std::string>>& arg);
107void PutArg(CmdArgs::CmdArgsArray& args_,
108 const std::vector<std::pair<
double, std::string>>& arg);
110template <
typename... Args>
113 auto& new_args = args.back();
114 new_args.reserve(
sizeof...(Args));
115 (PutArg(new_args, std::forward<Args>(_args)), ...);
120 bool buffering_enabled{
false};
121 size_t commands_buffering_threshold{0};
122 std::chrono::microseconds watch_command_timer_interval{0};
125 return buffering_enabled == o.buffering_enabled &&
126 commands_buffering_threshold == o.commands_buffering_threshold &&
127 watch_command_timer_interval == o.watch_command_timer_interval;
131enum class ConnectionMode {
137 bool timings_enabled{
true};
138 bool command_timings_enabled{
false};
139 bool request_sizes_enabled{
false};
140 bool reply_sizes_enabled{
false};
143 return timings_enabled == rhs.timings_enabled &&
144 command_timings_enabled == rhs.command_timings_enabled &&
145 request_sizes_enabled == rhs.request_sizes_enabled &&
146 reply_sizes_enabled == rhs.reply_sizes_enabled;
150 return !(*
this == rhs);
155 bool per_shard_stats_enabled{
true};
158 return per_shard_stats_enabled == rhs.per_shard_stats_enabled;
162 return !(*
this == rhs);
167 bool enable_monitoring{
false};
168 bool restrict_requests{
false};