00d0765152
Publish every session to valkey with the instance holding it, and route a command for a non-local session to its owner over a per-instance pub/sub channel. Entries expire, so a dead instance leaves the directory.
31 lines
1.1 KiB
C#
31 lines
1.1 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Threading;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace MediaBrowser.Controller.Session;
|
|
|
|
/// <summary>
|
|
/// The single-instance <see cref="ISessionDirectory"/>: nothing is published and no session is held
|
|
/// anywhere but here, which is exactly the behaviour of a deployment without a shared store.
|
|
/// </summary>
|
|
public sealed class NullSessionDirectory : ISessionDirectory
|
|
{
|
|
/// <summary>
|
|
/// Gets the shared instance.
|
|
/// </summary>
|
|
public static NullSessionDirectory Instance { get; } = new NullSessionDirectory();
|
|
|
|
/// <inheritdoc />
|
|
public Task PublishAsync(SessionDirectoryEntry entry, CancellationToken cancellationToken = default)
|
|
=> Task.CompletedTask;
|
|
|
|
/// <inheritdoc />
|
|
public Task RemoveAsync(string sessionId, CancellationToken cancellationToken = default)
|
|
=> Task.CompletedTask;
|
|
|
|
/// <inheritdoc />
|
|
public Task<IReadOnlyList<SessionDirectoryEntry>> GetAllAsync(CancellationToken cancellationToken = default)
|
|
=> Task.FromResult<IReadOnlyList<SessionDirectoryEntry>>(Array.Empty<SessionDirectoryEntry>());
|
|
}
|