-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor of HttpSender implementations with Factory Pattern (1/2) #171
Conversation
- refactor Http senders to expose a factory `HttpSenderFactory` and provide an implementation according to the configuration - Use abstraction `AbstractHttpSender` for sending message and sending with retry - Every Http request is handled by a `HttpSender` implementation, even retrieving an access token with `AccessTokenHttpSender` - Each `HttpSender` implementation creates its own `HttpRequestBuilder` with separate responsibilities - Add Code coverage on `sender` package to test the HttpRequest configuration
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some comments on the main implementation. Will look into the tests a bit later.
Thanks @aprodhomme-dkt !
src/main/java/io/aiven/kafka/connect/http/recordsender/BatchRecordSender.java
Outdated
Show resolved
Hide resolved
src/test/java/io/aiven/kafka/connect/http/config/HttpSinkConfigTest.java
Outdated
Show resolved
Hide resolved
src/main/java/io/aiven/kafka/connect/http/sender/HttpSenderFactory.java
Outdated
Show resolved
Hide resolved
src/main/java/io/aiven/kafka/connect/http/sender/AccessTokenHttpSender.java
Outdated
Show resolved
Hide resolved
src/main/java/io/aiven/kafka/connect/http/sender/HttpSender.java
Outdated
Show resolved
Hide resolved
src/main/java/io/aiven/kafka/connect/http/sender/OAuth2HttpSender.java
Outdated
Show resolved
Hide resolved
src/main/java/io/aiven/kafka/connect/http/sender/AccessTokenHttpSender.java
Outdated
Show resolved
Hide resolved
src/main/java/io/aiven/kafka/connect/http/sender/AccessTokenHttpSender.java
Outdated
Show resolved
Hide resolved
src/main/java/io/aiven/kafka/connect/http/sender/AccessTokenHttpSender.java
Outdated
Show resolved
Hide resolved
src/main/java/io/aiven/kafka/connect/http/sender/AccessTokenHttpSender.java
Outdated
Show resolved
Hide resolved
src/main/java/io/aiven/kafka/connect/http/sender/AccessTokenHttpSender.java
Outdated
Show resolved
Hide resolved
src/main/java/io/aiven/kafka/connect/http/sender/OAuth2HttpSender.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@aprodhomme-dkt this is looking good! Thanks for helping me understand some of the changes.
I've added some additional comments on both PRs, mostly cosmetic.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@aprodhomme-dkt thanks for applying most suggestions! I think there's a last missing nit to resolve; otherwise I'm happy to approve this PR.
Thanks again for the efforts here.
@@ -26,9 +26,9 @@ interface HttpResponseHandler { | |||
|
|||
Logger LOGGER = LoggerFactory.getLogger(HttpResponseHandler.class); | |||
|
|||
void onResponse(final HttpResponse<String> response) throws IOException; | |||
void onResponse(final HttpResponse<String> response, int retriesNumber) throws IOException; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the last nit missing
Here you go :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple of Test classes may need to be renamed
src/test/java/io/aiven/kafka/connect/http/sender/DefaultTokenHttpSenderTest.java
Outdated
Show resolved
Hide resolved
src/test/java/io/aiven/kafka/connect/http/sender/StaticTokenHttpSenderTest.java
Outdated
Show resolved
Hide resolved
@jeqo any news on those PRs? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR looks good to me, just two small changes requested.
src/test/java/io/aiven/kafka/connect/http/sender/HttpSenderTestUtils.java
Outdated
Show resolved
Hide resolved
src/main/java/io/aiven/kafka/connect/http/sender/AbstractHttpSender.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@aprodhomme-dkt thanks for this contribution! I'm preemptively approving this, and we can merge it once Jaarkko's suggestions are resolved.
# Conflicts: # src/main/java/io/aiven/kafka/connect/http/HttpSinkTask.java
Hi @jeqo and @jjaakola-aiven, thanks for your reviews. I have just took into account your last comments. |
Thanks, @aprodhomme-dkt! Let's have a look at #172 to wrap up this contribution 🙌🏽 |
This PR aims to have clearer responsibilities between the multiple HttpSender implementations. This is required to increase code coverage before introducing a new way to retrieve an access token (see 2nd PR: #172)
Changes:
HttpSenderFactory
and provide an implementation according to the configurationAbstractHttpSender
for sending message and sending with retryHttpSender
implementation, even retrieving an access token withAccessTokenHttpSender
HttpSender
implementation creates its ownHttpRequestBuilder
with separate responsibilitiesThis refactor allows to test the HttpRequest that is sent to the API publisher and it covers all scenarios depending on the configuration.