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

namespace TakeoutSaaS.Module.Messaging.Services;

/// <summary>
/// 空实现消息订阅器：用于未配置 RabbitMQ 的开发/测试场景。
/// </summary>
public sealed class NoOpMessageSubscriber(ILogger<NoOpMessageSubscriber> logger) : IMessageSubscriber
{
    /// <inheritdoc />
    public Task SubscribeAsync<T>(string queue, string routingKey, Func<T, CancellationToken, Task<bool>> handler, CancellationToken cancellationToken = default)
    {
        logger.LogWarning("未配置 RabbitMQ，消息订阅被禁用：Queue={Queue} RoutingKey={RoutingKey}", queue, routingKey);
        return Task.CompletedTask;
    }

    // 1. (空行后) 释放资源（NoOp 实现无实际资源）
    /// <inheritdoc />
    public ValueTask DisposeAsync()
    {
        logger.LogDebug("NoOpMessageSubscriber 已释放。");
        return ValueTask.CompletedTask;
    }
}
