This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-05-01
Channels
- # aws (1)
- # beginners (237)
- # boot (2)
- # calva (6)
- # cider (16)
- # clara (10)
- # clj-kondo (1)
- # cljs-dev (24)
- # clojure (29)
- # clojure-brasil (2)
- # clojure-dev (20)
- # clojure-europe (1)
- # clojure-italy (56)
- # clojure-japan (1)
- # clojure-nl (16)
- # clojure-spec (12)
- # clojure-uk (12)
- # clojurescript (24)
- # clojureverse-ops (3)
- # core-async (3)
- # cursive (21)
- # datascript (5)
- # datomic (82)
- # devops (5)
- # duct (14)
- # emacs (2)
- # fulcro (2)
- # jobs (6)
- # juxt (7)
- # kaocha (6)
- # leiningen (19)
- # luminus (3)
- # nrepl (51)
- # off-topic (208)
- # other-languages (1)
- # re-frame (8)
- # reagent (9)
- # remote-jobs (6)
- # shadow-cljs (37)
- # spacemacs (6)
- # testing (12)
- # tools-deps (25)
This channel still work?
For me it looks like you should create your component, which will connect / disconnect to database on init / halt
You should also note https://github.com/metabase/toucan/issues/42
Looks like toucan prefers to set global default connection and then all functions will use it.
So, one of the ways is like this
clojure
(ns foo.database.toucan
(:require [toucan.db :as db]))
(defmethod ig/init-key :foo.database/toucan [_ options]
; the options are
; {:classname "org.postgresql.Driver"
; :subprotocol "postgresql"
; :subname "//localhost:5432/my_db"
; :user "cam"}
(db/set-default-db-connection! options))
(defmethod ig/halt-key! :foo.database/toucan [_ {:keys [spec]}]
;; somehow close connection, probably should look into toucan / clojure.java.jdbc
)
The problem with connection closing is that duct workflow includes reloading the system, and when the system reloads you should, probably, close old connections.
For connection pools it might be easier, because connection pool will be component by itself.
But there’s other issue with toucan — the default db connection is an implicit dependency, and duct / integrant style prefers explicit dependencies.
Issue https://github.com/metabase/toucan/issues/42 contains a general description of explicit dependency usage.