9e66708d87
Ownership is claimed with a Lua check-and-set keyed on the instance holding the websocket, routing prefers a live controller over a local copy, the session list deduplicates by owner, removal is ownership-checked, undelivered routed messages surface, single-session lookups stop scanning the keyspace and directory writes leave the request path bounded by a timeout.
34 lines
1.3 KiB
C#
34 lines
1.3 KiB
C#
using System;
|
|
using System.Threading;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace MediaBrowser.Controller.Session;
|
|
|
|
/// <summary>
|
|
/// Point-to-point delivery between instances: every instance listens on a channel of its own, so a
|
|
/// message can be addressed to the one instance holding a given connection.
|
|
/// </summary>
|
|
public interface IPodMessageBus
|
|
{
|
|
/// <summary>
|
|
/// Gets the identity of this instance.
|
|
/// </summary>
|
|
string PodId { get; }
|
|
|
|
/// <summary>
|
|
/// Sends a message to one instance and reports how many listeners took it, so that a message
|
|
/// addressed to an instance that is no longer there is not mistaken for a delivered one.
|
|
/// </summary>
|
|
/// <param name="targetPod">The instance to deliver to.</param>
|
|
/// <param name="message">The message.</param>
|
|
/// <param name="cancellationToken">The cancellation token.</param>
|
|
/// <returns>The number of instances the message reached.</returns>
|
|
Task<long> PublishAsync(string targetPod, PodMessage message, CancellationToken cancellationToken = default);
|
|
|
|
/// <summary>
|
|
/// Registers a handler for the messages addressed to this instance.
|
|
/// </summary>
|
|
/// <param name="handler">The handler.</param>
|
|
void Subscribe(Func<PodMessage, Task> handler);
|
|
}
|