Skip to content
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

Merged
merged 20 commits into from
Feb 9, 2024
Merged

Feature/550 queue splitter #557

merged 20 commits into from
Feb 9, 2024

Conversation

gcastaldi
Copy link
Collaborator

No description provided.

Copy link

codecov bot commented Feb 6, 2024

Codecov Report

Attention: 25 lines in your changes are missing coverage. Please review.

Comparison is base (0483480) 47.42% compared to head (c6597cd) 48.04%.
Report is 14 commits behind head on develop.

Files Patch % Lines
...e/queuing/splitter/QueueSplitterConfiguration.java 54.16% 10 Missing and 1 partial ⚠️
...isspush/gateleen/queue/queuing/QueuingHandler.java 0.00% 8 Missing ⚠️
...ing/splitter/QueueSplitterConfigurationParser.java 90.90% 3 Missing ⚠️
...leen/queue/queuing/splitter/QueueSplitterImpl.java 94.11% 0 Missing and 2 partials ⚠️
...itter/executors/QueueSplitExecutorFromRequest.java 93.75% 0 Missing and 1 partial ⚠️
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.
📢 Have feedback on the report? Share it here.

@mcweba mcweba self-requested a review February 6, 2024 10:33
@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);
Copy link
Collaborator

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");
Copy link
Collaborator

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 @@
{
Copy link
Collaborator

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#",
Copy link
Collaborator

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": {
Copy link
Collaborator

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());
Copy link
Collaborator

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?

Copy link
Collaborator Author

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()));
Copy link
Collaborator

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)) {
Copy link
Collaborator

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",
Copy link
Collaborator

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 ;-)

Copy link
Collaborator

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() {
Copy link
Collaborator

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?

Copy link
Collaborator Author

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.

@gcastaldi gcastaldi merged commit 161ce36 into develop Feb 9, 2024
6 checks passed
@gcastaldi gcastaldi deleted the feature/550_queue_splitter branch February 9, 2024 07:52
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.

3 participants