diff options
Diffstat (limited to 'libbrep')
-rw-r--r-- | libbrep/build-extra.sql | 3 | ||||
-rw-r--r-- | libbrep/build-package.hxx | 17 | ||||
-rw-r--r-- | libbrep/build.hxx | 2 | ||||
-rw-r--r-- | libbrep/build.xml | 2 | ||||
-rw-r--r-- | libbrep/common.hxx | 14 | ||||
-rwxr-xr-x | libbrep/odb.sh | 9 | ||||
-rw-r--r-- | libbrep/package.hxx | 44 | ||||
-rw-r--r-- | libbrep/package.xml | 10 | ||||
-rw-r--r-- | libbrep/version.hxx.in | 4 |
9 files changed, 87 insertions, 18 deletions
diff --git a/libbrep/build-extra.sql b/libbrep/build-extra.sql index 9e51a51..0c0f010 100644 --- a/libbrep/build-extra.sql +++ b/libbrep/build-extra.sql @@ -46,10 +46,13 @@ CREATE FOREIGN TABLE build_tenant ( id TEXT NOT NULL, private BOOLEAN NOT NULL, interactive TEXT NULL, + creation_timestamp BIGINT NOT NULL, archived BOOLEAN NOT NULL, service_id TEXT NULL, service_type TEXT NULL, service_data TEXT 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 9a9c277..13645eb 100644 --- a/libbrep/build-package.hxx +++ b/libbrep/build-package.hxx @@ -32,12 +32,25 @@ namespace brep class build_tenant { public: + // Create tenant for an unloaded CI request (see the build_unloaded() + // tenant services notification for details). + // + build_tenant (string i, tenant_service s, timestamp t, duration n) + : id (move (i)), + creation_timestamp (timestamp::clock::now ()), + service (move (s)), + unloaded_timestamp (t), + unloaded_notify_interval (n) {} + string id; - bool private_; + bool private_ = false; optional<string> interactive; - bool archived; + timestamp creation_timestamp; + bool archived = false; optional<tenant_service> service; + optional<timestamp> unloaded_timestamp; + optional<duration> unloaded_notify_interval; optional<timestamp> queued_timestamp; optional<build_toolchain> toolchain; diff --git a/libbrep/build.hxx b/libbrep/build.hxx index af49c03..55fd42b 100644 --- a/libbrep/build.hxx +++ b/libbrep/build.hxx @@ -28,7 +28,7 @@ // #define LIBBREP_BUILD_SCHEMA_VERSION_BASE 20 -#pragma db model version(LIBBREP_BUILD_SCHEMA_VERSION_BASE, 27, closed) +#pragma db model version(LIBBREP_BUILD_SCHEMA_VERSION_BASE, 28, closed) // We have to keep these mappings at the global scope instead of inside the // brep namespace because they need to be also effective in the bbot namespace diff --git a/libbrep/build.xml b/libbrep/build.xml index 1eba85a..90b4b4f 100644 --- a/libbrep/build.xml +++ b/libbrep/build.xml @@ -1,4 +1,6 @@ <changelog xmlns="http://www.codesynthesis.com/xmlns/odb/changelog" database="pgsql" schema-name="build" version="1"> + <changeset version="28"/> + <changeset version="27"/> <changeset version="26"/> 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/odb.sh b/libbrep/odb.sh index 608ca41..7c62acb 100755 --- a/libbrep/odb.sh +++ b/libbrep/odb.sh @@ -16,6 +16,8 @@ if test -d ../.bdep; then sed -r -ne 's#^(@[^ ]+ )?([^ ]+)/ .*default.*$#\2#p')" fi + # Note: here we use libodb*, not libbutl-odb. + # inc+=("-I$(echo "$cfg"/libodb-[1-9]*/)") inc+=("-I$(echo "$cfg"/libodb-pgsql-[1-9]*/)") @@ -33,11 +35,8 @@ sed -r -ne 's#^(@[^ ]+ )?([^ ]+)/ .*default.*$#\2#p')" else - inc+=("-I$HOME/work/odb/builds/default/libodb-pgsql-default") - inc+=("-I$HOME/work/odb/libodb-pgsql") - - inc+=("-I$HOME/work/odb/builds/default/libodb-default") - inc+=("-I$HOME/work/odb/libodb") + inc+=("-I$HOME/work/odb/odb/libodb-pgsql") + inc+=("-I$HOME/work/odb/odb/libodb") inc+=(-I.. -I../../libbbot -I../../libbpkg -I../../libbutl) diff --git a/libbrep/package.hxx b/libbrep/package.hxx index 45008d4..76c5836 100644 --- a/libbrep/package.hxx +++ b/libbrep/package.hxx @@ -20,7 +20,7 @@ // #define LIBBREP_PACKAGE_SCHEMA_VERSION_BASE 27 -#pragma db model version(LIBBREP_PACKAGE_SCHEMA_VERSION_BASE, 33, closed) +#pragma db model version(LIBBREP_PACKAGE_SCHEMA_VERSION_BASE, 34, closed) namespace brep { @@ -133,7 +133,7 @@ namespace brep optional<version_constraint> constraint; // Resolved dependency package. Can be NULL if the repository load was - // shallow and the package dependency could not be resolved. + // shallow or the package dependency could not be resolved. // lazy_shared_ptr<package_type> package; @@ -251,19 +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; - 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> 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 @@ -284,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 @@ -318,6 +328,10 @@ namespace brep #pragma db index member(service.id) + // Speed-up queries with ordering the result by unloaded_timestamp. + // + #pragma db member(unloaded_timestamp) index + private: friend class odb::access; tenant () = default; @@ -427,6 +441,20 @@ namespace brep repository (): tenant (id.tenant), canonical_name (id.canonical_name) {} }; + // Repositories count. + // + #pragma db view object(repository) + struct repository_count + { + size_t result; + + operator size_t () const {return result;} + + // Database mapping. + // + #pragma db member(result) column("count(" + repository::id.tenant + ")") + }; + // The 'to' expression calls the PostgreSQL to_tsvector(weighted_text) // function overload (package-extra.sql). Since we are only interested // in "write-only" members of this type, make the 'from' expression diff --git a/libbrep/package.xml b/libbrep/package.xml index 96e93a7..f33119e 100644 --- a/libbrep/package.xml +++ b/libbrep/package.xml @@ -1,4 +1,14 @@ <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="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> + <changeset version="33"> <add-table name="public_key" kind="object"> <column name="tenant" type="TEXT" null="false"/> diff --git a/libbrep/version.hxx.in b/libbrep/version.hxx.in index 3ac3752..9adb5ab 100644 --- a/libbrep/version.hxx.in +++ b/libbrep/version.hxx.in @@ -49,11 +49,11 @@ $libbbot.check(LIBBBOT_VERSION, LIBBBOT_SNAPSHOT)$ #include <odb/version.hxx> -$libodb.check(LIBODB_VERSION, LIBODB_SNAPSHOT)$ +$libodb.check(LIBODB_VERSION_FULL, LIBODB_SNAPSHOT)$ #include <odb/pgsql/version.hxx> -$libodb_pgsql.check(LIBODB_PGSQL_VERSION, LIBODB_PGSQL_SNAPSHOT)$ +$libodb_pgsql.check(LIBODB_PGSQL_VERSION_FULL, LIBODB_PGSQL_SNAPSHOT)$ // For now these are the same. // |