From dbbc19b77dcf6ea828aabd64d7aa8cab9635aaf5 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Tue, 4 Apr 2017 20:53:00 +0300 Subject: Implement build task, result and log requests handling --- mod/database-module.cxx | 52 +++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 48 insertions(+), 4 deletions(-) (limited to 'mod/database-module.cxx') diff --git a/mod/database-module.cxx b/mod/database-module.cxx index 6fd5025..e7a6883 100644 --- a/mod/database-module.cxx +++ b/mod/database-module.cxx @@ -4,13 +4,23 @@ #include +#include // EIO + +#include + #include +#include // throw_generic_error() + #include #include +#include namespace brep { + using namespace std; + using namespace butl; + // While currently the user-defined copy constructor is not required (we // don't need to deep copy nullptr's), it is a good idea to keep the // placeholder ready for less trivial cases. @@ -19,15 +29,49 @@ namespace brep database_module (const database_module& r) : module (r), retry_ (r.retry_), - db_ (r.initialized_ ? r.db_ : nullptr) + package_db_ (r.initialized_ ? r.package_db_ : nullptr), + build_db_ (r.initialized_ ? r.build_db_ : nullptr), + build_conf_ (r.initialized_ ? r.build_conf_ : nullptr) + { + } + + void database_module:: + init (const options::package_db& o, size_t retry) { + package_db_ = shared_database (o.package_db_user (), + o.package_db_password (), + o.package_db_name (), + o.package_db_host (), + o.package_db_port (), + o.package_db_max_connections ()); + + retry_ = retry_ < retry ? retry : retry_; } void database_module:: - init (const options::db& o) + init (const options::build& bo, const options::build_db& dbo, size_t retry) { - retry_ = o.db_retry (); - db_ = shared_database (o); + try + { + build_conf_ = shared_build_config (bo.build_config ()); + } + catch (const io_error& e) + { + ostringstream os; + os << "unable to read build configuration '" << bo.build_config () + << "': " << e; + + throw_generic_error (EIO, os.str ().c_str ()); + } + + build_db_ = shared_database (dbo.build_db_user (), + dbo.build_db_password (), + dbo.build_db_name (), + dbo.build_db_host (), + dbo.build_db_port (), + dbo.build_db_max_connections ()); + + retry_ = retry_ < retry ? retry : retry_; } bool database_module:: -- cgit v1.1