diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2025-01-22 10:32:10 +0200 |
---|---|---|
committer | Karen Arutyunov <karen@codesynthesis.com> | 2025-01-22 12:01:15 +0200 |
commit | f2cc61de479448a227136ee278941413560ecffc (patch) | |
tree | 8d9ae58c8cb6cc314888e636ea8b0efd0dad642f /mod/mod-build-result.cxx | |
parent | b0515694b711c1ff57c2fc636e066d8639fd6da6 (diff) |
Add support for tenant_service_build_built::build_completed() notification
Diffstat (limited to 'mod/mod-build-result.cxx')
-rw-r--r-- | mod/mod-build-result.cxx | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/mod/mod-build-result.cxx b/mod/mod-build-result.cxx index cc058b5..b303386 100644 --- a/mod/mod-build-result.cxx +++ b/mod/mod-build-result.cxx @@ -565,7 +565,7 @@ handle (request& rq, response&) { assert (tss); // Wouldn't be here otherwise. - const tenant_service& ss (tss->first); + tenant_service& ss (tss->first); const build& b (*tss->second); // Release the database connection since build_built() notification can @@ -576,7 +576,33 @@ handle (request& rq, response&) if (auto f = tsb->build_built (b.tenant, ss, b, log_writer_)) { conn = build_db_->connection (); - update_tenant_service_state (conn, ss.type, ss.id, f); + + bool build_completed (false); + + if (optional<string> data = + update_tenant_service_state ( + conn, ss.type, ss.id, + [&f, &build_completed] (const string& tid, + const tenant_service& ts) + { + auto r (f (tid, ts)); + build_completed = r.second; + return move (r.first); + })) + { + ss.data = move (data); + } + + if (build_completed) + { + // Release the database connection since the build_completed() + // notification can potentially be time-consuming (e.g., it may + // perform an HTTP request). + // + conn.reset (); + + tsb->build_completed (b.tenant, ss, log_writer_); + } } } |