From 451fb4ab1466a86c60b1900374b4d822d020471b Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 5 Nov 2024 09:28:01 +0200 Subject: Sketch improvements to ci_start::rebuild() --- mod/ci-common.cxx | 16 +++++++++++++++- mod/ci-common.hxx | 12 +++++++++++- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/mod/ci-common.cxx b/mod/ci-common.cxx index 5b039ef..164cace 100644 --- a/mod/ci-common.cxx +++ b/mod/ci-common.cxx @@ -819,10 +819,16 @@ namespace brep } optional ci_start:: - rebuild (odb::core::database& db, const build_id& id) const + rebuild (odb::core::database& db, + const build_id& id, + function (const tenant_service&, + build_state)> uf) const { using namespace odb::core; + //@@@ Should we not retry transactions (here and in other functions that + // update)? + // NOTE: don't forget to update build_force::handle() if changing anything // here. // @@ -850,6 +856,14 @@ namespace brep b->force = force; db.update (b); } + + if (uf != nullptr) + { + // @@ TODO: + // + // - get tenant from build object? + // - call function and update tenant if necessary. + } } t.commit (); diff --git a/mod/ci-common.hxx b/mod/ci-common.hxx index 1703ae0..e574760 100644 --- a/mod/ci-common.hxx +++ b/mod/ci-common.hxx @@ -200,10 +200,20 @@ namespace brep // possible to avoid races). Instead, it is assumed the service will // perform any equivalent actions directly based on the returned state. // + // The last argument, if not NULL, is called to update the service data + // associated with the tenant to which this build object belongs. It has + // the same semantics as the retuned function in the tenant service + // callbacks (see tenant_service_build_queued). Note that it is only + // called if the rebuild was actually schedules, that is, the current + // state is building or built. + // // Note: should be called out of the database transaction. // optional - rebuild (odb::core::database&, const build_id&) const; + rebuild (odb::core::database&, + const build_id&, + function (const tenant_service&, + build_state)> = nullptr) const; // Find the tenant given the tenant service type and id and return the // associated data or nullopt if there is no such tenant. -- cgit v1.1