Skip to content

Commit

Permalink
[v4] Add config for raw verbatim strings
Browse files Browse the repository at this point in the history
  • Loading branch information
ptaoussanis committed Sep 18, 2024
1 parent ce93e0a commit a1378a5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
11 changes: 4 additions & 7 deletions src/taoensso/carmine_v4.clj
Original file line number Diff line number Diff line change
Expand Up @@ -185,13 +185,10 @@
(enc/get-env {:as :bool, :default true}
:taoensso.carmine.auto-thaw))

(def ^:dynamic *keywordize-maps?*
"TODO Docstring incl. env config."
true)

(def ^:dynamic *freeze-opts*
"TODO Docstring incl. env config?"
nil)
;; TODO Docstrings incl. env config.
(def ^:dynamic *raw-verbatim-strings?* false)
(def ^:dynamic *keywordize-maps?* true)
(def ^:dynamic *freeze-opts* nil)

(def ^:dynamic *issue-83-workaround?*
"TODO Docstring incl. env config.
Expand Down
12 changes: 8 additions & 4 deletions src/taoensso/carmine_v4/resp/read.clj
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
(enc/declare-remote
^:dynamic taoensso.carmine-v4/*keywordize-maps?*
^:dynamic taoensso.carmine-v4/*push-fn*
^:dynamic taoensso.carmine-v4/*issue-83-workaround?*)
^:dynamic taoensso.carmine-v4/*issue-83-workaround?*
^:dynamic taoensso.carmine-v4/*raw-verbatim-strings?*)

(alias 'core 'taoensso.carmine-v4)

Expand Down Expand Up @@ -338,6 +339,8 @@

(declare complete-reply)

(defrecord VerbatimString [format content])

(let [sentinel-end-of-aggregate-stream com/sentinel-end-of-aggregate-stream
sentinel-null-reply com/sentinel-null-reply]

Expand Down Expand Up @@ -401,9 +404,10 @@
^String s (read-blob nil false in)]
(when-not skip?
(let [format (subs s 0 3) ; "txt", "mkd", etc.
payload (subs s 4)]
;; TODO API okay? Dynamic opt to just return payload?
[:carmine/verbatim-string format payload])))
content (subs s 4)]
(if taoensso.carmine-v4/*raw-verbatim-strings?*
(VerbatimString. format content)
(do content)))))

(int \,) ; Double ✓
(let [s (.readLine in)]
Expand Down

0 comments on commit a1378a5

Please sign in to comment.