Allow requesting raw data

This commit is contained in:
niten 2024-02-20 13:09:18 -08:00
parent 111522845d
commit 2c5b228f42
1 changed files with 11 additions and 2 deletions

View File

@ -58,7 +58,8 @@
(add-channel! [_ chan]) (add-channel! [_ chan])
(stop! [_]) (stop! [_])
(subscribe-topic! [_ topic opts]) (subscribe-topic! [_ topic opts])
(get-topic! [_ topic opts])) (get-topic! [_ topic opts])
(get-topic-raw! [_ topic opts]))
(defrecord MilquetoastClient [client open-channels verbose] (defrecord MilquetoastClient [client open-channels verbose]
IMilquetoastClient IMilquetoastClient
@ -101,7 +102,8 @@
(.unsubscribe client topic)))) (.unsubscribe client topic))))
#(.reconnect client)) #(.reconnect client))
(first (alts!! [result-chan (first (alts!! [result-chan
(async/timeout (* timeout 1000))]))))) (async/timeout (* timeout 1000))]))))
(get-topic-raw! [c topic opts] (get-topic! c topic opts)))
(defn- parallelism [] (defn- parallelism []
(-> (Runtime/getRuntime) (-> (Runtime/getRuntime)
@ -131,6 +133,10 @@
(get-topic! [_ topic opts] (get-topic! [_ topic opts]
(if-let [msg (get-topic! client topic opts)] (if-let [msg (get-topic! client topic opts)]
(json-parse-message msg) (json-parse-message msg)
nil))
(get-topic-raw! [_ topic opts]
(if-let [msg (get-topic! client topic opts)]
msg
nil))) nil)))
(defn send! [client topic msg & {:keys [qos retain] (defn send! [client topic msg & {:keys [qos retain]
@ -140,6 +146,9 @@
(defn get! [client topic & options] (defn get! [client topic & options]
(get-topic! client topic options)) (get-topic! client topic options))
(defn get-raw! [client topic & options]
(get-topic-raw! client topic options))
(defn open-channel! (defn open-channel!
[client topic & {:keys [buffer-size qos retain] [client topic & {:keys [buffer-size qos retain]
:or {buffer-size 1 :or {buffer-size 1