ashwanthkumar / suuchi

सूचि - Toolkit to build Distributed Data Systems
https://ashwanthkumar.github.io/suuchi/
53 stars 12 forks source link

Pluggable Replicator #27

Closed ashwanthkumar closed 7 years ago

ashwanthkumar commented 7 years ago

New Workflow for replication

                                Client

                                  ||
                                  ||
                                  ||
                                  \/

                                Request

                                  ||
                                  ||
                                  ||
                                  \/

                            HandleOrForward

                               /\    ||
[Header:REPLICATION_REQUEST]   ||    ||  Header: ELIGIBLE_NODES=[]
 (times: nrOfReplica)          ||    ||
                               ||    \/

                            ReplicationRouter

HandleOrForward Interceptor always sets a header called "ELIGIBLE_NODES" which contains list of all nodes that're eligible to participate in the current operation as defined by RoutingStrategy.

SequentialReplicator would know to replicate the incomingMessage based on ELIGIBLE_NODES, if REPLICATION_REQUEST header is not set. Now while replicating the message it would add REPLICATION_REQUEST header to those messages so ReplicationRouter on the other node (or process) will not forward the message instead just delegate it to the local handler.

As part of this change we've also made ReplicationRouter an abstract class and provided an implementation called SequentialReplicator which does Sequential replication to all the ELIGIBLE_NODES.

codecov-io commented 7 years ago

Current coverage is 62.63% (diff: 75.00%)

Merging #27 into multi-find-consistent-hash will increase coverage by 12.49%

@@           multi-find-consistent-hash        #27   diff @@
============================================================
  Files                              20         22     +2   
  Lines                             359        380    +21   
  Methods                             0          0          
  Messages                            0          0          
  Branches                           54         56     +2   
============================================================
+ Hits                              180        238    +58   
+ Misses                            164        124    -40   
- Partials                           15         18     +3   

Powered by Codecov. Last update ebab3a6...3fe47d3

ashwanthkumar commented 7 years ago

Just as I was writing tests for SequentialReplication this happened 😄

twitter

brewkode commented 7 years ago

Fixes #21