aboutsummaryrefslogtreecommitdiff
path: root/guix-data-service/web/nar/controller.scm
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/nar/controller.scm
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/nar/controller.scm')
-rw-r--r--guix-data-service/web/nar/controller.scm51
1 files changed, 21 insertions, 30 deletions
diff --git a/guix-data-service/web/nar/controller.scm b/guix-data-service/web/nar/controller.scm
index 2164860..e2ace7a 100644
--- a/guix-data-service/web/nar/controller.scm
+++ b/guix-data-service/web/nar/controller.scm
@@ -34,6 +34,7 @@
#:use-module (guix-data-service utils)
#:use-module (guix-data-service database)
#:use-module (guix-data-service web render)
+ #:use-module (guix-data-service web controller)
#:use-module (guix-data-service web nar html)
#:use-module (guix-data-service model derivation)
#:export (nar-controller
@@ -99,11 +100,9 @@
mime-types
file-name)
(or
- (and=> (parallel-via-thread-pool-channel
- (with-thread-postgresql-connection
- (lambda (conn)
- (select-serialized-derivation-by-file-name conn
- file-name))))
+ (and=> (with-resource-from-pool (reserved-connection-pool) conn
+ (select-serialized-derivation-by-file-name conn
+ file-name))
(lambda (derivation-text)
(let ((derivation-bytevector
(string->bytevector derivation-text
@@ -130,11 +129,9 @@
mime-types
file-name)
(or
- (and=> (parallel-via-thread-pool-channel
- (with-thread-postgresql-connection
- (lambda (conn)
- (select-derivation-source-file-nar-data-by-file-name conn
- file-name))))
+ (and=> (with-resource-from-pool (reserved-connection-pool) conn
+ (select-derivation-source-file-nar-data-by-file-name conn
+ file-name))
(lambda (data)
(list (build-response
#:code 200
@@ -150,11 +147,9 @@
(define (render-narinfo request
hash)
(or
- (and=> (parallel-via-thread-pool-channel
- (with-thread-postgresql-connection
- (lambda (conn)
- (select-derivation-by-file-name-hash conn
- hash))))
+ (and=> (with-resource-from-pool (reserved-connection-pool) conn
+ (select-derivation-by-file-name-hash conn
+ hash))
(lambda (derivation)
(list (build-response
#:code 200
@@ -162,17 +157,15 @@
(let ((derivation-file-name (second derivation)))
(letpar&
((derivation-text
- (with-thread-postgresql-connection
- (lambda (conn)
- (select-serialized-derivation-by-file-name
- conn
- derivation-file-name))))
+ (with-resource-from-pool (reserved-connection-pool) conn
+ (select-serialized-derivation-by-file-name
+ conn
+ derivation-file-name)))
(derivation-references
- (with-thread-postgresql-connection
- (lambda (conn)
- (select-derivation-references-by-derivation-id
- conn
- (first derivation))))))
+ (with-resource-from-pool (reserved-connection-pool) conn
+ (select-derivation-references-by-derivation-id
+ conn
+ (first derivation)))))
(let* ((derivation-bytevector
(string->bytevector derivation-text
"ISO-8859-1"))
@@ -195,11 +188,9 @@
(narinfo-string derivation-file-name
nar-bytevector
derivation-references)))))))
- (and=> (parallel-via-thread-pool-channel
- (with-thread-postgresql-connection
- (lambda (conn)
- (select-derivation-source-file-data-by-file-name-hash conn
- hash))))
+ (and=> (with-resource-from-pool (reserved-connection-pool) conn
+ (select-derivation-source-file-data-by-file-name-hash conn
+ hash))
(match-lambda
((store-path compression compressed-size
hash-algorithm hash uncompressed-size)