5#include <unordered_set>
8#include <userver/utils/not_null.hpp>
10USERVER_NAMESPACE_BEGIN
12namespace utils::impl {
14class UserverExperiment
final {
19 explicit UserverExperiment(std::string name,
20 bool force_enabling_allowed =
false);
22 UserverExperiment(UserverExperiment&&) =
delete;
23 UserverExperiment& operator=(UserverExperiment&&) =
delete;
25 bool IsEnabled()
const noexcept {
return enabled_; }
26 bool IsForceEnablingAllowed()
const {
return force_enabling_allowed_; }
27 const std::string& GetName()
const {
return name_; }
30 friend struct UserverExperimentSetter;
34 bool force_enabling_allowed_{
false};
37class InvalidUserverExperiments
final :
public std::runtime_error {
38 using std::runtime_error::runtime_error;
41using UserverExperimentSet = std::unordered_set<std::string>;
44class UserverExperimentsScope
final {
46 UserverExperimentsScope();
48 UserverExperimentsScope(UserverExperimentsScope&&) =
delete;
49 UserverExperimentsScope& operator=(UserverExperimentsScope&&) =
delete;
50 ~UserverExperimentsScope();
52 void Set(UserverExperiment& experiment,
bool value)
noexcept;
55 void EnableOnly(
const UserverExperimentSet& enabled_experiments,
56 bool force_enable =
false);
59 const std::vector<utils::NotNull<UserverExperiment*>> old_enabled_;
63extern UserverExperiment kRedisClusterAutoTopologyExperiment;
64extern UserverExperiment kRedisRetryBudgetExperiment;