UPDATE FOR LATER READERS: the Pipeline project was renamed to Relay shortly after announcement.
Taking our conversation from email to Github so that others can have some input...
On Jun 5, 2015, at 12:57, Woody Gilk [email protected] wrote:
What's your vision for PipelinePHP? Do you want to roll Pipeline into Spark and share collaboration on it, or are you thinking that Pipeline should be the nexus between Spark and Radar?
I see Pipeline as the nexus between the two, and (one hopes) a wide range of other middleware systems. The idea would be, again one hopes, for a collection of middleware packages to spring up that follow the same signature and expectations. Then Radar, and Spark, and whatever-else-comes can say they are Pipeline compliant.
We're nearly ready to start prototyping with Spark and would like to get this sorted out soon so that we can collaborate more closely and work on core ADR stuff together, rather than duplicating efforts.
/me nods
As far as core ADR stuff, Pipeline might provide a good non-project-specific nexus, or maybe not. There's a case for publishing separate package that is not attached to any particular project.
Regardless, the fact that the middleware dispatching is separated out means each project gets to its own .env setup (before Pipeline), container setup (which creates Pipeline and other objects), and middleware objects (which Pipeline executes). Those surrounding pieces are where the fun and preferences live.
You've already talked about this, but I'll reiterate. I think the remaining pieces for an ADR set of interfaces are:
- An Action handler signature. It strikes me that this ought to be "just another middleware." It takes $request, $response, $next, and returns a $response. As such, it might not need an interface per se, but it would need a set of expectations on how to pick the classes for the action. Information from the routing phase might be passed as ServerRequest attributes: e.g., ['adr:input' => 'InputClassName', 'adr:domain' => 'DomainClassName', 'adr:responder' => 'ResponderClassName']. Actions would expect those to be there, and to use them appropriately (whatever that means).
- I don't know that a common Route interface would be needed, so long as the Action-related specifics of the route can be passed through to a later Action handler. Tough to type hint with a standard middleware signature in place. Alternatively, an ActionDescriptor might be good, and it would carry the input/domain/responder information, possibly along with the means to create those objects for the Action. It would still have to be passed via the $request as an attribute, maybe "adr:descriptor".
- A common Input interface sounds good.
__invoke(ServerRequest $request)
would be just fine, which you have in place. The return would have to be an array of params suitable for call_user_func_array()
.
- I don't know that a common Domain interface is really needed.
call_user_func_array($domain, $input($request))
seems to cover every possible case.
- A common Responder interface is a little tricky. Although I like the idea of __invoke($request, $response, $payload = null), I have to wonder about the Payload interface at that point. Do we require one, or do we just say "$payload is whatever comes back from your Domain"?
Actual implementations of these, might go well in their own projects. That would mean an interface-only package, and then separate projects that implement them according to the desires of the implementors.
(/me wipes brow)
None of that is set in stone, obviously, but it seems like a good start combined with your spark/adr work.
Over to you!