-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Capture interval as command line argument #61
Changes from 15 commits
46ce93a
d5b665a
f92cf1c
d908cf0
080071e
5ba466a
3e13d0a
327804b
55bff59
6310f6b
d77e9e2
a282b0e
4ac9f8e
c7a6ce3
26d53ef
aa68570
4dbc33c
05cd4fa
286cd56
6c38015
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,6 +53,11 @@ class Options { | |
* @return const std::string& the service zone where the server is running. | ||
*/ | ||
virtual const std::string& serviceZone() PURE; | ||
|
||
/** | ||
* @return std::chrono::milliseconds the duration in msec between log flushes | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. minor: put '.' at the very end. |
||
*/ | ||
virtual std::chrono::milliseconds fileFlushIntervalMsec() PURE; | ||
}; | ||
|
||
} // Server |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,7 @@ namespace Api { | |
*/ | ||
class Impl : public Api::Api { | ||
public: | ||
Impl(); | ||
Impl(std::chrono::milliseconds flush_interval_msec); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fix here :-) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. file_flush_interval_msec |
||
|
||
// Api::Api | ||
Event::DispatcherPtr allocateDispatcher() override; | ||
|
@@ -21,6 +21,7 @@ class Impl : public Api::Api { | |
|
||
private: | ||
Filesystem::OsSysCallsPtr os_sys_calls_; | ||
std::chrono::milliseconds file_flush_interval_msec_; | ||
}; | ||
|
||
} // Api |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,8 +6,9 @@ | |
|
||
#include "common/api/api_impl.h" | ||
|
||
ConnectionHandler::ConnectionHandler(Stats::Store& stats_store, spdlog::logger& logger) | ||
: stats_store_(stats_store), logger_(logger), api_(new Api::Impl()), | ||
ConnectionHandler::ConnectionHandler(Stats::Store& stats_store, spdlog::logger& logger, | ||
std::chrono::milliseconds flush_interval_msec) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. here for flush_interval There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. file_flush_interval_msec |
||
: stats_store_(stats_store), logger_(logger), api_(new Api::Impl(flush_interval_msec)), | ||
dispatcher_(api_->allocateDispatcher()), | ||
watchdog_miss_counter_(stats_store.counter("server.watchdog_miss")), | ||
watchdog_mega_miss_counter_(stats_store.counter("server.watchdog_mega_miss")) {} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,7 +33,7 @@ struct ListenerStats { | |
*/ | ||
class ConnectionHandler final : NonCopyable { | ||
public: | ||
ConnectionHandler(Stats::Store& stats_store, spdlog::logger& logger); | ||
ConnectionHandler(Stats::Store& stats_store, spdlog::logger& logger, std::chrono::milliseconds flush_interval_msec); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would just pass options object here since you are still in server code There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same below in worker There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ignore this per offline discussion There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. file_flush_interval_msec |
||
~ConnectionHandler(); | ||
|
||
Api::Api& api() { return *api_; } | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,8 +7,9 @@ | |
|
||
#include "common/common/thread.h" | ||
|
||
Worker::Worker(Stats::Store& stats_store, ThreadLocal::Instance& tls) | ||
: tls_(tls), handler_(new ConnectionHandler(stats_store, log())) { | ||
Worker::Worker(Stats::Store& stats_store, ThreadLocal::Instance& tls, | ||
std::chrono::milliseconds flush_interval_msec) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. file_flush_interval_msec |
||
: tls_(tls), handler_(new ConnectionHandler(stats_store, log(), flush_interval_msec)) { | ||
tls_.registerThread(handler_->dispatcher(), false); | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,8 @@ typedef std::map<Server::Configuration::Listener*, Network::TcpListenSocketPtr> | |
*/ | ||
class Worker : Logger::Loggable<Logger::Id::main> { | ||
public: | ||
Worker(Stats::Store& stats_store, ThreadLocal::Instance& tls); | ||
Worker(Stats::Store& stats_store, ThreadLocal::Instance& tls, | ||
std::chrono::milliseconds flush_interval_msec); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. file_flush_interval_msec |
||
~Worker(); | ||
|
||
Event::Dispatcher& dispatcher() { return handler_->dispatcher(); } | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
namespace Api { | ||
|
||
TEST(ApiImplTest, readFileToEnd) { | ||
Impl api; | ||
Impl api(std::chrono::milliseconds(10000)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit, Impl api(std::...10000); and other places. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
|
||
const std::string file_path = "/tmp/test_api_envoy"; | ||
unlink(file_path.c_str()); | ||
|
@@ -17,10 +17,10 @@ TEST(ApiImplTest, readFileToEnd) { | |
} | ||
|
||
TEST(ApiImplTest, fileExists) { | ||
Impl api; | ||
Impl api(std::chrono::milliseconds(10000)); | ||
|
||
EXPECT_TRUE(api.fileExists("/dev/null")); | ||
EXPECT_FALSE(api.fileExists("/dev/blahblahblah")); | ||
} | ||
|
||
} // Api | ||
} // Api |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
string -> integer