replikativ / konserve

A clojuresque key-value/document store protocol with core.async.
Eclipse Public License 1.0
298 stars 25 forks source link

Example how to setup custom serializers #71

Open awb99 opened 2 years ago

awb99 commented 2 years ago

The 'weak' point in clojure is that edn and transit encoding do not bring a lot of default serializers.

Example: date and uuid are not serializable by default, nor are records.

So I think it is essential to Be able to configure serializers for edn and transit in konserve. Could you add a little demo on this? It would also be enough to just add the key that needs to be passed on store initialization into the readme.

A persistence library is a very delicate thing. Once you add it to your project you will live and die with it. I have seen similar problems in clojure http requests and websocket requests. Just knowing that it is possible to work with all types that are used in the project brings peace of mind.

whilo commented 1 year ago

Date and UUIDs are handled by default in clojure.edn and fressian, and I think also transit (because they are part of the general edn semantics in Clojure). Currently there are two ways to extand handlers, one general one for records with incognito and one by adding custom handlers to each serializer. We in fact use the latter for Datahike and fressian here https://github.com/replikativ/datahike/blob/35773c5882227707a94047a2a97ea8ce5f98c658/src/datahike/index/persistent_set.cljc#L210. It is really just exposing the underlying serialization library handler interface.