3b416c7fb2
Timer-driven library tasks fire on every replica, so a library refresh or a database optimise runs once per pod against the same shared library. - add IScanLeaderLease with a Redis TTL implementation and a no-op default - skip timer-driven runs of the gated tasks on instances without the lease - treat an unreachable Redis as holding the lease so tasks never stop running - leave manual and API-triggered runs ungated
17 lines
606 B
C#
17 lines
606 B
C#
using System.Threading;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace MediaBrowser.Controller.ScheduledTasks;
|
|
|
|
/// <summary>
|
|
/// A no-op <see cref="IScanLeaderLease"/> used when scan-leader election is disabled or no Redis
|
|
/// connection is configured. Every instance is treated as the leader, preserving the default
|
|
/// single-instance behavior where all periodic tasks run locally.
|
|
/// </summary>
|
|
public sealed class NullScanLeaderLease : IScanLeaderLease
|
|
{
|
|
/// <inheritdoc />
|
|
public Task<bool> TryAcquireOrRenewAsync(CancellationToken cancellationToken = default)
|
|
=> Task.FromResult(true);
|
|
}
|