Skip to content
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

Do not export Encode/DecodeState but Encode/DecodeSnapshot #29

Merged
merged 3 commits into from
Nov 14, 2017

Commits on Nov 11, 2017

  1. Do not export Encode/DecodeState but Encode/DecodeSnapshot

    encodeState and decodeState were meant as internal operations for
    how we serialize states for transmitting them with raft.
    It turns out, they were not used in the end and instead encodeOp and
    decodeOp (which are very similar) took their place.
    
    As convinience, we used encodeState and decodeState as usable
    serializable format for snapshots. How snapshots are formatted
    is something useful to export, so users can work directly with them.
    But that format should not be tied to how states are [de]serialized
    for raft (an internal choice), which is what encodeState and
    decodeState were for in the first place (and might be used
    for in the future).
    
    For example, you could use msgpack for sending states and operations,
    but simply use json for snapshot formatting. This change allows more
    freedom if we are ever to change how things are serialized internally
    vs how snapshots are stored.
    
    License: MIT
    Signed-off-by: Hector Sanjuan <hector@protocol.ai>
    hsanjuan committed Nov 11, 2017
    Configuration menu
    Copy the full SHA
    4d47e91 View commit details
    Browse the repository at this point in the history
  2. Provide a way for States to decide their own serialization format.

    The way were were serializing and de-serializing states and operations
    was a bit hacky. Because deserialization does not work well on
    interface types, we passed in a concrete type (pointer to interface) and
    let Go do magic afterwards.
    
    In order to let the users provide their own serialization methods for
    snapshots, we need to do proper interface wrapping in concrete types
    (opWrapper, stateWrapper) and serialize/deserialize those instead.
    
    On the downside, testing shows states and ops original types should always be pointers.
    
    License: MIT
    Signed-off-by: Hector Sanjuan <hector@protocol.ai>
    hsanjuan committed Nov 11, 2017
    Configuration menu
    Copy the full SHA
    b6ca736 View commit details
    Browse the repository at this point in the history
  3. Some improvements on doc comments

    License: MIT
    Signed-off-by: Hector Sanjuan <hector@protocol.ai>
    hsanjuan committed Nov 11, 2017
    Configuration menu
    Copy the full SHA
    c8ef522 View commit details
    Browse the repository at this point in the history