From 3d7f248ee7aa7e5b470cb9bc2fcf76852e798db5 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Wed, 22 May 2024 19:12:55 +0300 Subject: Make poll interval for unloaded tenant configurable and rename loaded_timestamp tenant member to unloaded_timestamp --- libbrep/build-extra.sql | 3 ++- libbrep/build-package.hxx | 8 +++++--- libbrep/common.hxx | 14 ++++++++++++++ libbrep/package.hxx | 22 +++++++++++++--------- libbrep/package.xml | 7 ++++--- 5 files changed, 38 insertions(+), 16 deletions(-) (limited to 'libbrep') 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 service; - optional loaded_timestamp; + optional unloaded_timestamp; + optional unloaded_notify_interval; optional queued_timestamp; optional 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 (?).count ()) \ + from(brep::duration (std::chrono::nanoseconds (?))) + + using optional_duration = optional; + + #pragma db map type(optional_duration) as(brep::optional_uint64) \ + to((?) \ + ? std::chrono::duration_cast (*(?)).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 interactive; // Note: foreign-mapped in build. + optional 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 service; // Note: foreign-mapped in build. + optional 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 loaded_timestamp; // Note: foreign-mapped in build. + optional unloaded_timestamp; // Note: foreign-mapped in build. + + // The time interval between attempts to load the tenant, if unloaded. + // + optional 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 queued_timestamp; // Note: foreign-mapped in build. + optional 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 @@ - - - + + + + -- cgit v1.1