Open designermonkey opened 4 years ago
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.
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?
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
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.
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
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?