resilience4clj / resilience4clj-retry Goto Github PK
View Code? Open in Web Editor NEWResilience4Clj Retry lets you decorate a function call with a specified number of retry attempts.
License: MIT License
Resilience4Clj Retry lets you decorate a function call with a specified number of retry attempts.
License: MIT License
Thanks for the sweet lib!
The example of how to create a retry with configuration doesn't run:
(def retry (r/create {:max-attempts 10
:wait-duration 300}))
clojure.lang.PersistentArrayMap is in unnamed module of loader 'app'; java.lang.String is in module java.base of loader 'bootstrap')
This example requires a name string, e.g.
(def retry "my-retry" (r/create {:max-attempts 10
:wait-duration 300}))
=>
#object[io.github.resilience4j.retry.internal.RetryImpl
0x4941ec8f
"io.github.resilience4j.retry.internal.RetryImpl@4941ec8f"]
Fixing this would help others get started with the library, as I ran into this issue myself trying to get set up.
I have existing functions that I'm attempting to decorate as retriable, but I'm noticing that retry is not triggered when java.lang.Exception
is thrown, I'm not sure if this is an issue with the upstream dependency, but I can repro it with this code:
(require '[resilience4clj-retry.core :as r])
(def retry (r/create "test-retry"))
(r/listen-event retry
:RETRY
(fn [_] (println "retrying...")))
;; 1. Exception
(def retriable-fn
(r/decorate
(fn [] (throw (Exception. "not good")))
retry))
(retriable-fn)
;; Execution error at retry/fn (retry.clj:4).
;; not good
;; 2. ex-info
(def retriable-fn
(r/decorate
(fn [] (throw (ex-info "not good" {})))
retry))
(retriable-fn)
;; retrying...
;; retrying...
;; Execution error (ExceptionInfo) at retry/fn (retry.clj:3).
;; not good
;; 3. Exception caught and re-thrown as ex-info
(def retriable-fn
(r/decorate
(fn [] (throw (ex-info "not good" {} (Exception. "not good"))))
retry))
(retriable-fn)
;; retrying...
;; retrying...
;; Execution error at retry/fn (retry.clj:3).
;; not good
java.lang.Exception
and retry logic is never executedWhat am I missing here? Is there a config that I must add to catch java.lang.Exception
?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.