Code Monkey home page Code Monkey logo

statebox's People

Contributors

deadzen avatar etrepum avatar rzezeski avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

statebox's Issues

Dialyzer error (issue #4)

This issue still exists with v0.2.3 erlang R15B0[23]
I think the variable argument fun return on line 28 makes it choke.
Maybe fun(term(), term()) | fun(term(), term(), term()) instead of fun(...) ?

: ~/erlang/statebox $ dialyzer --build_plt --output_plt combo.plt -r .
Compiling some key modules to native code... done in 0m24.82s
Creating PLT combo.plt ...
dialyzer: Analysis failed with error:
Could not scan the following file(s): [{"/Users/.../erlang/statebox/ebin/statebox.beam",
" Error while parsing #statebox{}: Unable to find type 'fun'\n\n"}]
Last messages in the log cache:
Reading files and computing callgraph...

Using serialize/deserialize and #statebox{}

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) from statebox.erl I don't see a way to actually (de)construct the whole statebox record to (de)serialize it. I need to (de)serialize the queue field, right? Am I missing anything?

For now I just copied the record to my module, which is bad. Here's some code:

-spec serialize(statebox:statebox()) -> binary().
serialize(#statebox{value = Dict,
                    queue = Events,
                    last_modified = Ts}) ->
    Value = orddict:fetch(key, Dict),
    Queue = [serialize_event(E) || E <- Events],
    Json = [{<<"value">>, Value},
            {<<"queue">>, Queue},
            {<<"last_modified">>, Ts}],
    jsx:encode(Json).

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 and new/3.

-spec serialize(statebox:statebox()) -> binary().
serialize(Statebox) ->
    Value = orddict:fetch(key, statebox:value(Statebox)),
    Queue = [serialize_event(E) || E <- statebox:queue(Statebox)],
    Ts = statebox:last_modified(Statebox),
    Json = [{<<"value">>, Value},
            {<<"queue">>, Queue},
            {<<"last_modified">>, Ts}],
    jsx:encode(Json).

Cheers!

Can you please clarify the repeatability requirement?

Hi,

I am adapting statebox for some specific use case, and I was wondering if I understand the repeatability requirement correctly.

From what I understand, this has to do more with the use of riak-like systems where you will have more than one replica of such an operation on different vnodes, and therefore, when you merge, you'll end up with duplicate data.. and hence, the repeatability requirement โ€” so that replicas of the same operation don't effectively get applied twice.

Or is there any other reason for this requirement?

Lets say if I had some operation id "marker" embedded into operations that would allow me to figure out duplicates, and my own custom merge function which keeps trrack of applied operations and does not allow duplicates to be applied โ€” would that lift the repeatability requirement?

Type Error when adding to plt file

This is with version 1.2.2


Could not scan the following file(s): [{"/Users/zkessin/Documents/ProductStructure/WebAPI/deps/statebox/ebin/statebox.beam",
" Error while parsing #statebox{}: Unable to find type 'fun'\n\n"}]

Last messages in the log cache:

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.