Complete multi-instance support: Phases 3–6 & deployment
- Implements Phases 3–6: session isolation, cache coordination, primary election, and file system monitor coordination for Jellyfin with PostgreSQL. - Adds new database entities (Instance, DistributedLock, FileSystemChange) and EF model configurations. - Includes SQL migration scripts and EF migration for all required tables, columns, and helper functions. - Updates Device entity and JellyfinDbContext for multi-instance tracking. - Integrates new DI services for instance registry, distributed locks, cache coordinator, and primary election. - Adds publishing profiles (Win/Linux/FrameworkDependent) and automation script for deployment. - Extensive documentation for architecture, setup, and publishing. - All changes are backward compatible and build successfully.
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
// <copyright file="IPrimaryElectionService.cs" company="PlaceholderCompany">
|
||||
// Copyright (c) PlaceholderCompany. All rights reserved.
|
||||
// </copyright>
|
||||
|
||||
namespace Jellyfin.Server.Implementations.Clustering
|
||||
{
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
/// <summary>
|
||||
/// Service for managing primary instance election and coordination.
|
||||
/// </summary>
|
||||
public interface IPrimaryElectionService
|
||||
{
|
||||
/// <summary>
|
||||
/// Event raised when the primary instance changes.
|
||||
/// </summary>
|
||||
event EventHandler<PrimaryInstanceChangedEventArgs>? PrimaryInstanceChanged;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the current instance is the primary instance.
|
||||
/// </summary>
|
||||
bool IsPrimary { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the ID of the current primary instance, if any.
|
||||
/// </summary>
|
||||
Guid? PrimaryInstanceId { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Starts the primary election service and begins monitoring.
|
||||
/// </summary>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns>
|
||||
Task StartAsync(CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// Stops the primary election service.
|
||||
/// </summary>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns>
|
||||
Task StopAsync(CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// Runs the primary election algorithm.
|
||||
/// </summary>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <returns>The ID of the elected primary instance.</returns>
|
||||
Task<Guid?> ElectPrimaryAsync(CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// Checks if this instance should execute scheduled tasks.
|
||||
/// </summary>
|
||||
/// <returns>True if this instance should execute scheduled tasks, false otherwise.</returns>
|
||||
bool ShouldExecuteScheduledTasks();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user