Fork me on GitHub
#babashka
<
2021-08-25
>
grzm14:08:17

@borkdude Any thoughts on adding the java.net.Http* packages introduced in JDK 11 to babashka? Working with them in Clojure is quite nice, and would provide a method of doing http requests without additional dependencies. babashkalorians can then use their own simple wrappers if desired—in the spirit of http-kit but without buying into http-kit’s idiosyncrasies.

dpsutton14:08:33

> babashkalorians 😱

🙀 6
🚀 6
borkdude14:08:19

@grzm Yes, worth considering and perhaps in favor of the httpkit client at some point? In an early version I've tried out hato as a built-in client but it bloated the image considerably. Just adding the vanilla classes might work, but it remains to be seen how much the image grows. Worth a shot though, if you would like to experiment with this.

borkdude14:08:02

I think the httpkit client works pretty well for most things though and it was a really tiny increase in image size for both the client and server

grzm14:08:12

I tend to write a lot of cljc babashka, and the clj version of http-kit has quite a few warts that we don’t like to work with in our clj code.

grzm14:08:39

I’m sympathetic to the bloat issue, though, so I hear you there. Which is why I floated the question 🙂

borkdude14:08:50

yes, just make a PR with those classes added

borkdude14:08:58

and then we can inspect the image growth in #babashka-circleci-builds

grzm14:08:18

Cool. I got some learnin’ to do then 🙂 Thanks for the feedback!

borkdude14:08:19

it's not that hard: you can just add the classes you need to babashka.impl.classes.clj

borkdude14:08:25

and that's pretty much it

👍 3
borkdude14:08:45

there are some issues with the http client

borkdude14:08:49

httpkit one

borkdude14:08:55

as in it doesn't properly support streaming etc

borkdude14:08:09

so adding the java 11 one will at least make that future proof

borkdude14:08:03

one of the problems with adding an off-the-shelf clojure java 11 client is that there is no one popular canonical client yet

borkdude14:08:11

so adding the bare classes might be good to start with

grzm14:08:26

Indeed. That's my thinking, too. (I also think the clojure clients tend to try to do too much and as a result end up being more opinionated than I like. But that's a taste thing.)

borkdude14:08:09

the same issue with java.time

borkdude14:08:20

that's why we just added java.time directly in bb

💯 3
grzm14:08:44

Most of the concrete implementations of the http://java.net.http.* stuff are hidden inner classes (the interfaces and builders are what is exposed as the API). Is there anything I need to keep in mind for babashka.impl.classes.clj ?

borkdude15:08:23

these inner classes are referred to using the dollar signs

grzm15:08:25

Yeah. Guess I'll just find out 🙂

borkdude15:08:37

write some tests as well then :)

grzm15:08:22

Okay, that'll have to wait until later today 🙂 Thanks again for the assistance!

schmee15:08:23

might be worth a shot, have no idea if it will be bigger or smaller than Hato when it comes to image size

borkdude15:08:38

@U3L6TFEJF I have seen it, but the dependency on spec may be trouble-some with image size.

schmee15:08:54

hmm… I’d be happy to try to find a solution to that. would it work if I just remove the dependency on spec? spec is bundled with Clojure so it should work anyway, right?

borkdude15:08:55

as spec uses lazy-load stuff which isn't graalvm friendly

borkdude15:08:30

In general I think it helps when you move the specs to a different namespace and also the loading of spec itself

borkdude15:08:35

so users can optionally load it

schmee15:08:17

right, I’d have to think about that a bit

schmee15:08:23

maybe I should just get rid of the specs entirely

schmee15:08:37

I prefer Malli these days anyway ¯\(ツ)

borkdude15:08:04

just moving them to some other namespace should do the trick

schmee15:08:24

ahh, just saw the wiki page you linked above, didn’t know you’ve already created a test branch with it, nice 😄

schmee15:08:40

I can def move the specs to a separate namespace if you’re interested in moving forward with this

borkdude15:08:10

That would help general graalvm usage of your library so regardless of if babashka is going to use it, I'd do it :) There is still this consideration: > one of the problems with adding an off-the-shelf clojure java 11 client is that there is no one popular canonical client yet But if we added those classes to bb, then we could perhaps try to make your library work from source in bb

👍 3
borkdude15:08:04

There is also the telex client which is similar to yours I think but has some interceptor stuff

borkdude15:08:46

So choosing one off the shelf is a bit hard. Perhaps starting with your client and vendor it as babashka.http-client can work as well

schmee15:08:57

understandable! I intentionally didn’t mimic the clj-http API in my client, which might be a drawback for this use-case since that’s what most other clients do

schmee15:08:42

I’ll see about moving the specs to a separate namespace, if you want to use it for something then that’s awesome, if not that’s no problem at all 😄

borkdude15:08:50

I'll keep an eye out, I've seen several people use your lib, so I do think it's a good option :) Just needs some hammock time

🎉 3
bherrmann20:08:47

along these lines, is there anything handy for decoding GET's url parameters?

bherrmann20:08:39

At the moment, I am using this - which is pretty stinky.

(def url-parameter-of get "%7B%0D%0A%0D%0A++%22address%22%3A+%7B%0D%0A++++%22city%22%3A+%22Boston%22%2C%0D%0A++++%22country%22%3A+%22USA%22%2C%0D%0A++++%22postalCode%22%3A+%2202123%22%2C%0D%0A++++%22state%22%3A+%22MA%22%2C%0D%0A++++%22stre")

(-> url-parameter-of-get
    (str/replace "+" " ")
    (str/replace "%2C" ",")
    (str/replace "%0D" "")
    (str/replace "%0A" "")
    (str/replace "%7B" "{")
    (str/replace "%3A" ":")
    (str/replace "%22" "\"")
    )

escherize00:08:18

This is genius in a way

borkdude20:08:49

@bherrmann

(java.net.URLDecoder/decode url)

bherrmann20:08:49

Thats way better. I thought I tried it and thought that class wasnt there bUt I mUst have MisTyped it. THANKS!

😄 3