12#include <userver/storages/redis/fwd.hpp>
14USERVER_NAMESPACE_BEGIN
20namespace storages::
redis {
22inline constexpr std::chrono::milliseconds kDefaultTimeoutSingle{500};
23inline constexpr std::chrono::milliseconds kDefaultTimeoutAll{2000};
24inline constexpr std::size_t kDefaultMaxRetries{4};
32 bool IsAny()
const {
return id_ == -1; }
34 bool operator==(
const ServerId& other)
const {
return other.id_ == id_; }
35 bool operator!=(
const ServerId& other)
const {
return !(other == *
this); }
37 bool operator<(
const ServerId& other)
const {
return id_ < other.id_; }
45 static ServerId Invalid() {
return invalid_; }
47 int64_t GetId()
const {
return id_; }
49 void SetDescription(std::string description)
const;
50 void RemoveDescription()
const;
51 std::string GetDescription()
const;
54 static std::atomic<std::int64_t> next_id_;
61 std::size_t operator()(
ServerId server_id)
const noexcept {
return std::hash<std::size_t>{}(server_id.GetId()); }
133 CommandControl() =
default;
135 const std::optional<std::chrono::milliseconds>& timeout_single,
136 const std::optional<std::chrono::milliseconds>& timeout_all,
137 const std::optional<size_t>& max_retries
146 std::string ToString()
const;
157#ifdef USERVER_FEATURE_LEGACY_REDIS_NAMESPACE
159using storages::redis::kDefaultMaxRetries;
160using storages::redis::kDefaultTimeoutAll;
161using storages::redis::kDefaultTimeoutSingle;
163using storages::redis::kRetryNilFromMaster;
164using storages::redis::RetryNilFromMaster;
165using storages::redis::ServerIdHasher;
167using storages::redis::CommandControl;
168using storages::redis::ServerId;
169using storages::redis::StrategyFromString;
170using storages::redis::StrategyToString;