kafka.entity.changelog.topic.TopicBootstrap Maven / Gradle / Ivy
package kafka.entity.changelog.topic;
import io.micrometer.core.instrument.Metrics;
import kafka.entity.changelog.schema.Topic;
import static kafka.entity.changelog.schema.Topic.TopicsFound;
public class TopicBootstrap implements Runnable {
final TopicMetadataSource metadataSource;
final TopicCommandRepository commandRepository;
TopicBootstrap(TopicChangelog topicChangelog) {
this.metadataSource = topicChangelog.metadataSource;
this.commandRepository = topicChangelog.commandRepository;
}
@Override public void run() {
TopicsFound topicsFound = metadataSource.findTopics();
if (topicsFound == null) throw new RuntimeException("Error bootstrapping topics");
commandRepository.put(Topic.Command.newBuilder().setTopicsFound(topicsFound).build());
}
}