clojure

New to Clojure? Try the #beginners channel. Official docs: https://clojure.org/ Searchable message archives: https://clojurians-log.clojureverse.org/
timsgardner 2020-10-30T08:25:53.416300Z

Hello, I'm wondering if people have recommendations for a straightforward Clojure request library with reasonable async support, along the lines of axios? I'm looking at https://github.com/dakrone/clj-http, I don't know if that's the current state of the art however. Thanks!

borkdude 2020-10-31T07:48:24.430800Z

@timsgardner I’m reasoning from the perspective of building a GraalVM native image like babashka. Spec doesn’t yield optimal binaries because it has dynamic requires. But this is easy to fix.

mafcocinco 2020-11-02T15:27:22.027Z

I haven’t seen it mentioned here, but we have used aleph with great success so far. https://github.com/aleph-io/aleph

flowthing 2020-10-30T08:30:05.416500Z

Not familiar with Axios, but you might also want to take a look at https://github.com/gnarroway/hato or https://github.com/schmee/java-http-clj for no-dependencies options (if you’re on Java 11+).

borkdude 2020-10-30T08:35:03.417100Z

https://github.com/http-kit/http-kit

timsgardner 2020-10-30T08:41:41.417500Z

Thanks! I'll check those out

borkdude 2020-10-30T08:43:27.417700Z

@timsgardner since httpkit is part of babashka, you can also use it in shell scripts. Btw, I enjoyed the podcast interview on defnpodcast a while ago.

timsgardner 2020-10-30T08:45:10.418Z

oh thanks!

timsgardner 2020-10-30T08:45:58.418300Z

it's funny to be getting back into normal JVM clojure, I've just been in the Arcadia pocket universe for years

timsgardner 2020-10-30T08:47:04.418500Z

I was trying to scrape the Notion API in python and I got really frustrated with the REPL experience. So here I am

timsgardner 2020-10-30T08:48:18.418900Z

Have you used Aleph at all? I was looking at it because I like Zach's libs, it does seem more complicated than http-kit in some ways

borkdude 2020-10-30T08:48:48.419100Z

I've mostly used Aleph server, but I've also used the client. It works

dharrigan 2020-10-30T11:04:53.419500Z

I use clj-http and it supports async operations. Works great.

mpenet 2020-10-30T11:11:02.419700Z

starting to use jdk11 client more and more, it's really good

mpenet 2020-10-30T11:13:12.419900Z

had problems with both aleph/http-kit in the past. It was a long time ago for http-kit so maybe it's better now not sure. And aleph the fact it's in life-support + some deadlocks we had makes me reconsider its use

2020-10-30T14:02:07.420800Z

nice little bit of nostalgia courtesy of @technomancy and you two. :)

borkdude 2020-10-30T14:03:33.421100Z

I'm honoured to finally meet the person behind the name :)

rutledgepaulv 2020-10-30T14:04:46.421300Z

i've also had problems with aleph and http-kit and so would recommend clj-http.. unfortunately http-kit doesn't support true response streaming, it buffers the entire response into a byte array regardless of what you request: https://github.com/http-kit/http-kit/issues/90

rutledgepaulv 2020-10-30T14:05:36.421600Z

I keep hoping someone will remake a clj-http library on top of OkHttp 🙂. maybe one day I can

2020-10-30T14:11:35.421900Z

🙂 thank you! I’m honored and happy to meet you! Thanks so much for your work and initiative in producing such useful and clever tools for us.

borkdude 2020-10-30T14:13:52.422100Z

I wonder why the problem in httpkit isn't fixed yet. One should maybe be able to pass in an object that is compatible with http://clojure.java.io which the response gets written to, without keeping it all in memory. That's the approach I took with babashka/process: https://github.com/babashka/process

rutledgepaulv 2020-10-30T14:21:22.422500Z

Yeah I'm not sure why but it's one of the main reasons I never use it. Anyone have experience reports with https://github.com/schmee/java-http-clj ?

mpenet 2020-10-30T14:57:43.422800Z

it's quite similar to hato, both are very minimalistic, the java api is not bad at all.

mpenet 2020-10-30T14:58:36.423Z

hato I think is somewhat compatible with clj-http api

mpenet 2020-10-30T14:59:27.423200Z

I wrote a super thin wrapper for it as well with our specifics, interceptors at the bottom etc (not on gh for now)

borkdude 2020-10-30T16:22:59.424300Z

I kind of regret having to make choices of what goes into babashka (right now it contains httpkit since it worked really well with GraalVM), but the Java 11 client space doesn't seem to have a clear winner yet. The java-http library seems simple enough to copy paste and base a babashka.http-client namespace on though, maybe in the future.

borkdude 2020-10-30T16:24:06.424500Z

hato really didn't work well with GraalVM, since it has all kinds of dynamic require things. the java-http lib pulls in spec in the core namespace which also isn't great, but at least that's easy to get rid off

mpenet 2020-10-30T16:31:38.424700Z

yeah it copied some of this stuff from clj-http I think

mpenet 2020-10-30T16:31:55.424900Z

not a fan of dynamic requires either, but I understand the intention

mpenet 2020-10-30T16:32:08.425100Z

(clj-http compatiblity)

mpenet 2020-10-30T16:32:25.425300Z

aleph does more or less the same

borkdude 2020-10-30T16:33:17.425500Z

btw, not async, but I have a very light weight clj-http like wrapper around curl: https://github.com/borkdude/babashka.curl

mpenet 2020-10-30T16:33:40.425900Z

I ll see if we could make the repo for our client public eventually

mpenet 2020-10-30T16:35:09.426200Z

one cool thing it does is not assuming input/output formats, everything is wired via an interceptor chain, you can use ring1, ring2, or just pain protocol fns depending on the interceptor chain you use with the client. So you can be extremely minimal / low overhead if you need to, or inject some crazy behavior to the chain if you need to

borkdude 2020-10-30T16:35:30.426400Z

@mpenet Interested in seeing that

mpenet 2020-10-30T16:36:19.426600Z

I ll see on monday if I can have it open

unbalanced 2020-10-30T19:32:06.427300Z

I wear that cone all the time 🌀 @markbastian