Skip to content

Commit c6ffa6c

Browse files
committed
refactor: compile dynamic fns aot
1 parent 8d636ae commit c6ffa6c

File tree

4 files changed

+14
-10
lines changed

4 files changed

+14
-10
lines changed

deps.edn

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
:extra-deps {io.github.clojure/tools.build {:git/tag "v0.9.6"
1515
:git/sha "8e78bcc"
1616
:exclusions [org.slf4j/slf4j-nop]}}}
17+
1718
;; Run all tests
1819
;; clj -M:test
1920
;; Run specific test

dev/com/moclojer/tools/build.clj

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
(ns com.moclojer.tools.build
22
(:refer-clojure :exclude [test])
3-
(:require [clojure.string :as string]
4-
[clojure.tools.build.api :as b]
5-
[com.moclojer.rq :as rq]))
3+
(:require
4+
[clojure.string :as string]
5+
[clojure.tools.build.api :as b]
6+
[com.moclojer.rq :as rq]))
67

78
(def class-dir "target/classes")
89
(def jar-file "target/com.moclojer.rq.jar")
@@ -36,7 +37,7 @@
3637
:main 'com.moclojer.rq
3738
:version rq/version
3839
:basis basis
39-
:ns-compile '[com.moclojer.rq]
40+
:ns-compile '[com.moclojer.rq com.moclojer.rq.queue]
4041
:uber-file jar-file
4142
:jar-file jar-file
4243
:target "target"

src/com/moclojer/internal/reflection.clj

+2-5
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,9 @@
4646
function itself, options like key pattern and encoding/decoding."
4747
[method parameters allowmap]
4848
(let [wrapped-method (clojure.string/replace method #"[`0-9]" "")
49-
base-doc (str "Wraps redis.clients.jedis.JedisPooled." wrapped-method)
5049
param-syms (map #(-> % :name symbol) parameters)
51-
[doc _ enc dec] (get allowmap method ["" nil :none :none])]
52-
`(defn ~(symbol method)
53-
~(str base-doc \newline doc)
54-
50+
[_ _ enc dec] (get allowmap method ["" nil :none :none])]
51+
`(fn
5552
~(-> (into ['client] param-syms)
5653
(conj '& 'options))
5754

src/com/moclojer/rq/queue.clj

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
(ns com.moclojer.rq.queue
22
(:refer-clojure :exclude [pop! range])
33
(:require
4+
[clojure.string :as str]
45
[com.moclojer.internal.reflection :as reflection]
56
[com.moclojer.rq.adapters :as adapters]))
67

@@ -41,7 +42,11 @@
4142
(doseq [[method parameters] (reflection/get-klazz-methods
4243
redis.clients.jedis.JedisPooled
4344
allowmap)]
44-
(eval `(reflection/->wrap-method ~method ~parameters ~allowmap)))
45+
(let [method' (str/replace method #"[`0-9]" "")
46+
_base-doc (str "Wraps redis.clients.jedis.JedisPooled." method')]
47+
(intern
48+
*ns* (symbol method')
49+
(eval `(reflection/->wrap-method ~method ~parameters ~allowmap)))))
4550

4651
;; --- directional ---
4752

0 commit comments

Comments
 (0)