Pass app_config to test() instead of single options
This commit is contained in:
parent
9d4d52bed0
commit
8f8865e4df
3 changed files with 10 additions and 13 deletions
|
@ -21,6 +21,7 @@
|
||||||
#include "eventia/signal.hpp"
|
#include "eventia/signal.hpp"
|
||||||
#include "roar11/ThreadPool.hpp"
|
#include "roar11/ThreadPool.hpp"
|
||||||
#include "oro/dboperation.hpp"
|
#include "oro/dboperation.hpp"
|
||||||
|
#include "app_config.hpp"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
namespace duck {
|
namespace duck {
|
||||||
|
@ -56,22 +57,22 @@ namespace {
|
||||||
};
|
};
|
||||||
} //unnamed 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::Shops> TimerShops;
|
||||||
typedef TimerOroApi<oro::DBOperation::Items> TimerItems;
|
typedef TimerOroApi<oro::DBOperation::Items> TimerItems;
|
||||||
typedef TimerOroApi<oro::DBOperation::Icons> TimerIcons;
|
typedef TimerOroApi<oro::DBOperation::Icons> TimerIcons;
|
||||||
typedef TimerOroApi<oro::DBOperation::Creators> TimerCreators;
|
typedef TimerOroApi<oro::DBOperation::Creators> TimerCreators;
|
||||||
typedef TimerSettings TSet;
|
typedef TimerSettings TSet;
|
||||||
|
|
||||||
std::cout << "Running with " << thread_count << " worker threads\n";
|
std::cout << "Running with " << app_conf.worker_threads() << " worker threads\n";
|
||||||
roar11::ThreadPool pool(thread_count);
|
roar11::ThreadPool pool(app_conf.worker_threads());
|
||||||
eve::Eventia worker;
|
eve::Eventia worker;
|
||||||
pool.submit(worker.event_functor());
|
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);
|
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_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);
|
auto timer_icons = worker.make_event<TimerIcons>(TSet{5.0, ed, rj}, &pool, api, db);
|
||||||
|
|
|
@ -26,6 +26,8 @@ namespace oro {
|
||||||
|
|
||||||
namespace duck {
|
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
|
} //namespace duck
|
||||||
|
|
|
@ -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()));
|
std::unique_ptr<oro::OriginsDB> db(oro::OriginsDB::make(app_conf.backend(), app_conf.db_path()));
|
||||||
|
|
||||||
duck::test(
|
duck::test(oro_api.get(), db.get(), app_conf);
|
||||||
oro_api.get(),
|
|
||||||
db.get(),
|
|
||||||
app_conf.fetch_extra_delay(),
|
|
||||||
app_conf.worker_threads(),
|
|
||||||
app_conf.store_raw_json()
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
#if defined(OROTOOL_WITH_RESTCCPP)
|
#if defined(OROTOOL_WITH_RESTCCPP)
|
||||||
catch (const restc_cpp::CommunicationException& err) {
|
catch (const restc_cpp::CommunicationException& err) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue