Description
Dear @egarim
I appreciate your hard work. I found it an excellent sync library. I have seen all of your videos regarding the sync framework.
The Unit test is not depicting all the scenarios. Please consider the following procedure.
Let's say I have a client node connected to the server with Identity = store 1. The client syncs all its data to the server. Somehow client one crashed/lost their data, or I want the same data to be synced on 2nd device, or a fresh client with the same Identity want to restore data. It is working fine, but It does not sync its data; it syncs all other data. I have seen the code in ISyncServerNode,
which fetches deltas for other Nodes.
public class SyncServerNode : ISyncServerNode
{
...
public virtual Task<IEnumerable<IDelta>> GetDeltasAsync(Guid startindex, string identity, CancellationToken cancellationToken)
{
return this.deltaStore?.GetDeltasFromOtherNodes(startindex, identity, cancellationToken);
}
...
Look at this code return this.deltaStore?.GetDeltasFromOtherNodes(startindex, identity, cancellationToken);
It fetches data of other nodes. There should be another function in the ISyncServerNode.
public interface ISyncServerNode
{
string NodeId { get; set; }
Task SaveDeltasAsync(IEnumerable<IDelta> deltas, CancellationToken cancellationToken);
Task<IEnumerable<IDelta>> GetDeltasFromOtherNodesAsync(Guid startindex, string identity, CancellationToken cancellationToken);
Task<IEnumerable<IDelta>> GetDeltasAsync(Guid startindex, CancellationToken cancellationToken);
Task ProcessDeltasAsync(IEnumerable<IDelta> deltas, CancellationToken cancellationToken);
}
There should be two functions like
Task<IEnumerable<IDelta>> GetDeltasFromOtherNodesAsync(Guid startindex, string identity, CancellationToken cancellationToken);
Task<IEnumerable<IDelta>> GetDeltasAsync(Guid startindex, CancellationToken cancellationToken);
One should be used for the normal operation scenario, and the 2nd should be used in case of a fresh/new/crashed node. Similarly, the SynController
Fetch function should also be updated with NodeId and without NodeId or another filter header.
Thank you,
Qamar Abbas