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;
///
/// Executes operations with automatic retry and error handling support.
///
public interface IRetryExecutor
{
///
/// Executes an operation with automatic retry based on the specified policy.
///
/// The return type of the operation.
/// The async operation to execute.
/// The retry policy to apply.
/// Factory to create error context from exceptions.
/// Optional error handler for custom error processing.
/// Cancellation token.
/// The result of the operation.
/// Thrown when all retries are exhausted or a fatal error occurs.
Task ExecuteWithRetryAsync(
Func> operation,
RetryPolicy policy,
Func errorContextFactory,
ISynchronizerErrorHandlerFactory errorHandler = null,
CancellationToken cancellationToken = default);
///
/// Executes an operation with automatic retry based on the specified policy (void return).
///
/// The async operation to execute.
/// The retry policy to apply.
/// Factory to create error context from exceptions.
/// Optional error handler for custom error processing.
/// Cancellation token.
/// Thrown when all retries are exhausted or a fatal error occurs.
Task ExecuteWithRetryAsync(
Func operation,
RetryPolicy policy,
Func errorContextFactory,
ISynchronizerErrorHandlerFactory errorHandler = null,
CancellationToken cancellationToken = default);
///
/// Executes an operation with default retry policy.
///
/// The return type of the operation.
/// The async operation to execute.
/// Factory to create error context from exceptions.
/// Cancellation token.
/// The result of the operation.
Task ExecuteWithRetryAsync(
Func> operation,
Func errorContextFactory,
CancellationToken cancellationToken = default);
}