diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 189105d..2f3eecb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,5 +12,3 @@ jobs: uses: innmind/github-workflows/.github/workflows/psalm-matrix.yml@main cs: uses: innmind/github-workflows/.github/workflows/cs.yml@main - with: - php-version: '8.2' diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..933b1af --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,9 @@ +# Changelog + +## [Unreleased] + +### Changed + +- Requires PHP `8.4` +- Requires `innmind/operating-system:~7.0` +- Requires `innmind/time:~1.0` diff --git a/composer.json b/composer.json index 9bb7604..e55e612 100644 --- a/composer.json +++ b/composer.json @@ -15,12 +15,12 @@ "issues": "http://github.com/innmind/async/issues" }, "require": { - "php": "~8.2", - "innmind/operating-system": "~6.2", - "innmind/immutable": "~5.18", - "innmind/io": "^3.5.1", - "innmind/time-warp": "^4.1.1", - "innmind/signals": "^4.1.1" + "php": "~8.4", + "innmind/operating-system": "~7.0", + "innmind/immutable": "~6.0", + "innmind/io": "~4.0", + "innmind/time": "~1.0", + "innmind/signals": "~5.0" }, "autoload": { "psr-4": { @@ -28,7 +28,7 @@ } }, "require-dev": { - "innmind/static-analysis": "^1.2.1", + "innmind/static-analysis": "~1.3", "innmind/black-box": "~6.5", "innmind/coding-standard": "~2.0" } diff --git a/proofs/functional.php b/proofs/functional.php index ebae093..8058859 100644 --- a/proofs/functional.php +++ b/proofs/functional.php @@ -5,9 +5,12 @@ Scheduler, Task, }; -use Innmind\OperatingSystem\Factory; +use Innmind\OperatingSystem\{ + Factory, + Config\Resilient, +}; use Innmind\Signals\Signal; -use Innmind\TimeContinuum\Period; +use Innmind\Time\Period; use Innmind\Filesystem\Name; use Innmind\Http\{ Request, @@ -111,23 +114,23 @@ static function($assert) { [false, 0] => $continuation ->schedule(Sequence::of( static function($os) { - $os->process()->halt(Period::second(1))->unwrap(); - $os->process()->halt(Period::second(1))->unwrap(); + $_ = $os->process()->halt(Period::second(1))->unwrap(); + $_ = $os->process()->halt(Period::second(1))->unwrap(); }, static function($os) { - $os->process()->halt(Period::second(1))->unwrap(); - $os->process()->halt(Period::second(1))->unwrap(); + $_ = $os->process()->halt(Period::second(1))->unwrap(); + $_ = $os->process()->halt(Period::second(1))->unwrap(); }, static function($os) { - $os->process()->halt(Period::second(1))->unwrap(); - $os->process()->halt(Period::second(1))->unwrap(); + $_ = $os->process()->halt(Period::second(1))->unwrap(); + $_ = $os->process()->halt(Period::second(1))->unwrap(); }, )) ->carryWith(true), [true, 0] => (static function($os, $continuation) { // this halt is executed at the same time at the // second one in each task - $os->process()->halt(Period::second(1))->unwrap(); + $_ = $os->process()->halt(Period::second(1))->unwrap(); return $continuation; })($os, $continuation), @@ -154,7 +157,7 @@ static function($assert) { ->with( static function($started, $os, $continuation) use ($assert, &$results) { if ($started) { - $os + $_ = $os ->process() ->halt(Period::second(2)) ->unwrap(); @@ -170,14 +173,14 @@ static function($os) use (&$results) { // This task halts for 4 seconds because // if less then it may sometime finish // before the scope. (as 3-1 ~= 2s) - $os + $_ = $os ->process() ->halt(Period::second(4)) ->unwrap(); $results[] = 'task 1'; }, static function($os) use (&$results) { - $os + $_ = $os ->process() ->halt(Period::second(1)) ->unwrap(); @@ -210,11 +213,11 @@ static function($assert) { ->with( static function($started, $os, $continuation) use ($assert, &$results) { if ($started) { - $os + $_ = $os ->process() ->halt(Period::second(3)) ->unwrap(); - $os + $_ = $os ->process() ->halt(Period::second(1)) ->unwrap(); @@ -227,14 +230,14 @@ static function($started, $os, $continuation) use ($assert, &$results) { ->carryWith(true) ->schedule(Sequence::of( static function($os) use (&$results) { - $os + $_ = $os ->process() ->halt(Period::second(2)) ->unwrap(); $results[] = 'task 1'; }, static function($os) use (&$results) { - $os + $_ = $os ->process() ->halt(Period::second(1)) ->unwrap(); @@ -404,17 +407,17 @@ static function($os) use ($assert, &$chunks) { 'HTTP requests are handled asynchronously', static function($assert) { $order = []; - Scheduler::of(Factory::build()) + Scheduler::of(Factory::build()->map(Resilient::new())) ->sink(null) ->with( static function($_, $__, $continuation) use ($assert, &$order) { return $continuation ->schedule(Sequence::of( static function($os) use ($assert, &$order) { - $os + $_ = $os ->remote() ->http()(Request::of( - Url::of('https://httpbun.org/delay/2'), + Url::of('https://httpbin.org/delay/5'), Method::get, ProtocolVersion::v11, )) @@ -425,10 +428,10 @@ static function($os) use ($assert, &$order) { $order[] = 'first'; }, static function($os) use ($assert, &$order) { - $os + $_ = $os ->remote() ->http()(Request::of( - Url::of('https://httpbun.org/delay/1'), + Url::of('https://httpbin.org/delay/1'), Method::get, ProtocolVersion::v11, )) @@ -466,7 +469,7 @@ static function($assert) { ->wakeOnResult(), ); - $assert->count(0, $results); + $assert->same(0, $results->size()); }, ); @@ -522,7 +525,7 @@ static function($started, $os, $continuation) { 10, static function($os) { $continue = true; - $os + $_ = $os ->process() ->signals() ->listen( @@ -530,10 +533,11 @@ static function($os) { static function() use (&$continue) { $continue = false; }, - ); + ) + ->unwrap(); while ($continue) { - $os + $_ = $os ->process() ->halt(Period::second(2)) ->unwrap(); @@ -542,7 +546,7 @@ static function() use (&$continue) { )); } - $os + $_ = $os ->process() ->halt(Period::second(1)) ->unwrap(); diff --git a/src/Config/Async.php b/src/Config/Async.php index e9e636c..0ae532c 100644 --- a/src/Config/Async.php +++ b/src/Config/Async.php @@ -5,13 +5,14 @@ use Innmind\OperatingSystem\Config; use Innmind\Signals\Async\Interceptor; -use Innmind\TimeContinuum\{ +use Innmind\Time\{ Clock, Period, + Halt, }; -use Innmind\HttpTransport\Curl; -use Innmind\TimeWarp\Halt; +use Innmind\HttpTransport\Transport; use Innmind\IO\IO; +use Innmind\Signals\Handler; /** * @internal @@ -29,22 +30,23 @@ private function __construct( public function __invoke(Config $config): Config { - $halt = Halt\Async::of($this->clock); - $io = IO::async($this->clock); - // todo handle max concurrency + ssl configuration + $halt = Halt::async($this->clock); + $io = IO::async( + $config->io(), + $this->clock, + ); // todo build a native client based on innmind/io to better integrate in // this system. - $http = Curl::of( + $http = Transport::async( $this->clock, $io, - ) - ->heartbeat( - Period::millisecond(10), // this is blocking the active task so it needs to be low - static fn() => $halt(Period::millisecond(1))->unwrap(), // this allows to jump between tasks - ); - $signals = $config - ->signalsHandler() - ->async($this->interceptor); + Period::millisecond(10), // this is blocking the active task so it needs to be low + static fn() => $halt(Period::millisecond(1))->unwrap(), // this allows to jump between tasks + ); + $signals = Handler::async( + $config->signalsHandler(), + $this->interceptor, + ); return $config ->haltProcessVia($halt) diff --git a/src/Config/Provider.php b/src/Config/Provider.php index b4e5166..02171fe 100644 --- a/src/Config/Provider.php +++ b/src/Config/Provider.php @@ -4,7 +4,7 @@ namespace Innmind\Async\Config; use Innmind\Signals\Async\Interceptor; -use Innmind\TimeContinuum\Clock; +use Innmind\Time\Clock; /** * @internal diff --git a/src/Resumption.php b/src/Resumption.php index 1a72537..376820f 100644 --- a/src/Resumption.php +++ b/src/Resumption.php @@ -3,7 +3,7 @@ namespace Innmind\Async; -use Innmind\TimeWarp\Async\Resumable as Halt; +use Innmind\Time\Halt\Async\Resumable as Halt; use Innmind\IO\Internal\Async\Resumable as IO; /** diff --git a/src/Scope/Suspended.php b/src/Scope/Suspended.php index b25c57a..49f9025 100644 --- a/src/Scope/Suspended.php +++ b/src/Scope/Suspended.php @@ -8,7 +8,7 @@ Suspension, Wait, }; -use Innmind\TimeContinuum\Clock; +use Innmind\Time\Clock; /** * Waiting for IO to be ready or halt to be finished diff --git a/src/Suspension.php b/src/Suspension.php index 7281861..1febed6 100644 --- a/src/Suspension.php +++ b/src/Suspension.php @@ -3,11 +3,11 @@ namespace Innmind\Async; -use Innmind\TimeContinuum\{ +use Innmind\Time\{ Clock, Period, + Halt\Async\Suspended as Halt, }; -use Innmind\TimeWarp\Async\Suspended as Halt; use Innmind\IO\Internal\{ Async\Suspended as IO, Watch, diff --git a/src/Task/Suspended.php b/src/Task/Suspended.php index 1abd89b..06cec7e 100644 --- a/src/Task/Suspended.php +++ b/src/Task/Suspended.php @@ -11,7 +11,7 @@ Async\Interceptor, Signal, }; -use Innmind\TimeContinuum\Clock; +use Innmind\Time\Clock; /** * Waiting for IO to be ready or halt to be finished diff --git a/src/Wait.php b/src/Wait.php index f441c8f..5d9e021 100644 --- a/src/Wait.php +++ b/src/Wait.php @@ -4,7 +4,7 @@ namespace Innmind\Async; use Innmind\OperatingSystem\OperatingSystem; -use Innmind\TimeContinuum\Period; +use Innmind\Time\Period; use Innmind\IO\Internal\Watch; /**