github roadrunner-server/roadrunner v2.9.0-alpha.1

latest releases: v2024.2.1, v2024.2.0, v2024.1.5...
pre-release2 years ago

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.

Don't miss a new roadrunner release

NewReleases is sending notifications on new releases.