Skip to content

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

Open
bonigo1998 wants to merge 1 commit into
iluwatar:masterfrom
bonigo1998:feature/scatter-gather
Open

feat: add scatter-gather design pattern #3577#3590
bonigo1998 wants to merge 1 commit 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 a new scatter-gather module implementing the Scatter-Gather concurrency pattern. Adds Aggregator, TaskSupplier, AirlineService, and ScatterGatherExecutor to execute multiple tasks in parallel with a timeout, gather successful results, and aggregate them. Includes App skeleton, unit tests for Aggregator, AirlineService, and ScatterGatherExecutor, a README with an overview and a diagram, and a root pom.xml module update.

Changes

File Summary
pom.xml Updated root pom to include new module scatter-gather as a submodule, enabling the build of the new pattern module.
scatter-gather/README.md Explains the Scatter-Gather pattern in Java, with an airline search example. Details the three stages (Scatter, Gather, Aggregate), provides a concise programmatic interface TaskSupplier, and references. Includes an architecture diagram and guidance to run the example.
scatter-gather/etc/scatter-gather-pattern.png Adds the architecture diagram illustrating the Scatter-Gather flow.
scatter-gather/pom.xml Defines the new Maven module scatter-gather, declares dependencies (slf4j, logback, junit-jupiter-engine), and main class com.iluwatar.scattergather.App for assembly.
scatter-gather/src/main/java/com/iluwatar/scattergather/Aggregator.java Aggregates a list of strings by joining them with the system line separator to form the final output.
scatter-gather/src/main/java/com/iluwatar/scattergather/AirlineService.java Implements TaskSupplier to return a formatted airline price string like '<Airline>: $<price>'.
scatter-gather/src/main/java/com/iluwatar/scattergather/App.java License header only; serves as the entry point placeholder for the Scatter-Gather demo.
scatter-gather/src/main/java/com/iluwatar/scattergather/ScatterGatherExecutor.java Executes a list of TaskSupplier concurrently using a fixed thread pool, collects completed results within a timeout, ignores failed tasks, and shuts down the executor.
scatter-gather/src/main/java/com/iluwatar/scattergather/TaskSupplier.java Defines a functional interface TaskSupplier with execute() returning String.
scatter-gather/src/test/java/com/iluwatar/scattergather/AggregatorTest.java Tests that aggregate concatenates results with newlines and returns empty string for no results.
scatter-gather/src/test/java/com/iluwatar/scattergather/AirlineServiceTest.java Verifies AirlineService.execute() returns '<Airline>: $<price>' formatting.
scatter-gather/src/test/java/com/iluwatar/scattergather/ScatterGatherExecutorTest.java Tests gathering from all tasks, timeout-based filtering, ignoring failed tasks, and empty input handling.

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.82%. Comparing base (c842319) to head (50eb9d9).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff              @@
##             master    #3590      +/-   ##
============================================
+ Coverage     83.69%   83.82%   +0.12%     
- Complexity     4257     4268      +11     
============================================
  Files          1115     1118       +3     
  Lines         15066    15090      +24     
  Branches        721      723       +2     
============================================
+ Hits          12610    12649      +39     
+ Misses         2161     2147      -14     
+ Partials        295      294       -1     

☔ 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.

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.

1 participant