Feedback requests: Conflict resolution #322
Replies: 4 comments 6 replies
-
Hi Adrian, Thanks |
Beta Was this translation helpful? Give feedback.
-
Personally I think it's too limited as it only handles conflict errors. In my experience there can be other types of issues that have to be handled. Just to name few: Gone, NotFound, Unauthorized, BadRequest, ServiceUnavailable... I think it would be a lot more useful if you allow it to handle all unsuccessful responses. |
Beta Was this translation helpful? Give feedback.
-
I have observed an issue "Precondition Failed" while pushing data to server as below . Will the conflict resolver help to come out of it ? |
Beta Was this translation helpful? Give feedback.
-
The PR for the conflict resolver has now been merged. We can keep discussing here until I write the documentation for it! |
Beta Was this translation helpful? Give feedback.
-
I am currently adding conflict resolution to the client library and would like feedback on the API and functionality.
Conflict resolution ONLY affects the push operation.
During the
OnDatasyncInitialization()
method, you can add a conflict resolver to the entity. For example:There are two default conflict resolvers -
ClientWinsConflictResolver
andServerWinsConflictResolver
. There is also an interface you can implement:IConflictResolver
and anAbstractConflictResolver<T>
that implements a typed conflict resolver instead. Here is the client-wins conflict resolver for the typed version:When the push operation gets a 409 or 412, then conflict resolver is called. If the conflict resolver is null or the conflict resolver returns null then the old behavior (just log an error) happens. If, however, the response from the conflict resolver is an object, the object is serialized and sent to the server using the "force" option - the operation is the same (delete, replace, add). The response from this operation is what is recorded (so if this fails, the whole thing fails as before).
There is no "default" conflict resolver. Would that be useful? i.e.
optionsBuilder.UseConflictResolver(new ServerWinsConflictResolver())
You can find the updated library code here: https://github.com/adrianhall/CommunityToolkit-Datasync/tree/issues/298
You will have to compile the library code to test this out. I may be updating the code during the week as I do more testing.
I'm not going to create the PR for another week (next Friday) to allow folks to give feedback on the conflict resolver code. Is it useful? Is the API sensible? Does it work for you?
If you use it (even if you like it), please drop me a note here. If you have comments, bugs, etc. then please let me know here as well.
Beta Was this translation helpful? Give feedback.
All reactions