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

Introduce HeaderFilterSpec to streamline DSL API #8636

Merged
merged 2 commits into from Jun 1, 2023

Conversation

artembilan
Copy link
Member

The concern has been driven by the discussion from: #8625 The point is that Java method arguments are not so descriptive when we read the code. Therefore, it is better to design DSL the way it would be cleaner from reading perspective. Plus less choice of methods to chain would give a better end-user experience from coding.

  • Add a HeaderFilterSpec which can accept headersToRemove and patternMatch as individual options instead of top-level deprecated headerFilter(headersToRemove, patternMatch) IntegrationFlow method. This way Kotlin and Groovy DSLs get a gain from their "inner section" style.
  • Such a Consumer<HeaderFilterSpec> way to configure an endpoint is similar to already existing aggregate(Consumer<AggregatorSpec>), resequence(Consumer<ResequencerSpec>) etc. In other words those components which has a dedicated ConsumerEndpointSpec extension are OK from an idiomatic DSL style perspective
  • Expose a HeaderFilter.setHeadersToRemove() to make it working smoothly with this new DSL requirements
  • Apply a new headerFilter() style into Kotlin and Groovy DSLs

This is just an initial work to surface an idea.
If it is OK, I'll slow continue with others to realign and simplify the paradox of choice.

The concern has been driven by the discussion from: spring-projects#8625
The point is that Java method arguments are not so descriptive when we read the code.
Therefore, it is better to design DSL the way it would be cleaner from reading perspective.
Plus less choice of methods to chain would give a better end-user experience from coding.

* Add a `HeaderFilterSpec` which can accept `headersToRemove` and `patternMatch` as individual
options instead of top-level deprecated `headerFilter(headersToRemove, patternMatch)` `IntegrationFlow` method.
This way Kotlin and Groovy DSLs get a gain from their "inner section" style.
* Such a `Consumer<HeaderFilterSpec>` way to configure an endpoint is similar to already
existing `aggregate(Consumer<AggregatorSpec>)`, `resequence(Consumer<ResequencerSpec>)` etc.
In other words those components which has a dedicated `ConsumerEndpointSpec` extension are OK
from an idiomatic DSL style perspective
* Expose a `HeaderFilter.setHeadersToRemove()` to make it working smoothly with this new
DSL requirements
* Apply a new `headerFilter()` style into Kotlin and Groovy DSLs

This is just an initial work to surface an idea.
If it is OK, I'll slow continue with others to realign and simplify the paradox of choice.
Copy link
Contributor

@garyrussell garyrussell left a comment

Choose a reason for hiding this comment

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

Otherwise LGTM; do you want this merged or will you add more work to this PR?

import org.springframework.integration.router.MethodInvokingRouter
import org.springframework.integration.router.RecipientListRouter
import org.springframework.integration.handler.*
import org.springframework.integration.router.*
Copy link
Contributor

Choose a reason for hiding this comment

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

??

I guess checkstyle doesn't check Kotlin files.

Copy link
Member Author

Choose a reason for hiding this comment

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

No, it does not https://checkstyle.org/index.html.
But I'll fix my IDE to not squash imports into asterisk.
Thanks

@artembilan
Copy link
Member Author

do you want this merged

Yes, I want this merged.
It is probably would be easier for you to review small chunks of changes in a scope of specific component.
Apparently this way of API refactoring going to affect those Kotlin and Groovy DSLs as well.
So, just one by one would be great. More over no push since it is not a breaking change (yet) and just nice addition to the existing API.

FYI: The failed test with Debezium batch mode is not related to the PR: I let @tzolov know that we have some race condition over there with batching or so.

@garyrussell garyrussell merged commit e01d0a9 into spring-projects:main Jun 1, 2023
1 of 2 checks passed
@artembilan artembilan deleted the Better_DSL_style branch June 1, 2023 16:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants