This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-09-01
Channels
- # announcements (6)
- # atom-editor (4)
- # babashka (59)
- # beginners (51)
- # bristol-clojurians (6)
- # calva (5)
- # cider (22)
- # clara (6)
- # cljfx (28)
- # clojure (182)
- # clojure-australia (1)
- # clojure-berlin (1)
- # clojure-dev (21)
- # clojure-europe (12)
- # clojure-italy (8)
- # clojure-nl (7)
- # clojure-norway (13)
- # clojure-uk (20)
- # clojurescript (2)
- # code-reviews (24)
- # conjure (9)
- # cursive (9)
- # datomic (35)
- # defnpodcast (45)
- # fulcro (18)
- # graalvm (3)
- # graphql (1)
- # hugsql (1)
- # jobs (3)
- # jobs-discuss (2)
- # klipse (1)
- # leiningen (1)
- # malli (5)
- # membrane (4)
- # off-topic (7)
- # portal (2)
- # reitit (30)
- # remote-jobs (1)
- # rewrite-clj (5)
- # ring (2)
- # shadow-cljs (25)
- # test-check (2)
- # tools-deps (5)
- # vrac (26)
- # xtdb (17)
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!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]}]
Maybe @alekcz360 knows a proper solution to this?
./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 \"\")))"
@alekcz360 That's already been done in babashka.impl.http_kit.clj
@alekcz360 https://github.com/borkdude/babashka/blob/5a28a8ac51808cfeb11be5e0a7174bd3d3cf8852/src/babashka/impl/http_kit.clj#L8
@alekcz360 You can run this locally from the bb repo as follows:
clojure -m babashka.main "@(org.httpkit.client/get \"\")"
@borkdude It worked when running locally. I'll investigate more tomorrow. Going afk for the evening.
Yes, note that it works as is, but not when you uncomment the alter-var-root line :)
Upgrading to AdoptOpenJDK 11.0.8 worked! https://github.com/http-kit/http-kit/issues/440
Thanks @borkdude for creating a great tool! https://www.karimarttila.fi/clojure/2020/09/01/using-clojure-in-command-line-with-babashka.html
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
I updated the README a bit: https://github.com/borkdude/babashka#built-in-namespaces
But I do get your point: Python has a much bigger library ecosystem, no argument there :)
Thanks for your nice blog. Are you going to share it anywhere? Reddit / Twitter, etc?
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!
Changed the text regarding Babashka built-in namespaces. Thanks for the feedback!
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
Ok. Good to know. I'll use the library support for sql next time!
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 :)
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
Sure. Happy to share the awesome stuff you and @U1G869VNV have made 🙂
To be honest I hadn't used clojure.datafy that much myself, but I'm mind blown now ;)
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
I wasn't aware of the metadata on that and I think you need to turn this on explicitly, it's probably not currently
Even if there is metadata support, not sure this would work because the metadata it puts on are protocol fns
Example metadata:
#:clojure.core.protocols{datafy #object[next.jdbc.result_set$navize_row$fn__17145 0x4c1ea0ab "next.jdbc.result_set$navize_row$fn__17145@4c1ea0ab"]}
we could hack around that by representing the function using a name, but if it's a closure then that won't work
if everything was in babashka itself, it would work. I'm partial about including only postgres, but we could
https://github.com/seancorfield/next-jdbc/blob/97332c1a1a7f7b630d9909ff05fe8928cc644d62/src/next/jdbc/datafy.clj#L126-L152 is one place where datafy support is added
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
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]
@U088NU894 Are you using bb 0.2.0?
Works now! (did a brew update
before testing ... should have done a brew upgrade babashka
:face_palm::skin-tone-3: )
Also works for json or transit. Thanks for sharing @cldwalker