Skip to content

Commit

Permalink
switch to use metadata on query-fn component
Browse files Browse the repository at this point in the history
  • Loading branch information
Yogthos committed Jan 18, 2024
1 parent 2163dad commit f8a94c1
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 19 deletions.
6 changes: 3 additions & 3 deletions build/deps.edn
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,16 @@
cheshire/cheshire {:mvn/version "5.11.0"}
;; kit-quartz
com.troy-west/cronut {:mvn/version "0.2.6"}
io.github.kit-clj/kit-core {:mvn/version "1.0.4"}
io.github.kit-clj/kit-core {:mvn/version "1.0.6"}
;; kit-redis
org.clojure/core.cache {:mvn/version "1.0.225"}
com.taoensso/carmine {:mvn/version "3.2.0"}
;; kit-repl
;; kit-selmer
selmer/selmer {:mvn/version "1.12.59"}
;; kit-sql
io.github.kit-clj/kit-sql-conman {:mvn/version "1.0.8"}
io.github.kit-clj/kit-sql-migratus {:mvn/version "1.0.3"}
io.github.kit-clj/kit-sql-conman {:mvn/version "1.10.0"}
io.github.kit-clj/kit-sql-migratus {:mvn/version "1.0.4"}
;; kit-sql-conman
conman/conman {:mvn/version "0.9.6"}
;; kit-sql-hikari
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"kit-repl" "1.0.2"
"kit-selmer" "1.0.3"
"kit-sql-migratus" "1.0.4"
"kit-sql-conman" "1.0.9"
"kit-sql-conman" "1.10.0"
"kit-sql-hikari" "1.0.4"
"kit-sql" "1.1.4"
"kit-undertow" "1.0.6"
Expand Down
2 changes: 1 addition & 1 deletion libs/kit-nrepl/deps.edn
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
:deps {org.clojure/tools.logging {:mvn/version "1.2.4"}
integrant/integrant {:mvn/version "0.8.1"}
nrepl/nrepl {:mvn/version "1.0.0"}
io.github.kit-clj/kit-core {:mvn/version "1.0.4"}}}
io.github.kit-clj/kit-core {:mvn/version "1.0.6"}}}
2 changes: 1 addition & 1 deletion libs/kit-quartz/deps.edn
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
:deps {aero/aero {:mvn/version "1.1.6"}
integrant/integrant {:mvn/version "0.8.1"}
com.troy-west/cronut {:mvn/version "0.2.6"}
io.github.kit-clj/kit-core {:mvn/version "1.0.4"}}}
io.github.kit-clj/kit-core {:mvn/version "1.0.6"}}}
2 changes: 1 addition & 1 deletion libs/kit-redis/deps.edn
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
:deps {integrant/integrant {:mvn/version "0.8.1"}
org.clojure/core.cache {:mvn/version "1.0.225"}
com.taoensso/carmine {:mvn/version "3.2.0"}
io.github.kit-clj/kit-core {:mvn/version "1.0.4"}}}
io.github.kit-clj/kit-core {:mvn/version "1.0.6"}}}
2 changes: 1 addition & 1 deletion libs/kit-sql-conman/deps.edn
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{:paths ["src"]
:deps {integrant/integrant {:mvn/version "0.8.1"}
conman/conman {:mvn/version "0.9.6"}
io.github.kit-clj/kit-core {:mvn/version "1.0.4"}}}
io.github.kit-clj/kit-core {:mvn/version "1.0.6"}}}
18 changes: 8 additions & 10 deletions libs/kit-sql-conman/src/kit/edge/db/sql/conman.clj
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,21 @@
:or {options {}}}]
(let [filenames (or filenames [filename])
queries (apply conman/bind-connection-map conn options filenames)]
{:mtimes (map ig-utils/last-modified filenames)
:query-fn (fn
([query params]
(conman/query queries query params))
([conn query params & opts]
(apply conman/query conn queries query params opts)))}))

(defmethod ig/resolve-key :db.sql/query-fn [_ {:keys [query-fn]}]
query-fn)
(with-meta
(fn
([query params]
(conman/query queries query params))
([conn query params & opts]
(apply conman/query conn queries query params opts)))
{:mtimes (map ig-utils/last-modified filenames)})))

(defmethod ig/suspend-key! :db.sql/query-fn [_ _])

(defmethod ig/resume-key :db.sql/query-fn
[k {:keys [filename filenames] :as opts} old-opts old-impl]
(if (and (= opts old-opts)
(= (map ig-utils/last-modified (or filenames [filename]))
(:mtimes old-impl)))
(:mtimes (meta old-impl))))
old-impl
(do (ig/halt-key! k old-impl)
(ig/init-key k opts))))
2 changes: 1 addition & 1 deletion libs/kit-sql-hikari/deps.edn
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
:deps {integrant/integrant {:mvn/version "0.8.1"}
com.github.seancorfield/next.jdbc {:mvn/version "1.3.883"} ;; TODO: is this required here?
hikari-cp/hikari-cp {:mvn/version "3.0.1"}
io.github.kit-clj/kit-core {:mvn/version "1.0.4"}}}
io.github.kit-clj/kit-core {:mvn/version "1.0.6"}}}

0 comments on commit f8a94c1

Please sign in to comment.