diff --git a/backplane-dns-store.lisp b/backplane-dns-store.lisp index 6df4a75..5ccee03 100644 --- a/backplane-dns-store.lisp +++ b/backplane-dns-store.lisp @@ -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)) diff --git a/backplane-dns.lisp b/backplane-dns.lisp index dc655fd..184e1a4 100644 --- a/backplane-dns.lisp +++ b/backplane-dns.lisp @@ -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"