I'm trying to send tasks to the Worker Pool from a Request Handler. The Worker Pool initializes correctly. I wonder if this is the correct way or if it has to be done inside an async function. I appreciate your valuable help.
// Initialization code
$server->start(new class implements RequestHandler {
public function handleRequest(Request $request): Response
{
$execution = Worker\submit(new FetchTask('https://google.com'));
$execution->await();
return new Response(
status: HttpStatus::OK,
headers: ["content-type" => "text/plain; charset=utf-8"],
body: "Hello, World!",
);
}
}, new DefaultErrorHandler());
// Rest of code
Thanks.