-
Notifications
You must be signed in to change notification settings - Fork 20
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
Using serialize/deserialize and #statebox{} #7
Comments
Why not just use base64 encoding or fix the python riak client? There are libraries for reading ETF in other languages, including Python. |
That said, cross-language interop is not a goal of statebox and you'd have to re-implement it basically in its entirety to correctly use anything serialized with it, since consistency is achieved on read. Given these constraints, ETF is the best serialization as it is fast and compact and requires no transcoding to get the right data structures. Funs are used in the queue, so you will probably have a bad time making this work in JSON. |
Thanks for the suggestions. Still, IF I want to do a custom serialization, I can't because the API won't let me, that's my point. |
There's nothing truly opaque about records in Erlang. They're just tuples. The API isn't stopping you from doing anything. Sure, it doesn't make it easy for you to do what you think you want to do, but exposing that record definition is going to encourage people to use it, which isn't a good thing. I'd consider adding some kind of to_proplist / from_proplist or something like that, but I'm not sure the use case is really there. |
I'm using
statebox
+statebox_riak
and I want to serialize/deserialize the statebox record to JSON, so that it's not ETF and can be read in other languages (i.e. Python Riak client is crashing on ETF binaries:). The problem is that the statebox record is not in a header file and I cannot import it to use it directly. Looking at the accessors (value/1
,last_modified/1
) and constructors (new/1
,new/2
) fromstatebox.erl
I don't see a way to actually (de)construct the whole statebox record to (de)serialize it. I need to (de)serialize thequeue
field, right? Am I missing anything?For now I just copied the record to my module, which is bad. Here's some code:
If this is really a "bug", I would be happy to make a pull request, just let me know if you prefer to move the record into a header file or add
queue/1
andnew/3
.Cheers!
The text was updated successfully, but these errors were encountered: