summaryrefslogtreecommitdiff
path: root/tests/jobs_ok.php
blob: fa58dd9a8ea710f53fe6a40f8473c45516c5a8eb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<?php

/**
 * @var Goridge\RelayInterface $relay
 */

use Spiral\Goridge;
use Spiral\RoadRunner;
use Spiral\Goridge\StreamRelay;

require __DIR__ . "/vendor/autoload.php";

$rr = new RoadRunner\Worker(new StreamRelay(\STDIN, \STDOUT));

while ($in = $rr->waitPayload()) {
    try {
        $ctx = json_decode($in->header, true);
        $headers = $ctx['headers'];

        $rr->respond(new RoadRunner\Payload(json_encode([
            'type' => 0,
            'data' => [
                'message' => 'error',
                'requeue' => true,
                'delay_seconds' => 10,
                'headers' => $headers
            ]
        ])));
    } catch (\Throwable $e) {
        $rr->error((string)$e);
    }
}