Uh oh!
There was an error while loading. Please reload this page.
Add LimitConcurrentRequestsMiddleware to limit how many next handlers can be executed concurrently - #272
Conversation
| $pending--; | ||
| $that->processQueue(); | ||
| throw $error; |
There was a problem hiding this comment.
This seems to cause build errors on PHP versions below 7: https://travis-ci.org/reactphp/http/jobs/313201152#L517
There was a problem hiding this comment.
Indeed, updated to explicitly reject() in case the rejection value is not an Exception: https://github.com/reactphp/http/pull/272/files#diff-ab60bdad04437904e8a3c3e4c8eff52fR137![]()
| $once = $this->expectCallableOnce(); | ||
| $deferred = new Deferred(function () use ($once) { | ||
| $once(); | ||
| throw new RuntimeException('Cancelled'); |
There was a problem hiding this comment.
Travis is crashing on this: https://travis-ci.org/reactphp/http/jobs/313374574#L512
There was a problem hiding this comment.
Duh, updated invalid reference just now ![]()
clue
commented
Dec 8, 2017
Rebased to resolve merge conflict with #264 |
| ])); | ||
| ``` | ||
| More sophisticated examples include limiting the total number of of requests |
| * | ||
| * This class is used to buffer all events that happen on a given stream while | ||
| * it is paused. This allows you to pause a stream and no longer watch for any | ||
| * of its events. Once the stream is resumed, all buffered event will be |
| * ])); | ||
| * ``` | ||
| * | ||
| * More sophisticated examples include limiting the total number of of requests |
clue
commented
Dec 8, 2017
Thanks for spotting, updated |
WyriHaximus
commented
Dec 8, 2017
🚨 Merge conflicts 🚨 |
clue
commented
Dec 9, 2017
Rebased to resolve merge conflict now that #274 is in |
The new ~~~
LimitHandlersMiddleware(name subject to discussion / change)~~~LimitConcurrentRequestsMiddlewareallows consumers to limit how many next handlers can be executed concurrently. This can be useful in a streaming context, where the number of concurrent buffers have to be limited. Or if can be used to avoid concurrent execution of handlers entirely. See also README changes for more details.Accordingly, this functionality is also a requirement for implementing a buffering server (via #259). This allows you to limit this so that for example up to 100 requests with a maximum of 2 MiB each can be buffered and may take up to 200 MiB concurrently.
In a follow-up PR, we will eventually implement similar logic to limit total memory consumption instead. This will allow a higher concurrency under the reasonable assumption that many requests are way below a given limit (see #255).
Supersedes / closes#218, thanks @WyriHaximus!
Refs #194
Refs #259