This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-06-28
Channels
- # announcements (5)
- # babashka (7)
- # beginners (46)
- # biff (28)
- # calva (7)
- # cider (3)
- # clerk (82)
- # clj-commons (9)
- # clj-kondo (7)
- # clojure (37)
- # clojure-dev (16)
- # clojure-europe (18)
- # clojure-norway (7)
- # clojurescript (8)
- # clojureverse-ops (3)
- # cursive (5)
- # datomic (4)
- # emacs (20)
- # exercism (2)
- # lsp (58)
- # off-topic (32)
- # polylith (11)
- # reitit (7)
- # tools-build (7)
- # xtdb (4)
Hi A simple question about running a set of functions :
(defn apply-all [data]
(apply-role)
(apply-objectgroups data)
(apply-usergroups data)
(apply-permissions data)
(apply-users data)
(apply-user-to-usergroups data))
What I am finding is the first one runs, the subsequent ones run but don't evaluate their internals and the last one runs completely.
How do I get them all to run - internally they are calling rest calls?My suspicion is that your functions return lazy sequences, that are not realized since they are never inspected. This would happen if you're using map
or for
to perform side-effects, for instance. If that is the case, then doseq
is a good option for iterating over side-effecting code.
You might prefer https://clojuredocs.org/clojure.core/dorun if you don't plan to use the sequences returned by doseq
. It may not matter much in your case but where those sequences are large it makes a big difference. dorun
doesn't "retain the head" of the sequence, so each iteration is used once and then dropped so it can be garbage collected efficiently. (I sort of feel using doseq
without explicitly making use of the returned sequence should also allow each iteration to garbage collect well but that's much more difficult to reason about or prove!)
Yes, dorun
or run!
are best when you want to iterate for side-effects only and don't use the return value at all
> "Repeatedly executes body (presumably for side-effects) with > bindings and filtering as provided by \"for\". Does not retain > the head of the sequence. Returns nil."
You can also avoid sequence functions altogether and use eager functions like: mapv reduce any of the transducer arity loop/recur
Where are some good libraries or templates for writing ReST APIs in Clojure? Connect to Datomic, store some records, pull some records, etc. Bootstrapping a greenfield project here.
jetty web server, reitit+malli for routing, web handling and schema validation, Component for lifecycle management, aero for configuration
Not the smallest template or set of concepts to buy into but it could repay the investment? https://github.com/furkan3ayraktar/clojure-polylith-realworld-example-app

#biff is another option for a more full-stack template: https://biffweb.com/ Some of the built-in components rely on XTDB, but it wouldn't be that hard to modify to use Datomic instead It also uses jetty, ring, reitit, and malli
My Clojure North 2020 https://github.com/markbastian/clojure-north-2020’s final example uses REST/Swagger, Datahike (another datalog variant — would be easy to change to Datomic), Jetty web server, and Integrant to tie it all together.

Probably more of a java question than a clojure question but just in case: I am writing a CLI program that attempts to read the deps.edn
in the directory where the program is run. In manual testing (create a jar and then run it from various directories), it works, but I'd like to have an automated way to test that functionality. I see on Stack Overflow that there's no way to "cd" aka change the current working directory from within a Java process, but is there a clever way of saying in a test, "for the duration of this test/call, act as if the whole program is running in a temporary directory"?
I have helper functions and macros that can create temporary directories and files, the issue is making the test runner think "i'm in this specific directory", so calling (io/file "deps.edn")
sees the file in the temporary directory
I could, but I was hoping for something slightly less brittle. Maybe that would be fine, just makes me feel like I'm playing with fire
The boring answer is to make pwd
an argument. (System/getProperty "user.dir")
can be understood as a "side cause", those are best pushed to the boundaries of your program
Is there such a thing as a drop-in (saas?) Maven caching proxy? I have a tooling project which tests must hit Maven each time. Because it has many tests / multiplied by a CI matrix, I suspect the flakiness I'm seeing has more to do with rate limiting (unlikely to see for normal user loads) than anything else.
The best I can think of is setting up your own maven “repository” by starting up a webdav server in a container and making dummy credentials that allows leiningen et al to GET, PUT, and MKCOL as it wishes
at some point in time I had a webdav server as a private maven repository with apache2… if you’re interested, i can eventually dig up the configuration files. shouldn’t be hard to containerize it and run it in CI
Interesting. the key part is that it should be a proxy, e.g. if artifact foo is not found, query it in Central / Clojars Perhaps such an offering doesn't exist...
There are several drop in proxies
@U45T93RA6, I learned a bit, not much, but a bit, about Sonatype nexus as a cache https://github.com/clj-commons/pomegranate/issues/107
Did you consider the :local-repo
option in Lein (deps have a similar option)? There might be a special path on your machine that holds m2 artefacts, and you can install Clojure packages there. This folder would act like a cache. Not sure if it solves your problem, but just an idea.
You can even share that folder in CI across various steps/builds, and save the traffic.
Nice! @UE21H2HHD’s example seem much handy. Although I was surprised to find no good google hits for <Sonatype Nexus || JFrog Artifactory> + <circleci | github actions>
github actions can be set up to use specialized Maven settings, which I presume could use a Maven proxy (although not sure how that works when using it on github). The github java action lets you easily set up Maven repo caching which is kind of the norm.