using System.Threading;
using System.Threading.Tasks;
namespace MediaBrowser.Controller.MediaEncoding;
///
/// Provides a durable store for HLS transcoding session state, enabling
/// HA recovery and lease-based ownership between pods.
///
public interface ITranscodeSessionStore
{
///
/// Attempts to retrieve a transcoding session by its play session identifier.
///
/// The play session identifier.
/// A cancellation token.
///
/// The if it exists and its lease has not expired;
/// otherwise null.
///
Task TryGetAsync(string playSessionId, CancellationToken cancellationToken = default);
///
/// Attempts to take over ownership of an existing session by claiming the lease for
/// . Takeover succeeds only when the session exists and
/// its current lease has already expired.
///
/// The play session identifier.
/// The name of the pod attempting to claim ownership.
/// A cancellation token.
///
/// true if the takeover succeeded (the claiming pod now holds the lease);
/// false if the session does not exist, its lease is still valid, or another
/// concurrent caller already claimed it.
///
Task TryTakeoverAsync(string playSessionId, string claimingPod, CancellationToken cancellationToken = default);
///
/// Persists a new or updated transcoding session.
///
/// The session to store.
/// A cancellation token.
/// A representing the asynchronous operation.
Task SetAsync(TranscodeSession session, CancellationToken cancellationToken = default);
///
/// Renews the lease for an existing session, extending its
/// by the store's configured lease duration.
///
/// The play session identifier.
/// A cancellation token.
/// A representing the asynchronous operation.
Task RenewLeaseAsync(string playSessionId, CancellationToken cancellationToken = default);
///
/// Removes a transcoding session from the store.
///
/// The play session identifier.
/// A cancellation token.
/// A representing the asynchronous operation.
Task DeleteAsync(string playSessionId, CancellationToken cancellationToken = default);
}