Fork me on GitHub
#babashka-sci-dev
<
2022-04-06
>
cap10morgan18:04:27

@borkdude In reference to this from the babashka book:

In the future babashka (1.0.0?) may come with an HTTP client based on the JVM 11 java.net.http package that ticks all the boxes (async, HTTP/2, websockets, multi-part file uploads, sane memory usage) and is a suitable replacement for all of the above options. If you know about a GraalVM-friendly feature-complete well-maintained library, please reach out!

cap10morgan18:04:33

I'm thinking we may need that best-of-both-worlds option beyond curl & http-kit soon for our lambdas

borkdude18:04:50

java-http-clj is already compatible from source with bb :)

borkdude18:04:58

i.e. you can run it as a dependency

cap10morgan18:04:36

is that a candidate for inclusion in bb soon then? (just curious)

borkdude18:04:25

why would we include it if you can already run it?

cap10morgan18:04:12

b/c that paragraph from the book says you might

cap10morgan18:04:17

that I pasted above

borkdude18:04:45

I didn't anticipate that we would include the full java.net.http classes, but we now did

borkdude18:04:05

I am planning to work on an http client solution that is more general and can be swapped out with other implementations

borkdude18:04:05

so then you can say: hmm, bb uses clj-easy.tools.http-client with java-http-clj as the backing implementation, but in our app we want to use httpkit, so then it's just a matter of swapping out the implementations while programming against the same API

borkdude18:04:57

I wish I'd done that from the start, so I could freely choose between e.g. cheshire or jsonista or clojure.data.json as the json lib in bb for example, without exposing that

cap10morgan18:04:20

yeah, it's a great idea

borkdude19:04:01

what is it that you think are the best parts from bb.curl + httpkit? input for that API is surely welcome

cap10morgan19:04:17

I'm proxying an API w/ one of my lambdas, so it's going to be a mix of their two sweet spots (i.e. lots of small reqs for http-kit and some large reqs for curl). so having something that can handle both well would be ideal. so less API and more behavior.

borkdude19:04:45

you might just want to go with java.net.http directly then maybe or via that lib?

cap10morgan19:04:56

yeah I'll probably do that

borkdude19:04:26

@cap10morgan The overhead of loading that lib is pretty tiny:

$ bb -e '(babashka.deps/add-deps (quote {:deps {java-http-clj/java-http-clj {:mvn/version "0.4.3"}}})) (time (require (quote [java-http-clj.core :as http])))'
"Elapsed time: 14.39565 msecs"

👍 1