Skip to content
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

Closed
wants to merge 22 commits into from

Conversation

danog
Copy link
Contributor

@danog danog commented Jul 15, 2019

No description provided.

@bwoebi
Copy link
Member

bwoebi commented Jul 25, 2019

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 (recv(MSG_PEEK)). But here this is not trivially possible.

It feels to me that there is fundamental functionality lacking here.

@danog
Copy link
Contributor Author

danog commented Jul 25, 2019

Actually, I'm not throwing away anything because the other lines are being buffered in a static variable that persists after the function exits.
I, too, encountered some issues when working with non-file AMP streams, which is why I created my own incremental async stream APIs, with buffered wrappers, hashing proxies, generic proxies.
I intend to separate the stream and loop APIs of MadelineProto soon, so you can use them without including the entire project.

In the meantime you can try fiddling around with them if you like.

* @param string $string
* @return Promise
*/
function bufferEcho($string): Promise
Copy link
Member

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.

Copy link
Contributor Author

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

Copy link
Member

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?

Copy link
Member

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.

Copy link
Contributor Author

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.

Copy link
Member

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.

@kelunik
Copy link
Member

kelunik commented Jul 25, 2019

@bwoebi I don't think these need to be on the basic interface. While they're sometimes needed, they can be provided by wrappers.

@kelunik
Copy link
Member

kelunik commented Jul 25, 2019

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.

@kelunik kelunik mentioned this pull request Aug 22, 2019
lib/functions.php Outdated Show resolved Hide resolved
@kelunik kelunik closed this in #64 Aug 22, 2019
@kelunik kelunik reopened this Aug 22, 2019
lib/functions.php Outdated Show resolved Hide resolved
lib/functions.php Outdated Show resolved Hide resolved
@kelunik kelunik requested a review from trowski August 23, 2019 19:54
@danog
Copy link
Contributor Author

danog commented Dec 13, 2019

Ping?

@trowski trowski changed the base branch from master to 1.x December 23, 2022 22:31
@kelunik
Copy link
Member

kelunik commented Nov 19, 2023

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.

@kelunik kelunik closed this Nov 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants