Reconnect if the database connection has been lost.

This commit is contained in:
niten 2022-02-15 13:57:27 -08:00
parent 440efb7cf9
commit 46458f11aa
2 changed files with 8 additions and 0 deletions

View File

@ -105,6 +105,7 @@
(defgeneric set-ipv4 (store domain name ip))
(defgeneric set-ipv6 (store domain name ip))
(defgeneric set-sshfp (store domain name sshfp))
(defgeneric ensure-connection (store))
(defmethod set-ipv4 ((store postgres-dns-store)
(domain string)
@ -140,3 +141,9 @@
(sshfps list))
(if-let ((new-sshfps (mapcar #'sshfp-p sshfps)))
(replace-records domain name "SSHFP" new-sshfps)))
(defmethod ensure-connection ((store postgres-dns-store))
(let ((db postmodern:*database*))
(when (not (connected-p conn))
(reconnect conn))
store))

View File

@ -54,6 +54,7 @@
(handler-case
(if-let ((store *dns-store*))
(-> message
(ensure-connection store)
(handle-dns-message store)
(handle-dns-response (msg-id message)))
(make-error :msg "dns store is not initialized"