using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace JiShe.CollectBus.Kafka.AdminClient
{
    public interface IAdminClientService
    {
        /// <summary>
        /// 创建Kafka主题
        /// </summary>
        /// <param name="topic">主题名称</param>
        /// <param name="numPartitions">主题分区数量</param>
        /// <param name="replicationFactor">副本数量，不能高于Brokers数量</param>
        /// <returns></returns>
        Task CreateTopicAsync(string topic, int numPartitions, short replicationFactor);

        /// <summary>
        /// 删除Kafka主题
        /// </summary>
        /// <param name="topic"></param>
        /// <returns></returns>
        Task DeleteTopicAsync(string topic);

        /// <summary>
        /// 获取Kafka主题列表
        /// </summary>
        /// <returns></returns>
        Task<List<string>> ListTopicsAsync();

        /// <summary>
        /// 判断Kafka主题是否存在
        /// </summary>
        /// <param name="topic"></param>
        /// <returns></returns>
        Task<bool> TopicExistsAsync(string topic);

        /// <summary>
        /// 检测分区是否存在
        /// </summary>
        /// <param name="topic"></param>
        /// <param name="partitions"></param>
        /// <returns></returns>
        Dictionary<int, bool> CheckPartitionsExists(string topic, int[] partitions);

        /// <summary>
        /// 检测分区是否存在
        /// </summary>
        /// <param name="topic"></param>
        /// <param name="targetPartition"></param>
        /// <returns></returns>
        bool CheckPartitionsExist(string topic, int targetPartition);

        /// <summary>
        /// 获取主题的分区数量
        /// </summary>
        /// <param name="topic"></param>
        /// <returns></returns>
        int GetTopicPartitionsNum(string topic);
    }
}
