@@ -76,6 +76,23 @@ TParser<TInstant> GetDefaultParser<TInstant>();
76
76
YQL_PRIMITIVE_SETTING_PARSER_TYPES (YQL_DECLARE_SETTING_PARSER)
77
77
YQL_CONTAINER_SETTING_PARSER_TYPES (YQL_DECLARE_SETTING_PARSER)
78
78
79
+ #ifdef YQL_BETTER_CONF_SETTING_API
80
+ template <typename TType>
81
+ TMaybe<TType> GetValue (const NCommon::TConfSetting<TType, NCommon::EConfSettingType::StaticPerCluster>& setting, const TString& cluster) {
82
+ return setting.Get (cluster);
83
+ }
84
+
85
+ template <typename TType>
86
+ TMaybe<TType> GetValue (const NCommon::TConfSetting<TType, NCommon::EConfSettingType::Dynamic>& setting, const TString& cluster) {
87
+ return setting.Get (cluster);
88
+ }
89
+
90
+ template <typename TType>
91
+ TMaybe<TType> GetValue (const NCommon::TConfSetting<TType, NCommon::EConfSettingType::Static>& setting, const TString& cluster) {
92
+ Y_UNUSED (cluster);
93
+ return setting.Get ();
94
+ }
95
+ #else
79
96
template <typename TType>
80
97
TMaybe<TType> GetValue (const NCommon::TConfSetting<TType, true , false >& setting, const TString& cluster) {
81
98
return setting.Get (cluster);
@@ -96,6 +113,7 @@ TMaybe<TType> GetValue(const NCommon::TConfSetting<TType, false, false>& setting
96
113
Y_UNUSED (cluster);
97
114
return setting.Get ();
98
115
}
116
+ #endif
99
117
100
118
}
101
119
@@ -135,15 +153,23 @@ class TSettingDispatcher: public TThrRefBase {
135
153
TString Name_;
136
154
};
137
155
156
+ #ifdef YQL_BETTER_CONF_SETTING_API
157
+ template <typename TType, EConfSettingType SettingType>
158
+ #else
138
159
template <typename TType, bool RUNTIME, bool PERCLUSTER>
139
- class TSettingHandlerImpl : public TSettingHandler {
160
+ #endif
161
+ class TSettingHandlerImpl : public TSettingHandler {
140
162
public:
141
163
using TValueCallback = std::function<void (const TString&, TType)>;
142
164
143
165
private:
144
166
friend class TSettingDispatcher ;
145
167
168
+ #ifdef YQL_BETTER_CONF_SETTING_API
169
+ TSettingHandlerImpl (const TString& name, TConfSetting<TType, SettingType>& setting)
170
+ #else
146
171
TSettingHandlerImpl (const TString& name, TConfSetting<TType, RUNTIME, PERCLUSTER>& setting)
172
+ #endif
147
173
: TSettingHandler(name)
148
174
, Setting_(setting)
149
175
, Parser_(::NYql::NPrivate::GetDefaultParser<TType>())
@@ -322,8 +348,13 @@ class TSettingDispatcher: public TThrRefBase {
322
348
}
323
349
324
350
private:
351
+ #ifdef YQL_BETTER_CONF_SETTING_API
352
+ TConfSetting<TType, SettingType>& Setting_;
353
+ TMaybe<TConfSetting<TType, SettingType>> Defaul_;
354
+ #else
325
355
TConfSetting<TType, RUNTIME, PERCLUSTER>& Setting_;
326
356
TMaybe<TConfSetting<TType, RUNTIME, PERCLUSTER>> Defaul_;
357
+ #endif
327
358
::NYql::NPrivate::TParser<TType> Parser_;
328
359
TValueCallback ValueSetter_;
329
360
TVector<TValueCallback> Validators_;
@@ -349,9 +380,15 @@ class TSettingDispatcher: public TThrRefBase {
349
380
ValidClusters.insert (cluster);
350
381
}
351
382
383
+ #ifdef YQL_BETTER_CONF_SETTING_API
384
+ template <typename TType, EConfSettingType SettingType>
385
+ TSettingHandlerImpl<TType, SettingType>& AddSetting (const TString& name, TConfSetting<TType, SettingType>& setting) {
386
+ TIntrusivePtr<TSettingHandlerImpl<TType, SettingType>> handler = new TSettingHandlerImpl<TType, SettingType>(name, setting);
387
+ #else
352
388
template <typename TType, bool RUNTIME, bool PERCLUSTER>
353
389
TSettingHandlerImpl<TType, RUNTIME, PERCLUSTER>& AddSetting (const TString& name, TConfSetting<TType, RUNTIME, PERCLUSTER>& setting) {
354
390
TIntrusivePtr<TSettingHandlerImpl<TType, RUNTIME, PERCLUSTER>> handler = new TSettingHandlerImpl<TType, RUNTIME, PERCLUSTER>(name, setting);
391
+ #endif
355
392
if (!Handlers.insert ({NormalizeName (name), handler}).second ) {
356
393
ythrow yexception () << " Duplicate configuration setting name " << name.Quote ();
357
394
}
0 commit comments