Comments (5)
Interesting question, the function is available on the pipeline as a public method, but it looks like it's being used by the invoke method as if it were a private method. The process function does belong to the processor interface, and doesn't belong to the pipeline really. I wouldn't say that we would want the pipelineinterface to extend or be extended by the processor interface since that could confuse people on the functionality of the processor. I think that method may have been put there for convenience and not meant to be used as part of the interface. But this is one I would be interested to know if all my arbitrary theorizing is correct, when we get an answer.
from pipeline.
According to Separation of Concerns it's good practice to separate structure from it's processor.
And to do this in the clean way we can pass structure to executor in order to process it, passing structure to processor should be done through process method ( not constructor ) to make processor stateless and reusable to process other structures as well.
In our case I suggest to remove ProcessorInterface
reference from Pipeline
class and refactor process
method on ProcessorInterface
to accept PipelineInterface
and $payload
.
from pipeline.
I really like this suggestion actually. Replacing the current contract of the processor to accept the pipeline and providing access to the stages on the pipeline for use in the processor. By doing that, you don't have to know up front how you want to process the stages, that can now be done later if you want.
Similarly, we could finally make the pipeline immutable if we wanted, as it is only an ordered collection of callables at that point. But maybe I'm hoping for too much with that.
from pipeline.
I think the current structure is doing Dependency Inversion correctly.
from pipeline.
I think the current structure is doing Dependency Inversion correctly.
In this case, perhaps the docs need to change?
This is the example from the docs.
$pipeline = (new Pipeline)
->pipe(new TimesTwoStage)
->pipe(new AddOneStage);
$pipeline->process(10);
The issue is that $pipeline
is an instance of PipelineInterface
and not Pipeline
, so it's wrong to assume there is a process()
method that can be called. Insightful IDEs correctly report this code as a problem.
I suspect the example should instead be the following.
$pipeline = (new Pipeline)
->pipe(new TimesTwoStage)
->pipe(new AddOneStage);
$pipeline(10);
Otherwise, the examples should be switched around to the following:
$pipeline = new Pipeline(
null,
(new TimesTwoStage),
(new AddOneStage)
);
$pipeline->process(10);
I'm happy to submit a PR for the change if there is an agreement.
from pipeline.
Related Issues (20)
- Pipeline should use call_user_func HOT 2
- Add variadic variable to __invoke HOT 4
- Add PipelineBuilderInterface HOT 3
- Remove InterruptibleProcessor and Rename FingersCrossedProcessor HOT 3
- quick question on the pipe methos HOT 2
- tag new version with processor included
- Never heard of a pattern named pipeline HOT 2
- [feature request] Inject errorHandler into processor (optional) HOT 1
- [Feature Request] Attach a listener to a pipeline HOT 2
- [Feature Request] Fork-Join HOT 2
- Generator Processor HOT 1
- When to use a PipelineBuilder? HOT 1
- Simple question HOT 6
- windows is ok? HOT 2
- How to use $check in InterruptibleProcessor.php? HOT 1
- PipelineBuilder build returns PipelineBuilderInterface in error HOT 2
- [Feature Request] Lazily retrieve pipeline stages from PSR-11 container HOT 3
- Why do you want to clone the current object when you execute the pipe method? HOT 1
- PipelineInterface does not have a `process` method HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pipeline.