diff options
author | Karen Arutyunov <karen@codesynthesis.com> | 2024-05-22 19:34:06 +0300 |
---|---|---|
committer | Karen Arutyunov <karen@codesynthesis.com> | 2024-05-23 15:40:29 +0300 |
commit | 1dfc20c02d3b1076570a7146581799eab0773d6d (patch) | |
tree | 3d08ca9a4ccb69393dc365b0e96563f8d42b93be | |
parent | 3d7f248ee7aa7e5b470cb9bc2fcf76852e798db5 (diff) |
Replace ci_start::abandon() with ci_start::cancel()
-rw-r--r-- | mod/buildfile | 2 | ||||
-rw-r--r-- | mod/ci-common.cxx | 50 | ||||
-rw-r--r-- | mod/ci-common.hxx | 16 |
3 files changed, 28 insertions, 40 deletions
diff --git a/mod/buildfile b/mod/buildfile index ff04ae5..2d6ef39 100644 --- a/mod/buildfile +++ b/mod/buildfile @@ -39,7 +39,7 @@ mod{brep}: {hxx ixx txx cxx}{* -module-options -{$libu_src}} \ # the debugging of the notifications machinery. # cxx.poptions += -DBREP_CI_TENANT_SERVICE -cxx.poptions += -DBREP_CI_TENANT_SERVICE_UNLOADED +#cxx.poptions += -DBREP_CI_TENANT_SERVICE_UNLOADED libus{mod}: ../web/xhtml/libus{xhtml} libue{mod}: ../web/xhtml/libue{xhtml} diff --git a/mod/ci-common.cxx b/mod/ci-common.cxx index 6ce47f2..7c41a7b 100644 --- a/mod/ci-common.cxx +++ b/mod/ci-common.cxx @@ -685,12 +685,13 @@ namespace brep return r; } - void ci_start:: - abandon (const basic_mark& error, - const basic_mark&, - const basic_mark* trace, - odb::core::database& db, - tenant_service&& service) const + optional<tenant_service> ci_start:: + cancel (const basic_mark&, + const basic_mark&, + const basic_mark* trace, + odb::core::database& db, + const string& type, + const string& id) const { using namespace odb::core; @@ -701,37 +702,22 @@ namespace brep using query = query<build_tenant>; shared_ptr<build_tenant> t ( - db.query_one<build_tenant> (query::service.id == service.id && - query::service.type == service.type)); - + db.query_one<build_tenant> (query::service.id == id && + query::service.type == type)); if (t == nullptr) - { - error << "unable to find tenant for service " << service.id << ' ' - << service.type; - - return; - } - else if (!t->unloaded_timestamp) - { - error << "tenant " << t->id << " for service " << service.id << ' ' - << service.type << " is already loaded"; + return nullopt; - return; - } - - // We could probably remove the tenant from the database, but let's just - // archive it and keep for troubleshooting. - // - if (!t->archived) - { - t->archived = true; - db.update (t); - } + optional<tenant_service> r (move (t->service)); + t->service = nullopt; + t->archived = true; + db.update (t); tr.commit (); if (trace != nullptr) - *trace << "unloaded CI request " << t->id << " for service " - << service.id << ' ' << service.type << " is abandoned"; + *trace << "CI request " << t->id << " for service " << id << ' ' << type + << " is canceled"; + + return r; } } diff --git a/mod/ci-common.hxx b/mod/ci-common.hxx index f332dc2..8efeb26 100644 --- a/mod/ci-common.hxx +++ b/mod/ci-common.hxx @@ -98,16 +98,18 @@ namespace brep tenant_service&&, const repository_location& repository) const; - // Abandon previously created (as unloaded) CI request. + // Cancel previously created or started CI request. Return the service + // state or nullopt if there is no tenant for such a type/id pair. // // Note: should be called out of the database transaction. // - void - abandon (const basic_mark& error, - const basic_mark& warn, - const basic_mark* trace, - odb::core::database&, - tenant_service&&) const; + optional<tenant_service> + cancel (const basic_mark& error, + const basic_mark& warn, + const basic_mark* trace, + odb::core::database&, + const string& type, + const string& id) const; // Helpers. // |