namespace JiShe.CollectBus.Kafka.Attributes;

[AttributeUsage(AttributeTargets.Method)]
public class KafkaSubscribeAttribute : Attribute
{
    /// <summary>
    ///     订阅主题
    /// </summary>
    /// <param name="batchTimeout"></param>
    public KafkaSubscribeAttribute(string topic)
    {
        Topic = topic;
    }

    /// <summary>
    ///     订阅主题
    /// </summary>
    public KafkaSubscribeAttribute(string topic, int partition)
    {
        Topic = topic;
        Partition = partition;
    }

    /// <summary>
    ///     订阅的主题
    /// </summary>
    public string Topic { get; set; } = null!;

    /// <summary>
    ///     分区
    /// </summary>
    public int Partition { get; set; } = -1;

    /// <summary>
    ///     消费者组
    /// </summary>
    public string? GroupId { get; set; } = null; //"default"

    /// <summary>
    ///     任务数(默认是多少个分区多少个任务)
    ///     如设置订阅指定Partition则任务数始终为1
    /// </summary>
    public int TaskCount { get; set; } = -1;

    /// <summary>
    ///     批量处理数量
    /// </summary>
    public int BatchSize { get; set; } = 100;

    /// <summary>
    ///     是否启用批量处理
    /// </summary>
    public bool EnableBatch { get; set; } = false;

    /// <summary>
    ///     批次超时时间
    ///     格式:("00:05:00")
    /// </summary>
    public TimeSpan? BatchTimeout { get; set; } = null;
}