Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
0.7.0 include safely for exponential backoff
  • Loading branch information
ibarrick committed Jan 3, 2020
commit fd631bc732ff6cdedc73c9ab05dd38fd263a4742
5 changes: 3 additions & 2 deletions project.clj
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
(defproject org.batch/yesql "0.6.9"
(defproject org.batch/yesql "0.7.0"
:description "A Clojure library for using SQL"
:url "https://github.com/krisajenkins/yesql"
:license {:name "Eclipse Public License"
:url "http://www.eclipse.org/legal/epl-v10.html"}
:dependencies [[org.clojure/clojure "1.8.0"]
[org.clojure/java.jdbc "0.7.6"]
[instaparse "1.4.1" :exclusions [org.clojure/clojure]]]
[instaparse "1.4.1" :exclusions [org.clojure/clojure]]
[com.brunobonacci/safely "0.5.0-alpha8" :exclusions [com.google.errorprone/error_prone_annotations org.clojure/clojure com.google.code.findbugs/jsr305]]]
:pedantic? :abort
:scm {:name "git"
:url "https://github.com/krisajenkins/yesql"}
Expand Down
12 changes: 8 additions & 4 deletions src/yesql/generate.clj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
[clojure.string :refer [join lower-case split trim]]
[yesql.util :refer [create-root-var]]
[yesql.types :refer [map->Query]]
[yesql.statement-parser :refer [tokenize]])
[yesql.statement-parser :refer [tokenize]]
[safely.core :refer [safely]])
(:import yesql.types.Query)
(:import java.lang.IllegalArgumentException))

Expand Down Expand Up @@ -139,9 +140,12 @@
((:before-delete @(:hooks query-options)) args statement (assoc call-options :uuid uuid))
(and (= execute-handler jdbc-fn) (:hooks query-options) (= "update" (lower-case (first (split (trim statement) #" ")))) (:before-update @(:hooks query-options)))
((:before-update @(:hooks query-options)) args statement (assoc call-options :uuid uuid)))
(let [ret (jdbc-fn connection
(rewrite-query-for-jdbc tokens args)
call-options)]
(let [ret (safely (jdbc-fn connection
(rewrite-query-for-jdbc tokens args)
call-options)
:on-error
:max-retries 5
:retry-delay [:random-exp-backoff :base 50 :+/- 0.5])]
(cond (and (= insert-handler jdbc-fn) (:hooks query-options) (:after-insert @(:hooks query-options)))
((:after-insert @(:hooks query-options)) ret args statement (assoc call-options :uuid uuid))
(and (= execute-handler jdbc-fn) (:hooks query-options) (= "delete" (lower-case (first (split (trim statement) #" ")))) (:after-delete @(:hooks query-options)))
Expand Down