Skip to content

Commit

Permalink
#17: Support connection validation
Browse files Browse the repository at this point in the history
  • Loading branch information
alaisi committed Jul 10, 2015
1 parent 3524713 commit be86d5d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
3 changes: 2 additions & 1 deletion dev/user.clj
Original file line number Diff line number Diff line change
Expand Up @@ -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))
2 changes: 1 addition & 1 deletion project.clj
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
4 changes: 3 additions & 1 deletion src/postgres/async.clj
Original file line number Diff line number Diff line change
Expand Up @@ -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")))))
Expand All @@ -30,6 +31,7 @@
(.password password)
(.ssl (boolean ssl))
(.poolSize (or pool-size 25))
(.validationQuery validation-query)
(.dataConverter (create-converter))
(.build)))

Expand Down

0 comments on commit be86d5d

Please sign in to comment.