Skip to content

Add topic client#58

Merged
philipp94831 merged 2 commits intomasterfrom
feature/add-topic-client
Mar 13, 2020
Merged

Add topic client#58
philipp94831 merged 2 commits intomasterfrom
feature/add-topic-client

Conversation

@philipp94831
Copy link
Copy Markdown
Member

No description provided.

@philipp94831 philipp94831 self-assigned this Mar 13, 2020
Copy link
Copy Markdown
Contributor

@torbsto torbsto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly minor things.
Besides this, there is one thing I would suggest. You always throw RuntimeException on encountering any problem. I think there are plenty of situations where you can recover from the error. I see that in most situations the application should stop. Therefore, checked exceptions maybe aren't ideal either. However, I suggest at least using custom exceptions so that you can catch them easily.

private final @NonNull Duration timeout;

/**
* Create a new {@code TopicClient} using the specified configuration.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* Create a new {@code TopicClient} using the specified configuration.
* Creates a new {@code TopicClient} using the specified configuration.

public void createIfNotExists(final String topicName, final TopicSettings settings,
final Map<String, String> config) {
if (this.exists(topicName)) {
log.debug("Topic {} already exists, no need to create.", topicName);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems more like an info level log statement to me?

Comment on lines +133 to +140
throw new RuntimeException("Failed to check if Kafka topic " + topicName + " exists", e);
}
} catch (final InterruptedException e) {
Thread.currentThread().interrupt();
throw new RuntimeException("Failed to check if Kafka topic " + topicName + " exists", e);
} catch (final TimeoutException e) {
throw new RuntimeException("Failed to check if Kafka topic " + topicName + " exists", e);
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

couldn't you throw the exception just once after the try-catch block? All valid responses are in early returns anyway

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have to handle the exceptions differently. InterruptedExceptions require Thread.currentThread().interrupt();

.build();
this.kafkaCluster = provisionWith(clusterConfig);
this.kafkaCluster.start();
Thread.sleep(TimeUnit.SECONDS.toMillis(TIMEOUT_SECONDS));
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should work without the timeout

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm unsure about this because I had to restart the build once...

}

/**
* Check whether a Kafka topic exists.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* Check whether a Kafka topic exists.
* Checks whether a Kafka topic exists.

}

/**
* Describe the current configuration of a Kafka topic.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* Describe the current configuration of a Kafka topic.
* Describes the current configuration of a Kafka topic.

@philipp94831 philipp94831 requested a review from torbsto March 13, 2020 09:31
@philipp94831 philipp94831 merged commit 0e83ce1 into master Mar 13, 2020
@philipp94831 philipp94831 deleted the feature/add-topic-client branch March 13, 2020 10:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants