Fork me on GitHub
#babashka
<
2020-09-01
>
borkdude10:09:42

I have a branch http-kit-client now in which I added the http-kit-client.

$ ./bb '(:status @(org.httpkit.client/get ""))'
200
Only a 0.7MB increase for an http client. That doesn't seem too bad!

borkdude10:09:42

I didn't get SNI working. When I did what the README said, I got a NPE:

$ clojure -A:bb-local "@(org.httpkit.client/get \"\")"
{:opts {:method :get, :url ""}, :error #error {
 :cause nil
 :via
 [{:type java.lang.NullPointerException
   :message nil
   :at [sun.net.util.IPAddressUtil textToNumericFormatV4 "IPAddressUtil.java" 49]}]

borkdude10:09:04

Maybe @alekcz360 knows a proper solution to this?

borkdude10:09:40

There are binaries in #babashka_circleci_builds for trying this out btw.

borkdude13:09:37

I guess error handling with http-kit works by checking manually for :error ?

alekcz17:09:00

@borkdude how do I include the SNI client? in bb

alekcz17:09:38

./bb "(require '[org.httpkit.sni-client :as sni-client])
      (require '[org.httpkit.client :as client])
      (:status (binding [org.httpkit.client/*default-client* sni-client/default-client]
          @(client/get \"\")))" 

borkdude17:09:01

@alekcz360 That's already been done in babashka.impl.http_kit.clj

borkdude17:09:12

At least, I tried, but it only works with JDK 1.8

borkdude17:09:37

@alekcz360 You can run this locally from the bb repo as follows:

clojure -m babashka.main "@(org.httpkit.client/get \"\")"

borkdude17:09:41

without compiling first

borkdude17:09:20

afk for a while now

alekcz19:09:12

@borkdude It worked when running locally. I'll investigate more tomorrow. Going afk for the evening.

borkdude20:09:50

Yes, note that it works as is, but not when you uncomment the alter-var-root line :)

borkdude20:09:55

Ah, it does work when I set JAVA_HOME to GraalVM 11!

borkdude20:09:06

but just not with AdoptOpenJDK 11

borkdude17:09:56

Awesome! I'm going to read through it tonight when I'm back at the keyboard!

borkdude20:09:19

I now fully read your blog. Very nice! Babashka does offer some libraries in addition to what is built-in: https://github.com/borkdude/babashka/blob/master/doc/libraries.md

borkdude20:09:39

But I do get your point: Python has a much bigger library ecosystem, no argument there :)

borkdude20:09:07

Thanks for your nice blog. Are you going to share it anywhere? Reddit / Twitter, etc?

kari03:09:44

Thanks for the feedback! I will update the blog article regarding Babashka library support, I missed that page you are referring! I advertised the blog article in my LinkedIn account. I don't use Twitter. But if you feel the blog article is good enough for sharing, please feel free to share it!

kari05:09:56

Changed the text regarding Babashka built-in namespaces. Thanks for the feedback!

borkdude07:09:37

Thanks 🙏 I shared the article on Twitter. On the libraries page there is also a library for psql. Also we have a pod so you can directly use jdbc.next and honeysql with Postgres

kari12:09:18

Ok. Good to know. I'll use the library support for sql next time!

borkdude12:09:15

At one point I had the JDBC driver for PostgreSQL included in babashka, so you could use next.jdbc directly from babashka, but I wasn't sure if this was the right approach, since I maybe would have also include drivers for other databases and this would maybe bloat babashka. But it is still possible to compile babashka with postgres support using a feature flag as well. So, several options. But your basic approach is also valid, whatever works :)

borkdude21:09:59

This is pretty awesome. Inspect a big chunk of edn using clojure.datafy, bb and portal:

$ cat deps.edn | bb -cp `clj -Spath -Sdeps '{:deps {djblue/portal {:mvn/version "RELEASE"}}}'` -m portal.main edn

cldwalker13:09:25

Sure. Happy to share the awesome stuff you and @U1G869VNV have made 🙂

borkdude13:09:15

To be honest I hadn't used clojure.datafy that much myself, but I'm mind blown now ;)

cldwalker13:09:23

Related to datafy, do you know if the pod edn format preserves metadata? I tried some of the https://github.com/babashka/babashka-sql-pods examples but wasn’t seeing any of the metadata next-jdbc puts on its results for datafy

borkdude13:09:40

I wasn't aware of the metadata on that and I think you need to turn this on explicitly, it's probably not currently

cldwalker13:09:44

Even if there is metadata support, not sure this would work because the metadata it puts on are protocol fns

borkdude13:09:59

yeah, I think this doesn't work with pods probably

borkdude13:09:28

well maybe we could make it work

borkdude13:09:38

a pod can also define client side functions

cldwalker13:09:40

Example metadata:

#:clojure.core.protocols{datafy #object[next.jdbc.result_set$navize_row$fn__17145 0x4c1ea0ab "[email protected]"]}

borkdude13:09:52

oh functions

borkdude13:09:19

we could hack around that by representing the function using a name, but if it's a closure then that won't work

borkdude13:09:42

can you point me to the place where next.jdbc attaches that metadata?

borkdude13:09:34

if everything was in babashka itself, it would work. I'm partial about including only postgres, but we could

borkdude13:09:44

it's still available behind a feature flag

borkdude13:09:52

if you compile bb on your own system

cldwalker13:09:58

Forgot about the feature flag. I’ll try that 🙂 I’m definitely not advocating for bloating bb core. It is interesting to see where pod’s limitations are

borkdude13:09:40

I'm very tempted to add postgres support, since it's so cool ;)

borkdude14:09:16

ah yeah, so it's a closure over this

mmz14:09:20

What am I missing? It is a library right? So I don't have to install a pod, correct? cat deps.edn | bb -cp clojure -Spath -Sdeps '{:deps {djblue/portal {:mvn/version "RELEASE"}}}'` -m portal.main edn` clojure.lang.ExceptionInfo: Could not resolve symbol: realized? [at portal/http_socket_server.clj, line 65, column 20]

borkdude14:09:04

@U088NU894 Are you using bb 0.2.0?

borkdude14:09:09

That one is required

mmz14:09:20

let me check ... bb -v ?

borkdude14:09:43

$ bb --version
babashka v0.2.0

mmz14:09:26

Works now! (did a brew update before testing ... should have done a brew upgrade babashka :face_palm::skin-tone-3: )

mmz14:09:36

This is indeed pretty awesome! 👍:skin-tone-3:

borkdude21:09:10

Also works for json or transit. Thanks for sharing @cldwalker