using System;
using Svrnty.CQRS.Events.Abstractions.Delivery;
using Svrnty.CQRS.Events.Abstractions.EventStore;
using System.Threading;
using System.Threading.Tasks;
namespace Svrnty.CQRS.Events.Abstractions.Delivery;
///
/// Abstraction for event delivery mechanisms (gRPC, RabbitMQ, Kafka, etc.).
///
///
///
/// Delivery providers are responsible for transporting events from the stream store
/// to consumers using a specific protocol or technology.
///
///
/// Phase 1 Implementation:
/// gRPC bidirectional streaming for low-latency push-based delivery.
///
///
/// Future Implementations:
/// - RabbitMQ provider for cross-service messaging
/// - Kafka provider for high-throughput scenarios
/// - SignalR provider for browser clients
///
///
public interface IEventDeliveryProvider
{
///
/// Name of this delivery provider (e.g., "gRPC", "RabbitMQ", "Kafka").
///
string ProviderName { get; }
///
/// Notify the provider that a new event has been enqueued and is ready for delivery.
///
/// The name of the stream containing the event.
/// The event that was enqueued.
/// Cancellation token.
/// A task representing the async notification.
///
///
/// This method is called by the event stream store when new events arrive.
/// The provider can then push the event to connected consumers or queue it
/// for later delivery.
///
///
/// Important:
/// This method should be fast and non-blocking. Heavy work should be offloaded
/// to background tasks or channels.
///
///
Task NotifyEventAvailableAsync(
string streamName,
ICorrelatedEvent @event,
CancellationToken cancellationToken = default);
///
/// Start the delivery provider (initialize connections, background workers, etc.).
///
/// Cancellation token.
/// A task that completes when the provider is started.
Task StartAsync(CancellationToken cancellationToken = default);
///
/// Stop the delivery provider (close connections, shutdown workers, etc.).
///
/// Cancellation token.
/// A task that completes when the provider is stopped.
Task StopAsync(CancellationToken cancellationToken = default);
///
/// Get the number of active connections/consumers for this provider.
///
/// The number of active consumers.
///
/// Used for monitoring and metrics.
///
int GetActiveConsumerCount();
///
/// Check if this provider is currently healthy and ready to deliver events.
///
/// True if healthy, false otherwise.
bool IsHealthy();
}