diff --git a/TelpoKafkaConsole.Service/KafkaAdminService.cs b/TelpoKafkaConsole.Service/KafkaAdminService.cs index ec94577..8c7fe16 100644 --- a/TelpoKafkaConsole.Service/KafkaAdminService.cs +++ b/TelpoKafkaConsole.Service/KafkaAdminService.cs @@ -324,7 +324,7 @@ namespace TelpoKafkaConsole.Service new() { Name = topicName, ReplicationFactor = 1, - NumPartitions = numPartitions, + NumPartitions = numPartitions>3 ? 3 : numPartitions, Configs = configEntries } }); diff --git a/TelpoKafkaConsole.WebApi/Controllers/ScramAclsController.cs b/TelpoKafkaConsole.WebApi/Controllers/ScramAclsController.cs index 12df26c..37042c3 100644 --- a/TelpoKafkaConsole.WebApi/Controllers/ScramAclsController.cs +++ b/TelpoKafkaConsole.WebApi/Controllers/ScramAclsController.cs @@ -30,28 +30,28 @@ namespace TelpoKafkaConsole.WebApi.Controllers var topics = await _servicekafkaAdmin.DescribeTopicsAsync(new List { consumer.Topic }); if (topics.Count.Equals(0)) { - await _servicekafkaAdmin.CreateTopic(consumer.Topic, TimeSpan.FromDays(3), consumer.NumPartitions); + await _servicekafkaAdmin.CreateTopic(consumer.Topic, TimeSpan.FromDays(3), consumer.NumPartitions>3 ? 3: consumer.NumPartitions); } // 创建 alcs List aclBindings = new() { - new AclBinding() - { - Pattern = new ResourcePattern - { - Type = ResourceType.Broker, - Name = "kafka-cluster", - ResourcePatternType = ResourcePatternType.Literal - }, - Entry = new AccessControlEntry - { - Principal = $"User:{consumer.Name}", - Host = "*", - Operation = AclOperation.All, - PermissionType = AclPermissionType.Deny - } - }, + //new AclBinding() + //{ + // Pattern = new ResourcePattern + // { + // Type = ResourceType.Broker, + // Name = "kafka-cluster", + // ResourcePatternType = ResourcePatternType.Literal + // }, + // Entry = new AccessControlEntry + // { + // Principal = $"User:{consumer.Name}", + // Host = "*", + // Operation = AclOperation.All, + // PermissionType = AclPermissionType.Deny + // } + //}, new AclBinding() { Pattern = new ResourcePattern diff --git a/TelpoKafkaConsole.WebApi/Controllers/TopicController.cs b/TelpoKafkaConsole.WebApi/Controllers/TopicController.cs index 9742760..eb407fd 100644 --- a/TelpoKafkaConsole.WebApi/Controllers/TopicController.cs +++ b/TelpoKafkaConsole.WebApi/Controllers/TopicController.cs @@ -26,7 +26,7 @@ namespace TelpoKafkaConsole.WebApi.Controllers [HttpPost] public async Task> Post([FromBody] TopicReq topic) { - await _servicekafkaAdmin.CreateTopic(topic.TopicName,TimeSpan.FromDays(3)); + await _servicekafkaAdmin.CreateTopic(topic.TopicName,TimeSpan.FromDays(3), topic.NumPartitions); return ApiResponse.Success($"创建 Topic {topic} 成功"); }