8000 #17: Support connection validation · alaisi/postgres.async@be86d5d · GitHub
[go: up one dir, main page]

Skip to content

Commit be86d5d

Browse files
committed
#17: Support connection validation
1 parent 3524713 commit be86d5d

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

dev/user.clj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
(pg/open-db {:hostname "localhost"
77
:database "postgres"
88
:username "postgres"
9-
:password "postgres"}))
9+
:password "postgres"
10+
:validation-query "select 1"}))
1011

1112
(defn reload []
1213
(repl/refresh))

project.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
:url "http://github.com/alaisi/postgres.async.git"}
88
:dependencies [[org.clojure/clojure "1.6.0"]
99
[org.clojure/core.async "0.1.346.0-17112a-alpha"]
10-
[com.github.alaisi.pgasync/postgres-async-driver "0.6"]
10+
[com.github.alaisi.pgasync/postgres-async-driver "0.7-SNAPSHOT"]
1111
[cheshire "5.5.0" :scope "provided"]]
1212
:lein-release {:deploy-via :clojars}
1313
:global-vars {*warn-on-reflection* true}

src/postgres/async.clj

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818

1919
(defn open-db
2020
"Creates a db connection pool"
21-
[{:keys [hostname port username password database pool-size ssl] :as config}]
21+
[{:keys [hostname port username password database pool-size ssl validation-query]
22+
:as config}]
2223
(doseq [param [:hostname :username :password :database]]
2324
(when (nil? (param config))
2425
(throw (IllegalArgumentException. (str param " is required")))))
@@ -30,6 +31,7 @@
3031
(.password password)
3132
(.ssl (boolean ssl))
3233
(.poolSize (or pool-size 25))
34+
(.validationQuery validation-query)
3335
(.dataConverter (create-converter))
3436
(.build)))
3537

0 commit comments

Comments
 (0)
0