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.
30 lines
948 B
C#
30 lines
948 B
C#
using System;
|
|
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. Delivery is best effort and never throws.
|
|
/// </summary>
|
|
/// <param name="targetPod">The instance to deliver to.</param>
|
|
/// <param name="message">The message.</param>
|
|
void Publish(string targetPod, PodMessage message);
|
|
|
|
/// <summary>
|
|
/// Registers a handler for the messages addressed to this instance.
|
|
/// </summary>
|
|
/// <param name="handler">The handler.</param>
|
|
void Subscribe(Func<PodMessage, Task> handler);
|
|
}
|