36 lines
1.5 KiB
C#
36 lines
1.5 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 waits for that instance to report what it did with it. The
|
|
/// number of subscribers only proves the target's connection to the broker is up, so delivery is
|
|
/// taken from the acknowledgement of the instance that has to act on the message.
|
|
/// </summary>
|
|
/// <param name="targetPod">The instance to deliver to.</param>
|
|
/// <param name="message">The message.</param>
|
|
/// <param name="cancellationToken">The cancellation token.</param>
|
|
/// <returns><c>true</c> if the target acknowledged having carried the message out.</returns>
|
|
Task<bool> RequestAsync(string targetPod, PodMessage message, CancellationToken cancellationToken = default);
|
|
|
|
/// <summary>
|
|
/// Registers a handler for the messages addressed to this instance. Whatever the handler returns is
|
|
/// sent back to the origin as the acknowledgement.
|
|
/// </summary>
|
|
/// <param name="handler">The handler.</param>
|
|
void Subscribe(Func<PodMessage, Task<bool>> handler);
|
|
}
|