From 9c51360f9119a4114bdcc21c8e61f0908a3c876d Mon Sep 17 00:00:00 2001 From: Valery Piashchynski Date: Sun, 18 Jul 2021 11:32:44 +0300 Subject: Started beanstalk driver. Add new Queue impl (not finished yet). Fix bugs in the AMQP, update proto-api Signed-off-by: Valery Piashchynski --- tests/psr-worker-bench.php | 75 ++++++++++++++-------------------------------- 1 file changed, 22 insertions(+), 53 deletions(-) (limited to 'tests/psr-worker-bench.php') diff --git a/tests/psr-worker-bench.php b/tests/psr-worker-bench.php index b4a028d4..80fc435c 100644 --- a/tests/psr-worker-bench.php +++ b/tests/psr-worker-bench.php @@ -1,59 +1,28 @@ getMode() === 'http') { - $worker = new RoadRunner\Http\PSR7Worker( - RoadRunner\Worker::create(), - new Factory\Psr17Factory(), - new Factory\Psr17Factory(), - new Factory\Psr17Factory() - ); - - while ($req = $worker->waitRequest()) { - try { - $rsp = new \Nyholm\Psr7\Response(); - $rsp->getBody()->write("hello world"); - $worker->respond($rsp); - } catch (\Throwable $e) { - $worker->getWorker()->error((string)$e); - } +require __DIR__ . "/vendor/autoload.php"; + +$worker = RoadRunner\Worker::create(); +$psr7 = new RoadRunner\Http\PSR7Worker( + $worker, + new \Nyholm\Psr7\Factory\Psr17Factory(), + new \Nyholm\Psr7\Factory\Psr17Factory(), + new \Nyholm\Psr7\Factory\Psr17Factory() +); + +while ($req = $psr7->waitRequest()) { + try { + $resp = new \Nyholm\Psr7\Response(); + $resp->getBody()->write("hello world"); + + $psr7->respond($resp); + } catch (\Throwable $e) { + $psr7->getWorker()->error((string)$e); } -} else { - /** - * @param string $dir - * @return array - */ - $getClasses = static function (string $dir): iterable { - $files = glob($dir . '/*.php'); - - foreach ($files as $file) { - yield substr(basename($file), 0, -4); - } - }; - - $factory = \Temporal\WorkerFactory::create(); - - $worker = $factory->newWorker('default'); - - // register all workflows - foreach ($getClasses(__DIR__ . '/src/Workflow') as $name) { - $worker->registerWorkflowTypes('Temporal\\Tests\\Workflow\\' . $name); - } - - // register all activity - foreach ($getClasses(__DIR__ . '/src/Activity') as $name) { - $class = 'Temporal\\Tests\\Activity\\' . $name; - $worker->registerActivityImplementations(new $class); - } - - $factory->run(); } -- cgit v1.2.3