//
// Copyright (c) PlaceholderCompany. All rights reserved.
//
namespace Jellyfin.Server.Implementations.Clustering
{
using System;
using System.Threading;
using System.Threading.Tasks;
///
/// Service for managing primary instance election and coordination.
///
public interface IPrimaryElectionService
{
///
/// Event raised when the primary instance changes.
///
event EventHandler? PrimaryInstanceChanged;
///
/// Gets a value indicating whether the current instance is the primary instance.
///
bool IsPrimary { get; }
///
/// Gets the ID of the current primary instance, if any.
///
Guid? PrimaryInstanceId { get; }
///
/// Starts the primary election service and begins monitoring.
///
/// The cancellation token.
/// A representing the asynchronous operation.
Task StartAsync(CancellationToken cancellationToken = default);
///
/// Stops the primary election service.
///
/// The cancellation token.
/// A representing the asynchronous operation.
Task StopAsync(CancellationToken cancellationToken = default);
///
/// Runs the primary election algorithm.
///
/// The cancellation token.
/// The ID of the elected primary instance.
Task ElectPrimaryAsync(CancellationToken cancellationToken = default);
///
/// Checks if this instance should execute scheduled tasks.
///
/// True if this instance should execute scheduled tasks, false otherwise.
bool ShouldExecuteScheduledTasks();
}
}