aboutsummaryrefslogtreecommitdiff
path: root/guix-data-service/web/revision
diff options
context:
space:
mode:
authorChristopher Baines <mail@cbaines.net>2023-07-09 16:52:35 +0100
committerChristopher Baines <mail@cbaines.net>2023-07-10 18:56:31 +0100
commit7251c7d653de29f36d50b33badf05a5db983b8e7 (patch)
tree3f74252cf1f0d13d35dc1253406d9a3b92b67f7e /guix-data-service/web/revision
parent672ee6216e1d15f7f550f53017323b59f05303cb (diff)
downloaddata-service-7251c7d653de29f36d50b33badf05a5db983b8e7.tar
data-service-7251c7d653de29f36d50b33badf05a5db983b8e7.tar.gz
Stop using a pool of threads for database operations
Now that squee cooperates with suspendable ports, this is unnecessary. Use a connection pool to still support running queries in parallel using multiple connections.
Diffstat (limited to 'guix-data-service/web/revision')
-rw-r--r--guix-data-service/web/revision/controller.scm694
1 files changed, 320 insertions, 374 deletions
diff --git a/guix-data-service/web/revision/controller.scm b/guix-data-service/web/revision/controller.scm
index 1cb4528..9cfddd4 100644
--- a/guix-data-service/web/revision/controller.scm
+++ b/guix-data-service/web/revision/controller.scm
@@ -30,6 +30,7 @@
#:use-module (guix-data-service web sxml)
#:use-module (guix-data-service web query-parameters)
#:use-module (guix-data-service web util)
+ #:use-module (guix-data-service web controller)
#:use-module (guix-data-service model utils)
#:use-module (guix-data-service jobs load-new-guix-revision)
#:use-module (guix-data-service model build)
@@ -84,7 +85,7 @@
(define (parse-build-server v)
(letpar& ((build-servers
- (with-thread-postgresql-connection select-build-servers)))
+ (with-resource-from-pool (connection-pool) conn select-build-servers)))
(or (any (match-lambda
((id url lookup-all-derivations? lookup-builds?)
(if (eq? (string->number v)
@@ -105,20 +106,16 @@
(match method-and-path-components
(('GET "revision" commit-hash)
- (if (parallel-via-thread-pool-channel
- (with-thread-postgresql-connection
- (lambda (conn)
- (guix-revision-loaded-successfully? conn commit-hash))))
+ (if (with-resource-from-pool (connection-pool) conn
+ (guix-revision-loaded-successfully? conn commit-hash))
(render-view-revision mime-types
commit-hash
#:path-base path)
(render-unknown-revision mime-types
commit-hash)))
(('GET "revision" commit-hash "news")
- (if (parallel-via-thread-pool-channel
- (with-thread-postgresql-connection
- (lambda (conn)
- (guix-revision-loaded-successfully? conn commit-hash))))
+ (if (with-resource-from-pool (connection-pool) conn
+ (guix-revision-loaded-successfully? conn commit-hash))
(let ((parsed-query-parameters
(parse-query-parameters
request
@@ -129,10 +126,8 @@
(render-unprocessed-revision mime-types
commit-hash)))
(('GET "revision" commit-hash "packages")
- (if (parallel-via-thread-pool-channel
- (with-thread-postgresql-connection
- (lambda (conn)
- (guix-revision-loaded-successfully? conn commit-hash))))
+ (if (with-resource-from-pool (connection-pool) conn
+ (guix-revision-loaded-successfully? conn commit-hash))
(let ((parsed-query-parameters
(guard-against-mutually-exclusive-query-parameters
(parse-query-parameters
@@ -158,30 +153,24 @@
(render-unprocessed-revision mime-types
commit-hash)))
(('GET "revision" commit-hash "packages-translation-availability")
- (if (parallel-via-thread-pool-channel
- (with-thread-postgresql-connection
- (lambda (conn)
- (guix-revision-loaded-successfully? conn commit-hash))))
+ (if (with-resource-from-pool (connection-pool) conn
+ (guix-revision-loaded-successfully? conn commit-hash))
(render-revision-packages-translation-availability mime-types
commit-hash
#:path-base path)
(render-unprocessed-revision mime-types
commit-hash)))
(('GET "revision" commit-hash "package" name)
- (if (parallel-via-thread-pool-channel
- (with-thread-postgresql-connection
- (lambda (conn)
- (guix-revision-loaded-successfully? conn commit-hash))))
+ (if (with-resource-from-pool (connection-pool) conn
+ (guix-revision-loaded-successfully? conn commit-hash))
(render-revision-package mime-types
commit-hash
name)
(render-unprocessed-revision mime-types
commit-hash)))
(('GET "revision" commit-hash "package" name version)
- (if (parallel-via-thread-pool-channel
- (with-thread-postgresql-connection
- (lambda (conn)
- (guix-revision-loaded-successfully? conn commit-hash))))
+ (if (with-resource-from-pool (connection-pool) conn
+ (guix-revision-loaded-successfully? conn commit-hash))
(let ((parsed-query-parameters
(parse-query-parameters
request
@@ -194,10 +183,8 @@
(render-unprocessed-revision mime-types
commit-hash)))
(('GET "revision" commit-hash "package-derivations")
- (if (parallel-via-thread-pool-channel
- (with-thread-postgresql-connection
- (lambda (conn)
- (guix-revision-loaded-successfully? conn commit-hash))))
+ (if (with-resource-from-pool (connection-pool) conn
+ (guix-revision-loaded-successfully? conn commit-hash))
(let ((parsed-query-parameters
(guard-against-mutually-exclusive-query-parameters
(parse-query-parameters
@@ -228,10 +215,8 @@
(render-unprocessed-revision mime-types
commit-hash)))
(('GET "revision" commit-hash "fixed-output-package-derivations")
- (if (parallel-via-thread-pool-channel
- (with-thread-postgresql-connection
- (lambda (conn)
- (guix-revision-loaded-successfully? conn commit-hash))))
+ (if (with-resource-from-pool (connection-pool) conn
+ (guix-revision-loaded-successfully? conn commit-hash))
(let ((parsed-query-parameters
(guard-against-mutually-exclusive-query-parameters
(parse-query-parameters
@@ -254,10 +239,8 @@
(render-unprocessed-revision mime-types
commit-hash)))
(('GET "revision" commit-hash "package-derivation-outputs")
- (if (parallel-via-thread-pool-channel
- (with-thread-postgresql-connection
- (lambda (conn)
- (guix-revision-loaded-successfully? conn commit-hash))))
+ (if (with-resource-from-pool (connection-pool) conn
+ (guix-revision-loaded-successfully? conn commit-hash))
(let ((parsed-query-parameters
(guard-against-mutually-exclusive-query-parameters
(parse-query-parameters
@@ -287,10 +270,8 @@
(render-unprocessed-revision mime-types
commit-hash)))
(('GET "revision" commit-hash "system-tests")
- (if (parallel-via-thread-pool-channel
- (with-thread-postgresql-connection
- (lambda (conn)
- (guix-revision-loaded-successfully? conn commit-hash))))
+ (if (with-resource-from-pool (connection-pool) conn
+ (guix-revision-loaded-successfully? conn commit-hash))
(let ((parsed-query-parameters
(parse-query-parameters
request
@@ -302,40 +283,32 @@
(render-unprocessed-revision mime-types
commit-hash)))
(('GET "revision" commit-hash "channel-instances")
- (if (parallel-via-thread-pool-channel
- (with-thread-postgresql-connection
- (lambda (conn)
- (channel-instances-exist-for-guix-revision? conn commit-hash))))
+ (if (with-resource-from-pool (connection-pool) conn
+ (channel-instances-exist-for-guix-revision? conn commit-hash))
(render-revision-channel-instances mime-types
commit-hash
#:path-base path)
(render-unprocessed-revision mime-types
commit-hash)))
(('GET "revision" commit-hash "package-substitute-availability")
- (if (parallel-via-thread-pool-channel
- (with-thread-postgresql-connection
- (lambda (conn)
- (guix-revision-loaded-successfully? conn commit-hash))))
+ (if (with-resource-from-pool (connection-pool) conn
+ (guix-revision-loaded-successfully? conn commit-hash))
(render-revision-package-substitute-availability mime-types
commit-hash
#:path-base path)
(render-unprocessed-revision mime-types
commit-hash)))
(('GET "revision" commit-hash "package-reproducibility")
- (if (parallel-via-thread-pool-channel
- (with-thread-postgresql-connection
- (lambda (conn)
- (guix-revision-loaded-successfully? conn commit-hash))))
+ (if (with-resource-from-pool (connection-pool) conn
+ (guix-revision-loaded-successfully? conn commit-hash))
(render-revision-package-reproduciblity mime-types
commit-hash
#:path-base path)
(render-unprocessed-revision mime-types
commit-hash)))
(('GET "revision" commit-hash "builds")
- (if (parallel-via-thread-pool-channel
- (with-thread-postgresql-connection
- (lambda (conn)
- (guix-revision-loaded-successfully? conn commit-hash))))
+ (if (with-resource-from-pool (connection-pool) conn
+ (guix-revision-loaded-successfully? conn commit-hash))
(let ((parsed-query-parameters
(guard-against-mutually-exclusive-query-parameters
(parse-query-parameters
@@ -357,10 +330,8 @@
(render-unprocessed-revision mime-types
commit-hash)))
(('GET "revision" commit-hash "blocking-builds")
- (if (parallel-via-thread-pool-channel
- (with-thread-postgresql-connection
- (lambda (conn)
- (guix-revision-loaded-successfully? conn commit-hash))))
+ (if (with-resource-from-pool (connection-pool) conn
+ (guix-revision-loaded-successfully? conn commit-hash))
(let ((parsed-query-parameters
(guard-against-mutually-exclusive-query-parameters
(parse-query-parameters
@@ -381,10 +352,8 @@
(render-unprocessed-revision mime-types
commit-hash)))
(('GET "revision" commit-hash "lint-warnings")
- (if (parallel-via-thread-pool-channel
- (with-thread-postgresql-connection
- (lambda (conn)
- (guix-revision-loaded-successfully? conn commit-hash))))
+ (if (with-resource-from-pool (connection-pool) conn
+ (guix-revision-loaded-successfully? conn commit-hash))
(let ((parsed-query-parameters
(parse-query-parameters
request
@@ -424,18 +393,15 @@
#:code 404))
(else
(letpar& ((job
- (with-thread-postgresql-connection
- (lambda (conn)
- (select-job-for-commit conn commit-hash))))
+ (with-resource-from-pool (connection-pool) conn
+ (select-job-for-commit conn commit-hash)))
(git-repositories-and-branches
- (with-thread-postgresql-connection
- (lambda (conn)
- (git-branches-with-repository-details-for-commit conn
- commit-hash))))
+ (with-resource-from-pool (connection-pool) conn
+ (git-branches-with-repository-details-for-commit conn
+ commit-hash)))
(jobs-and-events
- (with-thread-postgresql-connection
- (lambda (conn)
- (select-jobs-and-events-for-commit conn commit-hash)))))
+ (with-resource-from-pool (connection-pool) conn
+ (select-jobs-and-events-for-commit conn commit-hash))))
(render-html
#:code 404
@@ -455,18 +421,15 @@
#:code 404))
(else
(letpar& ((job
- (with-thread-postgresql-connection
- (lambda (conn)
- (select-job-for-commit conn commit-hash))))
+ (with-resource-from-pool (connection-pool) conn
+ (select-job-for-commit conn commit-hash)))
(git-repositories-and-branches
- (with-thread-postgresql-connection
- (lambda (conn)
- (git-branches-with-repository-details-for-commit conn
- commit-hash))))
+ (with-resource-from-pool (connection-pool) conn
+ (git-branches-with-repository-details-for-commit conn
+ commit-hash)))
(jobs-and-events
- (with-thread-postgresql-connection
- (lambda (conn)
- (select-jobs-and-events-for-commit conn commit-hash)))))
+ (with-resource-from-pool (connection-pool) conn
+ (select-jobs-and-events-for-commit conn commit-hash))))
(render-html
#:code 404
@@ -482,27 +445,22 @@
(header-text
`("Revision " (samp ,commit-hash))))
(letpar& ((packages-count
- (with-thread-postgresql-connection
- (lambda (conn)
- (count-packages-in-revision conn commit-hash))))
+ (with-resource-from-pool (connection-pool) conn
+ (count-packages-in-revision conn commit-hash)))
(git-repositories-and-branches
- (with-thread-postgresql-connection
- (lambda (conn)
- (git-branches-with-repository-details-for-commit conn
- commit-hash))))
+ (with-resource-from-pool (connection-pool) conn
+ (git-branches-with-repository-details-for-commit conn
+ commit-hash)))
(derivations-counts
- (with-thread-postgresql-connection
- (lambda (conn)
- (count-packages-derivations-in-revision conn commit-hash))))
+ (with-resource-from-pool (connection-pool) conn
+ (count-packages-derivations-in-revision conn commit-hash)))
(jobs-and-events
- (with-thread-postgresql-connection
- (lambda (conn)
- (select-jobs-and-events-for-commit conn commit-hash))))
+ (with-resource-from-pool (connection-pool) conn
+ (select-jobs-and-events-for-commit conn commit-hash)))
(lint-warning-counts
- (with-thread-postgresql-connection
- (lambda (conn)
- (lint-warning-count-by-lint-checker-for-revision conn
- commit-hash)))))
+ (with-resource-from-pool (connection-pool) conn
+ (lint-warning-count-by-lint-checker-for-revision conn
+ commit-hash))))
(case (most-appropriate-mime-type
'(application/json text/html)
mime-types)
@@ -547,12 +505,11 @@
(header-link
(string-append "/revision/" commit-hash)))
(letpar& ((system-tests
- (with-thread-postgresql-connection
- (lambda (conn)
- (select-system-tests-for-guix-revision
- conn
- (assq-ref query-parameters 'system)
- commit-hash)))))
+ (with-resource-from-pool (connection-pool) conn
+ (select-system-tests-for-guix-revision
+ conn
+ (assq-ref query-parameters 'system)
+ commit-hash))))
(case (most-appropriate-mime-type
'(application/json text/html)
mime-types)
@@ -576,12 +533,11 @@
system-tests))))))
(else
(letpar& ((git-repositories
- (with-thread-postgresql-connection
- (lambda (conn)
- (git-repositories-containing-commit conn
- commit-hash))))
+ (with-resource-from-pool (connection-pool) conn
+ (git-repositories-containing-commit conn
+ commit-hash)))
(systems
- (with-thread-postgresql-connection list-systems)))
+ (with-resource-from-pool (connection-pool) conn list-systems)))
(render-html
#:sxml (view-revision-system-tests
commit-hash
@@ -603,9 +559,8 @@
(string-append "/revision/"
commit-hash)))
(letpar& ((channel-instances
- (with-thread-postgresql-connection
- (lambda (conn)
- (select-channel-instances-for-guix-revision conn commit-hash)))))
+ (with-resource-from-pool (connection-pool) conn
+ (select-channel-instances-for-guix-revision conn commit-hash))))
(case (most-appropriate-mime-type
'(application/json text/html)
mime-types)
@@ -632,12 +587,12 @@
commit-hash
#:key path-base)
(letpar& ((substitute-availability
- (with-thread-postgresql-connection
- (lambda (conn)
- (select-package-output-availability-for-revision conn
- commit-hash))))
+ (with-resource-from-pool (connection-pool) conn
+ (select-package-output-availability-for-revision conn
+ commit-hash)))
(build-server-urls
- (with-thread-postgresql-connection
+ (call-with-resource-from-pool
+ (connection-pool)
select-build-server-urls-by-id)))
(case (most-appropriate-mime-type
'(application/json text/html)
@@ -678,9 +633,8 @@
(string-append "/revision/"
commit-hash)))
(letpar& ((output-consistency
- (with-thread-postgresql-connection
- (lambda (conn)
- (select-output-consistency-for-revision conn commit-hash)))))
+ (with-resource-from-pool (connection-pool) conn
+ (select-output-consistency-for-revision conn commit-hash))))
(case (most-appropriate-mime-type
'(application/json text/html)
mime-types)
@@ -713,11 +667,10 @@
query-parameters
'()))))
(letpar& ((news-entries
- (with-thread-postgresql-connection
- (lambda (conn)
- (select-channel-news-entries-contained-in-guix-revision
- conn
- commit-hash)))))
+ (with-resource-from-pool (connection-pool) conn
+ (select-channel-news-entries-contained-in-guix-revision
+ conn
+ commit-hash))))
(case (most-appropriate-mime-type
'(application/json text/html)
mime-types)
@@ -774,26 +727,24 @@
(locale (assq-ref query-parameters 'locale)))
(letpar&
((packages
- (with-thread-postgresql-connection
- (lambda (conn)
- (if search-query
- (search-packages-in-revision
- conn
- commit-hash
- search-query
- #:limit-results limit-results
- #:locale locale)
- (select-packages-in-revision
- conn
- commit-hash
- #:limit-results limit-results
- #:after-name (assq-ref query-parameters 'after_name)
- #:locale (assq-ref query-parameters 'locale))))))
+ (with-resource-from-pool (connection-pool) conn
+ (if search-query
+ (search-packages-in-revision
+ conn
+ commit-hash
+ search-query
+ #:limit-results limit-results
+ #:locale locale)
+ (select-packages-in-revision
+ conn
+ commit-hash
+ #:limit-results limit-results
+ #:after-name (assq-ref query-parameters 'after_name)
+ #:locale (assq-ref query-parameters 'locale)))))
(git-repositories
- (with-thread-postgresql-connection
- (lambda (conn)
- (git-repositories-containing-commit conn
- commit-hash)))))
+ (with-resource-from-pool (connection-pool) conn
+ (git-repositories-containing-commit conn
+ commit-hash))))
(let ((show-next-page?
(and (not search-query)
(>= (length packages)
@@ -843,14 +794,12 @@
packages))))
#:extra-headers http-headers-for-unchanging-content))
(else
- (letpar&
- ((locale-options
- (with-thread-postgresql-connection
- (lambda (conn)
+ (let ((locale-options
+ (with-resource-from-pool (connection-pool) conn
(description-and-synopsis-locale-options
(package-description-and-synopsis-locale-options-guix-revision
conn
- (commit->revision-id conn commit-hash)))))))
+ (commit->revision-id conn commit-hash))))))
(render-html
#:sxml (view-revision-packages commit-hash
query-parameters
@@ -874,19 +823,17 @@
(header-text
`("Revision " (samp ,commit-hash))))
(letpar& ((package-synopsis-counts
- (with-thread-postgresql-connection
- (lambda (conn)
- (synopsis-counts-by-locale conn
- (commit->revision-id
- conn
- commit-hash)))))
+ (with-resource-from-pool (connection-pool) conn
+ (synopsis-counts-by-locale conn
+ (commit->revision-id
+ conn
+ commit-hash))))
(package-description-counts
- (with-thread-postgresql-connection
- (lambda (conn)
- (description-counts-by-locale conn
- (commit->revision-id
- conn
- commit-hash))))))
+ (with-resource-from-pool (connection-pool) conn
+ (description-counts-by-locale conn
+ (commit->revision-id
+ conn
+ commit-hash)))))
(case (most-appropriate-mime-type
'(application/json text/html)
mime-types)
@@ -916,16 +863,14 @@
(string-append
"/revision/" commit-hash)))
(letpar& ((package-versions
- (with-thread-postgresql-connection
- (lambda (conn)
- (select-package-versions-for-revision conn
- commit-hash
- name))))
+ (with-resource-from-pool (connection-pool) conn
+ (select-package-versions-for-revision conn
+ commit-hash
+ name)))
(git-repositories-and-branches
- (with-thread-postgresql-connection
- (lambda (conn)
- (git-branches-with-repository-details-for-commit conn
- commit-hash)))))
+ (with-resource-from-pool (connection-pool) conn
+ (git-branches-with-repository-details-for-commit conn
+ commit-hash))))
(case (most-appropriate-mime-type
'(application/json text/html)
mime-types)
@@ -963,48 +908,42 @@
(match-lambda
((locale)
locale))
- (parallel-via-thread-pool-channel
- (with-thread-postgresql-connection
- (lambda (conn)
- (delete-duplicates
- (append
- (package-description-and-synopsis-locale-options-guix-revision
- conn (commit->revision-id conn commit-hash))
- (lint-warning-message-locales-for-revision conn commit-hash))))))))
+ (with-resource-from-pool (connection-pool) conn
+ (delete-duplicates
+ (append
+ (package-description-and-synopsis-locale-options-guix-revision
+ conn (commit->revision-id conn commit-hash))
+ (lint-warning-message-locales-for-revision conn commit-hash))))))
(define locale (assq-ref query-parameters 'locale))
(letpar& ((metadata
- (with-thread-postgresql-connection
- (lambda (conn)
- (select-package-metadata-by-revision-name-and-version
- conn
- commit-hash
- name
- version
- locale))))
+ (with-resource-from-pool (connection-pool) conn
+ (select-package-metadata-by-revision-name-and-version
+ conn
+ commit-hash
+ name
+ version
+ locale)))
(derivations
- (with-thread-postgresql-connection
- (lambda (conn)
- (select-derivations-by-revision-name-and-version
- conn
- commit-hash
- name
- version))))
+ (with-resource-from-pool (connection-pool) conn
+ (select-derivations-by-revision-name-and-version
+ conn
+ commit-hash
+ name
+ version)))
(git-repositories
- (with-thread-postgresql-connection
- (lambda (conn)
- (git-repositories-containing-commit conn
- commit-hash))))
+ (with-resource-from-pool (connection-pool) conn
+ (git-repositories-containing-commit conn
+ commit-hash)))
(lint-warnings
- (with-thread-postgresql-connection
- (lambda (conn)
- (select-lint-warnings-by-revision-package-name-and-version
- conn
- commit-hash
- name
- version
- #:locale locale)))))
+ (with-resource-from-pool (connection-pool) conn
+ (select-lint-warnings-by-revision-package-name-and-version
+ conn
+ commit-hash
+ name
+ version
+ #:locale locale))))
(case (most-appropriate-mime-type
'(application/json text/html)
mime-types)
@@ -1062,9 +1001,11 @@
`((error . "invalid query"))))
(else
(letpar& ((systems
- (with-thread-postgresql-connection list-systems))
+ (call-with-resource-from-pool (connection-pool)
+ list-systems))
(targets
- (with-thread-postgresql-connection valid-targets)))
+ (call-with-resource-from-pool (connection-pool)
+ valid-targets)))
(render-html
#:sxml (view-revision-package-derivations commit-hash
query-parameters
@@ -1087,46 +1028,45 @@
(assq-ref query-parameters 'field)))
(letpar&
((derivations
- (with-thread-postgresql-connection
- (lambda (conn)
- (if search-query
- (search-package-derivations-in-revision
- conn
- commit-hash
- search-query
- #:systems (assq-ref query-parameters 'system)
- #:targets (assq-ref query-parameters 'target)
- #:maximum-builds (assq-ref query-parameters 'maximum_builds)
- #:minimum-builds (assq-ref query-parameters 'minimum_builds)
- #:build-from-build-servers (assq-ref query-parameters
- 'build_from_build_server)
- #:no-build-from-build-servers (assq-ref query-parameters
- 'no_build_from_build_server)
- #:build-status (and=> (assq-ref query-parameters
- 'build_status)
- string->symbol)
- #:limit-results limit-results
- #:after-name (assq-ref query-parameters 'after_name)
- #:include-builds? (member "builds" fields))
- (select-package-derivations-in-revision
- conn
- commit-hash
- #:systems (assq-ref query-parameters 'system)
- #:targets (assq-ref query-parameters 'target)
- #:maximum-builds (assq-ref query-parameters 'maximum_builds)
- #:minimum-builds (assq-ref query-parameters 'minimum_builds)
- #:build-from-build-servers (assq-ref query-parameters
- 'build_from_build_server)
- #:no-build-from-build-servers (assq-ref query-parameters
- 'no_build_from_build_server)
- #:build-status (and=> (assq-ref query-parameters
- 'build_status)
- string->symbol)
- #:limit-results limit-results
- #:after-name (assq-ref query-parameters 'after_name)
- #:include-builds? (member "builds" fields))))))
+ (with-resource-from-pool (connection-pool) conn
+ (if search-query
+ (search-package-derivations-in-revision
+ conn
+ commit-hash
+ search-query
+ #:systems (assq-ref query-parameters 'system)
+ #:targets (assq-ref query-parameters 'target)
+ #:maximum-builds (assq-ref query-parameters 'maximum_builds)
+ #:minimum-builds (assq-ref query-parameters 'minimum_builds)
+ #:build-from-build-servers (assq-ref query-parameters
+ 'build_from_build_server)
+ #:no-build-from-build-servers (assq-ref query-parameters
+ 'no_build_from_build_server)
+ #:build-status (and=> (assq-ref query-parameters
+ 'build_status)
+ string->symbol)
+ #:limit-results limit-results
+ #:after-name (assq-ref query-parameters 'after_name)
+ #:include-builds? (member "builds" fields))
+ (select-package-derivations-in-revision
+ conn
+ commit-hash
+ #:systems (assq-ref query-parameters 'system)
+ #:targets (assq-ref query-parameters 'target)
+ #:maximum-builds (assq-ref query-parameters 'maximum_builds)
+ #:minimum-builds (assq-ref query-parameters 'minimum_builds)
+ #:build-from-build-servers (assq-ref query-parameters
+ 'build_from_build_server)
+ #:no-build-from-build-servers (assq-ref query-parameters
+ 'no_build_from_build_server)
+ #:build-status (and=> (assq-ref query-parameters
+ 'build_status)
+ string->symbol)
+ #:limit-results limit-results
+ #:after-name (assq-ref query-parameters 'after_name)
+ #:include-builds? (member "builds" fields)))))
(build-server-urls
- (with-thread-postgresql-connection
+ (with-resource-from-pool (connection-pool) conn
select-build-server-urls-by-id)))
(let ((show-next-page?
(if all-results
@@ -1161,9 +1101,11 @@
derivations))))))
(else
(letpar& ((systems
- (with-thread-postgresql-connection list-systems))
+ (call-with-resource-from-pool (connection-pool)
+ list-systems))
(targets
- (with-thread-postgresql-connection valid-targets)))
+ (call-with-resource-from-pool (connection-pool)
+ valid-targets)))
(render-html
#:sxml (view-revision-package-derivations
commit-hash
@@ -1197,9 +1139,11 @@
`((error . "invalid query"))))
(else
(letpar& ((systems
- (with-thread-postgresql-connection list-systems))
+ (call-with-resource-from-pool (connection-pool)
+ list-systems))
(targets
- (with-thread-postgresql-connection valid-targets)))
+ (call-with-resource-from-pool (connection-pool)
+ valid-targets)))
(render-html
#:sxml (view-revision-fixed-output-package-derivations
commit-hash
@@ -1222,20 +1166,19 @@
(assq-ref query-parameters 'field)))
(letpar&
((derivations
- (with-thread-postgresql-connection
- (lambda (conn)
- (select-fixed-output-package-derivations-in-revision
- conn
- commit-hash
- (assq-ref query-parameters 'system)
- (assq-ref query-parameters 'target)
- #:latest-build-status (assq-ref query-parameters
- 'latest_build_status)
- #:limit-results limit-results
- #:after-derivation-file-name
- (assq-ref query-parameters 'after_name)))))
+ (with-resource-from-pool (connection-pool) conn
+ (select-fixed-output-package-derivations-in-revision
+ conn
+ commit-hash
+ (assq-ref query-parameters 'system)
+ (assq-ref query-parameters 'target)
+ #:latest-build-status (assq-ref query-parameters
+ 'latest_build_status)
+ #:limit-results limit-results
+ #:after-derivation-file-name
+ (assq-ref query-parameters 'after_name))))
(build-server-urls
- (with-thread-postgresql-connection
+ (with-resource-from-pool (connection-pool) conn
select-build-server-urls-by-id)))
(let ((show-next-page?
(if all-results
@@ -1251,9 +1194,11 @@
`((derivations . ,(list->vector derivations)))))
(else
(letpar& ((systems
- (with-thread-postgresql-connection list-systems))
+ (call-with-resource-from-pool (connection-pool)
+ list-systems))
(targets
- (with-thread-postgresql-connection valid-targets)))
+ (call-with-resource-from-pool (connection-pool)
+ valid-targets)))
(render-html
#:sxml (view-revision-fixed-output-package-derivations
commit-hash
@@ -1278,8 +1223,9 @@
(header-link
(string-append "/revision/" commit-hash)))
(define build-server-urls
- (parallel-via-thread-pool-channel
- (with-thread-postgresql-connection select-build-server-urls-by-id)))
+ (call-with-resource-from-pool
+ (connection-pool)
+ select-build-server-urls-by-id))
(if (any-invalid-query-parameters? query-parameters)
(case (most-appropriate-mime-type
@@ -1290,9 +1236,11 @@
`((error . "invalid query"))))
(else
(letpar& ((systems
- (with-thread-postgresql-connection list-systems))
+ (call-with-resource-from-pool (connection-pool)
+ list-systems))
(targets
- (with-thread-postgresql-connection valid-targets)))
+ (call-with-resource-from-pool (connection-pool)
+ valid-targets)))
(render-html
#:sxml (view-revision-package-derivation-outputs
commit-hash
@@ -1313,23 +1261,22 @@
(assq-ref query-parameters 'field)))
(letpar&
((derivation-outputs
- (with-thread-postgresql-connection
- (lambda (conn)
- (select-derivation-outputs-in-revision
- conn
- commit-hash
- #:search-query (assq-ref query-parameters 'search_query)
- #:nars-from-build-servers
- (assq-ref query-parameters 'substitutes_available_from)
- #:no-nars-from-build-servers
- (assq-ref query-parameters 'substitutes_not_available_from)
- #:output-consistency
- (assq-ref query-parameters 'output_consistency)
- #:system (assq-ref query-parameters 'system)
- #:target (assq-ref query-parameters 'target)
- #:include-nars? (member "nars" fields)
- #:limit-results limit-results
- #:after-path (assq-ref query-parameters 'after_path))))))
+ (with-resource-from-pool (connection-pool) conn
+ (select-derivation-outputs-in-revision
+ conn
+ commit-hash
+ #:search-query (assq-ref query-parameters 'search_query)
+ #:nars-from-build-servers
+ (assq-ref query-parameters 'substitutes_available_from)
+ #:no-nars-from-build-servers
+ (assq-ref query-parameters 'substitutes_not_available_from)
+ #:output-consistency
+ (assq-ref query-parameters 'output_consistency)
+ #:system (assq-ref query-parameters 'system)
+ #:target (assq-ref query-parameters 'target)
+ #:include-nars? (member "nars" fields)
+ #:limit-results limit-results
+ #:after-path (assq-ref query-parameters 'after_path)))))
(let ((show-next-page?
(if all-results
#f
@@ -1395,9 +1342,11 @@
derivation-outputs))))))
(else
(letpar& ((systems
- (with-thread-postgresql-connection list-systems))
+ (call-with-resource-from-pool (connection-pool)
+ list-systems))
(targets
- (with-thread-postgresql-connection valid-targets)))
+ (call-with-resource-from-pool (connection-pool)
+ valid-targets)))
(render-html
#:sxml (view-revision-package-derivation-outputs
commit-hash
@@ -1422,9 +1371,11 @@
(string-append "/revision/" commit-hash)))
(if (any-invalid-query-parameters? query-parameters)
(letpar& ((systems
- (with-thread-postgresql-connection list-systems))
+ (call-with-resource-from-pool (connection-pool)
+ list-systems))
(targets
- (with-thread-postgresql-connection valid-targets)))
+ (call-with-resource-from-pool (connection-pool)
+ valid-targets)))
(render-html
#:sxml
(view-revision-builds query-parameters
@@ -1438,41 +1389,40 @@
(let ((system (assq-ref query-parameters 'system))
(target (assq-ref query-parameters 'target)))
(letpar& ((systems
- (with-thread-postgresql-connection list-systems))
+ (call-with-resource-from-pool (connection-pool)
+ list-systems))
(targets
- (with-thread-postgresql-connection valid-targets))
+ (call-with-resource-from-pool (connection-pool)
+ valid-targets))
(build-server-options
- (with-thread-postgresql-connection
- (lambda (conn)
- (map (match-lambda
- ((id url lookup-all-derivations
- lookup-builds)
- (cons url id)))
- (select-build-servers conn)))))
+ (with-resource-from-pool (connection-pool) conn
+ (map (match-lambda
+ ((id url lookup-all-derivations
+ lookup-builds)
+ (cons url id)))
+ (select-build-servers conn))))
(stats
- (with-thread-postgresql-connection
- (lambda (conn)
- (select-build-stats
- conn
- (assq-ref query-parameters
- 'build_server)
- #:revision-commit commit-hash
- #:system system
- #:target target))))
+ (with-resource-from-pool (connection-pool) conn
+ (select-build-stats
+ conn
+ (assq-ref query-parameters
+ 'build_server)
+ #:revision-commit commit-hash
+ #:system system
+ #:target target)))
(builds
- (with-thread-postgresql-connection
- (lambda (conn)
- (select-builds-with-context
- conn
- (assq-ref query-parameters
- 'build_status)
- (assq-ref query-parameters
- 'build_server)
- #:revision-commit commit-hash
- #:system system
- #:target target
- #:limit (assq-ref query-parameters
- 'limit_results))))))
+ (with-resource-from-pool (connection-pool) conn
+ (select-builds-with-context
+ conn
+ (assq-ref query-parameters
+ 'build_status)
+ (assq-ref query-parameters
+ 'build_server)
+ #:revision-commit commit-hash
+ #:system system
+ #:target target
+ #:limit (assq-ref query-parameters
+ 'limit_results)))))
(render-html
#:sxml (view-revision-builds query-parameters
commit-hash
@@ -1494,9 +1444,11 @@
(string-append "/revision/" commit-hash)))
(if (any-invalid-query-parameters? query-parameters)
(letpar& ((systems
- (with-thread-postgresql-connection list-systems))
+ (call-with-resource-from-pool (connection-pool)
+ list-systems))
(targets
- (with-thread-postgresql-connection valid-targets)))
+ (call-with-resource-from-pool (connection-pool)
+ valid-targets)))
(render-html
#:sxml
(view-revision-blocking-builds query-parameters
@@ -1509,29 +1461,29 @@
(let ((system (assq-ref query-parameters 'system))
(target (assq-ref query-parameters 'target)))
(letpar& ((systems
- (with-thread-postgresql-connection list-systems))
+ (call-with-resource-from-pool (connection-pool)
+ list-systems))
(targets
- (with-thread-postgresql-connection valid-targets))
+ (call-with-resource-from-pool (connection-pool)
+ valid-targets))
(build-server-options
- (with-thread-postgresql-connection
- (lambda (conn)
- (map (match-lambda
- ((id url lookup-all-derivations
- lookup-builds)
- (cons url id)))
- (select-build-servers conn)))))
+ (with-resource-from-pool (connection-pool) conn
+ (map (match-lambda
+ ((id url lookup-all-derivations
+ lookup-builds)
+ (cons url id)))
+ (select-build-servers conn))))
(blocking-builds
- (with-thread-postgresql-connection
- (lambda (conn)
- (select-blocking-builds
- conn
- commit-hash
- #:build-server-ids
- (assq-ref query-parameters 'build_server)
- #:system system
- #:target target
- #:limit (assq-ref query-parameters
- 'limit_results))))))
+ (with-resource-from-pool (connection-pool) conn
+ (select-blocking-builds
+ conn
+ commit-hash
+ #:build-server-ids
+ (assq-ref query-parameters 'build_server)
+ #:system system
+ #:target target
+ #:limit (assq-ref query-parameters
+ 'limit_results)))))
(render-html
#:sxml (view-revision-blocking-builds query-parameters
commit-hash
@@ -1551,24 +1503,20 @@
(header-link
(string-append "/revision/" commit-hash)))
(define lint-checker-options
- (parallel-via-thread-pool-channel
- (with-thread-postgresql-connection
- (lambda (conn)
- (map (match-lambda
- ((name description network-dependent)
- (cons (string-append name ": " description )
- name)))
- (lint-checkers-for-revision conn commit-hash))))))
+ (with-resource-from-pool (connection-pool) conn
+ (map (match-lambda
+ ((name description network-dependent)
+ (cons (string-append name ": " description )
+ name)))
+ (lint-checkers-for-revision conn commit-hash))))
(define lint-warnings-locale-options
- (parallel-via-thread-pool-channel
- (with-thread-postgresql-connection
- (lambda (conn)
- (map
- (match-lambda
- ((locale)
- locale))
- (lint-warning-message-locales-for-revision conn commit-hash))))))
+ (with-resource-from-pool (connection-pool) conn
+ (map
+ (match-lambda
+ ((locale)
+ locale))
+ (lint-warning-message-locales-for-revision conn commit-hash))))
(if (any-invalid-query-parameters? query-parameters)
(case (most-appropriate-mime-type
@@ -1597,18 +1545,16 @@
(fields (assq-ref query-parameters 'field)))
(letpar&
((git-repositories
- (with-thread-postgresql-connection
- (lambda (conn)
- (git-repositories-containing-commit conn
- commit-hash))))
+ (with-resource-from-pool (connection-pool) conn
+ (git-repositories-containing-commit conn
+ commit-hash)))
(lint-warnings
- (with-thread-postgresql-connection
- (lambda (conn)
- (lint-warnings-for-guix-revision conn commit-hash
- #:locale locale
- #:package-query package-query
- #:linters linters
- #:message-query message-query)))))
+ (with-resource-from-pool (connection-pool) conn
+ (lint-warnings-for-guix-revision conn commit-hash
+ #:locale locale
+ #:package-query package-query
+ #:linters linters
+ #:message-query message-query))))
(let ((any-translated-lint-warnings?
(any-translated-lint-warnings? lint-warnings locale)))
(case (most-appropriate-mime-type