Skip to content

PSR-7 compatible stream abstraction #1446

@vladvildanov

Description

@vladvildanov

Is your feature request related to a problem? Please describe.
Currently, the connection object is also responsible for resource configuration, creation and usage without a proper abstraction around it. This leads to the following problems:

  1. Increased coupling. The code that represents different modules are mixed in one, which makes it harder to re-use (for example socket configuration and creation) and maintain.
  2. Code testability. Since, all the read/write operations performed directly from stream in connection object, it's impossible to mock it and test the actual business-logic (handshake, protocol parsing, exception handling etc.) without performing actual read/write.

Describe the solution you'd like

  1. Introduce PSR-7 (as a standard in PHP) compatible abstraction for streams to avoid direct streams usage and instead provide a proper API to decouple streams from connection.
  2. Introduce Stream Factory abstraction to separate a logic of configuration and creation of actual stream instance.
  3. Move a code to the right places.
  4. Added missing test coverage for connection

Describe alternatives you've considered
Do not use PSR-7 interface and instead provide a custom one.

Additional context
This feature requires a new dependency to be introduced, so we can follow PSR-7 interface - php-fig/http-message

Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions