-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[idea] Nippy Backend #3
Comments
Hi Harold, That is a neat idea indeed! Unfortunately, I will not be in a position to make this happen for at least another 2 weeks (maybe 3), as I'm on holidays abroad. If you feel like tackling it yourself, then by all means, have a go ;) Kind regards, |
Enjoy your holidays. I will try this when I reach performance limitations, for now I am still good to go. If you do do this at some point I'd be happy to try it out. Take care. |
Part of my logic relies on sorted-sets in a project, appearently edn silently transforms these into hash-sets. Nippy would be a solution and I think I could manage to implement it. Any ideas to let sorted-sets work with edn are welcome too though. |
@Sandarr95 - interesting, I never thought of that. It looks like you're right (duratom uses
Some indication that nippy may help:
|
So for anyone reading this that wants a quick fix, I saw someone forked and implemented it: I'm gonna take some time to get the abstractions right, so both edn and nippy will be available and more serialization methods and storage backends can be added without reworking the logic. |
Hi guys, I'm not in favour of the approach taken by the fork. Therefore, I spent a couple of hours last night and took a different approach. Basically, I'd like to be able to do something whereby people who want to carry on using plain edn can do so without changing anything. So what I've come up with so far for nippy users is something along these lines: ;; FILE-BACKED
(file-atom file-path lock initial-value
{:read (partial ut/read-edn-from-bytes! nippy/thaw-from-in!)
:write (partial ut/write-edn-as-bytes! nippy/freeze-to-out!)})
;; POSTGRES-BACKED
(postgres-atom db-config table-name row-id lock initial-value
{:read nippy/thaw
:write nippy/freeze
:column-type :bytea})
;; S3-BACKED
(s3-atom creds bucket k lock initial-value
{:read nippy/thaw
:write nippy/freeze}) So basically, nippy users will have to provide an extra argument when creating their duratoms.I think that's fair, and we avoid the dependency. I've not actually pushed any changes yet, so you won't be able to see the full solution yet, but the above should give you a clear idea of the direction I'm taking. Feedback is always welcome. |
duratom 0.3.5 is out and allows for custom encoders/decoders to be hooked on to the back-end. See the readme which specifically shows an example utilising nippy. Please do come back to me if you happen to find any problems. Closing this now. Thanks again... |
👏 |
https://github.com/ptaoussanis/nippy is a wicked serialization library that we use all over the place for storing edn.
The main trade-offs of nippy vs
pr-str
are:pr-str
is plain-text and nippy is binary byte blob (opaque)Now that I am storing non-trivial data in .edn duratoms, it occured to me that nippy might make an interesting backend for this lib.
Any thoughts? Any interest in a PR?
The text was updated successfully, but these errors were encountered: