summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorValery Piashchynski <[email protected]>2021-02-18 16:44:24 +0300
committerGitHub <[email protected]>2021-02-18 16:44:24 +0300
commit9fd1ab79d2c82605747e960014f68e95234a9eeb (patch)
tree84638cc3c347fb1a344e48ee01b55abdd849362a
parent8731107ad4e23004500b04442ed8fba0242dfbf2 (diff)
parent546b350a35b35af9eecb61aab5f7bcbbaffd449f (diff)
Merge branch 'master' into dependabot/go_modules/github.com/alicebob/miniredis/v2-2.14.3
-rw-r--r--README.md52
-rw-r--r--tests/broken.php2
-rw-r--r--tests/delay.php2
-rw-r--r--tests/echo.php2
-rw-r--r--tests/head.php2
-rw-r--r--tests/memleak.php2
-rw-r--r--tests/pid.php2
-rw-r--r--tests/plugins/server/socket.php2
-rw-r--r--tests/plugins/server/tcp.php2
-rw-r--r--tests/sleep.php2
-rw-r--r--tests/slow-pid.php2
-rw-r--r--tests/stop.php2
12 files changed, 56 insertions, 18 deletions
diff --git a/README.md b/README.md
index e00fcab8..066aaa62 100644
--- a/README.md
+++ b/README.md
@@ -51,7 +51,7 @@ Features:
- execTTL (brute, max_execution_time)
- Payload context and body
- Protocol, worker and job level error management (including PHP errors)
-- Very fast (~250k rpc calls per second on Ryzen 1700X using 16 threads)
+- Development Mode
- Integrations with Symfony, [Laravel](https://github.com/spiral/roadrunner-laravel), Slim, CakePHP, Zend Expressive
- Application server for [Spiral](https://github.com/spiral/framework)
- Automatic reloading on file changes
@@ -60,29 +60,67 @@ Features:
Installation:
--------
-```
-go get -u github.com/spiral/roadrunner/v2
+```bash
+$ composer require spiral/roadrunner:v2.0 nyholm/psr7
+$ ./vendor/bin/rr get-binary
```
-> For getting roadrunner binary file you can use our docker image: `spiralscout/roadrunner:X.X.X` (more information about image and tags can be found [here](https://hub.docker.com/r/spiralscout/roadrunner/))
+> For getting roadrunner binary file you can use our docker image: `spiralscout/roadrunner:X.X.X` (more information about
+> image and tags can be found [here](https://hub.docker.com/r/spiralscout/roadrunner/))
Configuration can be located in `.rr.yaml`
file ([full sample](https://github.com/spiral/roadrunner/blob/master/.rr.yaml)):
```yaml
+rpc:
+ listen: tcp://127.0.0.1:6001
+
+server:
+ command: "php worker.php"
+
http:
- address: 0.0.0.0:8080
- workers.command: "php worker.php"
+ address: "0.0.0.0:8080"
+
+logs:
+ level: error
```
> Read more in [Documentation](https://roadrunner.dev/docs).
+Example Worker:
+--------
+
+```php
+<?php
+
+use Spiral\RoadRunner;
+use Nyholm\Psr7;
+
+include "vendor/autoload.php";
+
+$worker = RoadRunner\Worker::create();
+$psrFactory = new Psr7\Factory\Psr17Factory();
+
+$worker = new RoadRunner\Http\PSR7Worker($worker, $psrFactory, $psrFactory, $psrFactory);
+
+while ($req = $worker->waitRequest()) {
+ try {
+ $rsp = new Psr7\Response();
+ $rsp->getBody()->write('Hello world!');
+
+ $worker->respond($rsp);
+ } catch (\Throwable $e) {
+ $worker->getWorker()->error((string)$e);
+ }
+}
+```
+
Run:
----
To run application server:
```
-$ ./rr serve -v -d
+$ ./rr serve
```
License:
diff --git a/tests/broken.php b/tests/broken.php
index 1f869b2d..413f860f 100644
--- a/tests/broken.php
+++ b/tests/broken.php
@@ -10,5 +10,5 @@ $rr = new RoadRunner\Worker($relay);
while ($in = $rr->waitPayload()) {
echo undefined_function();
- $rr->send((string)$in->body, null);
+ $rr->respond(new RoadRunner\Payload((string)$in->body, null));
}
diff --git a/tests/delay.php b/tests/delay.php
index f0435b05..2c8255ba 100644
--- a/tests/delay.php
+++ b/tests/delay.php
@@ -11,7 +11,7 @@ $rr = new RoadRunner\Worker($relay);
while ($in = $rr->waitPayload()) {
try {
usleep($in->body * 1000);
- $rr->send('');
+ $rr->respond(new RoadRunner\Payload(''));
} catch (\Throwable $e) {
$rr->error((string)$e);
}
diff --git a/tests/echo.php b/tests/echo.php
index 83eec92e..64510465 100644
--- a/tests/echo.php
+++ b/tests/echo.php
@@ -10,7 +10,7 @@ $rr = new RoadRunner\Worker($relay);
while ($in = $rr->waitPayload()) {
try {
- $rr->send((string)$in->body);
+ $rr->respond(new RoadRunner\Payload((string)$in->body));
} catch (\Throwable $e) {
$rr->error((string)$e);
}
diff --git a/tests/head.php b/tests/head.php
index 3c57258f..80733166 100644
--- a/tests/head.php
+++ b/tests/head.php
@@ -10,7 +10,7 @@ $rr = new RoadRunner\Worker($relay);
while ($in = $rr->waitPayload()) {
try {
- $rr->send("", (string)$in->header);
+ $rr->respond(new RoadRunner\Payload("", (string)$in->header));
} catch (\Throwable $e) {
$rr->error((string)$e);
}
diff --git a/tests/memleak.php b/tests/memleak.php
index 169fe4f5..f2879e18 100644
--- a/tests/memleak.php
+++ b/tests/memleak.php
@@ -11,5 +11,5 @@ $rr = new RoadRunner(new StreamRelay(\STDIN, \STDOUT));
$mem = '';
while($rr->waitPayload()){
$mem .= str_repeat("a", 1024*1024);
- $rr->send("");
+ $rr->respond(new \Spiral\RoadRunner\Payload(""));
}
diff --git a/tests/pid.php b/tests/pid.php
index f8b2515d..962b609a 100644
--- a/tests/pid.php
+++ b/tests/pid.php
@@ -10,7 +10,7 @@
while ($in = $rr->waitPayload()) {
try {
- $rr->send((string)getmypid());
+ $rr->respond(new RoadRunner\Payload((string)getmypid()));
} catch (\Throwable $e) {
$rr->error((string)$e);
}
diff --git a/tests/plugins/server/socket.php b/tests/plugins/server/socket.php
index 3159c445..f90dda6f 100644
--- a/tests/plugins/server/socket.php
+++ b/tests/plugins/server/socket.php
@@ -18,7 +18,7 @@ $rr = new RoadRunner\Worker($relay);
while ($in = $rr->waitPayload()) {
try {
- $rr->send((string)$in->body);
+ $rr->respond(new RoadRunner\Payload((string)$in->body));
} catch (\Throwable $e) {
$rr->error((string)$e);
}
diff --git a/tests/plugins/server/tcp.php b/tests/plugins/server/tcp.php
index 88c49848..873f25b2 100644
--- a/tests/plugins/server/tcp.php
+++ b/tests/plugins/server/tcp.php
@@ -13,7 +13,7 @@ $rr = new RoadRunner\Worker($relay);
while ($in = $rr->waitPayload()) {
try {
- $rr->send((string)$in->body);
+ $rr->respond(new RoadRunner\Payload((string)$in->body));
} catch (\Throwable $e) {
$rr->error((string)$e);
}
diff --git a/tests/sleep.php b/tests/sleep.php
index e34a6834..fb5c9df2 100644
--- a/tests/sleep.php
+++ b/tests/sleep.php
@@ -11,5 +11,5 @@ $rr = new RoadRunner(new StreamRelay(\STDIN, \STDOUT));
while($rr->waitPayload()){
sleep(3);
- $rr->send("");
+ $rr->respond(new \Spiral\RoadRunner\Payload(""));
}
diff --git a/tests/slow-pid.php b/tests/slow-pid.php
index 3660cb40..82785610 100644
--- a/tests/slow-pid.php
+++ b/tests/slow-pid.php
@@ -11,7 +11,7 @@
while ($in = $rr->waitPayload()) {
try {
sleep(1);
- $rr->send((string)getmypid());
+ $rr->respond(new RoadRunner\Payload((string)getmypid()));
} catch (\Throwable $e) {
$rr->error((string)$e);
}
diff --git a/tests/stop.php b/tests/stop.php
index f83d3f29..93263821 100644
--- a/tests/stop.php
+++ b/tests/stop.php
@@ -18,7 +18,7 @@ while ($in = $rr->waitPayload()) {
}
$used = true;
- $rr->send((string)getmypid());
+ $rr->respond(new RoadRunner\Payload((string)getmypid()));
} catch (\Throwable $e) {
$rr->error((string)$e);
}