Skip to content

v2.10.0-alpha.1

Pre-release
Pre-release

Choose a tag to compare

@rustatian rustatian released this 13 Apr 17:16
· 1334 commits to master since this release
fdc584f

👀 New:

  • ✏️ [ALPHA] HTTP response streaming. Available only in the alfa builds.

Worker sample:

<?php

use Nyholm\Psr7\Factory\Psr17Factory;
use Nyholm\Psr7\Response;
use Nyholm\Psr7\Stream;
use Spiral\RoadRunner;

ini_set('display_errors', 'stderr');
require __DIR__ . "/vendor/autoload.php";

$worker = RoadRunner\Worker::create();
$psr7 = new RoadRunner\Http\PSR7Worker(
    $worker,
    new Psr17Factory(),
    new Psr17Factory(),
    new Psr17Factory()
);

$psr7->chunk_size = 10 * 10 * 1024;
$filename = 'file.tmp'; // big file or response

while ($req = $psr7->waitRequest()) {
    try {
        $fp = \fopen($filename, 'rb');
        \flock($fp, LOCK_SH);
        $resp = (new Response())->withBody(Stream::create($fp));
        $psr7->respond($resp);
    } catch (\Throwable $e) {
        $psr7->getWorker()->error((string)$e);
    }

Known issues:

  1. RR will not notify a worker if HTTP connection was interrupted. RR will read all responses from the worker and drop them. That will be fixed in the stable streaming release.
  2. Sometimes RR may miss the immediate error from the worker and send a 0 payload with 200 status. This is related only to the HTTP response.
  • ✏️ [BETA] Local activities support link.