Associate a name with database connections
This helps when working out which connection to the database is doing what.
This commit is contained in:
parent
1b5db7adac
commit
743cec7cb6
14 changed files with 20 additions and 4 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -703,6 +703,7 @@ ORDER BY load_new_guix_revision_jobs.id DESC")
|
|||
(lambda ()
|
||||
(let ((result
|
||||
(with-postgresql-connection
|
||||
(simple-format #f "load-new-guix-revision ~A logging" id)
|
||||
(lambda (logging-conn)
|
||||
(insert-empty-log-entry logging-conn id)
|
||||
(let ((logging-port (log-port id logging-conn)))
|
||||
|
|
|
|||
|
|
@ -568,6 +568,7 @@
|
|||
#t
|
||||
(lambda ()
|
||||
(with-postgresql-connection
|
||||
"web healthcheck"
|
||||
(lambda (conn)
|
||||
(number?
|
||||
(string->number
|
||||
|
|
@ -585,6 +586,7 @@
|
|||
500))))
|
||||
(_
|
||||
(with-postgresql-connection
|
||||
"web"
|
||||
(lambda (conn)
|
||||
(controller-with-database-connection request
|
||||
method-and-path-components
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue