swarm
swarm copied to clipboard
How to implement conflict resolution (ie: manual merge conflicts)
Through my quick prototype it seemed the merge strategy here is "last write wins", I was wondering is it possible to implement a more refined conflict resolution, ie: let the user to manually merge two copies of data and resolve the conflict.
Thoughts?
Something more refined is used in Text and Vector (Causal Trees, very much like 3-way merge for linear structures). Manual resolution also is possible to implement. The type will have to explicitly declare state of conflict. Absolutely no problem. May you tell more about your use case?
Take TodoMVC app for example, say I'm working with a couple of colleagues on the same list, then I jump on a plane and for the next 18 hours I will be offline but still making changes to the same list, next time when I'm back online, the todo list on my laptop should be synced with the server, but, if there's any conflict (two people edited the same todo item), I would like one of these to happen:
- The app is smart enough to try auto merging my copy and the one on server
- If auto merge failed, present me with a 3-way merge-alike UI, so I could chose which copy to use, or manually merge the two then mark the conflict resolved
In the mixin for react, I saw something like this this.sync.on( function (spec,val,source) {...} ) which seems to be a good entry point to do just that, it would be great if I get a chance to see the old and new content first, and if there's a conflict, I can do the merge myself, or prepare a nice UI for user to decide how to resolve.
I'm a total noob to this project but it seems like the whole point of this project is to eliminate the need for manual merges via the CRDT approach, no? What role does manual merge really have in the vision of what swarm.js is trying to do?
Well, my point is that manual merge is still possible to implement, in case there are some reasons to do so.
On 29 October 2014 09:56, Andrew Luetgers [email protected] wrote:
I'm a total noob to this project but it seems like the whole point of this project is to eliminate the need for manual merges via the CRDT approach, no? What role does manual merge really have in the vision of what swarm.js is trying to do?
— Reply to this email directly or view it on GitHub https://github.com/gritzko/swarm/issues/35#issuecomment-60877706.
Victor
Agreed, crdt is perfect for the job, but how do you guys normally handle conflict? A simple use case where two people modified same text field, do you just let last write wins?
@gritzko quick question, is there any way to listen to rm events from Host or Set/Vector?
Here's the code I got now but it only works on set event, help?
Swarm.env.localhost.onObjectEvent( function( spec, val, src ){
// only set event will be triggered, but not rm event
})
In linear structures, concurrency is handled by Causal trees. The result is like per-letter 3-way merge. http://www.pds.ewi.tudelft.nl/~victor/#ct In the TodoMVC demo, the text is actually LWW, while the collection is linear (Vector).
Regarding set/rm, LWW objects have set and no rm (see Model).
Vectors have in and rm.
On 29 October 2014 13:07, Jeremy Lu [email protected] wrote:
Agreed, crdt is perfect for the job, but how do you guys normally handle conflict? A simple use case where two people modified same text field, do you just let last write wins?
@gritzko https://github.com/gritzko quick question, is there any way to listen to rm events from Host or Set/Vector? Here's the code I got now but it only works on set event, help?
Swarm.env.localhost.onObjectEvent( function( spec, val, src ){ // only set event will be triggered, but not rm event})
— Reply to this email directly or view it on GitHub https://github.com/gritzko/swarm/issues/35#issuecomment-60892123.
Victor
How do I listen to the event whenever any TodoItem of a TodoList was removed?
Here's the code I'm using now, but it works on when TodoItems was created or updated, not removed.
In short, I'm looking for a way to globally listen to any set and rm events of any objects (be it Model/Set/Vector), originally I thought this could be done via Host but obviously not, need guidance here, thanks!
myTodoList.onObjectEvent( function( spec, val, src ){
console.log( '\n', spec, val, src );
})
Ended up this seems to be the correct way to do it:
myTodoList.on( 'rm', function( spec, val, src ){
console.log( 'TodoList > RM', arguments );
})
myTodoList.on( 'in', function( spec, val, src ){
console.log( 'TodoList > IN', arguments );
})
How many events like this are there in the whole lib, is there any document I could read? Thanks.