using System.Collections.Generic;
using Svrnty.CQRS.Events.Abstractions.Storage;
using Svrnty.CQRS.Events.Abstractions.Models;
using System.Threading;
using System.Threading.Tasks;
namespace Svrnty.CQRS.Events.Abstractions.Storage;
///
/// Storage abstraction for event stream retention policies.
/// Manages retention policy configuration and enforcement.
///
public interface IRetentionPolicyStore
{
///
/// Set or update a retention policy for a stream.
///
/// The retention policy to set.
/// Cancellation token.
/// A task representing the asynchronous operation.
///
/// If a policy already exists for the stream, it will be updated.
/// Use stream name "*" to set the default policy for all streams.
///
Task SetPolicyAsync(
IRetentionPolicy policy,
CancellationToken cancellationToken = default);
///
/// Get the retention policy for a specific stream.
///
/// The stream name.
/// Cancellation token.
/// The retention policy, or null if no specific policy exists.
///
/// Returns the stream-specific policy if it exists.
/// Does NOT automatically return the default ("*") policy as a fallback.
///
Task GetPolicyAsync(
string streamName,
CancellationToken cancellationToken = default);
///
/// Get all configured retention policies.
///
/// Cancellation token.
/// List of all retention policies, including the default policy.
Task> GetAllPoliciesAsync(
CancellationToken cancellationToken = default);
///
/// Delete a retention policy for a stream.
///
/// The stream name.
/// Cancellation token.
/// True if the policy was deleted, false if it didn't exist.
///
/// Cannot delete the default ("*") policy. Attempting to do so will return false.
///
Task DeletePolicyAsync(
string streamName,
CancellationToken cancellationToken = default);
///
/// Apply all enabled retention policies and delete events that exceed retention limits.
///
/// Cancellation token.
/// Statistics about the cleanup operation.
///
/// This method:
/// - Iterates through all enabled retention policies
/// - Deletes events that are older than MaxAge (if configured)
/// - Deletes events that exceed MaxEventCount (if configured)
/// - Returns statistics about streams processed and events deleted
///
/// This is typically called by a background service on a schedule.
///
Task ApplyRetentionPoliciesAsync(
CancellationToken cancellationToken = default);
}