topic config

This commit is contained in:
许晓东
2021-11-04 23:53:42 +08:00
parent 2f2ee7f901
commit c362f69273
4 changed files with 34 additions and 0 deletions

View File

@@ -46,6 +46,16 @@ public class ConfigController {
return configService.getTopicConfig(topic);
}
@PostMapping("/topic")
public Object setTopicConfig(@RequestBody AlterConfigDTO dto) {
return configService.alterTopicConfig(dto.getEntity(), dto.to(), AlterType.SET);
}
@DeleteMapping("/topic")
public Object deleteTopicConfig(@RequestBody AlterConfigDTO dto) {
return configService.alterTopicConfig(dto.getEntity(), dto.to(), AlterType.DELETE);
}
@GetMapping("/broker")
public Object getBrokerConfig(String brokerId) {
return configService.getBrokerConfig(brokerId);

View File

@@ -17,4 +17,6 @@ public interface ConfigService {
ResponseData getBrokerConfig(String brokerId);
ResponseData alterBrokerConfig(String brokerId, ConfigEntry entry, AlterType type);
ResponseData alterTopicConfig(String topic, ConfigEntry entry, AlterType type);
}

View File

@@ -49,4 +49,18 @@ public class ConfigServiceImpl implements ConfigService {
return (boolean) tuple2._1() ? ResponseData.create().success() : ResponseData.create().failed(tuple2._2());
}
@Override
public ResponseData alterTopicConfig(String topic, ConfigEntry entry, AlterType type) {
Tuple2<Object, String> tuple2 = null;
switch (type) {
case SET:
tuple2 = configConsole.setTopicConfig(topic, entry);
break;
case DELETE:
tuple2 = configConsole.deleteTopicConfig(topic, entry);
break;
}
return (boolean) tuple2._1() ? ResponseData.create().success() : ResponseData.create().failed(tuple2._2());
}
}