https://graalworkshop.github.io/2021/ ^ babashka talk at this conference
I came across https://practicalli.github.io/clojure/clojure-tools/data-browsers/ using data browsers inside a clojure project. I was wondering if this also would be possible when using BB?
It should be possible: From here: https://practicalli.github.io/clojure/clojure-tools/data-browsers/reveal.html > Use Reveal with https://practicalli.github.io/clojure/clojure-tools/data-browsers/reveal.html#using-reveal-in-a-terminal, a https://practicalli.github.io/clojure/clojure-tools/data-browsers/reveal.html#using-reveal-with-nrepl-editors, such as Emacs Cider and Spacemacs. Reveal can be added as a tap source to any running REPL, eg. using https://practicalli.github.io/clojure/clojure-tools/data-browsers/reveal.html#using-reveal-with-rebel-and-tap. And here: https://book.babashka.org/#repl
@marco.pasopas Try portal:
(require '[babashka.deps :as deps])
(deps/add-deps '{:deps {djblue/portal {:mvn/version "0.9.0"}}})
(require '[portal.api :as p])
(.addShutdownHook (Runtime/getRuntime)
(Thread. (fn [] (p/close))))
(p/open)
(p/tap)
(tap> [1 2 3])
@(promise)
The (tap> [1 2 3])
call is where you send data to portal and it will display it
@djblue Is the shutdown hook still needed or is this included by portal itself now? ^
You can also do this "one-liner" to view e.g. an EDN file:
$ cat deps.edn | bb -e "(babashka.deps/add-deps '{:deps {djblue/portal {:mvn/version \"0.9.0\"}}})" \
-e "(require 'portal.main)" \
-e "(portal.main/-main \"edn\")"
Not if you call portal.main 😄
ah
it seemed portal shut down correctly when I pressed ctrl-c in the above snippet
oh yeah, I get your point now
@jayzawrotny Now release 0.0.2 with static linux versions: https://github.com/babashka/babashka-sql-pods/releases/tag/v0.0.2
Awesome! Testing it now with my cgi script
… and it worked! 🚀
Out of curiosity would it have been possible to uberjar the jdbc + postgresql driver? When should a pod be chosen over creating an uberjar?
@jayzawrotny babashka doesn't run a JVM so just a postgres driver doesn't work.
I see so the pod is a specific package written for babashka where as an uberjar is suited for cross-platform or already babashka friendly code?
right
a pod can be written in any language, as long as it offers the API in a certain format. a pod is basically another CLI that acts as a service
Messages go back and forth in EDN, JSON or transit. So all the function args you use have to be either pure data, or there has to be some magic to represent objects as data. E.g. we represent db connections or transactions by an id that is sent back and forth.
Ahh good to know, and sounds like a pretty powerful\flexible system.