@@ -285,14 +285,15 @@ class TClientCommandServerBase : public TClientCommand {
285
285
config.Opts ->SetFreeArgDefaultTitle (" PATH" , " path to protobuf file; files are merged in order in which they are enlisted" );
286
286
}
287
287
288
- template <typename TProto>
289
- TProto *MutableConfigPart (TConfig& config, const char *optname,
290
- bool (NKikimrConfig::TAppConfig::*hasConfig)() const ,
291
- const TProto& (NKikimrConfig::TAppConfig::*getConfig)() const ,
292
- TProto* (NKikimrConfig::TAppConfig::*mutableConfig)(),
293
- ui32 kind,
294
- TCallContext callCtx) {
295
- TProto *res = nullptr ;
288
+ template <typename TFieldTag>
289
+ auto MutableConfigPart (TConfig& config, const char *optname,
290
+ TFieldTag tag,
291
+ TCallContext callCtx) -> decltype((AppConfig.*std::get<2 >(NKikimrConfig::TAppConfig::GetFieldAccessorsByFieldTag(tag)))())
292
+ {
293
+ auto [hasConfig, getConfig, mutableConfig] = NKikimrConfig::TAppConfig::GetFieldAccessorsByFieldTag (tag);
294
+ ui32 kind = NKikimrConfig::TAppConfig::GetFieldIdByFieldTag (tag);
295
+
296
+ typename std::remove_reference<decltype (*(AppConfig.*mutableConfig)())>::type *res = nullptr ;
296
297
if ((AppConfig.*hasConfig)()) {
297
298
return nullptr ; // this field is already provided in AppConfig, so we don't overwrite it
298
299
}
@@ -310,15 +311,18 @@ class TClientCommandServerBase : public TClientCommand {
310
311
return res;
311
312
}
312
313
313
- template <typename TProto>
314
- TProto *MutableConfigPartMerge (TConfig& config, const char *optname,
315
- TProto* (NKikimrConfig::TAppConfig::*mutableConfig)(),
316
- ui32 kind,
317
- TCallContext callCtx) {
318
- TProto *res = nullptr ;
314
+ template <typename TFieldTag>
315
+ auto MutableConfigPartMerge (TConfig& config, const char *optname,
316
+ TFieldTag tag,
317
+ TCallContext callCtx) -> decltype((AppConfig.*std::get<2 >(NKikimrConfig::TAppConfig::GetFieldAccessorsByFieldTag(tag)))())
318
+ {
319
+ auto mutableConfig = std::get<2 >(NKikimrConfig::TAppConfig::GetFieldAccessorsByFieldTag (tag));
320
+ ui32 kind = NKikimrConfig::TAppConfig::GetFieldIdByFieldTag (tag);
321
+
322
+ typename std::remove_reference<decltype (*(AppConfig.*mutableConfig)())>::type *res = nullptr ;
319
323
320
324
if (config.ParseResult ->Has (optname)) {
321
- TProto cfg;
325
+ typename std::remove_reference< decltype (*(AppConfig.*mutableConfig)())>::type cfg;
322
326
bool success = ParsePBFromFile (config.ParseResult ->Get (optname), &cfg);
323
327
Y_ABORT_UNLESS (success);
324
328
res = (AppConfig.*mutableConfig)();
@@ -361,19 +365,15 @@ class TClientCommandServerBase : public TClientCommand {
361
365
virtual void Parse (TConfig& config) override {
362
366
TClientCommand::Parse (config);
363
367
364
- #define OPTION (NAME, FIELD ) MutableConfigPart(config, NAME, &NKikimrConfig::TAppConfig::Has##FIELD, \
365
- &NKikimrConfig::TAppConfig::Get##FIELD, &NKikimrConfig::TAppConfig::Mutable##FIELD, \
366
- (ui32)NKikimrConsole::TConfigItem:: FIELD ## Item, TCallContext{__FILE__, __LINE__})
367
- #define OPTION_MERGE (NAME, FIELD ) MutableConfigPartMerge(config, NAME, &NKikimrConfig::TAppConfig::Mutable##FIELD, \
368
- (ui32)NKikimrConsole::TConfigItem:: FIELD ## Item, TCallContext{__FILE__, __LINE__})
368
+ using TCfg = NKikimrConfig::TAppConfig;
369
369
370
- OPTION ( " auth-file" , AuthConfig );
370
+ MutableConfigPart (config, " auth-file" , TCfg::TAuthConfigFieldTag{}, CALL_CTX () );
371
371
LoadBootstrapConfig (config);
372
372
LoadYamlConfig (CALL_CTX ());
373
- OPTION_MERGE ( " auth-token-file" , AuthConfig );
373
+ MutableConfigPartMerge (config, " auth-token-file" , TCfg::TAuthConfigFieldTag{}, CALL_CTX () );
374
374
375
375
// start memorylog as soon as possible
376
- if (auto mem = OPTION ( " memorylog-file" , MemoryLogConfig )) {
376
+ if (auto mem = MutableConfigPart (config, " memorylog-file" , TCfg::TMemoryLogConfigFieldTag{}, CALL_CTX () )) {
377
377
if (mem->HasLogBufferSize () && mem->GetLogBufferSize () > 0 ) {
378
378
if (mem->HasLogGrainSize () && mem->GetLogGrainSize () > 0 ) {
379
379
TMemoryLog::CreateMemoryLogBuffer (mem->GetLogBufferSize (), mem->GetLogGrainSize ());
@@ -384,7 +384,7 @@ class TClientCommandServerBase : public TClientCommand {
384
384
}
385
385
}
386
386
387
- OPTION ( " naming-file" , NameserviceConfig );
387
+ MutableConfigPart (config, " naming-file" , TCfg::TNameserviceConfigFieldTag{}, CALL_CTX () );
388
388
389
389
if (config.ParseResult ->Has (" node" )) {
390
390
if (NodeIdValue == " static" ) {
@@ -460,16 +460,16 @@ class TClientCommandServerBase : public TClientCommand {
460
460
461
461
LoadYamlConfig (CALL_CTX ());
462
462
463
- OPTION ( " sys-file" , ActorSystemConfig );
463
+ MutableConfigPart (config, " sys-file" , TCfg::TActorSystemConfigFieldTag{}, CALL_CTX () );
464
464
if (!AppConfig.HasActorSystemConfig ()) {
465
465
AppConfig.MutableActorSystemConfig ()->CopyFrom (*DummyActorSystemConfig ());
466
466
TRACE_CONFIG_CHANGE_INPLACE_T (ActorSystemConfig, SetExplicitly);
467
467
}
468
468
469
- OPTION ( " domains-file" , DomainsConfig );
470
- OPTION ( " bs-file" , BlobStorageConfig );
469
+ MutableConfigPart (config, " domains-file" , TCfg::TDomainsConfigFieldTag{}, CALL_CTX () );
470
+ MutableConfigPart (config, " bs-file" , TCfg::TBlobStorageConfigFieldTag{}, CALL_CTX () );
471
471
472
- if (auto logConfig = OPTION ( " log-file" , LogConfig )) {
472
+ if (auto logConfig = MutableConfigPart (config, " log-file" , TCfg::TLogConfigFieldTag{}, CALL_CTX () )) {
473
473
if (config.ParseResult ->Has (" syslog" ))
474
474
logConfig->SetSysLog (true );
475
475
if (config.ParseResult ->Has (" log-level" ))
@@ -495,45 +495,45 @@ class TClientCommandServerBase : public TClientCommand {
495
495
TRACE_CONFIG_CHANGE_INPLACE_T (LogConfig, UpdateExplicitly);
496
496
}
497
497
498
- if (auto interconnectConfig = OPTION ( " ic-file" , InterconnectConfig )) {
498
+ if (auto interconnectConfig = MutableConfigPart (config, " ic-file" , TCfg::TInterconnectConfigFieldTag{}, CALL_CTX () )) {
499
499
if (config.ParseResult ->Has (" tcp" )) {
500
500
interconnectConfig->SetStartTcp (true );
501
501
TRACE_CONFIG_CHANGE_INPLACE_T (InterconnectConfig, UpdateExplicitly);
502
502
}
503
503
}
504
504
505
- OPTION ( " channels-file" , ChannelProfileConfig );
505
+ MutableConfigPart (config, " channels-file" , TCfg::TChannelProfileConfigFieldTag{}, CALL_CTX () );
506
506
507
- if (auto bootstrapConfig = OPTION ( " bootstrap-file" , BootstrapConfig )) {
507
+ if (auto bootstrapConfig = MutableConfigPart (config, " bootstrap-file" , TCfg::TBootstrapConfigFieldTag{}, CALL_CTX () )) {
508
508
bootstrapConfig->MutableCompileServiceConfig ()->SetInflightLimit (CompileInflightLimit);
509
509
TRACE_CONFIG_CHANGE_INPLACE_T (BootstrapConfig, UpdateExplicitly);
510
510
}
511
511
512
- OPTION ( " vdisk-file" , VDiskConfig );
513
- OPTION ( " drivemodel-file" , DriveModelConfig );
514
- OPTION ( " grpc-file" , GRpcConfig );
515
- OPTION ( " dyn-nodes-file" , DynamicNameserviceConfig );
516
- OPTION ( " cms-file" , CmsConfig );
517
- OPTION ( " pq-file" , PQConfig );
518
- OPTION ( " pqcd-file" , PQClusterDiscoveryConfig );
519
- OPTION ( " netclassifier-file" , NetClassifierConfig );
520
- OPTION ( " auth-file" , AuthConfig );
521
- OPTION_MERGE ( " auth-token-file" , AuthConfig );
522
- OPTION ( " key-file" , KeyConfig );
523
- OPTION ( " pdisk-key-file" , PDiskKeyConfig );
524
- OPTION ( " sqs-file" , SqsConfig );
525
- OPTION ( " http-proxy-file" , HttpProxyConfig );
526
- OPTION ( " public-http-file" , PublicHttpConfig );
527
- OPTION ( " feature-flags-file" , FeatureFlags );
528
- OPTION ( " rb-file" , ResourceBrokerConfig );
529
- OPTION ( " metering-file" , MeteringConfig );
530
- OPTION ( " audit-file" , AuditConfig );
531
- OPTION ( " kqp-file" , KQPConfig );
532
- OPTION ( " incrhuge-file" , IncrHugeConfig );
533
- OPTION ( " alloc-file" , AllocatorConfig );
534
- OPTION ( " fq-file" , FederatedQueryConfig );
535
- OPTION ( nullptr , TracingConfig );
536
- OPTION ( nullptr , FailureInjectionConfig );
512
+ MutableConfigPart (config, " vdisk-file" , TCfg::TVDiskConfigFieldTag{}, CALL_CTX () );
513
+ MutableConfigPart (config, " drivemodel-file" , TCfg::TDriveModelConfigFieldTag{}, CALL_CTX () );
514
+ MutableConfigPart (config, " grpc-file" , TCfg::TGRpcConfigFieldTag{}, CALL_CTX () );
515
+ MutableConfigPart (config, " dyn-nodes-file" , TCfg::TDynamicNameserviceConfigFieldTag{}, CALL_CTX () );
516
+ MutableConfigPart (config, " cms-file" , TCfg::TCmsConfigFieldTag{}, CALL_CTX () );
517
+ MutableConfigPart (config, " pq-file" , TCfg::TPQConfigFieldTag{}, CALL_CTX () );
518
+ MutableConfigPart (config, " pqcd-file" , TCfg::TPQClusterDiscoveryConfigFieldTag{}, CALL_CTX () );
519
+ MutableConfigPart (config, " netclassifier-file" , TCfg::TNetClassifierConfigFieldTag{}, CALL_CTX () );
520
+ MutableConfigPart (config, " auth-file" , TCfg::TAuthConfigFieldTag{}, CALL_CTX () );
521
+ MutableConfigPartMerge (config, " auth-token-file" , TCfg::TAuthConfigFieldTag{}, CALL_CTX () );
522
+ MutableConfigPart (config, " key-file" , TCfg::TKeyConfigFieldTag{}, CALL_CTX () );
523
+ MutableConfigPart (config, " pdisk-key-file" , TCfg::TPDiskKeyConfigFieldTag{}, CALL_CTX () );
524
+ MutableConfigPart (config, " sqs-file" , TCfg::TSqsConfigFieldTag{}, CALL_CTX () );
525
+ MutableConfigPart (config, " http-proxy-file" , TCfg::THttpProxyConfigFieldTag{}, CALL_CTX () );
526
+ MutableConfigPart (config, " public-http-file" , TCfg::TPublicHttpConfigFieldTag{}, CALL_CTX () );
527
+ MutableConfigPart (config, " feature-flags-file" , TCfg::TFeatureFlagsFieldTag{}, CALL_CTX () );
528
+ MutableConfigPart (config, " rb-file" , TCfg::TResourceBrokerConfigFieldTag{}, CALL_CTX () );
529
+ MutableConfigPart (config, " metering-file" , TCfg::TMeteringConfigFieldTag{}, CALL_CTX () );
530
+ MutableConfigPart (config, " audit-file" , TCfg::TAuditConfigFieldTag{}, CALL_CTX () );
531
+ MutableConfigPart (config, " kqp-file" , TCfg::TKQPConfigFieldTag{}, CALL_CTX () );
532
+ MutableConfigPart (config, " incrhuge-file" , TCfg::TIncrHugeConfigFieldTag{}, CALL_CTX () );
533
+ MutableConfigPart (config, " alloc-file" , TCfg::TAllocatorConfigFieldTag{}, CALL_CTX () );
534
+ MutableConfigPart (config, " fq-file" , TCfg::TFederatedQueryConfigFieldTag{}, CALL_CTX () );
535
+ MutableConfigPart (config, nullptr , TCfg::TTracingConfigFieldTag{}, CALL_CTX () );
536
+ MutableConfigPart (config, nullptr , TCfg::TFailureInjectionConfigFieldTag{}, CALL_CTX () );
537
537
538
538
if (!AppConfig.HasAllocatorConfig ()) {
539
539
AppConfig.MutableAllocatorConfig ()->CopyFrom (*DummyAllocatorConfig ());
0 commit comments