use of com.google.pubsub.v1.Topic in project beam by apache.
the class PubsubGrpcClient method listTopics.
@Override
public List<TopicPath> listTopics(ProjectPath project) throws IOException {
ListTopicsRequest.Builder request = ListTopicsRequest.newBuilder().setProject(project.getPath()).setPageSize(LIST_BATCH_SIZE);
ListTopicsResponse response = publisherStub().listTopics(request.build());
if (response.getTopicsCount() == 0) {
return ImmutableList.of();
}
List<TopicPath> topics = new ArrayList<>(response.getTopicsCount());
while (true) {
for (Topic topic : response.getTopicsList()) {
topics.add(topicPathFromPath(topic.getName()));
}
if (response.getNextPageToken().isEmpty()) {
break;
}
request.setPageToken(response.getNextPageToken());
response = publisherStub().listTopics(request.build());
}
return topics;
}
use of com.google.pubsub.v1.Topic in project beam by apache.
the class PubsubGrpcClient method createTopic.
@Override
public void createTopic(TopicPath topic) throws IOException {
Topic request = Topic.newBuilder().setName(topic.getPath()).build();
// ignore Topic result.
publisherStub().createTopic(request);
}
Aggregations