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 swoole adapter #43

Draft
wants to merge 23 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
b943115
:sparkles: add swoole adapter
matyo91 Apr 18, 2021
f4a441e
:hammer: fix wait with Event->exit
matyo91 Apr 19, 2021
e0ab738
:green_heart: roolback test
matyo91 Apr 19, 2021
39ee2e6
:art: not using channels way
matyo91 Apr 19, 2021
7b2c723
:hammer: refactor promise and clean
matyo91 Apr 20, 2021
9feff23
:hammer: move swoole extension check
matyo91 Apr 21, 2021
40d8f76
:bulb: ABCABA example
matyo91 Apr 21, 2021
1894ee6
:bulb: wait exemple
matyo91 Apr 21, 2021
b19c9b2
:construction: introduce Yield promise
matyo91 Apr 21, 2021
4de1766
:construction: integrate new EventLoop with YieldPromise
matyo91 Apr 21, 2021
3092714
:construction: integrate EventLoop->idle
matyo91 Apr 21, 2021
7bed8a1
:construction: integrate EventLoop->{deferred,promiseFulfilled,promis…
matyo91 Apr 21, 2021
f1667c7
:construction: integrate EventLoop->promiseAll
matyo91 Apr 21, 2021
679e4da
:construction: integrate Internal\Wait
matyo91 Apr 22, 2021
9501dbf
:construction: integrate Internal\DummyPromise
matyo91 Apr 22, 2021
debe065
:construction: streams
matyo91 Apr 22, 2021
d75a090
:lipstick: move logic from DummyPromise->isPending to EventLoop->isPe…
matyo91 Apr 22, 2021
60a770d
:construction: promise race
matyo91 Apr 23, 2021
02efbc7
:lipstick: cs fixer
matyo91 Apr 24, 2021
d7cee78
:construction_worker: add github CI
matyo91 Apr 24, 2021
0dead13
:hammer: yield event loop test
matyo91 Apr 24, 2021
ca47e61
:construction_worker: travis CI
matyo91 Apr 24, 2021
d0e4b18
:heavy_minus_sign: remove github CI for PR #45
matyo91 Apr 24, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
/vendor/
/composer.lock
/.php_cs.cache
/.phpunit.result.cache
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ before_script:
- phpenv config-rm xdebug.ini
- composer install

before_install:
- printf "\n" | pecl install swoole

env:
- TASK=tests-unit
- TASK=tests-examples
Expand Down
2 changes: 2 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,13 @@
"react/promise": "^2.7",
"phpstan/phpstan": "^0.10.5",
"symfony/http-client": "^4.3",
"swoole/ide-helper": "^4.6.5",
"psr/http-factory": "^1.0",
"http-interop/http-factory-guzzle": "^1.0"
},
"suggest": {
"ext-curl": "Required to use Curl and HTTP2 features",
"ext-swoole": "Required to use Tornado\\Adapter\\Swoole\\EventLoop",
"amphp/amp": "Required to use Tornado\\Adapter\\Amp\\EventLoop",
"react/event-loop": "Required to use Tornado\\Adapter\\ReactPhp\\EventLoop",
"react/promise": "Required to use Tornado\\Adapter\\ReactPhp\\EventLoop",
Expand Down
1 change: 1 addition & 0 deletions examples/00-README-samples.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ function waitException(Tornado\EventLoop $eventLoop)
//$eventLoop = new Tornado\Adapter\Tornado\SynchronousEventLoop();
//$eventLoop = new Tornado\Adapter\Amp\EventLoop();
//$eventLoop = new Tornado\Adapter\ReactPhp\EventLoop(new \React\EventLoop\StreamSelectLoop());
//$eventLoop = new Tornado\Adapter\Swoole\EventLoop();

// Tornado provides only one HttpClient implementation, using Guzzle
$httpClient = new Tornado\Adapter\Guzzle\HttpClient($eventLoop, new Tornado\Adapter\Guzzle\CurlMultiClientWrapper());
Expand Down
1 change: 1 addition & 0 deletions examples/01-async-countdown.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ function asynchronousCountdown(EventLoop $eventLoop, string $name, int $count):
//$eventLoop = new Adapter\Tornado\SynchronousEventLoop();
//$eventLoop = new Adapter\Amp\EventLoop();
//$eventLoop = new Adapter\ReactPhp\EventLoop(new \React\EventLoop\StreamSelectLoop());
//$eventLoop = new Tornado\Adapter\Swoole\EventLoop();

echo "Let's start!\n";

Expand Down
1 change: 1 addition & 0 deletions examples/02-failures.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ function throwingGenerator(): \Generator
//$eventLoop = new Adapter\Tornado\SynchronousEventLoop();
//$eventLoop = new Adapter\Amp\EventLoop();
//$eventLoop = new Adapter\ReactPhp\EventLoop(new \React\EventLoop\StreamSelectLoop());
//$eventLoop = new Tornado\Adapter\Swoole\EventLoop();

echo "Let's start!\n";

Expand Down
1 change: 1 addition & 0 deletions examples/03-http-client.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ function monitorRequest(EventLoop $eventLoop, HttpClient $httpClient, string $ur
//$eventLoop = new Adapter\Tornado\SynchronousEventLoop();
//$eventLoop = new Adapter\Amp\EventLoop();
//$eventLoop = new Adapter\ReactPhp\EventLoop(new \React\EventLoop\StreamSelectLoop());
//$eventLoop = new Tornado\Adapter\Swoole\EventLoop();

// Choose your adapter
$httpClient = new Adapter\Symfony\HttpClient(new \Symfony\Component\HttpClient\CurlHttpClient(), $eventLoop, new \Http\Factory\Guzzle\ResponseFactory(), new \Http\Factory\Guzzle\StreamFactory());
Expand Down
1 change: 1 addition & 0 deletions examples/04-foreach.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ function compareMethods(EventLoop $eventLoop)
//$eventLoop = new Adapter\Tornado\SynchronousEventLoop();
//$eventLoop = new Adapter\Amp\EventLoop();
//$eventLoop = new Adapter\ReactPhp\EventLoop(new \React\EventLoop\StreamSelectLoop());
//$eventLoop = new Tornado\Adapter\Swoole\EventLoop();

echo "Let's start!\n";
// Run the event loop until our goal promise is reached.
Expand Down
2 changes: 1 addition & 1 deletion src/Adapter/Amp/EventLoop.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ function (Promise $promise) {
$promises
);

foreach ($promises as $index => $promise) {
foreach ($promises as $promise) {
\Amp\Promise\rethrow(new \Amp\Coroutine($wrapPromise($promise)));
}

Expand Down
2 changes: 2 additions & 0 deletions src/Adapter/ReactPhp/EventLoop.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ public function async(\Generator $generator): Promise
try {
if (!$generator->valid()) {
$deferred->resolve($generator->getReturn());

return;
}
$promise = $generator->current();
if (!$promise instanceof Internal\PromiseWrapper) {
Expand Down
Loading