using MongoDB.Bson;

namespace StellaOps.Feedser.Storage.Mongo;

public interface ISourceStateRepository
{
    Task<SourceStateRecord?> TryGetAsync(string sourceName, CancellationToken cancellationToken);

    Task<SourceStateRecord> UpsertAsync(SourceStateRecord record, CancellationToken cancellationToken);

    Task<SourceStateRecord?> UpdateCursorAsync(string sourceName, BsonDocument cursor, DateTimeOffset completedAt, CancellationToken cancellationToken);

    Task<SourceStateRecord?> MarkFailureAsync(string sourceName, DateTimeOffset failedAt, TimeSpan? backoff, string? failureReason, CancellationToken cancellationToken);
}
