This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-12-30
Channels
- # aleph (25)
- # announcements (20)
- # babashka (29)
- # babashka-sci-dev (12)
- # beginners (27)
- # biff (3)
- # clojure (29)
- # clojure-europe (21)
- # clojure-nl (1)
- # clojure-norway (1)
- # clojurescript (3)
- # clr (5)
- # code-reviews (4)
- # data-science (7)
- # datahike (6)
- # datascript (3)
- # emacs (9)
- # fulcro (5)
- # graalvm (10)
- # malli (15)
- # nbb (7)
- # off-topic (17)
- # pathom (9)
- # polylith (4)
- # practicalli (15)
- # reitit (3)
- # releases (2)
- # rum (1)
- # shadow-cljs (73)
- # squint (34)
- # tools-deps (3)
- # xtdb (11)
Am I doing something wrong here:
(require '[babashka.deps :as deps])
(deps/add-deps '{:deps {java-http-clj/java-http-clj {:mvn/version "0.4.3"}}})
(require '[java-http-clj.core :as http])
Gives the error:
Can't change/establish root binding of #'clojure.core/*warn-on-reflection* with set
What is your bb version and how are you executing the above code, in a script, repl?
workaround:
(binding [*warn-on-reflection* *warn-on-reflection*]
(require '[java-http-clj.core :as http]))
please post an issueDear babashka friends! Just finished up writing the babashka http-client today and I think it's ready to be used. Please provide your feedback while this library is in flux so we can move it to a built-in somewhere in 2023! https://github.com/babashka/http-client
The new parts I just finished are • interceptors https://github.com/babashka/http-client#interceptors • async https://github.com/babashka/http-client#async
(def resp (client/post "" {:body "From Clojure"}))
(json/parse-string (:body resp)) ;;=> {"args" {}, "data" "", ...}
Is this example right? I expected to see "from Clojure" somewhere in the response body.Is it possible to deref a CompletableFuture? In other words, is it possible to deref the result of an async get request?
I don't think it's possible to directly implement IDeref
for CompletableFuture
but we could implement a wrapper like we did for process
maybe...
At first, I expected that clj-http supported deref for getting the result of async requests. I see that's not the case, clj-http has callbacks. https://github.com/dakrone/clj-http#async-http-request
To implement chaining you can use something like this: https://github.com/babashka/http-client/blob/aa5b209e678b4d76e19f3d5e265533310a851515/src/babashka/http_client/internal.clj#L176 which I use internally to chain the interceptors onto the future
oh wait, that apache future also derives from java.util.concurrent.Future
so I guess you could use deref there too
I guess we could support those callbacks too like this: https://github.com/schmee/java-http-clj/blob/master/src/java_http_clj/core.clj#L165-L168
cool! I haven't thought much of how separate of a concern it should technically be, but would you consider adding websocket functionality to this? Or would that belong in a different library that depends on this? In practice I often use both together and I like that java-http-clj offers it as a packaged deal
Just a side question, is it virtual thread friendly? I believe they changed underlying code on Java 19+ and it should be vthreads friendly.
http-client doesn't really do anything vthread specific - what underlying code did they change? CompletableFuture?
I believe they just changed internal implementation, API remains the same - in Java tradition. I recall Ron Pressler mentioned this, cannot really find the reference though.