mirror of
https://github.com/penpot/penpot.git
synced 2025-03-11 23:31:21 -05:00
✨ Improve db/pool initialization and reusability
This commit is contained in:
parent
41d34de9e1
commit
3cf4a3facc
1 changed files with 17 additions and 10 deletions
|
@ -59,8 +59,8 @@
|
||||||
(s/def ::read-only? ::us/boolean)
|
(s/def ::read-only? ::us/boolean)
|
||||||
|
|
||||||
(s/def ::pool-options
|
(s/def ::pool-options
|
||||||
(s/keys :req [::uri]
|
(s/keys :opt [::uri
|
||||||
:opt [::name
|
::name
|
||||||
::min-size
|
::min-size
|
||||||
::max-size
|
::max-size
|
||||||
::connection-timeout
|
::connection-timeout
|
||||||
|
@ -89,15 +89,16 @@
|
||||||
|
|
||||||
(defmethod ig/init-key ::pool
|
(defmethod ig/init-key ::pool
|
||||||
[_ {:keys [::uri ::read-only?] :as cfg}]
|
[_ {:keys [::uri ::read-only?] :as cfg}]
|
||||||
(l/info :hint "initialize connection pool"
|
(when uri
|
||||||
:name (d/name (::name cfg))
|
(l/info :hint "initialize connection pool"
|
||||||
:uri uri
|
:name (d/name (::name cfg))
|
||||||
:read-only read-only?
|
:uri uri
|
||||||
:with-credentials (and (contains? cfg ::username)
|
:read-only read-only?
|
||||||
(contains? cfg ::password))
|
:with-credentials (and (contains? cfg ::username)
|
||||||
:min-size (::min-size cfg)
|
(contains? cfg ::password))
|
||||||
|
:min-size (::min-size cfg)
|
||||||
:max-size (::max-size cfg))
|
:max-size (::max-size cfg))
|
||||||
(create-pool cfg))
|
(create-pool cfg)))
|
||||||
|
|
||||||
(defmethod ig/halt-key! ::pool
|
(defmethod ig/halt-key! ::pool
|
||||||
[_ pool]
|
[_ pool]
|
||||||
|
@ -144,6 +145,7 @@
|
||||||
[v]
|
[v]
|
||||||
(instance? javax.sql.DataSource v))
|
(instance? javax.sql.DataSource v))
|
||||||
|
|
||||||
|
(s/def ::conn some?)
|
||||||
(s/def ::pool pool?)
|
(s/def ::pool pool?)
|
||||||
(s/def ::nilable-pool (s/nilable ::pool))
|
(s/def ::nilable-pool (s/nilable ::pool))
|
||||||
(s/def ::conn-or-pool some?)
|
(s/def ::conn-or-pool some?)
|
||||||
|
@ -430,6 +432,11 @@
|
||||||
(.setType "jsonb")
|
(.setType "jsonb")
|
||||||
(.setValue (json/encode-str data)))))
|
(.setValue (json/encode-str data)))))
|
||||||
|
|
||||||
|
(defn get-update-count
|
||||||
|
[result]
|
||||||
|
(:next.jdbc/update-count result))
|
||||||
|
|
||||||
|
|
||||||
;; --- Locks
|
;; --- Locks
|
||||||
|
|
||||||
(def ^:private siphash-state
|
(def ^:private siphash-state
|
||||||
|
|
Loading…
Add table
Reference in a new issue