-
-
Notifications
You must be signed in to change notification settings - Fork 30
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
Add async readline/echo and add composer commands #63
Conversation
Thanks, I was missing something akin to readLine just yesterday (just on a TCP socket to be used via telnet) ... But there's a catch: you are throwing away everything but the first line. :-/ This is just a bit stupid due to that we have absolutely no buffering in out ResourceOutputStream. Is just sort of ... too primitive. Even on the kernel level you have the possibility to peek at the input stream and decide how much you want to consume ( It feels to me that there is fundamental functionality lacking here. |
Actually, I'm not throwing away anything because the other lines are being buffered in a static variable that persists after the function exits. In the meantime you can try fiddling around with them if you like. |
* @param string $string | ||
* @return Promise | ||
*/ | ||
function bufferEcho($string): Promise |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see much value in such a function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought it'd be nice to have an async way to log to stdout
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can just do getStdout()->write()
then, no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see any value in this function either. The name seems misleading as well, as buffering depends on SAPI.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I use buffer to match the name of the functions used to get the output stream.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair point. Those names have the same problem I guess.
More to the main point though – how many functions do we want to introduce to save another method call? I don't think this function is necessary, nor is prompt
.
@bwoebi I don't think these need to be on the basic interface. While they're sometimes needed, they can be provided by wrappers. |
We could include an implementation similar to https://github.com/kelunik/streaming-json/blob/c8b5bb9f65c67c0ca1fd2771ef00332c4c8ffe93/src/StreamingJsonParser.php, which doesn't do the JSON decoding and allows for customization of the line ending. |
Closes amphp#63.
Ping? |
This is something we see out of scope of this package, so I'm closing this. It hasn't received much attention in the last 4 years. |
No description provided.