taoensso / carmine

Redis client + message queue for Clojure
https://www.taoensso.com/carmine
Eclipse Public License 1.0
1.15k stars 130 forks source link

Utility function to add classes to Nippy allowlists #242

Closed sironjuh closed 3 years ago

sironjuh commented 3 years ago

After upgrading to carmine 3.x, we had one class that needed to be added to nippys serializable allowlist.

We would like to do this programmatically, and while the alter-var-root method works, now our code is directly modifying the behaviour of an internal dependency of carmine.

Would it be possible to add functions to carmine itself that would hide this direct modification from using clients?

ptaoussanis commented 3 years ago

@sironjuh Hi Juha-Matti,

You've got two ways of doing this without altering the root var:

  1. Use carmine/with-thaw-opts with {:serializable-allowlist _}.
  2. Use binding with nippy/*thaw-serializable-allowlist*.

Both will establish thread-local options to cover whatever code is in the relevant body.

Hope that helps? Cheers! :-)

sironjuh commented 3 years ago

@ptaoussanis Hello,

Option 1 could work as well for our use case, just needs a bit different approach what we currently have. I'll tinker around. Thanks for the nice lib btw.