This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-01-19
Channels
- # aws-lambda (1)
- # babashka (3)
- # beginners (97)
- # cider (20)
- # clojure (9)
- # clojure-spec (8)
- # clojure-uk (9)
- # clojurescript (25)
- # core-async (2)
- # cryogen (7)
- # cursive (4)
- # fulcro (9)
- # graalvm (14)
- # graphql (8)
- # luminus (2)
- # off-topic (18)
- # pathom (3)
- # re-frame (1)
- # reagent (4)
- # shadow-cljs (36)
- # spacemacs (1)
- # vscode (2)
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(https://github.com/stuartsierra/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. https://github.com/markbastian/conj2019
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
clojure.lang.Agent/pooledExecutor]]
(.shutdown e)
(when-not (.awaitTermination e 5 java.util.concurrent.TimeUnit/SECONDS)
(log/debug "forcing" e)
(.shutdownNow e))))