use of io.confluent.kafkarest.controllers.TopicManager in project kafka-rest by confluentinc.
the class TopicsResource method list.
@GET
@PerformanceMetric("topics.list+v2")
@ResourceName("api.v2.topics.list")
public void list(@Suspended AsyncResponse asyncResponse) {
TopicManager topicManager = topicManagerProvider.get();
CompletableFuture<List<String>> response = topicManager.listLocalTopics().thenApply(topics -> topics.stream().map(Topic::getName).collect(Collectors.toList()));
AsyncResponses.asyncResume(asyncResponse, response);
}
use of io.confluent.kafkarest.controllers.TopicManager in project kafka-rest by confluentinc.
the class TopicsResource method getTopic.
@GET
@Path("/{topic}")
@PerformanceMetric("topic.get+v2")
@ResourceName("api.v2.topics.get")
public void getTopic(@Suspended AsyncResponse asyncResponse, @PathParam("topic") String topicName) {
TopicManager topicManager = topicManagerProvider.get();
TopicConfigManager topicConfigManager = topicConfigManagerProvider.get();
CompletableFuture<Topic> topicFuture = topicManager.getLocalTopic(topicName).thenApply(topic -> topic.orElseThrow(Errors::topicNotFoundException));
CompletableFuture<GetTopicResponse> response = topicFuture.thenCompose(topic -> topicConfigManager.listTopicConfigs(topic.getClusterId(), topicName)).thenCombine(topicFuture, (configs, topic) -> GetTopicResponse.fromTopic(topic, configs));
AsyncResponses.asyncResume(asyncResponse, response);
}
Aggregations