This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-03-01
Channels
- # announcements (26)
- # babashka (58)
- # bangalore-clj (1)
- # beginners (48)
- # bitcoin (1)
- # chlorine-clover (9)
- # clara (7)
- # clj-kondo (11)
- # cljs-dev (10)
- # cljsrn (36)
- # clojars (11)
- # clojure (161)
- # clojure-europe (39)
- # clojure-italy (2)
- # clojure-nl (6)
- # clojure-uk (14)
- # clojured (1)
- # clojurescript (38)
- # conjure (25)
- # core-async (18)
- # cursive (19)
- # datascript (9)
- # datomic (11)
- # emacs (10)
- # events (2)
- # figwheel-main (2)
- # fulcro (44)
- # funcool (5)
- # girouette (1)
- # graalvm (6)
- # jobs (1)
- # lsp (93)
- # malli (3)
- # membrane (3)
- # off-topic (17)
- # pedestal (2)
- # polylith (12)
- # re-frame (2)
- # remote-jobs (1)
- # shadow-cljs (47)
- # specter (2)
- # startup-in-a-month (1)
- # tools-deps (4)
humdum, realising that asking this before doing any amount of study 😄, but does integrant work with babashka? 🙂
There is a list of projects that are known to work and integrant is not on it https://github.com/babashka/babashka/blob/master/doc/projects.md
First obstacle:
user=> (require '[integrant.core :as ig])
java.lang.Exception: Could not find namespace: clojure.spec.alpha. [at integrant/core.cljc:3:3]
0% cat deps.edn
{:deps {integrant/integrant {:mvn/version "0.8.0"}}
:paths ["resources"]}
kimmoko@paju ~/work/bb-integrant
0% export BABASHKA_CLASSPATH=$(clojure -Spath)
kimmoko@paju ~/work/bb-integrant
0% echo $BABASHKA_CLASSPATH
resources:/Users/kimmoko/.m2/repository/integrant/integrant/0.8.0/integrant-0.8.0.jar:/Users/kimmoko/.m2/repository/org/clojure/clojure/1.10.1/clojure-1.10.1.jar:/Users/kimmoko/.m2/repository/weavejester/dependency/0.2.1/dependency-0.2.1.jar:/Users/kimmoko/.m2/repository/org/clojure/core.specs.alpha/0.2.44/core.specs.alpha-0.2.44.jar:/Users/kimmoko/.m2/repository/org/clojure/spec.alpha/0.2.176/spec.alpha-0.2.176.jar
kimmoko@paju ~/work/bb-integrant
0% bb
Babashka v0.2.10 REPL.
Use :repl/quit or :repl/exit to quit the REPL.
Clojure rocks, Bash reaches.
user=> (require '[integrant.core :as ig])
clojure.lang.ExceptionInfo: Could not resolve symbol: clojure.lang.Compiler/demunge [at clojure/spec/alpha.clj:128:16]
the previous paste already had some hacksah, spec is tracked on https://github.com/babashka/babashka/issues/558
@U06QSF3BK You can maybe use spartan.spec
as a standin
Instead of clojure.lang.Compiler/demunge
they should probably use demunge
from:
(require '[clojure.main :refer [demunge]])
which works with bb0% cat deps.edn
{:deps {integrant/integrant {:mvn/version "0.8.0"}
borkdude/spartan.spec {:git/url ""
:sha "e5c9f40ebcc64b27b3e3e83ad2a285ccc0997097"}}
:paths ["resources"]
:aliases {:remove-clojure {:classpath-overrides {org.clojure/clojure nil
org.clojure/spec.alpha nil
org.clojure/core.specs.alpha nil}}}}
kimmoko@paju ~/work/bb-integrant
0% cat
(require 'spartan.spec)
(require '[integrant.core :as ig]
'[org.httpkit.server :as server]
'[ :as io])
(defn app [_req]
{:status 200
:body "Hello from Babashka!"})
(defmethod ig/init-key :system/handler [_ _]
app)
(defmethod ig/init-key :system/http-server [_ {:keys [port ip]}]
{:stop-fn (server/run-server app
{:port port
:ip ip})})
(defmethod ig/halt-key! :system/http-server [_ {:keys [stop-fn]}]
(stop-fn))
(let [config (ig/read-string (slurp (io/resource "config.edn")))
system (ig/init config)]
(println "System started, press enter to exit")
(.read System/in)
(ig/halt! system)
(println "System stopped"))
kimmoko@paju ~/work/bb-integrant
0% cat resources/config.edn
{:system/http-server {:port 1234
:ip "127.0.0.1"
:handler #ig/ref :system/handler}
:system/handler {}}
wrote https://github.com/babashka/babashka/issues/743, and while writing, realised that I used that remove-clojure
alias
ah, that's tracked on https://github.com/babashka/babashka/issues/241
@adam.james btw, the remove-clojure alias is also a solution to your uberscript problem with spartan.spec:
:aliases {:remove-clojure {:classpath-overrides {org.clojure/clojure nil
org.clojure/spec.alpha nil
org.clojure/core.specs.alpha nil}}
but I've adapted the README to how to best load spartan.spec to make it compatible with uberscript
Oh, thanks for the tip! I'll have to try this soon :)
👋 I’m trying to create a Web app with Babashka and I’m running into a problem inserting into a PostgreSQL array column with the PostgreSQL pod.
I’m having trouble debugging this problem and I don’t have a lot of time so I’m considering dropping the pod, adding a JVM to my server environment, and switching to using babashka.deps
to download and utilize the full-blown jdbc.next
and standard PostgreSQL JDBC driver. (I was already considering doing so, in order to use Compojure and Ring.) Before I take the time to do that, I thought I’d ask if anyone has any suggestions?
Links: https://gist.github.com/aviflax/f804c40e1ae823e7ce9e2c3766f75f53, https://github.com/aviflax/availability.help/blob/95caba1e7f3e1b9282e0cdb0ed8f2ae1daf89939/web/server.bb#L242
Thanks!
@aviflax Hey hey! The current workaround for this (and json
and jsonb
) is to convert it to ::text
and then convert it to something else in Clojure.
@aviflax There is an issue here: https://github.com/babashka/babashka-sql-pods/issues/7 What would be the sane thing to do here? Convert to a vector automatically? Same for json/jsonb -> Clojure?
I get the select
as ::text
part, but that doesn’t (seem to) address how to insert
.
That said, now that I’m thinking about this with a fresher mind (rather than at midnight last night) I think I’m being perfectionist here, in my very specific use case right now. I can just change this column to text
, store a comma-delimited string value, and get on with it. It’ll suffice.
I think I’ll proceed with that, unless there is some quick workaround for inserting into a Postgres array column.
BTW am I missing something, or do I indeed need a JVM and need to use babashka.deps
if I want to use Ring and Compojure in a bb script?
ah, inserting a vector you mean? yeah we could also automatically convert that into a pg array on the pod side, feel free to comment in the same issue
about ring and compojure: if there is ring middleware that happens to work from source, you can add this as a dep. compojure doesn't work from source right now I believe (since it has a dependency on instaparse?)
You can build a small router from core.match, that might help: https://gist.github.com/borkdude/1627f39d072ea05557a324faf5054cf3
@aviflax I think the insert problem will solve itself if we switch the pod format to transit which can cope with serializing arrays
For retrieving array we still need to do something, as described here: https://github.com/seancorfield/next-jdbc/blob/develop/doc/tips-and-tricks.md#working-with-arrays
well no a few more, instead of EDN we need to use transit, but should be relatively small change
I have a pod using transit already here: https://github.com/babashka/pod-babashka-buddy
What do you think, will it be possible to run #reveal (using JavaFX) via bb? Though at that point I can perhaps just start clj because it will not be that fast anyway...
You could try https://github.com/djblue/portal if you wanted to inspect data from bb
Ah, thanks!
Yeah, building a small web-app on top of httpkit is probably a better approach for bb than javafx :)