Refactored all synchronizers to deal with some of the chronic issues.
This commit is contained in:
@@ -171,4 +171,19 @@ public interface IAccountService
|
||||
/// <returns>Whether the notifications should be created after sync or not.</returns>
|
||||
Task<bool> IsNotificationsEnabled(Guid accountId);
|
||||
Task UpdateAccountCustomServerInformationAsync(CustomServerInformation customServerInformation);
|
||||
|
||||
/// <summary>
|
||||
/// Updates the last folder structure sync date for the given account.
|
||||
/// Used for optimization to skip folder sync if it was done recently.
|
||||
/// </summary>
|
||||
/// <param name="accountId">Account id.</param>
|
||||
Task UpdateLastFolderStructureSyncDateAsync(Guid accountId);
|
||||
|
||||
/// <summary>
|
||||
/// Checks if folder structure should be synced based on the configured interval.
|
||||
/// Returns true if LastFolderStructureSyncDate is null or older than the interval.
|
||||
/// </summary>
|
||||
/// <param name="accountId">Account id.</param>
|
||||
/// <param name="syncInterval">Minimum interval between folder syncs.</param>
|
||||
Task<bool> ShouldSyncFolderStructureAsync(Guid accountId, TimeSpan syncInterval);
|
||||
}
|
||||
|
||||
@@ -162,4 +162,12 @@ public interface IMailService
|
||||
/// <param name="onlineArchiveMailIds">Retrieved MailCopy ids from search result.</param>
|
||||
/// <returns>Result model that contains added and removed mail copy ids.</returns>
|
||||
Task<GmailArchiveComparisonResult> GetGmailArchiveComparisonResultAsync(Guid archiveFolderId, List<string> onlineArchiveMailIds);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the most recent mail IDs for a folder.
|
||||
/// Used for notification purposes after sync completes.
|
||||
/// </summary>
|
||||
/// <param name="folderId">Folder ID.</param>
|
||||
/// <param name="count">Number of recent mails to return.</param>
|
||||
Task<IEnumerable<string>> GetRecentMailIdsForFolderAsync(Guid folderId, int count);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Wino.Core.Domain.Models.Retry;
|
||||
using Wino.Core.Domain.Models.Synchronization;
|
||||
|
||||
namespace Wino.Core.Domain.Interfaces;
|
||||
|
||||
/// <summary>
|
||||
/// Executes operations with automatic retry and error handling support.
|
||||
/// </summary>
|
||||
public interface IRetryExecutor
|
||||
{
|
||||
/// <summary>
|
||||
/// Executes an operation with automatic retry based on the specified policy.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The return type of the operation.</typeparam>
|
||||
/// <param name="operation">The async operation to execute.</param>
|
||||
/// <param name="policy">The retry policy to apply.</param>
|
||||
/// <param name="errorContextFactory">Factory to create error context from exceptions.</param>
|
||||
/// <param name="errorHandler">Optional error handler for custom error processing.</param>
|
||||
/// <param name="cancellationToken">Cancellation token.</param>
|
||||
/// <returns>The result of the operation.</returns>
|
||||
/// <exception cref="Exception">Thrown when all retries are exhausted or a fatal error occurs.</exception>
|
||||
Task<T> ExecuteWithRetryAsync<T>(
|
||||
Func<CancellationToken, Task<T>> operation,
|
||||
RetryPolicy policy,
|
||||
Func<Exception, SynchronizerErrorContext> errorContextFactory,
|
||||
ISynchronizerErrorHandlerFactory errorHandler = null,
|
||||
CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// Executes an operation with automatic retry based on the specified policy (void return).
|
||||
/// </summary>
|
||||
/// <param name="operation">The async operation to execute.</param>
|
||||
/// <param name="policy">The retry policy to apply.</param>
|
||||
/// <param name="errorContextFactory">Factory to create error context from exceptions.</param>
|
||||
/// <param name="errorHandler">Optional error handler for custom error processing.</param>
|
||||
/// <param name="cancellationToken">Cancellation token.</param>
|
||||
/// <exception cref="Exception">Thrown when all retries are exhausted or a fatal error occurs.</exception>
|
||||
Task ExecuteWithRetryAsync(
|
||||
Func<CancellationToken, Task> operation,
|
||||
RetryPolicy policy,
|
||||
Func<Exception, SynchronizerErrorContext> errorContextFactory,
|
||||
ISynchronizerErrorHandlerFactory errorHandler = null,
|
||||
CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// Executes an operation with default retry policy.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The return type of the operation.</typeparam>
|
||||
/// <param name="operation">The async operation to execute.</param>
|
||||
/// <param name="errorContextFactory">Factory to create error context from exceptions.</param>
|
||||
/// <param name="cancellationToken">Cancellation token.</param>
|
||||
/// <returns>The result of the operation.</returns>
|
||||
Task<T> ExecuteWithRetryAsync<T>(
|
||||
Func<CancellationToken, Task<T>> operation,
|
||||
Func<Exception, SynchronizerErrorContext> errorContextFactory,
|
||||
CancellationToken cancellationToken = default);
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
using System.Threading.Tasks;
|
||||
using Wino.Core.Domain.Models.Synchronization;
|
||||
|
||||
namespace Wino.Core.Domain.Interfaces;
|
||||
|
||||
public interface ISynchronizerErrorHandlerFactory
|
||||
{
|
||||
Task<bool> HandleErrorAsync(SynchronizerErrorContext error);
|
||||
}
|
||||
Reference in New Issue
Block a user