aboutsummaryrefslogtreecommitdiff
path: root/libbrep
diff options
context:
space:
mode:
Diffstat (limited to 'libbrep')
-rw-r--r--libbrep/build-extra.sql3
-rw-r--r--libbrep/build-package.hxx8
-rw-r--r--libbrep/common.hxx14
-rw-r--r--libbrep/package.hxx22
-rw-r--r--libbrep/package.xml7
5 files changed, 38 insertions, 16 deletions
diff --git a/libbrep/build-extra.sql b/libbrep/build-extra.sql
index c31cc31..0c0f010 100644
--- a/libbrep/build-extra.sql
+++ b/libbrep/build-extra.sql
@@ -51,7 +51,8 @@ CREATE FOREIGN TABLE build_tenant (
service_id TEXT NULL,
service_type TEXT NULL,
service_data TEXT NULL,
- loaded_timestamp BIGINT NULL,
+ unloaded_timestamp BIGINT NULL,
+ unloaded_notify_interval BIGINT NULL,
queued_timestamp BIGINT NULL,
toolchain_name TEXT OPTIONS (column_name 'build_toolchain_name') NULL,
toolchain_version_epoch INTEGER OPTIONS (column_name 'build_toolchain_version_epoch') NULL,
diff --git a/libbrep/build-package.hxx b/libbrep/build-package.hxx
index 2611678..13645eb 100644
--- a/libbrep/build-package.hxx
+++ b/libbrep/build-package.hxx
@@ -35,11 +35,12 @@ namespace brep
// Create tenant for an unloaded CI request (see the build_unloaded()
// tenant services notification for details).
//
- build_tenant (string i, tenant_service s, timestamp l)
+ build_tenant (string i, tenant_service s, timestamp t, duration n)
: id (move (i)),
creation_timestamp (timestamp::clock::now ()),
service (move (s)),
- loaded_timestamp (l) {}
+ unloaded_timestamp (t),
+ unloaded_notify_interval (n) {}
string id;
@@ -48,7 +49,8 @@ namespace brep
timestamp creation_timestamp;
bool archived = false;
optional<tenant_service> service;
- optional<timestamp> loaded_timestamp;
+ optional<timestamp> unloaded_timestamp;
+ optional<duration> unloaded_notify_interval;
optional<timestamp> queued_timestamp;
optional<build_toolchain> toolchain;
diff --git a/libbrep/common.hxx b/libbrep/common.hxx
index 1433c8c..4be9ce9 100644
--- a/libbrep/common.hxx
+++ b/libbrep/common.hxx
@@ -141,6 +141,20 @@ namespace brep
std::chrono::nanoseconds (*(?)))) \
: brep::optional_timestamp ())
+ #pragma db map type(duration) as(uint64_t) \
+ to(std::chrono::duration_cast<std::chrono::nanoseconds> (?).count ()) \
+ from(brep::duration (std::chrono::nanoseconds (?)))
+
+ using optional_duration = optional<duration>;
+
+ #pragma db map type(optional_duration) as(brep::optional_uint64) \
+ to((?) \
+ ? std::chrono::duration_cast<std::chrono::nanoseconds> (*(?)).count () \
+ : brep::optional_uint64 ()) \
+ from((?) \
+ ? brep::duration (std::chrono::nanoseconds (*(?))) \
+ : brep::optional_duration ())
+
// version
//
using bpkg::version;
diff --git a/libbrep/package.hxx b/libbrep/package.hxx
index affa2ac..61477a0 100644
--- a/libbrep/package.hxx
+++ b/libbrep/package.hxx
@@ -251,25 +251,29 @@ namespace brep
// If this flag is true, then display the packages in the web interface
// only in the tenant view mode.
//
- bool private_; // Note: foreign-mapped in build.
+ bool private_; // Note: foreign-mapped in build.
// Interactive package build breakpoint.
//
// If present, then packages from this tenant will only be built
// interactively and only non-interactively otherwise.
//
- optional<string> interactive; // Note: foreign-mapped in build.
+ optional<string> interactive; // Note: foreign-mapped in build.
- timestamp creation_timestamp; // Note: foreign-mapped in build.
- bool archived = false; // Note: foreign-mapped in build.
+ timestamp creation_timestamp; // Note: foreign-mapped in build.
+ bool archived = false; // Note: foreign-mapped in build.
- optional<tenant_service> service; // Note: foreign-mapped in build.
+ 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: foreign-mapped in build.
+ optional<timestamp> unloaded_timestamp; // Note: foreign-mapped in build.
+
+ // The time interval between attempts to load the tenant, if unloaded.
+ //
+ optional<duration> unloaded_notify_interval; // Note: foreign-mapped in build.
// Note that due to the implementation complexity and performance
// considerations, the service notifications are not synchronized. This
@@ -290,7 +294,7 @@ namespace brep
// natural reasons (non-zero build task execution time, etc) and thus we
// just ignore them.
//
- optional<timestamp> queued_timestamp; // Note: foreign-mapped in build.
+ optional<timestamp> queued_timestamp; // Note: foreign-mapped in build.
// Note that after the package tenant is created but before the first
// build object is created, there is no easy way to produce a list of
@@ -324,9 +328,9 @@ namespace brep
#pragma db index member(service.id)
- // Speed-up queries with ordering the result by loaded_timestamp.
+ // Speed-up queries with ordering the result by unloaded_timestamp.
//
- #pragma db member(loaded_timestamp) index
+ #pragma db member(unloaded_timestamp) index
private:
friend class odb::access;
diff --git a/libbrep/package.xml b/libbrep/package.xml
index fe010ad..f33119e 100644
--- a/libbrep/package.xml
+++ b/libbrep/package.xml
@@ -1,9 +1,10 @@
<changelog xmlns="http://www.codesynthesis.com/xmlns/odb/changelog" database="pgsql" schema-name="package" version="1">
<changeset version="34">
<alter-table name="tenant">
- <add-column name="loaded_timestamp" type="BIGINT" null="true"/>
- <add-index name="tenant_loaded_timestamp_i">
- <column name="loaded_timestamp"/>
+ <add-column name="unloaded_timestamp" type="BIGINT" null="true"/>
+ <add-column name="unloaded_notify_interval" type="BIGINT" null="true"/>
+ <add-index name="tenant_unloaded_timestamp_i">
+ <column name="unloaded_timestamp"/>
</add-index>
</alter-table>
</changeset>