-
Notifications
You must be signed in to change notification settings - Fork 35
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
Feature/550 queue splitter #557
Conversation
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## develop #557 +/- ##
=============================================
+ Coverage 47.42% 48.04% +0.61%
- Complexity 1790 1850 +60
=============================================
Files 225 232 +7
Lines 11820 11950 +130
Branches 1239 1260 +21
=============================================
+ Hits 5606 5741 +135
+ Misses 5720 5713 -7
- Partials 494 496 +2 ☔ View full report in Codecov by Sentry. |
@Override | ||
public void resourceRemoved(String resourceUri) { | ||
if (configResourceUri() != null && configResourceUri().equals(resourceUri)) { | ||
log.info("Queue splitter configuration resource {} was removed. Going to close all kafka producers", resourceUri); |
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.
Change wrong log statement (kafka producers).
public void resourceRemoved(String resourceUri) { | ||
if (configResourceUri() != null && configResourceUri().equals(resourceUri)) { | ||
log.info("Queue splitter configuration resource {} was removed. Going to close all kafka producers", resourceUri); | ||
System.out.println("Queue splitter configuration resource removed"); |
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.
Remove System.out.println
@@ -0,0 +1,32 @@ | |||
{ |
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.
Do not allow other properties to be added. Use additionalProperties=false
@@ -0,0 +1,32 @@ | |||
{ | |||
"$schema": "http://json-schema.org/draft-04/schema#", |
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.
Add a description
property to all the properties
"additionalProperties": { | ||
"$ref": "#/definitions/QueueSplitter" | ||
}, | ||
"definitions": { |
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.
Try to add more schema constraints like oneOf
to clearify that only postfixFromStatic or (postfixFromHeader or postfixFromUrl) can be used. Checkout the schema defined for gateleen-delegates
where this is used.
queueSplitter.initialize().onComplete(event -> { | ||
|
||
// Then | ||
context.assertFalse(queueSplitter.isInitialized()); |
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.
Shouldn't the queueSplitter
be initialized now?
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.
If the configuration is missing or invalid the QueueSplitterIml is not initialized
redisProvider, | ||
request, | ||
monitoringHandler, | ||
queueSplitter != null ? queueSplitter : new NoOpQueueSplitter())); |
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.
You already do this logic in the QueuingHandler constructor. I would suggest to just use the queueSplitter
even if null and do this check in the Constructor. When null
is passed you could create a NoOpQueueSplitter
JsonObject postfixFromRequest = queueConfig.getJsonObject(POSTFIX_FROM_REQUEST_KEY); | ||
String postfixFromHeader = postfixFromRequest != null ? postfixFromRequest.getString(POSTFIX_FROM_HEADER_KEY) : null; | ||
String postfixFromUrl = postfixFromRequest != null ? postfixFromRequest.getString(POSTFIX_FROM_URL_KEY) : null; | ||
if (postfixFromRequest != null && (postfixFromHeader != null || postfixFromUrl != null)) { |
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.
postfixFromRequest != null
can be omitted since you already check postfixFromHeader
and postfixFromUrl
@@ -1,5 +1,6 @@ | |||
{ | |||
"$schema": "http://json-schema.org/draft-04/schema#", | |||
"description": "A list of queue splitter configurations", |
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.
queue splitter configurations are not in a list ;-)
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.
You could also add unit tests for the schema validation. See KafkaTopicConfigurationSchemaValidationTest
as example
return promise.future(); | ||
} | ||
|
||
public boolean isInitialized() { |
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.
What do you need
public boolean isInitialized() {
return initialized;
}
for? Only for tests? What happens if you remove the config resource and initialized=false
is set?
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.
Yes, the method is used only in QueueSplitterImpl tests to verify the current configuration is valid. Same purpose as KafkaHandler.isInitialized() also used only in KafkaHandler tests.
No description provided.