Skip to content

feat: add scatter-gather design pattern #3577 - #3590

Open
bonigo1998 wants to merge 2 commits into
iluwatar:masterfrom
bonigo1998:feature/scatter-gather
Open

feat: add scatter-gather design pattern #3577#3590
bonigo1998 wants to merge 2 commits into
iluwatar:masterfrom
bonigo1998:feature/scatter-gather

Conversation

@bonigo1998

Copy link
Copy Markdown

Pull Request Template

What does this PR do?

@github-actions

github-actions Bot commented Aug 27, 2026

Copy link
Copy Markdown

PR Summary

Introduced the Scatter-Gather module with core components, tests, and documentation to run multiple tasks concurrently, gather responses within a timeout, and aggregate results.

Changes

File Summary
pom.xml Modified root pom.xml to include the new scatter-gather module in the multi-module Maven project.
scatter-gather/README.md New README documenting the Scatter-Gather pattern, intent, and a Java airline-search example.
scatter-gather/etc/scatter-gather-pattern.png New architecture diagram illustrating the Scatter-Gather flow.
scatter-gather/pom.xml New Maven module pom for scatter-gather including dependencies and build configuration.
scatter-gather/src/main/java/com/iluwatar/scattergather/Aggregator.java Implements aggregation by joining gathered List<String> results with line separators.
scatter-gather/src/main/java/com/iluwatar/scattergather/AirlineService.java Implements TaskSupplier, returning a formatted string like "Airline: $price" for a given airline.
scatter-gather/src/main/java/com/iluwatar/scattergather/App.java New entry-point placeholder file for the Scatter-Gather module (expects a main class).
scatter-gather/src/main/java/com/iluwatar/scattergather/ScatterGatherExecutor.java Executes multiple TaskSuppliers concurrently with a timeout, collecting successful results and ignoring failures.
scatter-gather/src/main/java/com/iluwatar/scattergather/TaskSupplier.java Defines a TaskSupplier functional interface representing a unit of work for the scatter-gather operation.
scatter-gather/src/test/java/com/iluwatar/scattergather/AggregatorTest.java Tests that Aggregator.aggregate correctly concatenates results and returns an empty string for no input.
scatter-gather/src/test/java/com/iluwatar/scattergather/AirlineServiceTest.java Tests that AirlineService.execute returns the expected airline and price string.
scatter-gather/src/test/java/com/iluwatar/scattergather/ScatterGatherExecutorTest.java Tests ScatterGatherExecutor across scenarios: all tasks succeed, timeout filtering, ignoring failed tasks, and no tasks.

autogenerated by presubmit.ai

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

LGTM!

Review Summary

Commits Considered (1)
Files Processed (12)
  • pom.xml (1 hunk)
  • scatter-gather/README.md (1 hunk)
  • scatter-gather/etc/scatter-gather-pattern.png (0 hunks)
  • scatter-gather/pom.xml (1 hunk)
  • scatter-gather/src/main/java/com/iluwatar/scattergather/Aggregator.java (1 hunk)
  • scatter-gather/src/main/java/com/iluwatar/scattergather/AirlineService.java (1 hunk)
  • scatter-gather/src/main/java/com/iluwatar/scattergather/App.java (1 hunk)
  • scatter-gather/src/main/java/com/iluwatar/scattergather/ScatterGatherExecutor.java (1 hunk)
  • scatter-gather/src/main/java/com/iluwatar/scattergather/TaskSupplier.java (1 hunk)
  • scatter-gather/src/test/java/com/iluwatar/scattergather/AggregatorTest.java (1 hunk)
  • scatter-gather/src/test/java/com/iluwatar/scattergather/AirlineServiceTest.java (1 hunk)
  • scatter-gather/src/test/java/com/iluwatar/scattergather/ScatterGatherExecutorTest.java (1 hunk)
Actionable Comments (0)
Skipped Comments (5)
  • scatter-gather/src/main/java/com/iluwatar/scattergather/ScatterGatherExecutor.java [58-58]

    best_practice: "Replace toList() with Collectors.toList() for compatibility"

  • scatter-gather/src/main/java/com/iluwatar/scattergather/ScatterGatherExecutor.java [36-36]

    best_practice: "Add missing import for Collectors"

  • scatter-gather/src/main/java/com/iluwatar/scattergather/TaskSupplier.java [32-32]

    readability: "Javadoc formatting"

  • scatter-gather/src/main/java/com/iluwatar/scattergather/TaskSupplier.java [34-34]

    readability: "Typo in Javadoc"

  • scatter-gather/pom.xml [46-49]

    best_practice: "Add junit-jupiter-api test dependency"

@codecov

codecov Bot commented Aug 27, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 83.93%. Comparing base (41625d8) to head (00bf897).

Additional details and impacted files
@@             Coverage Diff              @@
##             master    #3590      +/-   ##
============================================
+ Coverage     83.79%   83.93%   +0.13%     
- Complexity     4277     4288      +11     
============================================
  Files          1121     1124       +3     
  Lines         15144    15168      +24     
  Branches        723      725       +2     
============================================
+ Hits          12690    12731      +41     
+ Misses         2159     2139      -20     
- Partials        295      298       +3     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

App.java seems to be empty. Usually we have here the main entry point of the program. You should supply commentary about the pattern and its implementation as well.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

See also that it has certain level of logging so that execution can traced.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

LGTM!

Review Summary

Commits Considered (1)
  • 00bf897: Merge branch 'master' into feature/scatter-gather
Files Processed (1)
  • pom.xml (1 hunk)
Actionable Comments (0)
Skipped Comments (1)
  • pom.xml [216-216]

    enhancement: "Add new Maven module to multimodule build."

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