-
Notifications
You must be signed in to change notification settings - Fork 3
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
Should PsrAdapter be splitted or not? #2
Comments
Depending on the use case you need every combination, yes. Main reason for splitting would be, because not every case needs the factories. I've added aed8333, which should simplify the usage. |
What should we do with https://github.com/amphp/http-client-psr7/blob/aed833358dbcc86010bf941375bc6ce7eab7cfd1/src/Internal/PsrMessageStream.php? Seems to be unused currently. |
It was designed as an honest bridge between Amp's and PSR's way of sequential reading the body, but it was blocked by amphp/amp#311 and amphp/amp#313; so now it looks like an overkill. I can either remove it (and rewrite it back when it becomes possible) or use it instead of |
I prefer not using it currently, but we could also allow to configure that behavior. What do you think about that? |
I think there's nothing of value to configure yet. I'll remove it for now and will get back to it when nested loops run okay. |
As for now,
PsrAdapter
class provides full set of methods to convert both Amp and PSR-7 requests and responses in both directions. There is an opinion that it could be split apart.I think that most frequent use cases will consist of the following (maybe partially):
toPsrRequest()
andfromPsrResponse()
methods):fromPsrRequest()
andtoPsrResponse()
methods):But, on the other hand, there are cases where "alien" code just alters messages and returns them back (adds headers, for example); in this case, we recieve the same class of object back, like this:
This case requires
toPsrRequest()
andfromPsrRequest()
methods, so I decided that splitting the adapter for the first group of cases can harm users that implement second group of cases and vice versa.I've looked through @trowski 's implementation of server message bridge; it just implements
MessageConverter
interface that declares methodsconvertRequest()
(that works like mytoPsrRequest()
) andconvertResponse()
(that works like myfromPsrResponse()
). Thus, it allows only first use case.@kelunik, what do you think about it?
The text was updated successfully, but these errors were encountered: