Skip to content

Commit

Permalink
refactor: compile dynamic fns aot
Browse files Browse the repository at this point in the history
  • Loading branch information
J0sueTM committed Sep 20, 2024
1 parent 8d636ae commit c6ffa6c
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 10 deletions.
1 change: 1 addition & 0 deletions deps.edn
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
:extra-deps {io.github.clojure/tools.build {:git/tag "v0.9.6"
:git/sha "8e78bcc"
:exclusions [org.slf4j/slf4j-nop]}}}

;; Run all tests
;; clj -M:test
;; Run specific test
Expand Down
9 changes: 5 additions & 4 deletions dev/com/moclojer/tools/build.clj
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
(ns com.moclojer.tools.build
(:refer-clojure :exclude [test])
(:require [clojure.string :as string]
[clojure.tools.build.api :as b]
[com.moclojer.rq :as rq]))
(:require
[clojure.string :as string]
[clojure.tools.build.api :as b]
[com.moclojer.rq :as rq]))

(def class-dir "target/classes")
(def jar-file "target/com.moclojer.rq.jar")
Expand Down Expand Up @@ -36,7 +37,7 @@
:main 'com.moclojer.rq
:version rq/version
:basis basis
:ns-compile '[com.moclojer.rq]
:ns-compile '[com.moclojer.rq com.moclojer.rq.queue]
:uber-file jar-file
:jar-file jar-file
:target "target"
Expand Down
7 changes: 2 additions & 5 deletions src/com/moclojer/internal/reflection.clj
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,9 @@
function itself, options like key pattern and encoding/decoding."
[method parameters allowmap]
(let [wrapped-method (clojure.string/replace method #"[`0-9]" "")
base-doc (str "Wraps redis.clients.jedis.JedisPooled." wrapped-method)
param-syms (map #(-> % :name symbol) parameters)
[doc _ enc dec] (get allowmap method ["" nil :none :none])]
`(defn ~(symbol method)
~(str base-doc \newline doc)

[_ _ enc dec] (get allowmap method ["" nil :none :none])]
`(fn
~(-> (into ['client] param-syms)
(conj '& 'options))

Expand Down
7 changes: 6 additions & 1 deletion src/com/moclojer/rq/queue.clj
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
(ns com.moclojer.rq.queue
(:refer-clojure :exclude [pop! range])
(:require
[clojure.string :as str]
[com.moclojer.internal.reflection :as reflection]
[com.moclojer.rq.adapters :as adapters]))

Expand Down Expand Up @@ -41,7 +42,11 @@
(doseq [[method parameters] (reflection/get-klazz-methods
redis.clients.jedis.JedisPooled
allowmap)]
(eval `(reflection/->wrap-method ~method ~parameters ~allowmap)))
(let [method' (str/replace method #"[`0-9]" "")
_base-doc (str "Wraps redis.clients.jedis.JedisPooled." method')]
(intern
*ns* (symbol method')
(eval `(reflection/->wrap-method ~method ~parameters ~allowmap)))))

;; --- directional ---

Expand Down

0 comments on commit c6ffa6c

Please sign in to comment.