using System;
using System.Threading;
using System.Threading.Tasks;
namespace MediaBrowser.Controller.Session;
///
/// 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.
///
public interface IPodMessageBus
{
///
/// Gets the identity of this instance.
///
string PodId { get; }
///
/// 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.
///
/// The instance to deliver to.
/// The message.
/// The cancellation token.
/// true if the target acknowledged having carried the message out.
Task RequestAsync(string targetPod, PodMessage message, CancellationToken cancellationToken = default);
///
/// Registers a handler for the messages addressed to this instance. Whatever the handler returns is
/// sent back to the origin as the acknowledgement.
///
/// The handler.
void Subscribe(Func> handler);
}