justone / brisk

Freeze and thaw with Nippy at the command line

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

thaw from stdin?

rgm opened this issue · comments

Hi Nate, thanks for making this. I'd love to contribute a feature but wanted to talk it through first (and possibly get a small amount of pod-preparation coaching):

Is it possible to make brisk freeze and thaw from stdin/stdout?

The carmine adapter for ring-session uses nippy to serialize session data into redis. There's a helpful Mac redis gui that will soon accept shell scripts to deal with viewing and mutating arbitrary serialization formats: luin/medis#262. This seems a great place to use babashka and brisk.

As far as I can tell, brisk works from files. I can hack around with temp files, but it could be useful if brisk were able to work in shell pipelines eg. cat x.nippy | brisk --thaw-from-stdin | jet ,,,

(I can probably figure out the code and set up a PR, but I'm not all that up on how to prepare pods for local dev or release).

I would love to see the same also for Babashka pods. I wanted to write a Babashka script that would first read some data, process it a bit and then I need to thaw it with nippy. Currently only thaw-from-file is available.

So, a couple things:

  1. I don't seem to be able to read all that well ... the binary already does what I asked, based on this docstring: https://github.com/justone/brisk/blob/master/src/brisk/main.clj#L78-L80. This should work: cat x.nippy | brisk --thaw | jet ,,,

  2. I decided to look into doing a very minimal pod of my own, to expose nippy/thaw-from-string and nippy/freeze-to-string to babashka. It's at https://github.com/rgm/pod-rgm-crisp/ if anyone wants to build it for themselves. I don't think it should go into the pod registry; it's better if we just add these two lines to this project instead: https://github.com/rgm/pod-rgm-crisp/blob/main/src/crisp/main.clj#L25-L26. @justone Let me know if you're interested in a PR and I'll put one together.

Hey @rgm, sorry to miss this before. I would definitely be open to a PR to integrate this into the brisk pod, if you'd like to work on one. Let me know.

Hey @rgm, sorry to miss this before.

No worries. PR provided.