clj-http

2025-01-23T15:46:04.234639Z

(defn retry-fn-exec [^HttpClientBuilder builder
                          request]
       (when (:retry-fn request)
         (.setServiceUnavailableRetryStrategy builder
                                              (proxy [ServiceUnavailableRetryStrategy] []
                                                (retryRequest [^HttpResponse resp cnt ctx]
                                                  (println ::AAA)
                                                  (boolean (when (and (= 400 (-> resp
                                                                                 .getStatusLine
                                                                                 .getStatusCode))
                                                                      (> 3 cnt))
                                                             true)))
                                                (getRetryInterval []
                                                  0)))))


#_(-> {:url ""
       :keystore-type      "pkcs12"
       :cache              true
       :retry-fn true
       :http-builder-fns [retry-fn-exec]}
      client/request)

lukasz 2025-02-05T16:27:36.940159Z

@d.ian.b just started working on this, indeed this works pretty nicely, doesn't quite cover (yet?) all the use cases for me, it def simplified a lot of code

🙏 1
2025-02-05T17:00:19.731519Z

that's awesome! 😄

2025-02-05T17:00:50.495979Z

which cases are not covered by this? (just out of curiosity)

lukasz 2025-02-05T17:13:40.082799Z

not sure yet, I need to tidy up the code and check failing tests - I'll report back 🫡

1
2025-01-23T15:49:38.891759Z

@lukaszkorecki 😄

lukasz 2025-01-23T16:00:44.882229Z

Nice, I have test harness which spins up a local jetty server to simulate all kinds of issues - I’ll see how that behaves 👍

2025-02-10T00:33:09.592359Z

Btw @lukaszkorecki, I have a lib for mock testing http-clj 😄 https://github.com/ianffcs/apache-http-client-ring-adapter/pulls

2025-02-10T00:33:34.453949Z

I've add a retryable client in this PR, if you think it's good enough 😄

2025-02-10T00:33:52.936519Z

(tomorrow I'll take a look again into it before merging it)

lukasz 2025-02-12T16:14:04.036139Z

interesting approach - I went a different way by providing a http client protocol, and different versions of the client - one for making real requests, and mock one that can be used to provide Ring-style responses on matched requests

2025-01-27T20:40:04.882739Z

I really wanna know about your exps on it

lukasz 2025-01-27T23:05:13.183439Z

prolly not gonna get to it this week, we will see

lukasz 2025-02-06T22:33:10.829859Z

Here's more or less what I ended up with - it does all the things my teams need: https://gist.github.com/lukaszkorecki/f2f83e98c3b2283b0f156814883ff11c

🙏 1
2025-02-06T23:38:56.452179Z

Nice. Why deftype and not defn+proxy?

lukasz 2025-02-07T00:10:01.854959Z

from what I remember, it things tidier from the JVM level: actual classes will be created and all that, so it will be somewhat faster to deal with than repeated call to proxy - also was much easier to express mutable nature of associated objects and such

👍 1
🤔 1