Dynamic-var housekeeping

Also toyed with:

  - Possibility single var derefs at `freeze`/`thaw` call.
    Abandoned since big change, and slower with opts destructuring.

  - Possibility of consolidating all config into a single var.
    Abandoned since breaking, and slower with opts destructuring.
This commit is contained in:
Peter Taoussanis 2020-07-24 11:59:58 +02:00
parent 809bcdc649
commit 1855c50d9b
2 changed files with 6 additions and 14 deletions

View file

@ -265,10 +265,11 @@
;;;; Dynamic config
;; See also `nippy.tools` ns for further dynamic config support
;; TODO Switch to thread-local proxies?
;; For back compatibility (nb Timbre's Carmine appender)
(enc/defonce ^:dynamic *final-freeze-fallback* "DEPRECATED: prefer `*freeze-fallback`." nil)
(enc/defonce ^:dynamic *freeze-fallback* "(fn [data-output x])->freeze, nil => default" nil)
(enc/defonce ^:dynamic *freeze-fallback* "(fn [data-output x]), nil => default" nil)
(enc/defonce ^:dynamic *custom-readers* "{<hash-or-byte-id> (fn [data-input])}" nil)
(enc/defonce ^:dynamic *custom-readers* "{<hash-or-byte-id> (fn [data-input])->read}" nil)
(enc/defonce ^:dynamic *auto-freeze-compressor*
"(fn [byte-array])->compressor used by `(freeze <x> {:compressor :auto}),
nil => default"
@ -278,8 +279,6 @@
(defn set-auto-freeze-compressor! [x] (alter-var-root #'*auto-freeze-compressor* (constantly x)))
(defn swap-custom-readers! [f] (alter-var-root #'*custom-readers* f))
(declare ^:dynamic *final-freeze-fallback*) ; DEPRECATED
;;;; Freezing
#_(do
@ -959,10 +958,7 @@
(try-write-serializable out x)
(try-write-readable out x)
;; For back compatibility (nb Timbre's Carmine appender)
(when-let [fff *final-freeze-fallback*]
(fff out x)
true)
(when-let [fff *final-freeze-fallback*] (fff out x) true) ; Deprecated
(throw-unfreezable x))))
@ -1713,6 +1709,4 @@
;;;; Deprecated
(enc/deprecated
(enc/defonce ^:dynamic *final-freeze-fallback* "DEPRECATED" nil)
(def freeze-fallback-as-str "DEPRECATED" write-unfreezable))
(enc/deprecated (def freeze-fallback-as-str "DEPRECATED" write-unfreezable))

View file

@ -3,8 +3,6 @@
Used by Carmine, Faraday, etc."
(:require [taoensso.nippy :as nippy]))
;; TODO Switch to thread-local proxies?
(def ^:dynamic *freeze-opts* nil)
(def ^:dynamic *thaw-opts* nil)