This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2024-08-06
Channels
- # announcements (9)
- # babashka (22)
- # beginners (33)
- # cider (3)
- # clj-kondo (25)
- # clj-on-windows (1)
- # cljsrn (3)
- # clojure (38)
- # clojure-dev (10)
- # clojure-europe (17)
- # clojure-norway (45)
- # clojure-uk (3)
- # clojurescript (16)
- # code-reviews (20)
- # cursive (23)
- # data-science (18)
- # datomic (19)
- # fulcro (14)
- # funcool (5)
- # humbleui (34)
- # hyperfiddle (17)
- # jobs-discuss (3)
- # joyride (1)
- # malli (4)
- # off-topic (15)
- # polylith (10)
- # portland-or (2)
- # reitit (7)
- # releases (8)
- # shadow-cljs (11)
- # vim (30)
• https://github.com/sunng87/diehard if you cannot use JDK17+ • https://github.com/KingMob/TrueGrit if you can
FWIW, cljdoc uses https://github.com/joegallo/robert-bruce
What are we retrying?
Interesting. I'm curious, why do you think calling the same function more than once might have a different result? Im just asking the first thing that comes to mind, so feel free to ignore me. 😜
huh ngl, the article seems to lack nuance. The vast majority of times what's being retried is network issues or the given remote api having some sort of hiccup. A good retry impl with specifically observe 5XX status codes or timeout exceptions. If peers didn't observe that, it has nothing to do with retrying or clojure 🤷
I don't have a particular opinion about file systems, although it's not rare to find articles explaining how they're quite the rabbit hole, a leaky abstraction, etc etc. I'd log the error for future examination but also retry if that happens to fix things. Most devs aren't going to casually become fs experts overnight.
funny, I'm currently working on a resilience lib that more or less solve the issues in that article
safely
, linked above, has a parameter - :retryable-error?
- that gives users control over when it actually makes sense to retry versus when it doesn't, by allowing them to pass a predicate function to match on the exception type.
it also logs using the excellent mulog
library by default, so it's not throwing information away.
it makes it pretty easy to "do the right thing" and gradually incorporate more error handling into the retry loop with the benefit of detailed logs, just as the article recommends.
If by "Clojure" library you mean "JVM" library, then I highly recommend failsafe. https://github.com/failsafe-lib/failsafe You might be after something written in Clojure and that's totally fair but when it comes to retry and fault tolerance, failsafe really does deserve a mention.
You actually don't need a library for retries. Here's exponential backoff with 4 attempts max:
(loop [retries [100 200 400 800]]
(let [res
(try :...
(catch Exception e
(if retries
(do (Thread/sleep (first retries))
:retry)
(throw e))))]
(if (= :retry res)
(recur (next retries))
res)))
Very annoyingly, you can't recur inside a catch, that's why it looks a bit more weird than it should.I'm probably not the right audience for the question since I don't know what it means. But out of curiosity - what does the question mean?
Unrelated, but still weird: https://github.com/phronmophobic/clj-media/blob/main/src/com/phronemophobic/clj_media/impl/cljfx.clj#L59-L61
Probably a missed second argument to locking
?
yup, it should almost certainly be locking on draw-lock
. I think that namespace was just for a proof of concept that I never finished.
is there a reason for the question?
I guess it has to do with the fact that keywords are interned. If you do it at least on namespaced keywords then you have global monitors usable from everywhere that don't even need to require? 😛 And then grep to understand what is going on
although they are interned with WeakReferences, so no idea what happens when you are locking against an object that can be collected?
Locking on interned things is deeply bad (this is a known bad pattern for Strings in Java for example). Please don’t do that :)
We were musing about if keywords could become value classes in Java 24 or whenever they land. If so, they would not have identity (so also don’t do identity checks) or be lockable.
Will get back to you in 5 yrs :)
> We were musing about if keywords could become value classes in Java 24 or whenever they land. If so, they would not have identity (so also don’t do identity checks) or be lockable. Would that be backwards incompatible with the edn spec? > If the target platform supports some notion of interning, it is a further semantic of keywords that all instances of the same keyword yield the identical object. > -- https://github.com/edn-format/edn