summaryrefslogtreecommitdiff
path: root/tests/psr-worker-slow.php
diff options
context:
space:
mode:
authorValery Piashchynski <[email protected]>2021-06-26 09:37:27 +0300
committerGitHub <[email protected]>2021-06-26 09:37:27 +0300
commitfc540f6029772ff51913b8ee3c082f8197010c52 (patch)
tree6f92954e4410ff6351e189338daf9fc4dc2feaea /tests/psr-worker-slow.php
parente9249c7896331bab97a18a7ee0db17803fdd31fb (diff)
parent744bf2e237e92e6ecddd3846dcb9a6b66967f67a (diff)
#738 fix(allocator): workers were not reallocating when `exec_ttl` was hitv2.3.1-rc.1
#738 fix(allocator): workers were not reallocating when `exec_ttl` was hit
Diffstat (limited to 'tests/psr-worker-slow.php')
-rw-r--r--tests/psr-worker-slow.php29
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/psr-worker-slow.php b/tests/psr-worker-slow.php
new file mode 100644
index 00000000..153dff68
--- /dev/null
+++ b/tests/psr-worker-slow.php
@@ -0,0 +1,29 @@
+<?php
+/**
+ * @var Goridge\RelayInterface $relay
+ */
+use Spiral\Goridge;
+use Spiral\RoadRunner;
+
+ini_set('display_errors', 'stderr');
+require __DIR__ . "/vendor/autoload.php";
+
+$worker = new RoadRunner\Worker(new Goridge\StreamRelay(STDIN, STDOUT));
+$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();
+ sleep(mt_rand(1,20));
+ $resp->getBody()->write("hello world");
+
+ $psr7->respond($resp);
+ } catch (\Throwable $e) {
+ $psr7->getWorker()->error((string)$e);
+ }
+}