Skip to content

v2.9.0-alpha.1

Pre-release
Pre-release
Compare
Choose a tag to compare
@rustatian rustatian released this 23 Mar 19:39
· 922 commits to master since this release
c9fddf5

Reason for This PR

  • Minor release cycle.

- ⚠️ Please, share your feedback about streaming here: #1070

Description of Changes

👀 New:

  • ✏️ [ALPHA] HTTP response streaming. Starting from the v2.9.0, RR is capable of streaming responses.
    To turn on that feature, please, add the following lines to the configuration:
experimental:
    response_streams: true

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->chunkSize = 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 the HTTP connection is interrupted, and RR will read all responses from the worker and drop them off. 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.
  • ✏️ API: add service proto API to manage services, FR (reporter @butschster)

🧹 Chore:

  • 🧑‍🏭 Update all dependencies to the most recent versions.