aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libbrep/package.hxx6
-rw-r--r--mod/ci-common.hxx34
-rw-r--r--mod/tenant-service.hxx15
3 files changed, 54 insertions, 1 deletions
diff --git a/libbrep/package.hxx b/libbrep/package.hxx
index 45008d4..b66fade 100644
--- a/libbrep/package.hxx
+++ b/libbrep/package.hxx
@@ -265,6 +265,12 @@ namespace brep
optional<tenant_service> service; // Note: foreign-mapped in build.
+ // If the tenant is loaded, this value is absent. Otherwise it is the time
+ // of the last attempt to load the tenant (see the build_unloaded() tenant
+ // services notification for details).
+ //
+ optional<timestamp> loaded_timestamp;
+
// Note that due to the implementation complexity and performance
// considerations, the service notifications are not synchronized. This
// leads to a potential race, so that before we have sent the `queued`
diff --git a/mod/ci-common.hxx b/mod/ci-common.hxx
index 6f62c4b..047faa1 100644
--- a/mod/ci-common.hxx
+++ b/mod/ci-common.hxx
@@ -36,6 +36,7 @@ namespace brep
package_name name;
optional<brep::version> version;
};
+
// Note that the inability to generate the reference is an internal
// error. Thus, it is not optional.
//
@@ -64,6 +65,39 @@ namespace brep
const vector<pair<string, string>>& custom_request = {},
const vector<pair<string, string>>& overrides = {});
+ // Create an unloaded CI request returning start_result::reference. Such a
+ // request is not started until loaded with the load() function below. See
+ // also the build_unloaded() tenant services notification.
+ //
+ string
+ create (const basic_mark& error,
+ const basic_mark& warn,
+ const basic_mark* trace,
+ tenant_service&&,
+ const optional<string>& client_ip,
+ const optional<string>& user_agent);
+
+ // Load (and start) previously created (as unloaded) CI request.
+ //
+ // Note that tenant_service::id is used to identify the CI request tenant.
+ //
+ // @@ What if already loaded/abandoned? Can we indicate this in status?
+ //
+ optional<start_result>
+ load (const basic_mark& error,
+ const basic_mark& warn,
+ const basic_mark* trace,
+ tenant_service&&,
+ const repository_location& repository);
+
+ // Abandon previously created (as unloaded) CI request.
+ //
+ void
+ abandon (const basic_mark& error,
+ const basic_mark& warn,
+ const basic_mark* trace,
+ tenant_service&&);
+
// Helpers.
//
diff --git a/mod/tenant-service.hxx b/mod/tenant-service.hxx
index 9205f76..2ec9cf6 100644
--- a/mod/tenant-service.hxx
+++ b/mod/tenant-service.hxx
@@ -21,7 +21,8 @@ namespace brep
virtual ~tenant_service_base () = default;
};
- // Possible build notifications:
+ // Possible build notifications (see also the unloaded special notification
+ // below):
//
// queued
// building
@@ -121,6 +122,18 @@ namespace brep
const diag_epilogue& log_writer) const noexcept = 0;
};
+ // This notification is only made on unloaded CI requests created with the
+ // ci_start::create() call and until they are loaded with ci_start::load()
+ // or, alternatively, ci_start::abandon().
+ //
+ class tenant_service_build_unloaded: public virtual tenant_service_base
+ {
+ public:
+ virtual function<optional<string> (const tenant_service&)>
+ build_unloaded (const tenant_service&,
+ const diag_epilogue& log_writer) const noexcept = 0;
+ };
+
// Map of service type (tenant_service::type) to service.
//
using tenant_service_map = std::map<string, shared_ptr<tenant_service_base>>;