Skip to content

Commit dcd908b

Browse files
committed
fix code format
1 parent 79652db commit dcd908b

3 files changed

Lines changed: 22 additions & 31 deletions

File tree

lib/AutoClusterFailover.cc

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -177,8 +177,8 @@ class AutoClusterFailoverImpl : public std::enable_shared_from_this<AutoClusterF
177177
std::lock_guard<std::mutex> lock(self->mutex_);
178178
auto now = currentTimeMs();
179179
LOG_INFO("Current service " << self->currentServiceUrl_ << " has been down for "
180-
<< (now - self->failedTimestamp_)
181-
<< " ms, switching to " << target);
180+
<< (now - self->failedTimestamp_) << " ms, switching to "
181+
<< target);
182182
self->performSwitch(target);
183183
self->failedTimestamp_ = -1;
184184
}
@@ -259,10 +259,10 @@ class AutoClusterFailoverImpl : public std::enable_shared_from_this<AutoClusterF
259259
self->failedTimestamp_ = -1;
260260
self->recoverTimestamp_ = -1;
261261
} else {
262-
LOG_ERROR("Current service "
263-
<< self->currentServiceUrl_ << " has been down for "
264-
<< (currentTimeMs() - self->failedTimestamp_) << " ms. Primary "
265-
<< self->primary_ << " is also not available.");
262+
LOG_ERROR("Current service " << self->currentServiceUrl_ << " has been down for "
263+
<< (currentTimeMs() - self->failedTimestamp_)
264+
<< " ms. Primary " << self->primary_
265+
<< " is also not available.");
266266
}
267267
}
268268
self->scheduleProbe();

lib/ClientImpl.cc

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ void ClientImpl::updateTlsTrustCertsFilePath(const std::string& tlsTrustCertsFil
163163
}
164164

165165
void ClientImpl::updateTlsTrustStorePathAndPassword(const std::string& tlsTrustStorePath,
166-
const std::string& tlsTrustStorePassword) {
166+
const std::string& tlsTrustStorePassword) {
167167
LOG_INFO("Updating TLS trust store path to: " << tlsTrustStorePath);
168168
// The C++ client doesn't have a TLS trust store path/password setting (Java-only feature),
169169
// so this is a no-op for now. The interface is provided for API compatibility.
@@ -229,21 +229,17 @@ void ClientImpl::probeAsync(const std::string& serviceUrl, int timeoutMs, ProbeC
229229
});
230230

231231
// Async resolve
232-
state->resolver.async_resolve(host, port,
233-
[state](const ASIO::error_code& ec,
234-
ASIO::ip::tcp::resolver::results_type endpoints) {
235-
if (ec) {
236-
state->complete(false);
237-
return;
238-
}
239-
// Async connect
240-
ASIO::async_connect(
241-
state->socket, endpoints,
242-
[state](const ASIO::error_code& connectEc,
243-
const ASIO::ip::tcp::endpoint&) {
244-
state->complete(!connectEc);
245-
});
246-
});
232+
state->resolver.async_resolve(
233+
host, port, [state](const ASIO::error_code& ec, ASIO::ip::tcp::resolver::results_type endpoints) {
234+
if (ec) {
235+
state->complete(false);
236+
return;
237+
}
238+
// Async connect
239+
ASIO::async_connect(state->socket, endpoints,
240+
[state](const ASIO::error_code& connectEc,
241+
const ASIO::ip::tcp::endpoint&) { state->complete(!connectEc); });
242+
});
247243
} catch (const std::exception& e) {
248244
LOG_WARN("Failed to probe " << serviceUrl << ": " << e.what());
249245
callback(false);

tests/AutoClusterFailoverTest.cc

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,7 @@ class AutoClusterFailoverTest : public ::testing::Test {
117117
ServiceUrlProviderPtr provider_;
118118

119119
// Build a provider with sensible fast defaults; individual tests can override via the builder.
120-
AutoClusterFailoverBuilder defaultBuilder(
121-
const std::vector<std::string>& secondaryUrls = {SECONDARY1}) {
120+
AutoClusterFailoverBuilder defaultBuilder(const std::vector<std::string>& secondaryUrls = {SECONDARY1}) {
122121
return AutoClusterFailover::builder()
123122
.primary(PRIMARY)
124123
.secondary(secondaryUrls)
@@ -129,8 +128,7 @@ class AutoClusterFailoverTest : public ::testing::Test {
129128

130129
// Build with defaults, initialize, and set probe results in one call.
131130
// `primaryUp` / `secondaryUp` control the initial probe availability.
132-
void initWithProbeResults(bool primaryUp, bool secondaryUp,
133-
AutoClusterFailoverBuilder builder) {
131+
void initWithProbeResults(bool primaryUp, bool secondaryUp, AutoClusterFailoverBuilder builder) {
134132
prober_.setProbeResult(PRIMARY, primaryUp);
135133
prober_.setProbeResult(SECONDARY1, secondaryUp);
136134
provider_ = builder.build();
@@ -193,9 +191,7 @@ TEST_F(AutoClusterFailoverTest, testBuilderMissingSwitchBackDelay) {
193191
std::invalid_argument);
194192
}
195193

196-
TEST_F(AutoClusterFailoverTest, testBuilderSuccess) {
197-
EXPECT_NO_THROW(defaultBuilder().build());
198-
}
194+
TEST_F(AutoClusterFailoverTest, testBuilderSuccess) { EXPECT_NO_THROW(defaultBuilder().build()); }
199195

200196
TEST_F(AutoClusterFailoverTest, testGetServiceUrlReturnsPrimary) {
201197
provider_ = defaultBuilder().build();
@@ -258,8 +254,7 @@ TEST_F(AutoClusterFailoverTest, testAuthenticationUpdatedOnFailover) {
258254
}
259255

260256
TEST_F(AutoClusterFailoverTest, testTlsUpdatedOnFailover) {
261-
auto builder =
262-
defaultBuilder().secondaryTlsTrustCertsFilePath({{SECONDARY1, "/path/to/secondary.pem"}});
257+
auto builder = defaultBuilder().secondaryTlsTrustCertsFilePath({{SECONDARY1, "/path/to/secondary.pem"}});
263258
initWithProbeResults(/*primaryUp=*/false, /*secondaryUp=*/true, std::move(builder));
264259
assertSwitchesTo(SECONDARY1);
265260
EXPECT_GE(client_.getUpdateTlsCount(), 1);

0 commit comments

Comments
 (0)