Associate a name with database connections

This helps when working out which connection to the database is doing what.
This commit is contained in:
Christopher Baines 2019-07-12 19:45:41 +01:00
parent 1b5db7adac
commit 743cec7cb6
14 changed files with 20 additions and 4 deletions

View file

@ -24,10 +24,12 @@
(define pg-conn-finish
(@@ (squee) pg-conn-finish))
(define (with-postgresql-connection f)
(define* (with-postgresql-connection name f)
(define paramstring
(or (getenv "GUIX_DATA_SERVICE_DATABASE_PARAMSTRING")
"dbname=guix_data_service user=guix_data_service"))
(string-append
(or (getenv "GUIX_DATA_SERVICE_DATABASE_PARAMSTRING")
"dbname=guix_data_service user=guix_data_service")
" application_name='guix-data-service " name "'"))
(let* ((conn (connect-to-postgres-paramstring paramstring)))
(with-throw-handler