Move backend name to config file
Still, only one backend is available at this point.
This commit is contained in:
parent
c5e0b01b06
commit
be1a19f7c7
6 changed files with 19 additions and 2 deletions
|
@ -1,6 +1,7 @@
|
||||||
[system]
|
[system]
|
||||||
db_path=originsro.db3
|
db_path=originsro.db3
|
||||||
worker_threads=3
|
worker_threads=3
|
||||||
|
backend=sqlite
|
||||||
|
|
||||||
[rules]
|
[rules]
|
||||||
fetch_extra_delay=30
|
fetch_extra_delay=30
|
||||||
|
|
|
@ -34,6 +34,9 @@ namespace {
|
||||||
constexpr const char g_worker_threads_sect[] = "system";
|
constexpr const char g_worker_threads_sect[] = "system";
|
||||||
constexpr const char g_worker_threads[] = "worker_threads";
|
constexpr const char g_worker_threads[] = "worker_threads";
|
||||||
|
|
||||||
|
constexpr const char g_backend_sect[] = "system";
|
||||||
|
constexpr const char g_backend[] = "backend";
|
||||||
|
|
||||||
constexpr const char g_fetch_extra_delay_sect[] = "rules";
|
constexpr const char g_fetch_extra_delay_sect[] = "rules";
|
||||||
constexpr const char g_fetch_extra_delay[] = "fetch_extra_delay";
|
constexpr const char g_fetch_extra_delay[] = "fetch_extra_delay";
|
||||||
constexpr const char g_fetch_extra_delay_def[] = "30";
|
constexpr const char g_fetch_extra_delay_def[] = "30";
|
||||||
|
@ -125,4 +128,8 @@ std::size_t AppConfig::fetch_extra_delay() const {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string_view AppConfig::backend() const {
|
||||||
|
return value_ifp(m_ini, g_backend_sect, g_backend, g_def_backend_name, false);
|
||||||
|
}
|
||||||
|
|
||||||
} //namespace duck
|
} //namespace duck
|
||||||
|
|
|
@ -32,6 +32,7 @@ public:
|
||||||
std::string_view api_key() const;
|
std::string_view api_key() const;
|
||||||
std::size_t worker_threads() const;
|
std::size_t worker_threads() const;
|
||||||
std::size_t fetch_extra_delay() const;
|
std::size_t fetch_extra_delay() const;
|
||||||
|
std::string_view backend() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
kamokan::IniFile m_ini;
|
kamokan::IniFile m_ini;
|
||||||
|
|
|
@ -31,4 +31,12 @@ constexpr const unsigned short int g_version_patch = @PROJECT_VERSION_PATCH@;
|
||||||
|
|
||||||
#mesondefine OROTOOL_WITH_SQLITE
|
#mesondefine OROTOOL_WITH_SQLITE
|
||||||
|
|
||||||
|
#if defined(OROTOOL_WITH_SQLITE)
|
||||||
|
constexpr const char g_sqlite_backend_name[] = "sqlite";
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(OROTOOL_WITH_SQLITE)
|
||||||
|
inline constexpr const auto& g_def_backend_name = g_sqlite_backend_name;
|
||||||
|
#endif
|
||||||
|
|
||||||
} //namespace duck
|
} //namespace duck
|
||||||
|
|
|
@ -74,7 +74,7 @@ int main(int argc, char* argv[]) {
|
||||||
|
|
||||||
print_ping(oro_api);
|
print_ping(oro_api);
|
||||||
|
|
||||||
std::unique_ptr<oro::OriginsDB> db(oro::OriginsDB::make("sqlite", 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,
|
&oro_api,
|
||||||
|
|
|
@ -29,7 +29,7 @@ namespace oro {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
#if defined(OROTOOL_WITH_SQLITE)
|
#if defined(OROTOOL_WITH_SQLITE)
|
||||||
else if (name == "sqlite") {
|
else if (name == duck::g_sqlite_backend_name) {
|
||||||
return std::make_unique<OriginsDBSQLite>(param);
|
return std::make_unique<OriginsDBSQLite>(param);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue