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
19using Password = utils::NonLoggable<
class PasswordTag, std::string>;
21enum class ConnectionSecurity { kNone, kTLS };
24 std::string host =
"localhost";
27 bool read_only =
false;
28 ConnectionSecurity connection_security = ConnectionSecurity::kNone;
31 ConnectionInfo() =
default;
32 ConnectionInfo(std::string host,
int port, Password password,
33 bool read_only =
false,
34 ConnectionSecurity security = ConnectionSecurity::kNone)
35 : host{std::move(host)},
37 password{std::move(password)},
39 connection_security(security) {}
45 double inprogress = 0.0;
46 double timeouts = 0.0;
56 template <
typename... Args>
57 CmdArgs(Args&&... _args) {
58 Then(std::forward<Args>(_args)...);
61 CmdArgs(
const CmdArgs& o) =
delete;
67 template <
typename... Args>
81using ScanCursor = int64_t;
83template <
typename Arg>
84typename std::enable_if<std::is_arithmetic<Arg>::value,
void>::type PutArg(
85 CmdArgs::CmdArgsArray& args_,
const Arg& arg) {
86 args_.emplace_back(std::to_string(arg));
89void PutArg(CmdArgs::CmdArgsArray& args_,
const char* arg);
91void PutArg(CmdArgs::CmdArgsArray& args_,
const std::string& arg);
93void PutArg(CmdArgs::CmdArgsArray& args_, std::string&& arg);
95void PutArg(CmdArgs::CmdArgsArray& args_,
const std::vector<std::string>& arg);
97void PutArg(CmdArgs::CmdArgsArray& args_,
98 const std::vector<std::pair<std::string, std::string>>& arg);
100void PutArg(CmdArgs::CmdArgsArray& args_,
101 const std::vector<std::pair<
double, std::string>>& arg);
103template <
typename... Args>
106 auto& new_args = args.back();
107 new_args.reserve(
sizeof...(Args));
108 (PutArg(new_args, std::forward<Args>(_args)), ...);
113 bool buffering_enabled{
false};
114 size_t commands_buffering_threshold{0};
115 std::chrono::microseconds watch_command_timer_interval{0};
118 return buffering_enabled == o.buffering_enabled &&
119 commands_buffering_threshold == o.commands_buffering_threshold &&
120 watch_command_timer_interval == o.watch_command_timer_interval;
124enum class ConnectionMode {
130 enum class Level { kCluster, kShard, kInstance };
133 bool timings_enabled{
true};
134 bool command_timings_enabled{
false};
135 bool request_sizes_enabled{
false};
136 bool reply_sizes_enabled{
false};
139 return timings_enabled == rhs.timings_enabled &&
140 command_timings_enabled == rhs.command_timings_enabled &&
141 request_sizes_enabled == rhs.request_sizes_enabled &&
142 reply_sizes_enabled == rhs.reply_sizes_enabled;
146 return !(*
this == rhs);
151 Level level{Level::kInstance};
154 return level == rhs.level;
158 return !(*
this == rhs);
167 : static_settings(static_settings), dynamic_settings(dynamic_settings) {}
168 MetricsSettings() =
default;
175 return static_settings == rhs.static_settings &&
176 dynamic_settings == rhs.dynamic_settings;
180 return !(*
this == rhs);
183 Level GetMetricsLevel()
const {
return static_settings.level; }
184 bool IsTimingsEnabled()
const {
return dynamic_settings.timings_enabled; }
185 bool IsCommandTimingsEnabled()
const {
186 return dynamic_settings.command_timings_enabled;
188 bool IsRequestSizesEnabled()
const {
189 return dynamic_settings.request_sizes_enabled;
191 bool IsReplySizesEnabled()
const {
192 return dynamic_settings.reply_sizes_enabled;
197 bool per_shard_stats_enabled{
true};
200 return per_shard_stats_enabled == rhs.per_shard_stats_enabled;
204 return !(*
this == rhs);
209 bool enable_monitoring{
false};
210 bool restrict_requests{
false};