babashka-sci-dev

cap10morgan 2022-04-06T18:51:27.029179Z

@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!

cap10morgan 2022-04-06T18:51:43.394989Z

... which boxes does https://github.com/schmee/java-http-clj not tick?

cap10morgan 2022-04-06T18:52:33.622079Z

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

borkdude 2022-04-06T18:52:50.527559Z

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

borkdude 2022-04-06T18:52:58.471969Z

i.e. you can run it as a dependency

cap10morgan 2022-04-06T18:53:13.498159Z

great!

cap10morgan 2022-04-06T18:53:36.474119Z

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

borkdude 2022-04-06T18:55:25.412669Z

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

cap10morgan 2022-04-06T18:56:12.823859Z

b/c that paragraph from the book says you might

cap10morgan 2022-04-06T18:56:17.924849Z

that I pasted above

borkdude 2022-04-06T18:56:45.415299Z

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

borkdude 2022-04-06T18:57:05.008799Z

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

borkdude 2022-04-06T18:57:17.198559Z

as part of https://github.com/clj-easy/tools.misc

borkdude 2022-04-06T18:58:05.473649Z

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

cap10morgan 2022-04-06T18:58:27.010839Z

I see

borkdude 2022-04-06T18:58:57.624189Z

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

cap10morgan 2022-04-06T18:59:20.944749Z

yeah, it's a great idea

borkdude 2022-04-06T19:00:01.711279Z

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

cap10morgan 2022-04-06T19:01:17.019329Z

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.

borkdude 2022-04-06T19:01:45.688679Z

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

cap10morgan 2022-04-06T19:01:56.785139Z

yeah I'll probably do that

borkdude 2022-04-06T19:25:26.840969Z

@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
borkdude 2022-04-06T19:34:11.069009Z

@cap10morgan Here's a demo of clj-easy.tool.json in bb: https://github.com/clj-easy/tools.misc/discussions/2#discussioncomment-2518657

👀 1
😍 1