mirror of
https://github.com/amphp/parallel.git
synced 2025-07-18 12:01:24 +02:00
26 lines
478 B
PHP
26 lines
478 B
PHP
<?php declare(strict_types=1);
|
|
|
|
namespace App\Worker;
|
|
|
|
use Amp\Cancellation;
|
|
use Amp\Parallel\Worker\Task;
|
|
use Amp\Sync\Channel;
|
|
|
|
/**
|
|
* @template-implements Task<string, never, never>
|
|
*/
|
|
final class FetchTask implements Task
|
|
{
|
|
private string $url;
|
|
|
|
public function __construct(string $url)
|
|
{
|
|
$this->url = $url;
|
|
}
|
|
|
|
public function run(Channel $channel, Cancellation $cancellation): mixed
|
|
{
|
|
return \file_get_contents($this->url);
|
|
}
|
|
}
|