Stop opening a PostgreSQL connection per request

This was good in that it avoided having to deal with long running connections,
but it probably takes some time to open the connection, and these changes are
a step towards offloading the PostgreSQL queries to other threads, so they
don't block the threads for fibers.
This commit is contained in:
Christopher Baines 2020-10-03 09:22:29 +01:00
parent 9723a18df4
commit 18b6dd9e6d
3 changed files with 16 additions and 20 deletions

View file

@ -31,6 +31,7 @@
(gcrypt pk-crypto)
(guix pki)
(guix-data-service config)
(guix-data-service database)
(guix-data-service web server)
(guix-data-service web controller)
(guix-data-service web nar controller))
@ -194,9 +195,12 @@
(assq-ref opts 'host)
(assq-ref opts 'port))
(start-guix-data-service-web-server
(assq-ref opts 'port)
(assq-ref opts 'host)
(assq-ref opts 'secret-key-base)
#:postgresql-statement-timeout
(with-postgresql-connection-per-thread
"web"
(lambda ()
(start-guix-data-service-web-server
(assq-ref opts 'port)
(assq-ref opts 'host)
(assq-ref opts 'secret-key-base)))
#:statement-timeout
(assq-ref opts 'postgresql-statement-timeout))))