Skip to content

Commit fe97d05

Browse files
committed
crimson/mgr/client: add Client::retry_interval()
Could be useful in the future, for now a mere refactor. Signed-off-by: Matan Breizman <[email protected]>
1 parent d3e0ca7 commit fe97d05

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

src/crimson/mgr/client.cc

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,17 @@ void Client::ms_handle_reset(crimson::net::ConnectionRef c, bool /* is_replace *
133133
});
134134
}
135135

136+
seastar::future<> Client::retry_interval()
137+
{
138+
LOG_PREFIX(Client::retry_interval);
139+
auto retry_interval = std::chrono::duration<double>(
140+
local_conf().get_val<double>("mgr_connect_retry_interval"));
141+
auto a_while = std::chrono::duration_cast<seastar::steady_clock_type::duration>(
142+
retry_interval);
143+
DEBUGDPP("reconnecting in {} seconds", *this, retry_interval);
144+
co_await seastar::sleep(a_while);
145+
}
146+
136147
seastar::future<> Client::reconnect()
137148
{
138149
LOG_PREFIX(Client::reconnect);
@@ -150,12 +161,7 @@ seastar::future<> Client::reconnect()
150161
WARNDPP("No active mgr available yet", *this);
151162
co_return;
152163
}
153-
auto retry_interval = std::chrono::duration<double>(
154-
local_conf().get_val<double>("mgr_connect_retry_interval"));
155-
auto a_while = std::chrono::duration_cast<seastar::steady_clock_type::duration>(
156-
retry_interval);
157-
DEBUGDPP("reconnecting in {} seconds", *this, retry_interval);
158-
co_await seastar::sleep(a_while);
164+
co_await retry_interval();
159165

160166
auto peer = mgrmap.get_active_addrs().pick_addr(msgr.get_myaddr().get_type());
161167
if (peer == entity_addr_t{}) {

src/crimson/mgr/client.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ class Client : public crimson::net::Dispatcher {
5656
seastar::future<> handle_mgr_conf(crimson::net::ConnectionRef conn,
5757
Ref<MMgrConfigure> m);
5858
seastar::future<> reconnect();
59+
seastar::future<> retry_interval();
5960

6061
void print(std::ostream&) const;
6162
friend std::ostream& operator<<(std::ostream& out, const Client& client);

0 commit comments

Comments
 (0)