From be86d5dd81242bd1039ecd7ce8cc7a488868aa33 Mon Sep 17 00:00:00 2001 From: Antti Laisi Date: Fri, 10 Jul 2015 22:09:25 +0300 Subject: [PATCH] #17: Support connection validation --- dev/user.clj | 3 ++- project.clj | 2 +- src/postgres/async.clj | 4 +++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/dev/user.clj b/dev/user.clj index 789214a..76db850 100644 --- a/dev/user.clj +++ b/dev/user.clj @@ -6,7 +6,8 @@ (pg/open-db {:hostname "localhost" :database "postgres" :username "postgres" - :password "postgres"})) + :password "postgres" + :validation-query "select 1"})) (defn reload [] (repl/refresh)) diff --git a/project.clj b/project.clj index 5afd892..b53815f 100644 --- a/project.clj +++ b/project.clj @@ -7,7 +7,7 @@ :url "http://github.com/alaisi/postgres.async.git"} :dependencies [[org.clojure/clojure "1.6.0"] [org.clojure/core.async "0.1.346.0-17112a-alpha"] - [com.github.alaisi.pgasync/postgres-async-driver "0.6"] + [com.github.alaisi.pgasync/postgres-async-driver "0.7-SNAPSHOT"] [cheshire "5.5.0" :scope "provided"]] :lein-release {:deploy-via :clojars} :global-vars {*warn-on-reflection* true} diff --git a/src/postgres/async.clj b/src/postgres/async.clj index 098fb26..4ee5979 100644 --- a/src/postgres/async.clj +++ b/src/postgres/async.clj @@ -18,7 +18,8 @@ (defn open-db "Creates a db connection pool" - [{:keys [hostname port username password database pool-size ssl] :as config}] + [{:keys [hostname port username password database pool-size ssl validation-query] + :as config}] (doseq [param [:hostname :username :password :database]] (when (nil? (param config)) (throw (IllegalArgumentException. (str param " is required"))))) @@ -30,6 +31,7 @@ (.password password) (.ssl (boolean ssl)) (.poolSize (or pool-size 25)) + (.validationQuery validation-query) (.dataConverter (create-converter)) (.build)))