nathanaschbacher / nodiak

Nodiak is a Node.js client for the Riak Distributed Database
MIT License
43 stars 16 forks source link

Should a read-resolved Sibling immediately write itself back to Riak? #10

Closed nathanaschbacher closed 11 years ago

nathanaschbacher commented 12 years ago

I'm on the fence about whether or not this should happen.

Basically the issue is this in pseudo-code:

object.get

if object.hasSiblings
    siblings = object.getSiblings
    object = siblings.resolveSiblings

    // Do I go ahead and do a object.save on the resolved object here?

    object.siblings = siblings

    return object
end

The reason I'm asking is that the point of attaching the siblings to the returned object is so that some ad-hoc sibling resolution can be performed upstream by the user.

My desire to do an immediate write back to Riak is to have as small a gap in time between the read-resolved siblings and the saving of the resolution.

My hesitation to doing this is that it writes something back to Riak (which at least by default will be client-side LWW) that a user expecting to be able to do their own ad-hoc resolution upstream, or desiring simply to ignore siblings because they have some edge case where they're useful, will have them obliterated by nodiak's auto-saving of the read-resolved object.

I'm leaning more toward not doing the save automatically, which is how it exists now. Thoughts?

nathanaschbacher commented 12 years ago

Spoke with evanmcc on the Riak IRC channel about this, and we agree that at least the default behavior should not be to write data back to Riak behind the user's back.

The question now is just whether or not to expose a flag that let's the user decide if they want nodiak to immediately write the resolution back to Riak, or simply continue to require them to make an explicit write step on their own.

nathanaschbacher commented 11 years ago

Decided to leave this decision up to the user. If they want to handle write-back, then it can be done immediately by the end-user.