repred
Insanely simple data replication.
<img src=https://secure.travis-ci.org/dominictarr/repred.png?branch=master>
Example
Pass in a reduce like function that merges an update into the node's collection.
var repred =var rr =//handle change eventsrr//add a name to the set.rr
The function must also return a change object, which is just the changes which actually applied.
if changes is non-empty, (not []
or {}
) then that update will be sent across the wire to any
connected nodes.
- write a map-reduce that is commutative and idempotent.
- distribute them, and connect them via streams.
- Eventual Consistency!
connect like this:
rs1 = rr1rs2 = rr2rs1
or, through a tcp stream...
var net =//on server...var rr1 =net//on client...var rr2 =var stream = netstream
map-reduce
Optionally pass in a map
function to transform update into the correct type.
if the return value of the map is nullish
(null or undefined) reduce will not be called.
var rr =rr //etc.
License
MIT