From 75750001ceffcb883ac6d7fd0063d557f02f6de2 Mon Sep 17 00:00:00 2001 From: Jason Rhinelander Date: Mon, 23 Mar 2020 22:29:14 -0300 Subject: [PATCH] Reduce connection check interval and make configurable The previous 1s default seems on the long side; this reduces it to 250ms. It also makes it a public member so that it can be configured (which is mainly needed for the test suite, but might be useful for lokimq-calling code that needs faster or slower connection cleanups). --- lokimq/lokimq.h | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lokimq/lokimq.h b/lokimq/lokimq.h index a42b90b..b44c781 100644 --- a/lokimq/lokimq.h +++ b/lokimq/lokimq.h @@ -71,9 +71,6 @@ template class Batch; */ static constexpr auto DEFAULT_SEND_KEEP_ALIVE = 30s; -// How frequently we cleanup connections (closing idle connections, calling connect or request failure callbacks) -static constexpr auto CONN_CHECK_INTERVAL = 1s; - // The default timeout for connect_remote() static constexpr auto REMOTE_CONNECT_TIMEOUT = 10s; @@ -202,6 +199,14 @@ public: * after the high-level zmq socket is closed. */ std::chrono::milliseconds CLOSE_LINGER = 5s; + /** How frequently we cleanup connections (closing idle connections, calling connect or request + * failure callbacks). Making this slower results in more "overshoot" before failure callbacks + * are invoked; making it too fast results in more proxy thread overhead. Any change to this + * variable must be set before calling start(). + */ + std::chrono::milliseconds CONN_CHECK_INTERVAL = 250ms; + + private: /// The lookup function that tells us where to connect to a peer, or empty if not found.