using StellaOps.Notify.Models; namespace StellaOps.Notifier.Worker.Channels; /// /// Sends rendered notifications through a specific channel type. /// public interface INotifyChannelAdapter { /// /// The channel type this adapter handles. /// NotifyChannelType ChannelType { get; } /// /// Sends a rendered notification through the channel. /// /// The channel configuration. /// The rendered notification content. /// Cancellation token. /// The dispatch result with status and any error details. Task SendAsync( NotifyChannel channel, NotifyDeliveryRendered rendered, CancellationToken cancellationToken); } /// /// Result of a channel dispatch attempt. /// public sealed record ChannelDispatchResult { public required bool Success { get; init; } public int? StatusCode { get; init; } public string? Reason { get; init; } public bool ShouldRetry { get; init; } public static ChannelDispatchResult Ok(int? statusCode = null) => new() { Success = true, StatusCode = statusCode }; public static ChannelDispatchResult Fail(string reason, int? statusCode = null, bool shouldRetry = true) => new() { Success = false, StatusCode = statusCode, Reason = reason, ShouldRetry = shouldRetry }; }