using System;
using System.Threading;
using System.Threading.Tasks;
namespace Svrnty.CQRS.Sagas.Abstractions.Messaging;
///
/// Abstraction for saga messaging transport.
///
public interface ISagaMessageBus
{
///
/// Publishes a saga command message to the message bus.
///
/// The message to publish.
/// Cancellation token.
Task PublishAsync(SagaMessage message, CancellationToken cancellationToken = default);
///
/// Publishes a saga step response to the message bus.
///
/// The response to publish.
/// Cancellation token.
Task PublishResponseAsync(SagaStepResponse response, CancellationToken cancellationToken = default);
///
/// Subscribes to saga messages for a specific command type.
///
/// The command type to subscribe to.
/// Handler that processes the message and returns a response.
/// Cancellation token.
Task SubscribeAsync(
Func> handler,
CancellationToken cancellationToken = default) where TCommand : class;
///
/// Subscribes to saga step responses.
///
/// Handler that processes responses.
/// Cancellation token.
Task SubscribeToResponsesAsync(
Func handler,
CancellationToken cancellationToken = default);
}