Skip to content

Conversation

@karthikbhat13
Copy link
Contributor

@karthikbhat13 karthikbhat13 commented Jun 16, 2021

FanOut/FanIn Pattern

  • The pattern refers to executing multiple instances of the activity function on multiple chunks in parallel
  • Resolves Fan-Out/Fan-In pattern #1627

Pull request description

  • Added code that implements the design pattern and test cases

Copy link
Owner

@iluwatar iluwatar left a comment

Choose a reason for hiding this comment

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

Thanks for implementing this pattern. Looks good in general. I added some improvement requests, please take a look and let us know when you're ready for another review.

@@ -0,0 +1,33 @@
---
layout: pattern
title: FanOut-FanIn
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
title: FanOut-FanIn
title: Fan-Out/Fan-In

title: FanOut-FanIn
folder: fanout-fanin
permalink: /patterns/fanout-fanin/
categories: Concurrency
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
categories: Concurrency
categories: Integration

Comment on lines 9 to 10
- Cloud distributed
- Performance
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
- Cloud distributed
- Performance
- Microservices

Comment on lines 14 to 20
The pattern that refers to executing multiple instances of the activity function concurrently. Generally "FanOut"
process is splitting the data into multiple chunks that would be passed to the activity function. "FanIn" process is
basically aggregating the result from individual instance of activity function and forming a single final result. <br />

Each activity function is a long-running process that takes in a chunk of data. A callback function, or a Consumer
is passed to the activity function, that will be called when the long-running process gets over. The consumer will
process the individual return value from activity function as they are done running into a final result.
Copy link
Owner

Choose a reason for hiding this comment

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

The term activity function is not self-explanatory. Could we perhaps talk about microservices?

Copy link
Owner

Choose a reason for hiding this comment

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

We should also explain how the caller eventually gets the aggregated result.

Copy link
Owner

Choose a reason for hiding this comment

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

We need an explanation section and some of the details could be placed there.

## Applicability

Use this pattern when you can chunk the workload or load into multiple chunks that can be dealt with separately.

Copy link
Owner

Choose a reason for hiding this comment

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

I think we could add a related patterns section, see https://github.com/iluwatar/java-design-patterns/wiki/02.-Pattern-template. Some of the microservices patterns we already have seemed to be quite similar.

@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

@iluwatar iluwatar merged commit 04bf566 into iluwatar:master Jul 9, 2021
@iluwatar
Copy link
Owner

iluwatar commented Jul 9, 2021

@karthikbhat13 I'm not sure what has happened, but the PR doesn't have any changed files anymore. Can you please take a look at it?

@karthikbhat13
Copy link
Contributor Author

Oh, didn't notice that. Lemme check. There is a hook to auto pull master branch to base repo. It probably replaced my branch. I will update again.

@karthikbhat13
Copy link
Contributor Author

@iluwatar Can I update this PR only to have the changes again? I can't figure it out. For now, I created one more PR, #1799

Let me know what I can do. Thanks

@iluwatar
Copy link
Owner

iluwatar commented Jul 9, 2021

@karthikbhat13 either way, but please ensure that you have addressed my earlier review comments.

@karthikbhat13
Copy link
Contributor Author

@karthikbhat13 either way, but please ensure that you have addressed my earlier review comments.

@iluwatar Have done that. I have fixed the comments and added the explanation and related patterns sections. 1948342 of #1799

@iluwatar
Copy link
Owner

iluwatar commented Jul 9, 2021

Ok, let's continue the process in #1799.

@karthikbhat13
Copy link
Contributor Author

Ok, let's continue the process in #1799.

@iluwatar There was the issue of pull bot again in this PR too. I have create a new one with custom branch, #1800. Please consider this whenever convenient.

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.

Fan-Out/Fan-In pattern

2 participants