Skip to content

Provide a mechanism for conflict resolution during offline sync operations #298

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
adrianhall opened this issue Feb 23, 2025 · 2 comments
Closed
Assignees
Labels
Client Improvements or additions to the client code
Milestone

Comments

@adrianhall
Copy link
Collaborator

When the service responds with a conflict during offline operations, that operation is permanently failed, leaving the developer with a problem on how to deal with it.

Suggested API involves the entity setup. Inside the offline client builder, allow developers to add a conflict resolver. Suggested interface:

Public interface IConflictResolver<T>
{
  Task<ConflictResult<T>> ResolveConflictAsync(DatasyncContext context, T clientEntity, T serverEntity, CancellationToken ct = default);
}

The response is a conflict result, which has values that can be used to determine the result of the conflict resolution - either Succeeded, UserInputRequired, etc.

Then provide a “DefaultConflictResolver” (which would be userinputrequired) “ClientSideWinsConflictResolver” and “ServerSideWinsConflictResolver” (probably need better names) that provide unattended conflict resolution.

The conflictresult (instead of the normal serviceresponse) would be added to the failed requests result if the conflict cannot be handled.

@adrianhall adrianhall added the Requires Triage This issue has not been checked by the project team. label Feb 23, 2025
@adrianhall adrianhall self-assigned this Feb 23, 2025
@adrianhall adrianhall added Client Improvements or additions to the client code and removed Requires Triage This issue has not been checked by the project team. labels Feb 23, 2025
@adrianhall adrianhall added this to the 9.0.1 milestone Feb 23, 2025
@adrianhall adrianhall modified the milestones: 9.0.1, 9.0.2 Feb 28, 2025
adrianhall added a commit to adrianhall/CommunityToolkit-Datasync that referenced this issue Mar 28, 2025
adrianhall added a commit to adrianhall/CommunityToolkit-Datasync that referenced this issue Mar 28, 2025
@adrianhall
Copy link
Collaborator Author

Added an IConflictResolver and AbstractConflictResolver<T> for resolving conflicts automatically. This can be assigned in the OnDatasyncInitialization() method of the OfflineDbContext. Code is in my branch right now - will create a PR next week to allow for testing.

adrianhall added a commit to adrianhall/CommunityToolkit-Datasync that referenced this issue Mar 31, 2025
…ra problematic round trip when server wins is chosen.
adrianhall added a commit that referenced this issue Apr 4, 2025
@adrianhall
Copy link
Collaborator Author

Completed as #325

adrianhall added a commit that referenced this issue Apr 11, 2025
* (#298) Conflict resolver.

* (#298) Pass the conflict resolver through all the entity options in the builder.

* (#298) Updated the conflict resolver to avoid the extra problematic round trip when server wins is chosen.

* (#281) Update of CommunityToolkit.WinUI packages
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Client Improvements or additions to the client code
Projects
None yet
Development

No branches or pull requests

1 participant