Skip to content

Commit ee678e8

Browse files
committed
[refactor]
1 parent 6af292f commit ee678e8

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

ydb/core/fq/libs/actors/database_resolver.cpp

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -468,22 +468,23 @@ class TDatabaseResolver: public TActor<TDatabaseResolver>
468468
NYql::IMdbEndpointGenerator::TEndpoint endpoint;
469469
TVector<TString> aliveHosts;
470470

471+
const auto& hostsArray = databaseInfo.GetMap().at("hosts").GetArraySafe();
471472

472-
for (const auto& host : databaseInfo.GetMap().at("hosts").GetArraySafe()) {
473-
const auto& hostMap = host.GetMap();
473+
for (const auto& host : hostsArray) {
474+
const auto& hostMap = host.GetMap();
474475

475476
if (!hostMap.contains("services")) {
476477
// indicates that cluster is down
477478
continue;
478479
}
479480

480481
// check if all services of a particular host are alive
481-
bool alive = std::all_of(
482-
hostMap.at("services").GetArraySafe().begin(),
483-
hostMap.at("services").GetArraySafe().end(),
484-
[](const auto& service) {
485-
return service["health"].GetString() == "ALIVE";
486-
}
482+
const bool alive = std::all_of(
483+
hostMap.at("services").GetArraySafe().begin(),
484+
hostMap.at("services").GetArraySafe().end(),
485+
[](const auto& service) {
486+
return service["health"].GetString() == "ALIVE";
487+
}
487488
);
488489

489490
if (alive) {
@@ -496,10 +497,10 @@ class TDatabaseResolver: public TActor<TDatabaseResolver>
496497
}
497498

498499
NYql::IMdbEndpointGenerator::TParams params = {
499-
.DatabaseType = NYql::EDatabaseType::MySQL,
500-
.MdbHost = aliveHosts[std::rand() % static_cast<int>(aliveHosts.size())],
501-
.UseTls = useTls,
502-
.Protocol = protocol,
500+
.DatabaseType = NYql::EDatabaseType::MySQL,
501+
.MdbHost = aliveHosts[std::rand() % static_cast<int>(aliveHosts.size())],
502+
.UseTls = useTls,
503+
.Protocol = protocol,
503504
};
504505

505506
endpoint = mdbEndpointGenerator->ToEndpoint(params);

0 commit comments

Comments
 (0)