diff --git a/src/evloop.cpp b/src/evloop.cpp index fec22c2..7f7647b 100644 --- a/src/evloop.cpp +++ b/src/evloop.cpp @@ -21,6 +21,7 @@ #include "eventia/signal.hpp" #include "roar11/ThreadPool.hpp" #include "oro/dboperation.hpp" +#include "app_config.hpp" #include namespace duck { @@ -56,22 +57,22 @@ namespace { }; } //unnamed namespace -void test(oro::Api* api, oro::OriginsDB* db, std::size_t extra_delay, std::size_t thread_count, bool store_raw_json) { +void test(oro::Api* api, oro::OriginsDB* db, const AppConfig& app_conf) { typedef TimerOroApi TimerShops; typedef TimerOroApi TimerItems; typedef TimerOroApi TimerIcons; typedef TimerOroApi TimerCreators; typedef TimerSettings TSet; - std::cout << "Running with " << thread_count << " worker threads\n"; - roar11::ThreadPool pool(thread_count); + std::cout << "Running with " << app_conf.worker_threads() << " worker threads\n"; + roar11::ThreadPool pool(app_conf.worker_threads()); eve::Eventia worker; pool.submit(worker.event_functor()); - const double ed = static_cast(extra_delay); + const double ed = static_cast(app_conf.fetch_extra_delay()); auto sig_int = worker.make_event(&worker); - const bool& rj = store_raw_json; + const bool rj = app_conf.store_raw_json(); auto timer_items = worker.make_event(TSet{0.0, ed, rj}, &pool, api, db); auto timer_icons = worker.make_event(TSet{5.0, ed, rj}, &pool, api, db); diff --git a/src/evloop.hpp b/src/evloop.hpp index 444c59e..67014ef 100644 --- a/src/evloop.hpp +++ b/src/evloop.hpp @@ -26,6 +26,8 @@ namespace oro { namespace duck { -void test(oro::Api* api, oro::OriginsDB* db, std::size_t extra_delay, std::size_t thread_count, bool store_raw_json); +class AppConfig; + +void test(oro::Api* api, oro::OriginsDB* db, const AppConfig& app_conf); } //namespace duck diff --git a/src/main.cpp b/src/main.cpp index f9c43ce..46dda43 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -78,13 +78,7 @@ int main(int argc, char* argv[]) { std::unique_ptr db(oro::OriginsDB::make(app_conf.backend(), app_conf.db_path())); - duck::test( - oro_api.get(), - db.get(), - app_conf.fetch_extra_delay(), - app_conf.worker_threads(), - app_conf.store_raw_json() - ); + duck::test(oro_api.get(), db.get(), app_conf); } #if defined(OROTOOL_WITH_RESTCCPP) catch (const restc_cpp::CommunicationException& err) {