From c1a0daf28d3160dee9021ea521553b23bade4853 Mon Sep 17 00:00:00 2001 From: John Shaffer Date: Mon, 24 Jan 2022 12:43:28 -0600 Subject: [PATCH] Add :allow-pool-suspension option Documented at https://github.com/brettwooldridge/HikariCP#infrequently-used --- CHANGELOG.md | 1 + src/hikari_cp/core.clj | 28 ++++++++++++++++++---------- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a54100f..ab6347a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ ## unreleased * updated `HikariCP` to `4.0.3` +* add `:allow-pool-suspension` option ## 2.13.0 diff --git a/src/hikari_cp/core.clj b/src/hikari_cp/core.clj index bc29079..f413588 100644 --- a/src/hikari_cp/core.clj +++ b/src/hikari_cp/core.clj @@ -6,15 +6,16 @@ [clojure.spec.alpha :as s])) (def default-datasource-options - {:auto-commit true - :read-only false - :connection-timeout 30000 - :validation-timeout 5000 - :idle-timeout 600000 - :max-lifetime 1800000 - :minimum-idle 10 - :maximum-pool-size 10 - :register-mbeans false}) + {:allow-pool-suspension false + :auto-commit true + :read-only false + :connection-timeout 30000 + :validation-timeout 5000 + :idle-timeout 600000 + :max-lifetime 1800000 + :minimum-idle 10 + :maximum-pool-size 10 + :register-mbeans false}) (def ^{:private true} adapters-to-datasource-class-names {"derby" "org.apache.derby.jdbc.ClientDataSource" @@ -55,6 +56,9 @@ [x] (or (== 0 x) (>= x 2000))) +(s/def ::allow-pool-suspension + boolean?) + (s/def ::auto-commit boolean?) @@ -101,7 +105,8 @@ ::read-only ::register-mbeans ::validation-timeout] - :opt-un [::connection-timeout + :opt-un [::allow-pool-suspension + ::connection-timeout ::transaction-isolation ::leak-detection-threshold]) ;; Make sure that if the user provides the class @@ -168,6 +173,7 @@ (def ^:private core-options [:adapter + :allow-pool-suspension :auto-commit :configure :connection-init-sql @@ -199,6 +205,7 @@ options (validate-options datasource-options) not-core-options (apply dissoc options core-options) {:keys [adapter + allow-pool-suspension datasource datasource-class-name auto-commit @@ -225,6 +232,7 @@ metrics-tracker-factory]} options] ;; Set pool-specific properties (doto config + (.setAllowPoolSuspension allow-pool-suspension) (.setAutoCommit auto-commit) (.setReadOnly read-only) (.setConnectionTimeout connection-timeout)