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

ReactPHP without Promises #92

Open
designermonkey opened this issue Mar 19, 2020 · 5 comments
Open

ReactPHP without Promises #92

designermonkey opened this issue Mar 19, 2020 · 5 comments

Comments

@designermonkey
Copy link

Do you have any idea how I could implement a ReactPHP EventLoop without having to use the asynchronous promises?

Is there any reason why your normal Client doesn't use a ReactPHP EventLoop?

@WyriHaximus
Copy link
Collaborator

Do you have any idea how I could implement a ReactPHP EventLoop without having to use the asynchronous promises?

What's your goal, what are you trying to achieve? You can, but you'd be limited.

Is there any reason why your normal Client doesn't use a ReactPHP EventLoop?

The Sync Client uses a very simple event loop internally.

@designermonkey
Copy link
Author

I guess I'm struggling with the whole approach to Promises; it's not very OO as far as I can see.

Our code will run in a docker container and only need to pick up 1 message at a time. Our concurrency comes from multiple copies of the container, not the need to asynchronously pick multiple messages off the queue and process them as and when each part can progress.

I love the idea of ReactPHP though, with it's robust event loop, and I was wondering why the choice had been made not to use it in the synchronous client as well.

I guess it doesn't really matter?

@WyriHaximus
Copy link
Collaborator

Promises are a confusing concept at first, since they are a push mechanic the then method is required. (Futures, on the other hand, are pull and more OO.)

Since you are processing one message at a time it shouldn't matter for you. Picking up messages and processing non-blocking only makes sense if either your operation is non-blocking, or you are handling them in threads/child processes.

Not sure why @jakubkulhan decided to do that, but might have a look at using it in the sync client as well

@jakubkulhan
Copy link
Owner

The initial idea was to be able to split sync and async clients in different packages, so the sync client wouldn't need to depend on ReactPHP. However, I never got to do that :)

If you want to use ReactPHP, I suggest you use the async client.

@WyriHaximus
Copy link
Collaborator

That makes sense to be honest, what might be interesting to consider is to use the AsyncClient internally in the Client. But rather focus on getting some new features and bug fixes out for now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants