Pass app_config to test() instead of single options

This commit is contained in:
King_DuckZ 2020-09-05 00:59:51 +01:00
parent 9d4d52bed0
commit 8f8865e4df
3 changed files with 10 additions and 13 deletions

View file

@ -21,6 +21,7 @@
#include "eventia/signal.hpp"
#include "roar11/ThreadPool.hpp"
#include "oro/dboperation.hpp"
#include "app_config.hpp"
#include <iostream>
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<oro::DBOperation::Shops> TimerShops;
typedef TimerOroApi<oro::DBOperation::Items> TimerItems;
typedef TimerOroApi<oro::DBOperation::Icons> TimerIcons;
typedef TimerOroApi<oro::DBOperation::Creators> 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<double>(extra_delay);
const double ed = static_cast<double>(app_conf.fetch_extra_delay());
auto sig_int = worker.make_event<SignalInt>(&worker);
const bool& rj = store_raw_json;
const bool rj = app_conf.store_raw_json();
auto timer_items = worker.make_event<TimerItems>(TSet{0.0, ed, rj}, &pool, api, db);
auto timer_icons = worker.make_event<TimerIcons>(TSet{5.0, ed, rj}, &pool, api, db);

View file

@ -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

View file

@ -78,13 +78,7 @@ int main(int argc, char* argv[]) {
std::unique_ptr<oro::OriginsDB> 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) {