-
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 10 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 const 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. do not see const in the declaration here as comment suggests. |
||
*/ | ||
virtual std::chrono::milliseconds flushIntervalMsec() PURE; | ||
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. fileFlushInternalMsec() |
||
}; | ||
|
||
} // Server |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,12 +9,13 @@ Event::DispatcherPtr Impl::allocateDispatcher() { | |
return Event::DispatcherPtr{new Event::DispatcherImpl()}; | ||
} | ||
|
||
Impl::Impl() : os_sys_calls_(new Filesystem::OsSysCallsImpl()) {} | ||
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. file_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. fixed |
||
: os_sys_calls_(new Filesystem::OsSysCallsImpl()), flush_interval_msec_(flush_interval_msec) {} | ||
|
||
Filesystem::FilePtr Impl::createFile(const std::string& path, Event::Dispatcher& dispatcher, | ||
Thread::BasicLockable& lock, Stats::Store& stats_store) { | ||
return Filesystem::FilePtr{ | ||
new Filesystem::FileImpl(path, dispatcher, lock, *os_sys_calls_, stats_store)}; | ||
return Filesystem::FilePtr{new Filesystem::FileImpl(path, dispatcher, lock, *os_sys_calls_, | ||
stats_store, flush_interval_msec_)}; | ||
} | ||
|
||
bool Impl::fileExists(const std::string& path) { return Filesystem::fileExists(path); } | ||
|
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 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 = Impl(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 = Impl(std::chrono::milliseconds(10000)); | ||
|
||
EXPECT_TRUE(api.fileExists("/dev/null")); | ||
EXPECT_FALSE(api.fileExists("/dev/blahblahblah")); | ||
} | ||
|
||
} // Api | ||
} // Api |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,7 +42,7 @@ BufferingStreamDecoderPtr IntegrationUtil::makeSingleRequest(uint32_t port, std: | |
std::string url, | ||
Http::CodecClient::Type type, | ||
std::string host) { | ||
Api::Impl api; | ||
Api::Impl api = Api::Impl(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. same in here, just go though whole change and fix those. |
||
Event::DispatcherPtr dispatcher(api.allocateDispatcher()); | ||
Stats::IsolatedStoreImpl stats_store; | ||
Http::CodecClientStats stats{ALL_CODEC_CLIENT_STATS(POOL_COUNTER(stats_store))}; | ||
|
@@ -66,7 +66,7 @@ BufferingStreamDecoderPtr IntegrationUtil::makeSingleRequest(uint32_t port, std: | |
|
||
RawConnectionDriver::RawConnectionDriver(uint32_t port, Buffer::Instance& initial_data, | ||
ReadCallback data_callback) { | ||
api_.reset(new Api::Impl()); | ||
api_.reset(new Api::Impl(std::chrono::milliseconds(10000))); | ||
dispatcher_ = api_->allocateDispatcher(); | ||
client_ = dispatcher_->createClientConnection(fmt::format("tcp://127.0.0.1:{}", port)); | ||
client_->addReadFilter(Network::ReadFilterPtr{new ForwardingFilter(*this, data_callback)}); | ||
|
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.
document default, delete source file reference below per previous comment. Grammar in general here is not great. I can update later unless you want to take another pass.
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.
--file-flush-interval-msec (basically just change this everywhere below, the name you have is not specific enough(
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.
fixed