dominictarr / crdt

Commutative Replicated Data Types for easy collaborative/distributed systems.
MIT License
836 stars 43 forks source link

crdt.Row is now a delta stream and a scuttlebutt instance #5

Closed Raynos closed 11 years ago

Raynos commented 12 years ago

Most of it is just API changes.

The only painpoint is the hasKey stuff in crdt.Set

This is needed because deltas trickle in one key/value pair at a time and the key/value pair isn't set initially.

I did a shit ton of debugging and testing to make sure all the examples & tests still pass (they do).

The added complexity in crdt.Set is a pain, suggestions on how to refactor that would be appreciated.

dominictarr commented 12 years ago

this looks good.

You need to add documentation to delta-stream though. you should basically be able to just copy the docs of scuttlebutt/model though. can you do that and i'll just link to delta-stream from there.

A reservation I have is that delta stream is named from the perspective of the implementation, not the user's perspective. the Delta is the change, but the user doesn't interact with the changes directly. To them it's it just looks like a Model from some backbone or something. Model, Observable, maybe StateStream would all be more obvious.

"delta-stream" is a cooler name, it's just a bit misleading.

what do you think?

Raynos commented 12 years ago

@dominictarr naming wise. Yes delta stream matches the name of the original project which was a streaming specification for how to represent deltas of change to an object.

Now it's simply a stateful representation on top of scuttlebutt.

@dominictarr Model & Observable are too vague. I'll take StateStream.

It's still an object that represents Deltas. Users do interact with deltas by listening to change events. and by emitting deltas by calling set.

Raynos commented 12 years ago

@dominictarr as for prototypes. Yes they are faster.

I wrote delta-stream with convenience in mind. i.e. no new and not worrying about invoking the method correctly with it's this value.

dominictarr commented 12 years ago

just put

if(!(this instanceof Constructor)) return new Constructor(opts)

I'd be expecting to create heaps of Rows/StatesStreams potentially. also, you arn't using many(any?) scoped (private) variables...

so refactoring looks really easy.

On Sat, Sep 1, 2012 at 8:11 PM, Raynos notifications@github.com wrote:

@dominictarr https://github.com/dominictarr as for prototypes. Yes they are faster.

I wrote delta-stream with convenience in mind. i.e. no new and not worrying about invoking the method correctly with it's this value.

— Reply to this email directly or view it on GitHubhttps://github.com/dominictarr/crdt/pull/5#issuecomment-8215196.

Raynos commented 12 years ago

Refactoring it is easy, that can be done.

Raynos commented 12 years ago

@dominictarr Added docs to delta-stream