-
Notifications
You must be signed in to change notification settings - Fork 75
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 Request] Fork-Join #38
Comments
juzerali
pushed a commit
to juzerali/pipeline
that referenced
this issue
Jan 9, 2018
Also it will be better if the fluent API to build the pipeline is shifted to the builder. As per Single Responsibility Principle, responsibility to build an object with complex graph should be outside the object itself, i.e. in a builder. So building the pipeline will look like this: $pipeline = (new PipelineBuilder)
->pipe(new TimeTwoStage)
->fork(function($payload) {
if($payload < 0) return "-";
if($payload >= 0) return "+";
})
->disjoin("-", $negativeNumberProcessingPipeline)
->disjoin("+", $positiveNumberOrZeroProcessingPipeline)
->join()
->pipe(new DivideByFiveStage)
->build(); |
juzerali
pushed a commit
to juzerali/pipeline
that referenced
this issue
Jan 9, 2018
juzerali
pushed a commit
to juzerali/pipeline
that referenced
this issue
Jan 9, 2018
juzerali
pushed a commit
to juzerali/pipeline
that referenced
this issue
Jan 9, 2018
juzerali
pushed a commit
to juzerali/pipeline
that referenced
this issue
Jan 9, 2018
I think this would be better solved by using something like php-fp-either, where every stage returns a Right or Left: use PhpFp\Either\Either;
$pipeline = new Pipeline();
$pipeline = $pipeline->pipe(function (Either $a) {
return $a->chain(function ($x) {
return $x * 2;
};
});
$output = $pipeline->process(Either::of(2))->either(
function ($left) {
return 'failed';
},
function ($right) {
return $right;
}
);
assert($output === 4); |
This was referenced Jun 8, 2018
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Sometimes based on some condition, a pipeline needs to be forked, meaning there is a need to follow one of several disparate paths which have nothing in common. Optionally, later the disjoint paths may join again.
The text was updated successfully, but these errors were encountered: