aboutsummaryrefslogtreecommitdiff
path: root/guix-data-service/database.scm
diff options
context:
space:
mode:
authorChristopher Baines <mail@cbaines.net>2020-10-03 08:55:56 +0100
committerChristopher Baines <mail@cbaines.net>2020-10-03 08:55:56 +0100
commit1bdc8855ba0fc78e86131e7f2bafb34984f5e79e (patch)
treee81b8eaef8ba24ea2a22e17604e676833ae1e532 /guix-data-service/database.scm
parent470573b318fb23c7fbf96ce83efc9d9de949e94d (diff)
downloaddata-service-1bdc8855ba0fc78e86131e7f2bafb34984f5e79e.tar
data-service-1bdc8855ba0fc78e86131e7f2bafb34984f5e79e.tar.gz
Extract out opening PostgreSQL connections
So this can be reused.
Diffstat (limited to 'guix-data-service/database.scm')
-rw-r--r--guix-data-service/database.scm9
1 files changed, 7 insertions, 2 deletions
diff --git a/guix-data-service/database.scm b/guix-data-service/database.scm
index 2ac26c4..1d29199 100644
--- a/guix-data-service/database.scm
+++ b/guix-data-service/database.scm
@@ -44,7 +44,7 @@
(define pg-conn-finish
(@@ (squee) pg-conn-finish))
-(define* (with-postgresql-connection name f #:key (statement-timeout #f))
+(define (open-postgresql-connection name statement-timeout)
(define paramstring
(string-append
(or (getenv "GUIX_DATA_SERVICE_DATABASE_PARAMSTRING")
@@ -62,8 +62,13 @@
conn
(simple-format #f "SET statement_timeout = ~A"
statement-timeout)))
+
+ conn))
+
+(define* (with-postgresql-connection name f #:key (statement-timeout #f))
+ (let ((conn (open-postgresql-connection name statement-timeout)))
(with-throw-handler
- #t
+ #t
(lambda ()
(call-with-values
(lambda ()