0

What would be the right way, according to the Middle-ware paradigm/design pattern to transfer resources (like connections to some IO devices).
It is not part of the Request, and it is definitely not part of the Response.
Is there a third object each Middleware step transfers to the next step in line?

The specifics of my question: I am using PHP a FW called TalisMS (which I have full control over). The resource I need to make global for this specific flow is a socket to an external system I need to fetch data from.

The socket can be to different places, and is decided in the first couple of steps, and then I need to continue use that through the entire flow.

I could make some global resource container, I guess, but I prefer something more Dependency-Injection like.

  • What is your technology stack and what specifically are your trying to share resources between? I have a feeling you are thinking about the problem incorrectly, but I'm not sure. – Berin Loritsch Feb 21 '18 at 17:05
  • The right way would be the way that works. I define "works" as "fulfills your software's functional and non-functional requirements." – Robert Harvey Feb 21 '18 at 18:43
  • 1
    And I'm pretty sure that the "middleware paradigm" (if such a thing exists) does not dictate the manner in which you transfer resources. – Robert Harvey Feb 21 '18 at 19:25
  • 1
    Why don't you just put your socket into a Context object and pass that around, or register it with your DI container as a Singleton? – Robert Harvey Feb 21 '18 at 19:36
  • 1
    This seems relevant: enterpriseintegrationpatterns.com/index.html – JimmyJames Feb 21 '18 at 19:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.