Fork me on GitHub

Hello everyone! I’m starting to work with clojure, and I’m having some questions about project organization, I have a project with compojure and monger, how to you usually organize the files? How do I handle the database connection among the application? Do I have to connect on every request or do I connect on application start and reuse the connection?


Use some kind of connection pool (for sql databases that would be something like c3p0). For namespace organization prefer more namespaces to fewer. Split your namespaces as they grow. A few hundred lines is a pretty nice size for a namespace, but sometimes they are a few thousand. For runtime state use something like component(


mark bastian's most recent conj talk might be worth examining - there is an associated repository with example code bringing various pieces together. he used integrant - which some might say is component-like.


Hi folks, hope you're all well. I just spent the better part of a day debugging an Agents problem (and learning a lot in the process)... Is there any natural way to add a timeout to clojure.core/shutdown-agents? I needed to resort to this:


(doseq [^ExecutorService e [clojure.lang.Agent/soloExecutor
  (.shutdown e)
  (when-not (.awaitTermination e 5 java.util.concurrent.TimeUnit/SECONDS)
    (log/debug "forcing" e)
    (.shutdownNow e))))


No, but you can use (await) with a timeout


(await-for timeout-ms & agents)


oh thank you. my specific use case is in shutting down cljfx gracefully and i don’t think i have direct access to its agents for that argument. maybe (on-fx-thread (await-for...))


i’m so dumb, had effectively been trying to shutdown-agents from within an agent thread... fixed with simple (.start (Thread. shutdown-agents))