using System;
using System.Threading;
using System.Threading.Tasks;

namespace StellaOps.Feedser.Storage.Mongo;

public static class SourceStateRepositoryExtensions
{
    public static Task<SourceStateRecord?> MarkFailureAsync(
        this ISourceStateRepository repository,
        string sourceName,
        DateTimeOffset failedAt,
        TimeSpan? backoff,
        CancellationToken cancellationToken)
    {
        ArgumentNullException.ThrowIfNull(repository);
        return repository.MarkFailureAsync(sourceName, failedAt, backoff, failureReason: null, cancellationToken);
    }
}
