using Microsoft.Extensions.Logging;
using TakeoutSaaS.Module.Messaging.Abstractions;

namespace TakeoutSaaS.Module.Messaging.Services;

/// <summary>
/// 空实现消息发布器：用于未配置 RabbitMQ 的开发/测试场景，避免启动依赖外部 MQ。
/// </summary>
public sealed class NoOpMessagePublisher(ILogger<NoOpMessagePublisher> logger) : IMessagePublisher
{
    /// <inheritdoc />
    public Task PublishAsync<T>(string routingKey, T message, CancellationToken cancellationToken = default)
    {
        logger.LogDebug(
            "未配置 RabbitMQ，已跳过消息发布：RoutingKey={RoutingKey} MessageType={MessageType}",
            routingKey,
            typeof(T).FullName ?? typeof(T).Name);
        return Task.CompletedTask;
    }
}

