aboutsummaryrefslogtreecommitdiff
path: root/mod
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2024-11-05 09:28:01 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2024-12-10 16:44:49 +0200
commitba1b6e96d3675d3dc7021213f08ed56359648ee4 (patch)
treee78fc32ac51b5cf1b75aefa90b0e4da3d79395c0 /mod
parent33ee65453e6a5c6bbb1d5c10f78b3c3b2e4bca40 (diff)
Update tenant service data in ci_start::rebuild()
Diffstat (limited to 'mod')
-rw-r--r--mod/ci-common.cxx23
-rw-r--r--mod/ci-common.hxx12
2 files changed, 33 insertions, 2 deletions
diff --git a/mod/ci-common.cxx b/mod/ci-common.cxx
index 5b039ef..c7dfdb9 100644
--- a/mod/ci-common.cxx
+++ b/mod/ci-common.cxx
@@ -819,10 +819,16 @@ namespace brep
}
optional<build_state> ci_start::
- rebuild (odb::core::database& db, const build_id& id) const
+ rebuild (odb::core::database& db,
+ const build_id& id,
+ function<optional<string> (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,21 @@ namespace brep
b->force = force;
db.update (b);
}
+
+ if (uf != nullptr)
+ {
+ shared_ptr<build_tenant> t (db.load<build_tenant> (b->tenant));
+
+ assert (t->service);
+
+ tenant_service& ts (*t->service);
+
+ if (optional<string> data = uf (ts, s))
+ {
+ ts.data = move (*data);
+ db.update (t);
+ }
+ }
}
t.commit ();
diff --git a/mod/ci-common.hxx b/mod/ci-common.hxx
index 1703ae0..b9cf14a 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 returned function in the tenant service
+ // callbacks (see tenant_service_build_queued). Note that it is only
+ // called if the rebuild was actually scheduled, that is, the current
+ // state is building or built.
+ //
// Note: should be called out of the database transaction.
//
optional<build_state>
- rebuild (odb::core::database&, const build_id&) const;
+ rebuild (odb::core::database&,
+ const build_id&,
+ function<optional<string> (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.