db/Configured: use struct ConfigData

This commit is contained in:
Max Kellermann 2018-07-17 23:06:17 +02:00
parent 4d80419982
commit 426b9672cf
3 changed files with 9 additions and 6 deletions

View File

@ -186,7 +186,7 @@ static bool
glue_db_init_and_load(const ConfigData &config) glue_db_init_and_load(const ConfigData &config)
{ {
instance->database = instance->database =
CreateConfiguredDatabase(instance->event_loop, CreateConfiguredDatabase(config, instance->event_loop,
instance->io_thread.GetEventLoop(), instance->io_thread.GetEventLoop(),
*instance); *instance);
if (instance->database == nullptr) if (instance->database == nullptr)

View File

@ -20,7 +20,7 @@
#include "config.h" #include "config.h"
#include "Configured.hxx" #include "Configured.hxx"
#include "DatabaseGlue.hxx" #include "DatabaseGlue.hxx"
#include "config/Global.hxx" #include "config/Data.hxx"
#include "config/Param.hxx" #include "config/Param.hxx"
#include "config/Block.hxx" #include "config/Block.hxx"
#include "fs/AllocatedPath.hxx" #include "fs/AllocatedPath.hxx"
@ -28,11 +28,12 @@
#include "util/RuntimeError.hxx" #include "util/RuntimeError.hxx"
Database * Database *
CreateConfiguredDatabase(EventLoop &main_event_loop, EventLoop &io_event_loop, CreateConfiguredDatabase(const ConfigData &config,
EventLoop &main_event_loop, EventLoop &io_event_loop,
DatabaseListener &listener) DatabaseListener &listener)
{ {
const auto *param = config_get_block(ConfigBlockOption::DATABASE); const auto *param = config.GetBlock(ConfigBlockOption::DATABASE);
const auto *path = config_get_param(ConfigOption::DB_FILE); const auto *path = config.GetParam(ConfigOption::DB_FILE);
if (param != nullptr && path != nullptr) if (param != nullptr && path != nullptr)
throw FormatRuntimeError("Found both 'database' (line %d) and 'db_file' (line %d) setting", throw FormatRuntimeError("Found both 'database' (line %d) and 'db_file' (line %d) setting",

View File

@ -22,6 +22,7 @@
#include "check.h" #include "check.h"
struct ConfigData;
class EventLoop; class EventLoop;
class DatabaseListener; class DatabaseListener;
class Database; class Database;
@ -34,7 +35,8 @@ class Database;
* Throws #std::runtime_error on error. * Throws #std::runtime_error on error.
*/ */
Database * Database *
CreateConfiguredDatabase(EventLoop &main_event_loop, EventLoop &io_event_loop, CreateConfiguredDatabase(const ConfigData &config,
EventLoop &main_event_loop, EventLoop &io_event_loop,
DatabaseListener &listener); DatabaseListener &listener);
#endif #endif